<?php
defined('IN_HS') or exit('Access Denied');

require_once HS_ROOT.'/include/tree.class.php';
require_once HS_ROOT.'/admin/include/category_channel.class.php';

$tree = new tree;

!empty($CATEGORY) or showmessage($LANG['have_no_category_yet'],"?mod=hs&file=category&action=add&channelid=$channelid",'form');

$category_select = category_select('catid', $LANG['please_select'], $catid);
$category_jump = category_select('catid', $LANG['please_choose_category_add_article'], $catid, "onchange=\"if(this.value!=''){location='?mod=$mod&file=$file&action=add&job=$job&channelid=$channelid&catid='+this.value;}\"");
$cat = new category_channel($channelid, $catid);
$list = $cat->get_list();
if(is_array($list))
{
	$categorys = array();
	foreach($list as $catid => $category)
	{
		$module = $CHA['module'];
		$linkurl = $category['linkurl'];
		$catdir = $category['islink'] ? "<a href='$linkurl' title={$LANG['click_here']} target='_blank'>".str_cut($linkurl,20)."</a>" : "<a href='$linkurl' title={$LANG['click_here']} target='_blank'>".$category['catdir']."</a>";
	
		$createlist = ' | <a href="?mod='.$module.'&file=createhtml&action=per_list&catid='.$category['catid'].'&channelid='.$channelid.'" title="'.$LANG['list_updated'].'">'.$LANG['list_updated'].'</a>';
		$createshow =  ' | <a href="?mod='.$module.'&file=createhtml&action=per_show&catid='.$category['catid'].'&channelid='.$channelid.'" title="'.$LANG['update_arcticle'].'">'.$LANG['update_arcticle'].'</a>';

		if($category['islink'] || ($category['child'] && !$category['enableadd']))
		{
			$addarticle = "<td style='display:none'>";
		}
		else
		{
			$addarticle = "<td><input style='color:red' class=btn type=button value=' Ìí ¼Ó ÎÄ ÕÂ ' onclick=window.location='?mod=$mod&file=$file&action=add&catid=$catid&channelid=$channelid'>&nbsp;&nbsp;&nbsp;";
		}
		$categorys[$category['catid']] = array('id'=>$category['catid'],'parentid'=>$category['parentid'],'name'=>$category['catname'],'catdir'=>$catdir,'listorder'=>$category['listorder'],'style'=>$category['style'],'items'=>$category['items'],'createlist'=>$createlist,'createshow'=>$createshow,'mod'=>$mod,'channelid'=>$channelid,'file'=>$file, 'addarticle'=>$addarticle);
	}
	$str = "<tr align='center' align='center'>
				<td>\$id</td>
				<td align='left'>\$spacer<a href='?mod=\$mod&file=\$file&action=manage&catid=\$id&channelid=\$channelid'><span style='\$style'>\$name</span></a></td>
				<td>\$items</td>
				\$addarticle<input class=btn type=button value=' ¹Ü Àí ' onclick=window.location='?mod=$mod&file=$file&action=manage&catid=\$id&channelid=\$channelid'>&nbsp;&nbsp;&nbsp;&nbsp;<input class=btn type=button value=' Éó ºË ' onclick=window.location='?mod=$mod&file=$file&action=manage&job=check&catid=\$id&channelid=\$channelid'></td>
			</tr>";
	$tree->tree($categorys);
	$categorys = $tree->get_tree(0,$str);
}
include admintpl($mod.'_main');
?>