<table width="100%" class="topmenu">
	<tr><td>
		<a href="column.php"><em>栏目管理</em></a><span>|</span>
		<a href="column.php?action=langset"><em>多语言显示设置</em></a><span>|</span>
		<a href="column.php?action=add" class="on"><em>添加栏目</em></a><span>|</span>
		<a href="javascript:doDialog('{?$saxue_admin_url?}/column.php?action=addlink','添加自定义页','500','240')"><em>添加自定义页</em></a><span>|</span>
		<a href="column.php?action=cache"><em>更新栏目缓存</em></a><span>|</span>
		<a href="batch.php"><em>批量编辑</em></a>
	</td></tr>
</table>
<form id="formAdd" method="post" action="?action=add">
<input type="hidden" name="dosubmit" value="1">
{?if $row.catid>0?}<input type="hidden" name="catid" value="{?$row.catid?}">{?/if?}
<ul class="tabBut">
	<li id="tab_setting_1" class="on" onclick="swapTab(4,1);">基本选项</li>
	<li id="tab_setting_2" onclick="swapTab(4,2);">URL设置</li>
	<li id="tab_setting_3" onclick="swapTab(4,3);">模版设置</li>
	<li id="tab_setting_4" onclick="swapTab(4,4);">SEO设置</li>
</ul>
<div id="div_setting_1" class="contentList">
	<table width="100%" class="grid">
		<tr>
			<td class="tdleft" width="150">选择模块：</td>
			<td>
				<select name="modid" id="modid" {?if $row.modforbid==1?}disabled{?else?}onchange="change_module(this.value,0)"{?/if?}>
					<option value="0">≡ 选择模块 ≡</option>
					{?section name=i loop=$modules?}{?if $modules[i].status==1?}<option value="{?$i['key']?}"{?if $i['key']==$row.modid?} selected{?/if?}>{?$modules[i].name?}</option>{?/if?}{?/section?}
				</select>
			</td>
		</tr>
		<tr>
			<td class="tdleft">上级栏目：</td>
			<td><select name="pid"><option value="0"{?if 0==$Saxue.request.pid?} selected{?/if?}>≡ 作为一级栏目 ≡</option>{?$column?}</select></td>
		</tr>
		<tr>
			<td class="tdleft">栏目名称：</td>
			<td><input type="text" class="text" name="catname" id="catname" size="25" maxlength="30" value="{?$row.catname?}" /></td>
		</tr>
		<tr>
			<td class="tdleft">英文目录/标识：</td>
			<td><input type="text" class="text" name="catdir" id="catdir" size="25" maxlength="20" value="{?$row.catdir?}" onkeyup="value=value.replace(/[^a-z0-9]/g,'');" /></td>
		</tr>
		<tr>
			<td class="tdleft">栏目图片：</td>
			<td><input type="text" class="text" name="image" id="image" size="60" maxlength="100" value="{?$row.image?}" />&nbsp;<input type="button" class="button" id="butimage" value="选择图片" /></td>
		</tr>
		<tr class="temp_column">
			<td class="tdleft">显示模式：</td>
			<td>
				<input type="radio" name="display" value="0"{?if $row.display==0?} checked{?/if?}> 栏目列表&nbsp;&nbsp;
				<input type="radio" name="display" value="1"{?if $row.display==1?} checked{?/if?}> 栏目首页&nbsp;&nbsp; 
			</td>
		</tr>
	</table>
</div>
<div id="div_setting_2" class="contentList" style="display:none;">
	<table width="100%" class="grid">
		<tr class="temp_list">
			<td class="tdleft" width="150">栏目列表页URL规则：</td>
			<td><select name="setting[list_ruleid]" id="list_ruleid"><option value="0">content.php?catid=1&page=1</option></select></td>
		</tr>
		<tr class="temp_show">
			<td class="tdleft" width="150">内容页URL规则：</td>
			<td><select name="setting[show_ruleid]" id="show_ruleid"><option value="0">content.php?catid=1&id=1</option></select></td>
		</tr>
	</table>
</div>
<div id="div_setting_3" class="contentList" style="display:none;">
	<table width="100%" class="grid">
		<tr>
			<td class="tdleft" width="150"></td>{?section name=i loop=$lang?}<td>{?$lang[i].name?}</td>{?/section?}
		</tr>
		<tr class="temp_column">
			<td class="tdleft">栏目首页模板：</td>
			{?section name=i loop=$lang?}<td><select name="setting[{?$i['key']?}][column_template]" id="column_template_{?$i['key']?}"><option value="column.html">默认模版</option></select></td>{?/section?}
		</tr>
		<tr class="temp_list">
			<td class="tdleft">列表页模板：</td>
			{?section name=i loop=$lang?}<td><select name="setting[{?$i['key']?}][list_template]" id="list_template_{?$i['key']?}"><option value="list.html">默认模版</option></select></td>{?/section?}
		</tr>
		<tr class="temp_list">
			<td class="tdleft">列表每页显示：</td>
			{?section name=i loop=$lang?}<td><input type="text" class="text" name="setting[{?$i['key']?}][list_pnum]" id="list_pnum_{?$i['key']?}" size="10" value="{?if $row.catid>0?}{?$row['setting'][i]['list_pnum']?}{?else?}20{?/if?}"  onkeyup="value=value.replace(/[^0-9]/g,'');" /></td>{?/section?}
		</tr>
		<tr class="temp_search">
			<td class="tdleft">搜索页模板：</td>
			{?section name=i loop=$lang?}<td><select name="setting[{?$i['key']?}][search_template]" id="search_template_{?$i['key']?}"><option value="search.html">默认模版</option></select></td>{?/section?}
		</tr>
		<tr class="temp_search">
			<td class="tdleft">搜索每页显示：</td>
			{?section name=i loop=$lang?}<td><input type="text" class="text" name="setting[{?$i['key']?}][search_pnum]" id="search_pnum_{?$i['key']?}" size="10" value="{?if $row.catid>0?}{?$row['setting'][i]['search_pnum']?}{?else?}20{?/if?}"  onkeyup="value=value.replace(/[^0-9]/g,'');" /></td>{?/section?}
		</tr>
		<tr class="temp_show">
			<td class="tdleft">内容页模板：</td>
			{?section name=i loop=$lang?}<td><select name="setting[{?$i['key']?}][show_template]" id="show_template_{?$i['key']?}"><option value="show.html">默认模版</option></select></td>{?/section?}
		</tr>
	</table>
</div>
<div id="div_setting_4" class="contentList" style="display:none;">
	<table width="100%" class="grid">
		<tr>
			<td class="tdleft" width="200"><strong>META Title（栏目标题）</strong><br/>针对搜索引擎设置的标题</td>
			<td><input type="text" class="text" name="seo[zh][meta_title]" id="meta_title" size="80" maxlength="30" value="{?$row['seo']['zh'].meta_title?}" /></td>
		</tr>
		<tr>
			<td class="tdleft"><strong>META Keywords（栏目关键词）</strong><br/>关键字中间用半角逗号隔开</td>
			<td><textarea class="textarea" name='seo[zh][meta_keywords]' id='meta_keywords' style="width:90%;height:50px">{?$row['seo']['zh'].meta_keywords?}</textarea></td>
		</tr>
		<tr>
			<td class="tdleft"><strong>META Description（栏目描述）</strong><br/>针对搜索引擎设置的网页描述</td>
			<td><textarea class="textarea" name='seo[zh][meta_description]' id='meta_description' style="width:90%;height:50px">{?$row['seo']['zh'].meta_description?}</textarea></td>
		</tr>
	</table>
</div>
<div><br><input type="submit" name="submit" id="submit" class="button" value="提 交"/></div>
</form>
<script type="text/javascript" src="{?$saxue_skin_server?}/editor/kindeditor-min.js"></script>
<script type="text/javascript" src="{?$saxue_skin_server?}/editor/lang/zh_CN.js"></script>
<link type="text/css" rel="stylesheet" href="{?$saxue_skin_server?}/editor/themes/default/default.css" />
<script type="text/javascript">
function change_module(modid, catid) {
	if(modid) {
		$.getJSON('{?$saxue_url?}/api/get_module.php?modid='+modid+'&catid='+catid, function(data){
			$('#show_ruleid').html(data.urlrule.show);
			$('#list_ruleid').html(data.urlrule.list);
			{?section name=i loop=$lang?}
			$('#show_template_{?$i["key"]?}').html('<option value="show.html">默认模版</option>'+data.template.{?$i['key']?}.show);
			$('#list_template_{?$i["key"]?}').html('<option value="list.html">默认模版</option>'+data.template.{?$i['key']?}.list);
			$('#column_template_{?$i["key"]?}').html('<option value="column.html">默认模版</option>'+data.template.{?$i['key']?}.column);
			$('#search_template_{?$i["key"]?}').html('<option value="search.html">默认模版</option>'+data.template.{?$i['key']?}.search);
			{?/section?}
			if(data.modtype==0){
				$('.temp_column').hide();
				$('.temp_list').hide();
				$('.temp_search').hide();
				$('.temp_show').show();
			} else if(data.modtype==1){
				$('.temp_column').hide();
				$('.temp_show').hide();
				$('.temp_search').hide();
				$('.temp_list').show();
			} else {
				$('.temp_column').show();
				$('.temp_show').show();
				$('.temp_search').show();
				$('.temp_list').show();
			}
			/*
			if(data.issearch==0){
				$('.temp_search').hide();
			} else {
				$('.temp_search').show();
			}
			*/
		});
	}
}
KindEditor.ready(function(K) {
	var editor = K.editor({
		langType : 'zh_CN',
		urlType  : 'domain',
		uploadJson : '{?$saxue_url?}/api/upload_json.php',
		fileManagerJson : '{?$saxue_url?}/api/file_manager_json.php',
		allowFileManager : true
	});
	K('#butimage').click(function() {
		editor.loadPlugin('image', function() {
			editor.plugin.imageDialog({
				imageUrl : K('#image').val(),
				clickFn : function(url, title, width, height, border, align) {
					K('#image').val(url);
					editor.hideDialog();
				}
			});
		});
	});
});
$(function(){
	{?if $row.modid>0?}change_module({?$row.modid?},{?$row.catid?});{?/if?}
	$.formValidator.initConfig({formid:"formAdd",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'250',height:'50'}, function(){this.close();$(obj).focus();})}});
	$("#modid").formValidator({onshow:"请选择模块",onfocus:"请选择模块",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请选择模块"});
	$("#catname").formValidator({onshow:"请输入栏目名称",onfocus:"请输入栏目名称",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请输入栏目名称"});
	$("#catdir").formValidator({onshow:"请输入目录/标识名称",onfocus:"请输入目录/标识名称"}).regexValidator({regexp:"^[a-zA-Z0-9]{0,30}$",onerror:"目录名称必须为字母、数字"}).inputValidator({min:1,onerror:"请输入目录/标识名称"});
	$("#formAdd").ajaxForm({
        dataType: "json",
        success : function(data){
			if(data.flag == 0){
				doTip(data.msg);
			}else{
				window.top.mainframe.location.href='column.php';
				doDialogClose();
				doTip('栏目已更新');
			}
        }
    });
})
</script>