<!--{template 'head'}-->
<!--{if !AJAX}-->
<script type="text/javascript">
var channelid = '{$channelid}';
function doCheck(){
	if ($('title').value=='' && $('more_title').value=='' ){
		alert('栏目名称不能为空。');
		ShowTabs(0);
		$('title').focus();
		return false;
	}
	$('divProcessing').style.display="";
	$('category_submit').disabled = true;
	return true;
};
function showMoreTitle(obj){
	if(obj.checked == true){
		$('title').value = '';
		$('category_more_title').style.display = '';
	}else{
		$('category_more_title').style.display = 'none';
	}
}
if(top != window) parent.document.getElementById('menu').contentWindow.show('submenu'+channelid.toString());
setSubject("{$channelname}栏目管理");
</script>

<table cellpadding="1" cellspacing="0" border="0" align=center  width="100%">
	<tr>
		<td class="tablerow"><b>管理选项：</b>
			<a href="system.php?sys=acategory&channelid={$channelid}&action=add"><!--{if $action=='add'}--><font color=red>栏目添加</font><!--{else}-->栏目添加<!--{/if}--></a> |
			<a href="system.php?sys=acategory&channelid={$channelid}&action=modify"><!--{if $action=='modify'}--><font color=red>栏目管理</font><!--{else}-->栏目管理<!--{/if}--></a> |
			<a href="system.php?sys=acategory&channelid={$channelid}&action=createdir">栏目目录生成</a> 
		</td>
	</tr>
</table>
<!--{/if}-->
<!--{if  $action == 'add' || $action == 'edit'}-->
<table width="100%" align="center" cellspacing="0" cellpadding="0" cellpadding='1'  class='tableborder border'>
	<tr>
		<td width="100%">
			<table width="100%" align="center" cellspacing="0" cellpadding="0" >
				<tr>
					<td width="100%" class="submenu" align=center height=25><strong>添加{$channeltitle}分类</strong></td>
				</tr>
			</table>
			<table width='100%'  border='0' align='center' cellpadding='0' cellspacing='0'  class="tableborder">
				<tr align='center'>
					<td id='TabTitle0' class='title6' onclick='ShowTabs(0)' height=24>基本信息</td>
					<td id='TabTitle1' class='title5' onclick='ShowTabs(1)'>权限设置</td>
					<td id='TabTitle2' class='title5' onclick='ShowTabs(2)'>栏目扩展</td>
					<td class="tablerow">&nbsp;</td>
				</tr>
		</table>
<form method="post" name=myform action="system.php?sys=acategory&channelid={$channelid}&action={$action}"  onsubmit="return doCheck();">
<table width="100%" align="center" cellspacing="1" cellpadding="0" >
	<tbody id='Tabs0' style="display:">
		<tr>
			<td class="tablerowl" width="150"><font color=red>上级分类</font></td>
			<td class="tablerow">
				<input type="hidden" name="cid" value="{$pcid}">
<select name="cupid" id='cupid'>
<option value='0'>作为根栏目</option>
{$strall}
</select>
</td>
</tr>
<tr id="category_title">
	<td class="tablerowl"><font color=red>分类名称</font></td>
	<td class="tablerow">
		<input type=text class="f-text"  name="title" id="title" value="{$category[title]}"> 
		<!--{if $action == 'add'}-->
		<input type="checkbox"  onclick="showMoreTitle(this)" id="checkbox_more" /><label for="checkbox_more">批量添加</label>
		<!--{/if}-->
	</td>
</tr>
<!--{if $action == 'add'}-->
<tr id="category_more_title" style="display:none">
	<td class="tablerowl"><font color=red>批量添加分类</font></td>
	<td class="tablerow">
		<textarea class="f-text"  name="more_title" id="more_title" style="width:156px;height:10em;"></textarea>
		<p style="color:blue;padding:5px 0">一行是一个分类，可以这样定义分类的目录名：文章教程|article</p>
	</td>
</tr>
<!--{/if}-->
<tr>
	<td class="tablerowl"><font color=red>目录名称</font></td>
	<td class="tablerow">
		<p style="padding-top:5px;"><input type=text class="f-text"  name='dir' id="dir" value="{$category[dir]}" /></p>
		<p style="color:blue;padding:5px 0">只能是英文，数字，_，- 组成，如果为空，系统会由栏目名称自动生成</p>
	</td>
</tr>
<tr>
<td class="tablerowl">分类简介</td>
<td class="tablerow"><textarea rows="3" cols="36" name="description" class="f-text">{$category[description]}</textarea></td>
</tr>
<tr>
<td class="tablerowl">栏目关键字</td>
<td class="tablerow"><textarea rows="3" cols="36" name="keyword" maxlen=255  class="f-text">{$category[keyword]}</textarea></td>
</tr>
<tr>
<td class="tablerowl">栏目模板</td>
<td class="tablerow">
	<p style="color:blue;padding-top:5px"><input type=text size=40 class="f-text"  name='showphp' id="showphp" value="{$category[showphp]}"> <input class="f-button" type="button" value="选择模版" onclick="SelectBrowse('{W_P}admin/images/browse.html?type=read&channelid=-1&callback=getDir','showphp',550,360);"/></p>
	<p style="color:blue;padding:5px 0">为空则使用系统默认，不具有继承性</p>
</td>
</tr>
<tr>
<td class="tablerowl">内容模板</td>
<td class="tablerow">
	<p style="color:blue;padding-top:5px"><input type=text size=40 class="f-text"  name='showmessage' id="showmessage" value="{$category[showmessage]}"> <input class="f-button"  type="button" value="选择模版" onclick="SelectBrowse('{W_P}admin/images/browse.html?type=read&channelid=-1&callback=getDir','showmessage',550,360);"/></p>
	<p style="color:blue;padding:5px 0">为空则使用系统默认，不具有继承性</p>
</td>
</tr>
<tr>
<td class="tablerowl">显示顺序</td>
<td class="tablerow">
	<input type=text class="f-text"  name="displayorder" value="{$category[displayorder]}" style="width:100px" />
	<p style="color:blue;padding:5px 0;">同级之间，数字小的在前</p>
</td>
</tr>
   <tr>
	<td class=tablerowl>栏目封面图片</td>
	<td class=tablerow>
		<input type=text class="f-text" name="pic" id="pic" size=40 maxlength="64" value="{$category[pic]}" /> 			
		<input type=button onclick="qmeCms.dialogView.iframe('上传图片','system.php?sys=upload&id=pic&channelid={$channelid}',{type:'abs'});" value="上传图片" class="f-button" />
		<input type=button onclick="SelectBrowse('{$_SET[webpath]}admin/images/browse.html?type=image&channelid={$channelid}','pic', 550,360);" value="浏览服务器" class="f-button" /></td>
  </tr> 
<tr>
	<td class="tablerowl">列表页浏览方式</td>
	<td class="tablerow"><select name="category_html" id="category_html"><option value="0">静态</option><option value="1">动态</option></select>
</tr>
<tr>
	<td class="tablerowl">内容页浏览方式</td>
	<td class="tablerow"><select name="html" id="html"><option value="0">静态</option><option value="1">动态</option></select>
</tr>
   <tr>
	<td class=tablerowl>自定义文件名</td>
	<td class=tablerow>
		<p style="color:blue;padding-top:5px"><input type=text class="f-text" name="cfilename" id="cfilename" size=25 maxlength="64" value="{$category[cfilename]}" /></p>
		<p style="color:blue;padding:5px 0;">自定义生成静态文件名，只能由英文字母和-_组成 <br />不包含文件的扩展名，如linux-php5-memcached<br />同级分类不要使用相同的名称，否则会出现不可预料的问题</p>
	</td>
  </tr>   
<tr>
<td class="tablerowl">列表页每页展现数</td>
<td class="tablerow"><input type=text class="f-text" id="num"  name="num" value="20" size="4" /> {$channelitem} </td>
</tr>
</tbody>
<tbody id='Tabs1' style="display:none">
	<tr>
		<td class="tablerowl" width=150>浏览/查看权限<br><font color=green>栏目权限没有任何继承关系，也就是子栏目的权限和父栏目没有关系</font></td>
		<td class="tablerow">
			<table border=0 cellpadding=1 cellspacing=1>
				<tr>
					<td colspan=2 class="tablerow" id="message" align=center></td>
				</tr>
				<tr>
					<td class="tablerowl" width=100>
						<input type='radio' name='pur_browse' id='pur_browse' value='0' checked /><label for="pur_browse">开放栏目</label>
					</td>
					<td class="tablerow">任何人（包括游客）可以浏览和查看此栏目下的信息</td>
				</tr>
				<tr>
					<td class="tablerowl">
						<input type='radio' name='pur_browse' value='1' id='pur_browse_1'><label for="pur_browse_1">认证栏目</label>
					</td>
					<td class="tablerow">游客不能浏览和查看,只有登录的会员才能看</td>
				</tr>
				<tr>
					<td class="tablerowl">
						<input type='radio' name='pur_browse' value='2' id='pur_browse_2'><label for="pur_browse_2">会员栏目</label>
					</td>
					<td class="tablerow">
						<div class="group-list">
							<ul>
							<!--{if $action == 'add'}-->
								<!--{eval groupCheck('pur_usergroup', array(1));}-->
							<!--{else}-->
								<!--{eval groupCheck('pur_usergroup', array(1), $category['pur_usergroup']);}-->
							<!--{/if}-->
							</ul>
						</div>
						<div class="clear"></div>
						<p style="padding-left:5px;"><font color="blue">如果选择会员栏目，只有这些被选中会员组才能查看</font></p>
					</td>
				</tr>				
			</table>
		</td>
	</tr>
	<tr>
		<td class="tablerowl">评论权限</td>
		<td class="tablerow">   
			<!--{if $action == 'add'}-->
			<input type=checkbox name='c_allow' value=1 checked id="c_allow_1" /><label for="c_allow_1">允许在此栏目发表评论</label><br />
			<!--{else}-->
			<input type=checkbox name='c_allow' value=1 <!--{if $category[c_allow] == 1}--> checked<!--{/if}--> id="c_allow_1"  /><label for="c_allow_1">允许在此栏目发表评论</label><br />
			<!--{/if}-->
		</td>
	</tr>
	<tr>
		<td class="tablerowl">允许投稿</td>
		<td class="tablerow">   
			<!--{if $action == 'add'}-->
			<input type=checkbox name='c_post' value=1 id="c_post_1" /><label for="c_post_1">允许在此栏目发布{$channeltitle}</label><br />
			<!--{else}-->
			<input type=checkbox name='c_post' value=1 <!--{if $category[c_post] == 1}--> checked<!--{/if}--> id="c_post_1"  /><label for="c_post_1">允许在此栏目供稿</label><br />
			<!--{/if}-->
		</td>
	</tr>
</tbody>
<tbody id='Tabs2' style="display:none">
			<tr>
				<th width="150">私有扩展</th>
				<th style="text-align:left"><input type="button" value="添加私有扩展" onclick="addPrivateExtend();"  /> (前台访问键值 cate_<font color="green">Key</font>)</th>
			</tr>
			<tr>
				<td class=tablerowl></td>
				<td class='tablerow'>
					<table border=0 width=100% id="extdata">
					<!--{if $action=='edit' && $category['extdata']}-->
					<!--{loop $category['extdata'] $k $v}-->
						<tr>
							<td width="180" style="vertical-align:top"><label class="f-label" style="width:40px">Key：</label><input name="extdata[key][]" type="text" value="{$v[key]}" class="f-text" size="15" /></td>
							<td width="410" style="vertical-align:top"><label class="f-label" style="width:60px">Value：</label><textarea id="extdata_{$k}" name="extdata[value][]" class="f-text" style="width:325px;height:50px;">{$v[value]}</textarea></td>
							<td style="vertical-align:top">
								<input type="button" value="上传" onclick="qmeCms.dialogView.iframe('上传','system.php?sys=upload&id=extdata_{$k}&channelid={$channelid}&file_type=all',{type:'abs'});" />
								<input type="button" value="删除" onclick="$('extdata').deleteRow(this.parentNode.parentNode.rowIndex)" />
							</td>
						</tr>
					<!--{/loop}-->
					<!--{else}-->
						<tr>
							<td width="180" style="vertical-align:top"><label class="f-label" style="width:40px">Key：</label><input name="extdata[key][]" type="text" value="" class="f-text" size="15" /></td>
							<td width="410" style="vertical-align:top"><label class="f-label" style="width:60px">Value：</label><textarea id="extdata_0" name="extdata[value][]" class="f-text" style="width:325px;height:50px;"></textarea></td>
							<td style="vertical-align:top">
								<input type="button" value="上传" onclick="qmeCms.dialogView.iframe('上传','system.php?sys=upload&id=extdata_0&channelid={$channelid}&file_type=all',{type:'abs'});" />
								<input type="button" value="删除" onclick="$('extdata').deleteRow(this.parentNode.parentNode.rowIndex)" />
							</td>
						</tr>
					<!--{/if}-->
					</table>
				</td>
			</tr>
</tbody>
<tbody>
<tr>
<td class="tablerowl" colspan=2>
<input type="hidden" name="myFormAc" value="update" />
<input type="submit" class="f-button" name=submit id="category_submit" value="   保存   " >&nbsp;
</td>
</tr>
</tbody>

</table></form>
</td>
</tr>
</table>
<!--{if $action == 'edit'}-->
<script language="javascript">
selectChecked( 'num', '{$category[num]}');
selectChecked( 'pur_browse', '{$category[pur_browse]}');
selectChecked( 'html', '{$category[html]}');
selectChecked( 'category_html', '{$category[category_html]}');
</script>
<!--{/if}-->

<!--{/if}-->

<!--{if $action == 'modify'}-->
<style>
.tableborder td b{margin-left:15px;}
.cate_tbody{overflow:hidden;zoom:1}
.cuptable td{padding:1px 3px;border-right:1px solid #fff;border-bottom:1px solid #fff}
.cuptable{overflow:hidden;display:inline-block;position:relative;width:100%}
</style>
<script type="text/javascript">
function getDetailCategory(cupid, obj){
	var h = obj.parentNode.parentNode.offsetHeight;
	var o = $("pp_"+cupid);
	if(obj.src.indexOf('explode.gif') > -1){
		obj.src = "images/implode.gif";
		o.style.height = 'auto';
		if($('childs_' + cupid) != null) return false;
		myCookie.set('_cp', cupid.toString());
		Ajax.get("system.php?sys=acategory&channelid={$channelid}&action=get&cupid="+cupid, function(resp){
			var div = document.createElement('div');
			div.id = 'childs_' + cupid ;
			div.innerHTML = resp;
			o.appendChild(div);
			gridTableEvent('childs_' + cupid);
		});
	}else{
		myCookie.set('_cp', '');
		obj.src = "images/explode.gif";
		o.style.height = (h) + 'px';
	}
};
domReady(function(){
	var cupid = myCookie.get('_cp');
	cupid = isNaN(parseInt(cupid)) ? 0 : parseInt(cupid);
	if(cupid > 0){
		var obj = $('pimg_'+cupid);
		if(obj == null) return;
		getDetailCategory(cupid, obj);
	}
});
</script>
<script type="text/javascript">
var channelid = '{$channelid}';
var channelselect = '{$channelselect}';
var mod  = '{$mod}';
var listphp = '{$listphp}';
var contentphp= '{$contentphp}';
var channeldir= '{$channeldir}';
var is_html = parseInt('{$is_html}');
setSubject("{$channeltitle}静态文件生成");
</script>
<script type="text/javascript" src="{AW_P}images/js/tohtml.js"></script>
<style>
td .relative{position:relative;height:20px;line-height:20px;}
td .relative .c-loading{position:absolute;left:0;top:0;height:20px;line-height:20px;background-color:red;width:0px;z-index:1}
td .relative .name{position:absolute;left:10px;top:0px;height:20px;line-height:20px;z-index:2;}
</style>
<table cellpadding="0" cellspacing="0" border="0" align=center class="tableborder mt5" width="100%">
	<tr>
		<td height=24 width="1"  id='loadhtml' bgcolor="red" align=center style="padding-left:0"></td>
		<td height=24 class="tablerow" style="padding-left:0"></td>
	</tr>
</table>
<form method="post" name=myform action="system.php?sys=acategory&channelid={$channelid}&action=updateorder" onsubmit="$('update-submit').disabled=true;return true;">
<table width=100% cellpadding='0' cellspacing='1' class="tableborder border" id="category_grid">
	<tbody>
		<tr>
			<th colspan=8>栏目管理</th>
		</tr>
		<tr align=center>
			<td class="tablerowhighlight" width="40"></td>
			<td class="tablerowhighlight" width="60">ID</td>
			<td class="tablerowhighlight" width="60">排序</td>
			<td class="tablerowhighlight" width="15">&nbsp;</td>
			<td class="tablerowhighlight">栏目名称</td>
			<td class="tablerowhighlight" width="60">栏目</td>
			<td class="tablerowhighlight" width="60">内容</td>
			<td class="tablerowhighlight" width="300">操作</td>
		</tr>
	</tbody>
	<!--{if $menus}-->
	<tbody>
		<tr><td colspan="8">
			<!--{loop $menus $key $val}-->
			<!--{if $val['cupid'] == 0}-->
			<div id="pp_{$val['cid']}" class="cuptable">
				<table class="tableborder" id="p_{$val['cid']}" width=100% cellpadding='0' cellspacing='0' style="border:0">
					<tr class='item'  id="item-{$val['cid']}" rel="{$val['parent_url']}" onmouseover="addClassName(this, 'item-hover');" onmouseout="removeClassName(this, 'item-hover')">
						<td width="40" height="28" align="center" class="tablerowl"><input type="checkbox" name="ids[]" id="ids_{$val['cid']}"  value="{$val['cid']}" onclick="try{event.cancelBubble=true;}catch(e){event.stopPropagation();}" /></td>
						<td width="60" align=center>{$val['cid']}</td>
						<td width="60" style="text-align:center"><input size="5" type="text" name="displayorder[{$val['cid']}]" value="{$val['displayorder']}" /></td>
						<td width="15" style="text-align:center"><!--{if $val['cupid'] == 0 && $val['child']}--><img id="pimg_{$val['cid']}" src="images/explode.gif" style="cursor:pointer;" onclick="getDetailCategory({$val['cid']}, this)" /><!--{/if}--></td>
						<td>
							<div class='relative' style='padding-left:20px'>
								<div class='c-loading' id="loading-{$val['cid']}"></div>
								<div class='name'>{$val['str']}{$val['title']}</div>
							</div>
						</td>
						<td width="60" align=center><!--{if $val['category_html'] || $val['pur_browse']}--><font color="green">动态</font><!--{else}-->静态<!--{/if}--></td>
						<td width="60" align=center><!--{if $val['html']}--><font color="green">动态</font><!--{else}-->静态<!--{/if}--></td>
						<td width="300" align="left" style="border-right:0">
							<a href="{$val['parent_url']}" target="_blank">[浏览]</a>
							<a href="{$val['preview_url']}" target="_blank">[预览]</a>
							<a href="system.php?sys=acategory&channelid={$channelid}&action=add&cid={$val['cid']}">[添加栏目]</a>
							<a href="system.php?sys=acategory&channelid={$channelid}&action=remove&cid={$val['cid']}" onclick="return makeSure();">[删除]</a>
							<a href="system.php?sys=acategory&channelid={$channelid}&action=edit&cid={$val['cid']}">[修改]</a>
							<!--{if !$val['child']}-->
							<a href="module.php?mod={$do_page}&channelid={$channelid}&action=add&cid={$val['cid']}">[添加内容]</a>
							<!--{/if}-->
						</td>
					</tr>
				</table>
			</div>
			<!--{/if}-->
			<!--{/loop}-->
			</td></tr>
		</tbody>
		<tbody>
			<tr>
				<td class="tablerowl"><input type="checkbox" value="checkbox" onclick="checkall(this.form)" id="chkall" name="chkall" /></td>
				<td colspan="7" class="tablerow" style="padding-left:15px;">
					<input type="submit" id="update-submit" class="f-button" value=" 更新排序 " />&nbsp;&nbsp;
					<input type="button" value="生成频道首页" onClick="htmlReady('h',1);" class="f-button" / >&nbsp;&nbsp;
					<input type="button" value="生成列表" onClick="htmlReady('c',1);" class="f-button" / >&nbsp;&nbsp;
					<input type="button" value="生成{$channeltitle}" onClick="htmlReady('a',1);" class="f-button" / >&nbsp;&nbsp;
					<input type="button" value="删除所有静态页面"  onClick="htmlReady('d',1);" class="f-button" / >&nbsp;&nbsp;
				</td>
			</tr>
		</tbody>
	<!--{else}-->
		<tbody>
			<tr class='item'>
				<td colspan="8" align="center"><p style="padding:12px;">当前频道下还没有栏目，<a href="system.php?sys=acategory&channelid={$channelid}&action=add">点此添加</a></p></td>
			</tr>
		</tbody>
	<!--{/if}-->
</table>
</form>
<script type="text/javascript">
	function wl( url){if( url){ window.location=url;};}
	var rm = new qmeCms.rightMenu('category_grid');
	rm.AddItem("添加子栏目","wl('system.php?sys=acategory&channelid={$channelid}&action=add&cid='+rm.id)");
	rm.AddItem("修改栏目","wl('system.php?sys=acategory&channelid={$channelid}&action=edit&cid='+rm.id)");
	rm.AddItem("删除栏目","if(makeSure()) wl('system.php?sys=acategory&channelid={$channelid}&action=remove&cid='+rm.id)");
	rm.AddLine();
	rm.AddItem("预览栏目","previewUrl('{W_P}index.php?mod={$channelid}&ac='+listphp+'&cid='+rm.id+'&preview=1')");
	rm.AddItem("查看栏目","window.open($('item-'+rm.id).getAttribute('rel'))");
	rm.AddLine();
	rm.AddItem("生成频道首页","htmlReady('h',1);");
	rm.AddItem("栏目生成静态","uncheckedAll();$('ids_'+rm.id).checked=true;htmlReady('c',1);rm.Close();");
	rm.AddItem("内容生成静态","uncheckedAll();$('ids_'+rm.id).checked=true;htmlReady('a',1);rm.Close();");
	domReady(function(){
		rm.Setup();
	});
</script>
<!--{/if}-->
<!--{if $action == 'get'}-->
		<!--{loop $menus $key $val}-->
			<table class="tableborder border" id="p_{$val['cid']}" width=100% cellpadding='0' cellspacing='0' style="border:0">
				<tr class='item'  id="item-{$val['cid']}" rel="{$val['parent_url']}" onmouseover="addClassName(this, 'item-hover');" onmouseout="removeClassName(this, 'item-hover')">
					<td width="40" height="28" align="center" class="tablerowl"><input type="checkbox" name="ids[]" id="ids_{$val['cid']}"  value="{$val['cid']}" onclick="try{event.cancelBubble=true;}catch(e){event.stopPropagation();}" /></td>
					<td width="60" align=center>{$val['cid']}</td>
					<td width="60" style="text-align:center"><input size="5" type="text" name="displayorder[{$val['cid']}]" value="{$val['displayorder']}" /></td>
					<td width="15" style="text-align:center"><!--{if $val['cupid'] == 0 && $val['child']}--><img src="images/explode.gif" style="cursor:pointer;" onclick="getDetailCategory({$val['cid']}, this)" /><!--{/if}--></td>
					<td>							
						<div class='relative' style='padding-left:20px'>
							<div class='c-loading' id="loading-{$val['cid']}"></div>
							<div class='name'>{$val['str']}{$val['title']}</div>
						</div>
					</td>
					<td width="60" align=center><!--{if $val['category_html'] || $val['pur_browse']}--><font color="green">动态</font><!--{else}-->静态<!--{/if}--></td>
					<td width="60" align=center><!--{if $val['html']}--><font color="green">动态</font><!--{else}-->静态<!--{/if}--></td>
					<td width="300" align="left" style="border-right:0">
						<a href="{$val['parent_url']}" target="_blank">[浏览]</a>
						<a href="{$val['preview_url']}" target="_blank">[预览]</a>
						<a href="system.php?sys=acategory&channelid={$channelid}&action=add&cid={$val['cid']}">[添加栏目]</a>
						<a href="system.php?sys=acategory&channelid={$channelid}&action=remove&cid={$val['cid']}" onclick="return makeSure();">[删除]</a>
						<a href="system.php?sys=acategory&channelid={$channelid}&action=edit&cid={$val['cid']}">[修改]</a>
						<!--{if !$val['child']}-->
						<a href="module.php?mod={$do_page}&channelid={$channelid}&action=add&cid={$val['cid']}">[添加内容]</a>
						<!--{/if}-->
					</td>
				</tr>
			</table>
		<!--{/loop}-->
<!--{/if}-->
<!--{template 'foot'}-->
