{include "header.inc.html"}
{$articleLang = $lang.admin.article.form}
<div class="content_box">
	<div class="toolbar_box">
		<div class="toolbar"> <span> <strong>{$lang.admin.article.name}</strong><br />
		<span class="english">{$lang.admin.article.name_en}</span> </span> </div>
	</div>
{if $smarty.get.act=="add" || $smarty.get.act=="edit"}
{include 'image.inc.html'}
<div class="articleForm">
<form class="form" action="" method="post" id="articleForm">
<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}" />
<input type="hidden" name="siteId" value="{$articleInfo.siteId}" />
{else}
<input type="hidden" name="siteId" value="{$siteConf.id}" />
{/if}
<div class="form-line"><label class="label">{$articleLang.title}：</label><div class="element"><input type="text" class="text w400" name="title" value="{$articleInfo.title}" />&nbsp;&nbsp;{$lang.form.iStatus}：<input type="checkbox" name="iStatus" value="1"{if $articleInfo.iStatus==1 || $smarty.get.act=='add'}checked{/if} /></div></div>
<div class="form-line"><label class="label">短标题：</label><div class="element"><input type="text" class="text w400" name="shortTitle" value="{$articleInfo.shortTitle}" /> 可用于在列表显示时精简标题</div></div>
<div class="form-line"><label class="label">{$articleLang.cat}：</label><div class="element"><select name="catId"><option value="0">{$lang.form.selectCat}</option>
{foreach from=$category item=cat}
<option value="{$cat.id}"{if $articleInfo.catId==$cat.id || ($smarty.get.act=="add" && $smarty.session.catId==$cat.id)} selected{/if}>{for $foo=1 to $cat.grade*4}&nbsp;{/for}{$cat.name}</option>
{/foreach}
</select>&nbsp;&nbsp;&nbsp;{$lang.form.sort}：<input type="text" class="text w80" name="sortId" value="{$articleInfo.sortId|default:50}" />
</div></div>
<div class="form-line"><label class="label">{$articleLang.from}：</label><div class="element"><input type="text" class="text w180" name="from" value="{$articleInfo.from}" />&nbsp;&nbsp;{$articleLang.fromUrl}：<input type="text" class="text w400" name="fromUrl" value="{$articleInfo.fromUrl}" /></div></div>
<div class="form-line"><label class="label">{$lang.seo.keywords}：</label><div class="element"><textarea name="keywords" style="width:600px;height:60px;">{$articleInfo.keywords}</textarea></div></div>
<div class="form-line"><label class="label">{$lang.seo.description}：</label><div class="element"><textarea name="description" style="width:600px;height:60px;">{$articleInfo.description}</textarea></div></div>
<div class="form-line"><label class="label">{$articleLang.content}：</label><div class="element">{editor content=$articleInfo.content}</div></div>
{if $config.article.thumbnail}
<div class="form-line">
<label class="label">缩略图：</label><div class="element"><input type="hidden" name="thumbId" id="id_pic_url" value="{$articleInfo.thumbId}" />
<script>document.write(generatePicAreaHTML('pic_url',-1, '缩略图','image',true, true));</script>
{if $articleInfo.thumbId}
{attachment id=$articleInfo.thumbId limit=1}
<script type="text/javascript">UPLOAD_IMG_NAME_VALUE='pic_url';showUploadImgResult({ "state":"SUCCESS","url":"{$item.url}","id":{$item.id} });</script>
{/attachment}
{/if}
</div>
</div>
{/if}
<div class="form-line"><label class="label">{$lang.form.seoUrl}：</label><div class="element"><input type="text" class="text w400" name="seoUrl" value="{$articleInfo.seoUrl}" /></div></div>
<div class="form-line"><label class="label">{$articleLang.template}：</label><div class="element"><input type="text" class="text w400" name="template" value="{$articleInfo.template}" /></div></div>
<div class="form-line"><label class="label">{$articleLang.externalLink}：</label><div class="element"><input type="text" class="text w400" name="externalLink" value="{$articleInfo.externalLink}" /></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>
{else}
<div class="tool">
<div class="left">
{if $smarty.get.act=="list" || $smarty.get.act==""}<a id="deleteChecked" class="ui-btn">删除所选</a>{/if}
</div>
<div class="right">
<form action="{$adminUrl}article/act/list/" method="get" class="form">
<select name="catId"><option value="">文章分类</option>{articlecat limit="false"}<option value="{$item.id}"{if $smarty.get.catId==$item.id} selected{/if}>{$item.name}</option>{/articlecat}</select> <input type="text" name="key" value="{$smarty.get.key}" /><input type="submit" class="btn_sub" value="{$lang.form.search}" />
</form>
</div>
<div class="clr"></div>
</div><!--.tool-->
 <table class="table-ca table_1" id="tInfo">
 <tr>
<th class="w30"><input type="checkbox" value="1" name="allid" id="checkall" /></th><th>{$lang.form.id}</th><th>{$articleLang.title}</th><th class="w60">{$lang.form.sort}</th><th class="w100">{$lang.form.catName}</th><th class="w150">自定URL</th><th class="w40">状态</th><th class="w120">{$lang.form.posttime}</th><th class="w80">{$lang.form.operate}</th>
 </tr>
{article limit=15 pager="true" key=$key catId=$smarty.get.catId search="true" fields="catName"}
<tr sid="{$item.id}">
<td><input type="checkbox" name="id[]" value="{$item.id}" /></td><td>{$item.id}</td><td class="tleft">{$item.title}</td><td><span class="smodedit" name="sortId" sid="{$item.id}" width="50">{$item.sortId}</span></td><td>{$item.catName} <span class="smodedit" name="catId" sid="{$item.id}" width="50">{$item.catId}</span></td><td>{$item.seoUrl}</td><td><img class="smodtoggle" name="iStatus" src="{$baseUrl}static/images/{if $item.iStatus==1}yes{else}no{/if}.gif"></td><td>{$item.posttime|date_format:"Y-m-d H:i:s"}</td><td><a href="{$item.url}" target="_blank" class="viewBtn" title="{$lang.view}">{$lang.view}</a> <a href="{$adminUrl}article/act/edit/id/{$item.id}" class="modBtn" title="{$lang.edit}">{$lang.edit}</a> <a href="javascript:void(0)" class="delBtn" title="{$lang.del}">{$lang.del}</a></td>
</tr>
{/article}
</table>
{if $key}
{$key = "/key/$key"}
{/if}
<div class="page">
	<div class="pagin fr">{pager allCount=$allCount url="/qkadmin/article$key/page/" number="false"}</div>
</div>
{/if}
{if $smarty.get.act=="edit" || $smarty.get.act=="add"}
<script type="text/javascript">
$(function(){
	$('#articleForm').validate({
		rules:{ 
			title:{ required:true }
		},
		messages:{
			title:{ required:'标题不能为空'  }
		},
		submitHandler:function(){
			ue.sync();
			$("#articleForm").ajaxSubmit({ dataType:'json',success:function(json){ qlib.tips({ icon:'success',msg:json.message}); if($("#articleForm input[name='act']").val()=='add'){ $("#articleForm input[type='text']").val("");$("#articleForm textarea").val("");ue.setContent(""); } },error:function(){ alert('ajax处理失败'); } });
		} 
	});
});
</script>
{else}
{literal}
<script type="text/javascript">
$(function(){
	$("a#deleteChecked").button().click(function(){
		if(!confirm(lang[4])){ return false; }		
		var id = [];
		$("input[name='id[]']:checkbox:checked").each(function(index){
			id[index] = $(this).val();
			var sid = $(this).val();
			if(sid){
				var tr = $(this).parent("td").parent("tr");
				var sdata = "inajax=1&act=del&id="+sid;
				$.ajax({
					type:"POST",
					url:"{$adminUrl}article",
					data:sdata,
					dataType:"json",
					success:function(data){
						if(data.success){
							tr.fadeOut("slow").remove();
						}else{
							alert(data.message);
						}
					}
				});			
			}
		});
	});
	$(".delBtn").click(function(){
		if(!confirm(lang[4])){return false;}
			var tr = $(this).parent("td").parent("tr");
			var id = tr.attr("sid");
			if(parseInt(id,10)){
				var sdata = "inajax=1&act=del&id="+id;
				$.ajax({
					type:"POST",
					url:"{$adminUrl}article",
					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"}