{include file="header.tpl" page_name=$page_name sys_name=$sys_name}
<div align="center">
{$admin_nav}
<table width="98%" border="0" cellpadding="0" cellspacing="0" class="adminMenu g-margin" align="center">
	<tr>
		<td><b>管理菜单：</b> <a href="?action={$action}&channel_type={$channel_type}">分类列表</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="?action={$action}&channel_type={$channel_type}&do=add">添加分类</a>&nbsp;&nbsp;</td>
	</tr>
</table>
{if $do == ''}
{if $category_list}
	<table width="98%" border="0" cellpadding="0" cellspacing="0" class="tableborder tableborder_line">
	<tr class="header">
	<td style="width:50px; overflow:hidden; text-align:center">编号</td>
	<td>分类名称</td>
    <td>标志位</td>
	<td>所属频道</td>
    <td>列表页显示条数</td>
    <td>密码</td>
	<td>管理选项</td>
	</tr>
	<tbody>
    {foreach from=$category_list item=list key=k}
    <tr style="background-color:">
		<td style="width:50px; overflow:hidden; text-align:center"><!--{$list.category_id}-->{$k+1}</td>
        <td style="text-align:left;">{$list.spacer}<a href="admincp.php?action=model_operate&task=list&channel_type={$list.channel_model}&category_id={$list.category_id}">{$list.category_name}</a> {if $list.total}{$list.total}{else}0{/if}</td>
        <td class="center">{if $list.cate_sign}{$list.cate_sign}{else}<font class="red">无</font>{/if}</td>
        <td class="center"><a href="admincp.php?action=category&channel_id={$list.channel_id}&channel_type={$channel_type}">{$list.channel_name}</a></td>
        <td class="center">{$list.cfg.show_number}</td>
        <td class="center">{if $list.category_pass}<font color="#FF0000">有</font>{else}无{/if}</td>
        <td class="center"><a href="admincp.php?action=category&do=edit&category_id={$list.category_id}&channel_type={$list.channel_model}">编辑</a> &nbsp;<a href="admincp.php?action=category&do=delete&category_id={$list.category_id}&channel_type={$list.channel_model}&channel_id={$list.channel_id}">删除</a></td>
        </tr>
        {/foreach}
        </tbody>
	</table>
    {else}
    <div class="notice_msg">无可用分类数据,请添加.</div>
    {/if}
{/if}
{if $do eq 'add' || $do eq 'edit'}
{literal}
	<script type="text/javascript">
    	$(document).ready(function(){
			$("#cate_channel").change(function(){
				var v = $(this).val();
				if(v!=0){
					var url = 'admincp.php?action=category&do=ajax_call_category&id='+v+'&channel_type='+$("#channel_types").val();
					$.getJSON(url,function(data){
						switch(data.error){
							case '1':
								alert(data.msg);
								return false;
							break;
							case '2':
									var string = '';
									var cc = data.msg;
									string += '<option value="0">作为一级分类</option>'+"\n"
									for(var i=0;i<cc.length;i++){
				string+='<option value="'+cc[i].category_id+'">&nbsp;'+cc[i].spacer+cc[i].category_name+'</option>'+"\n";
									}
								$("#category_datas").html(string);
								return ;
							break;
						}
					})
				}
			})
		})
    </script>
{/literal}
	<form action="admincp.php?action=category&channel_type={$channel_type}" method="post" name="frm" autocomplete="off">
    <input type="hidden" value="{$do}"  name="task"/>
    <input type="hidden" value="{$channel_type}" id="channel_types"  name="channel_type"/>
    {if $do eq 'edit'}
    	<input type="hidden" value="{$data.category_id}" name="category_id" />
    {/if}
	<table width="98%" border="0" cellpadding="0" cellspacing="0" class="tableborder">

	<tbody>
		<tr>
			<td width="12%" class="one">分类名称：</td>
			<td width="88%"><input type="text" name="category_name" size=50 maxlength="100" id="title" value="{$data.category_name}"><input type="hidden" name="channel_type" size=50 id="title" value="{$channel_type}">&nbsp;&nbsp;<font color=red>*</font></td>
		</tr>
		<tr>
			<td class="one">所属频道：</td>
			<td>
            {if $do eq 'edit'}
            	<input type="hidden" value="{$data.channel_id}" name="channel_id" />
                <select disabled="disabled">
                	<option disabled="disabled" selected="selected">{$channel_names}</option>
                </select>
                {else}
				<select name="channel_id" id="cate_channel" style="width:200px;">
                <option value="0" selected="selected">请选择所属频道</option>
					{foreach from=$channel_list item=list}
                    	<option value="{$list.channel_id}" {if $data.channel_id  eq $list.channel_id} selected="selected"{/if}>{$list.channel_name}</option>
                    {/foreach}
				</select>&nbsp;&nbsp;<font color=red>&nbsp;&nbsp;*&nbsp;&nbsp;注意:一旦选择了频道,在修改分类时将不能再选择频道</font>
            {/if}

			</td>
		</tr>
		<tr>
			<td class="one">所属分类：</td>
			<td>
				<select name="parent_id" id="category_datas" style="width:200px;">
					<option value="0">作为一级分类</option><br />
					{foreach from=$category_list item=list}
                    	<option value="{$list.category_id}" {if $list.category_id eq $data.parent_id} selected="selected"{/if}>{$list.spacer}{$list.category_name}</option>
                    {/foreach}
				</select>&nbsp;&nbsp;<font color=red>*</font>
			</td>
		</tr>
        <tr>
        	<td class="one">分类标志</td>
            <td><input type="text" value="{$data.cate_sign}" name="cate_sign" /> 调用程序时使用,可为空,若填则唯一</td>
        </tr>
		<tr>
			<td class="one">模版名称</td>
			<td>
				<input type="text" value="{$data.tpl_name}" maxlength="30" name="tpl_name" /> 
				可以不填写，不填写则使用系统默认 (若填写了但不存在该文件使用系统默认的)
			</td>
		</tr>
		<!--<tr>
			<td class="one"><div align="center"><b>会员发布：</b></div></td>
			<td>
				<input type="radio" name="allow_post" value="1" checked="checked"> 允许
				<input type="radio" name="allow_post" value="0" {if $data.allow_post == 0} checked="checked"{/if}> 禁止
			</td>
		</tr>-->
        <tr>
        	<td class="one">该分类下的文章列表每页显示条数:</td>
            <td>
            	<input type="text" value="{if $data.cfg.show_number}{$data.cfg.show_number}{else}20{/if}" name="cfg[show_number]"/>
            </td>
        </tr>
        <tr>
        	<td class="one">导航显示:</td>
            <td>
            否:<input  type="radio" value="0" {if $data.in_nav neq '1'} checked="checked"  {/if} name="in_nav"/>
            是:<input type="radio" value="1" name="in_nav" {if $data.in_nav eq '1'} checked="checked"{else}{/if} /> &nbsp;
            </td>
        </tr>
        <tr>
        	<td class="one">
            	前台标题标题显示使用:
            </td>
            <td>
            	短标题:<input type="radio" value="2" name="cfg[show_title]"  checked="checked" />&nbsp;长标题:<input type="radio" name="cfg[show_title]" value="1"  {if $data.cfg.show_title eq '2'}checked="checked"{/if} />
            </td>
        </tr>
       <tr>
			<td class="one">分类密码：</td>
			<td>
				<input type="text" value="{$data.category_pass}" style="width:200px;" name="category_pass" />若填写分类密码者访问改分类需要密码才能进入,包括分类下的文章(只针对当前分类)
			</td>
		</tr>
         <tr>
			<td class="one">查看权限：</td>
			<td>
				<select name="user_group" style="width:200px;">
                	{foreach from=$user_group_list item=group}
                    	<option value="{$group.id}" {if $data.user_group eq $group.id} selected="selected"{/if}>{$group.name}</option>
                    {/foreach}
                </select>
			</td>
		</tr>
		<tr>
			<td class="one">分类备注：</td>
			<td>
				<textarea name="category_desc" style="width:300px; height:100px;">{$data.category_desc}</textarea>
			</td>
		</tr>
   		<tr>
			<td class="one">分类关键字(SEO)：</td>
			<td>
				<textarea name="seo[kew_words]" style="width:300px; height:100px;">{$data.seo.kew_words}</textarea>
			</td>
		</tr>
           		<tr>
			<td class="one">分类描述(SEO)：</td>
			<td>
				<textarea name="seo[desc]" style="width:300px; height:100px;">{$data.seo.desc}</textarea>
			</td>
		</tr>
		<tr>
			<td colspan="2"><div align="center"><input type="submit" value=" 提交 "></div></td>
		</tr>
	</tbody>
	</table>
  	</form>
{/if}
</div>
{include file="footer.tpl"}