{include "header.inc.html"}
<div class="content_box">
	<div class="toolbar_box">
		<div class="toolbar"> <span> <strong>{$lang.admin.articlecat.name}</strong><br />
		<span class="english">{$lang.admin.articlecat.name_en}</span> </span> </div>
	</div>
{if $smarty.get.act=="add" || $smarty.get.act=="edit"}
{include 'image.inc.html'}
<div class="categoryForm">
<form class="form" action="" method="post" id="catForm">
<input type="hidden" name="inajax" value="1" /><input type="hidden" name="act" value="{$smarty.get.act}" />
{if $smarty.get.act=="edit"}<input type="hidden" name="id" value="{$smarty.get.id}" />{/if}
<div class="form-line"><label class="label">分类名称：</label><div class="element"><input type="text" class="text w300" name="name" value="{$catInfo.name}" /><label class="star">*</label></div></div>
<div class="form-line"><label class="label">分类页面标题：</label><div class="element"><input type="text" class="text w300" name="title" value="{$catInfo.title}" /><label class="star">*</label></div></div>
<div class="form-line"><label class="label">分类页面关键字：</label><div class="element"><textarea type="text" class="text w500" name="keywords">{$catInfo.keywords}</textarea><label class="star">*</label></div></div>
<div class="form-line"><label class="label">分类页面描述：</label><div class="element"><textarea type="text" class="text w500" name="description">{$catInfo.description}</textarea><label class="star">*</label></div></div>
<div class="form-line"><label class="label">上级分类：</label><div class="element"><select name="parentId"><option value="0">顶级分类</option>
{foreach from=$articleCat item=item}
<option value="{$item.id}"{if $catInfo.parentId==$item.id || ($smarty.get.act=="add" && $item.id==$smarty.request.parentId)} selected{/if}>{for $foo=1 to $item.grade*4}&nbsp;{/for}{$item.name}</option>
{/foreach}
</select>
</div></div>
<div class="form-line"><label class="label">排序：</label><div class="element"><input type="text" class="text w300" name="sortId" value="{$catInfo.sortId|default:10000}" /></div></div>
<div class="form-line"><label class="label">列表模板：</label><div class="element"><input type="text" class="text w200" name="template" value="{$catInfo.template}" /></div></div>
<div class="form-line"><label class="label">内容模板：</label><div class="element"><input type="text" class="text w200" name="templateView" value="{$catInfo.templateView}" /></div></div>
<div class="form-line"><label class="label">URL自定义：</label><div class="element"><input type="text" class="text w400" name="seoUrl" value="{$catInfo.seoUrl}" /> 以/开头并且符合URL规则</div></div>
<div class="form-line"><label class="label">转向URL：</label><div class="element"><input type="text" class="text w400" name="externalLink" value="{$catInfo.externalLink}" /></div></div>
<div class="form-line"><label class="label">详情页URL规则：</label><div class="element"><input type="text" class="text w200" name="articleUrl" value="{$catInfo.articleUrl}" /> 文章ID使用{ldelim}articleId{rdelim}代替。例如：/cat/view/{ldelim}articleId{rdelim}.html</div></div>

<div class="form-line">
<label class="label">缩略图：</label><div class="element">
{foreach from=$catInfo.thumbIdsArr item='thumb'}
	<input type="hidden" name="thumbIds[]" id="id_pic_url_{$thumb@index+1}" value="{$thumb}" />
	<script>document.write(generatePicAreaHTML('pic_url_{$thumb@index+1}',-1, '缩略图 {$thumb@index+1}','image',true, true));</script>
	{if $thumb}
	{attachment id=$thumb limit=1}
	<script type="text/javascript">UPLOAD_IMG_NAME_VALUE='pic_url_{$thumb@index+1}';showUploadImgResult({ "state":"SUCCESS","url":"{$item.url}","id":{$item.id} });</script>
	{/attachment}
	{/if}
{/foreach}

	<input type="hidden" name="thumbIds[]" id="id_pic_url" value="" />
	<script>document.write(generatePicAreaHTML('pic_url',-1, '缩略图','image',true, true));</script>

</div>
</div>


<div class="form-line"><label class="label">分类页内容：</label><div class="element">{editor content=$catInfo.content}</div></div>

<div class="form-line"><label class="label"></label><div class="element"><input type="submit" class="btn_sub" value="{$lang.form.submit}" /></div></div>
</form>
</div>
<script type="text/javascript">
$(function(){
	$('#catForm').validate({
		rules:{ 
			name:{ required:true }
		},
		messages:{
			name:{ required:'分类名称不能为空'  }
		},
		submitHandler:function(){
			ue.sync();
			$("#catForm").ajaxSubmit({ dataType:'json',success:function(json){ qlib.tips({ icon:'success',msg:json.message}); if($("#catForm input[name='act']").val()=='add'){ $("#catForm input[type='text']").val("");$("#catForm textarea").val(""); } },error:function(){ alert('ajax处理失败'); } });
		} 
	});
});
</script>

{else}
 <table class="table-ca table_1" id="tInfo">
 <tr>
<th class="w40">编号</th><th>分类名称</th><th class="w150">列表模板</th><th>内容模板</th><th>URL自定义</th><th>详情页URL规则</th><th class="w60">排序</th><th class="w90">添加时间</th><th class="w100">操作</th>
 </tr>
{foreach from=$articleCat item=item}
<tr sid="{$item.id}">
<td>{$item.id}</td><td class="tleft">&nbsp;&nbsp;{for $foo=1 to $item.grade*4}&nbsp;&nbsp;{/for}{$item.name}</td><td><span class="smodedit"  name="template" width="140">{$item.template}</span></td><td><span class="smodedit"  name="templateView" width="140">{$item.templateView}</span></td><td>{$item.seoUrl}</td><td>{$item.articleUrl}</td><td><span class="smodedit" name="sortId" width="40px">{$item.sortId}</span></td><td>{$item.posttime|date_format:"%Y-%m-%d"}</td><td><a href="/qkadmin/articlecat/act/edit/id/{$item.id}" class="modBtn">修改</a> <a href="/qkadmin/articlecat/act/del/id/{$item.id}" class="delBtn">删除</a></td>
</tr>
{/foreach}
</table>
{/if}
{if $smarty.get.act=="list" || $smarty.get.act==""}
{literal}
<script type="text/javascript">
$(function(){
	$(".delBtn").click(function(){
			if(!confirm("删除后不可恢复，是否确认删除？")){return false;}
			var tr = $(this).parent("td").parent("tr");
			var id = tr.find("td").eq(0).text();
			if(parseInt(id,10)){
				var sdata = "inajax=1&act=del&id="+id;
				$.ajax({
					type:"POST",
					url:".",
					data:sdata,
					dataType:"json",
					success:function(data){
						if(data.success){
							tr.fadeOut("slow").remove();
						}else{
							alert(data.message)
						}
					}
				});
			}
		return false;
	});
})
</script>
{/literal}
{/if}
</div><!--.content_box-->
{include "footer.inc.html"}