<table width="100%" class="topmenu">
	<tr><td>
		{?if $row.aid==0 || $row.status==1?}<a href="article.php"><em>文章列表</em></a>{?section name=i loop=$catepos?}<span>></span><a href="article.php?cid={?$catepos[i].cid?}">{?$catepos[i].cname?}</a>{?/section?}
		{?elseif $row.status==2?}<a href="pending.php?status=2"><em>审核不通过文章</em></a>{?section name=i loop=$catepos?}<span>></span><a href="pending.php?cid={?$catepos[i].cid?}&status=2">{?$catepos[i].cname?}</a>{?/section?}
		{?else?}<a href="pending.php"><em>待审核文章</em></a>{?section name=i loop=$catepos?}<span>></span><a href="pending.php?cid={?$catepos[i].cid?}">{?$catepos[i].cname?}</a>{?/section?}
		{?/if?}<span>></span>
		{?if $row.aid>0?}<a href="addarticle.php?aid={?$row.aid?}">{?$row.title?}</a>{?if $row.ischapter>0?}&nbsp;&nbsp;[<a href="chapter.php?aid={?$row.aid?}">章节管理</a>]{?/if?}{?else?}添加文章{?/if?}
	</td></tr>
</table>
<table width="100%" class="sgrid">
	<tr><td>
		单文章：内容和图集至少一个不为空；多章节文章：内容和图集可以为空
	</td></tr>
</table><br>
<form id="formAdd" method="post" onsubmit="return checkalbum()">
<input type="hidden" name="dosubmit" value="1">
<input type="hidden" name="timeline" value="{?$saxue_time?}">
<input type="hidden" name="cid" id="cid" value="{?$row.cid?}">
{?if $row.aid>0?}<input type="hidden" name="aid" value="{?$row.aid?}">{?/if?}
<table width="100%" class="grid">
	<tr>
		<td class="tdleft" width="80"><span class="red">*</span>文章类型：</td>
		<td><select name="ischapter"><option value="0"{?if 0==$row.ischapter?} selected{?/if?}>单文章</option><option value="1"{?if 1==$row.ischapter?} selected{?/if?}>多章节</option></select></td>
	</tr>
	<tr>
		<td class="tdleft"><span class="red">*</span>文章标题：</td>
		<td>
			<input name="title" id="title" type="text" value="{?$row.title?}" size="80" class="text" maxlength="100" />&nbsp;
			{?function saxue_getcolor:'style':$row.style?}
		</td>
	</tr>
	<tr>
		<td class="tdleft">文章副标题：</td>
		<td><input name="ftitle" id="ftitle" type="text" value="{?$row.ftitle?}" size="80" class="text" maxlength="100" /></td>
	</tr>
	<tr>
		<td class="tdleft">内容：</td>
		<td>{?function saxue_geteditor:'content':680:380:'default':$saxue_time?}<textarea name="content" id="content">{?$row.content?}</textarea></td>
	</tr>
	<tr>
		<td class="tdleft">内容选项：</td>
		<td>
			<label><input name="auto_remote" type="checkbox" value="1" checked />下载非本站图片到本地</label>&nbsp;
			<label><input name="auto_intro" type="checkbox" value="1" checked />截取内容</label><input name="intro_length" type="text" size="2" value="200" class="text"/>字符至简介&nbsp;
			<label><input name="auto_thumb" type="checkbox" value="1" checked />设置内容第</label><input name="thumb_no" type="text" size="1" value="1" class="text"/>张图片为标题图&nbsp;
			<label><input name="auto_link" type="checkbox" value="1" checked />清除非本站链接</label>&nbsp;<br>
			<label><input name="auto_format" type="checkbox" value="1" checked />自动排版</label>&nbsp;<span class="gray">（过滤&lt;a&gt;&lt;img&gt;&lt;embed&gt;&lt;strong&gt;&lt;h&gt;&lt;pre&gt;&lt;object&gt;之外的所有HTML标签，并插入内文广告）</span>
		</td>
	</tr>
	<tr>
		<td class="tdleft">图集：</td>
		<td>
			<div class="album_upload">
				<div id="uploadImgcontainer" class="clearfix pre-z"></div>
				<div class="clearfix">
					<a class="fl mr10 w_local" href="javascript:void(0)" >
						<span style="z-index:10" id="upload_Tip" onclick="$('#upload_Tip').hide();"><em></em>按住"Ctrl"可多选</span>
						<span id="flashContent"></span>
					</a>
					<a class="fl mr10 w_album" href="javascript:void(0)" id="albumDialog">已上传选取</a>
					<a class="fl mr10 w_confrom" href="javascript:void(0)" id="conFrom">提取内容图</a>
					<span class="fl f12 c_999"><span id="hazupinfo">已上传图片<b class="green upnum">0</b>/<b class="maxnum red">{?$configs.spics?}</b>，</span>每张最大 <b id="size_limit">{?$Saxue.SAXUE_ATTACHS_MAXSIZE?}</b> KB，支持<b id="photo_type">jpg/gif/png</b>格式</span>
				</div>
			</div>
		</td>
	</tr>
	<tr>
		<td class="tdleft">简介/摘要：</td>
		<td><textarea name="intro" id="intro" rows="2" style="width:670px;" class="textarea" maxlength="200">{?$row.intro?}</textarea></td>
	</tr>
	<tr>
		<td class="tdleft">标题图片：</td>
		<td><input name="thumb" id="thumb" type="text" size="80" value="{?$row.thumb?}" class="text readonly" readonly>&nbsp;<input type="button" class="button" id="imagethumb" value="选择图片" /></td>
	</tr>
	<tr>
		<td class="tdleft">文章TAG：<input name="tagids" id="tagids" type="hidden" value="{?$row.tagids?}"></td>
		<td><input name="tags" id="tags" type="text" size="80" value="{?$row.tags?}" class="text readonly" readonly>&nbsp;<input type="button" class="button" id="autotag" value="自动获取TAG" />&nbsp;<input type="button" class="button" id="changetag" value="选择TAG" /></td>
	</tr>
	<tr>
		<td class="tdleft">文章作者：</td>
		<td>
			<input type="text" class="text" size="10" name="author" id="author" value="{?$row.author?}" maxlength="30" />&nbsp;
			文章来源：<input type="text" class="text" size="20" name="copyfrom" id="copyfrom" value="{?$row.copyfrom?}" maxlength="30" />&nbsp;
			来源链接：<input type="text" class="text" size="50" name="fromurl" id="fromurl" value="{?$row.fromurl?}" maxlength="100" />
		</td>
	</tr>
	<tr>
		<td class="tdleft">浏览次数：</td>
		<td>
			<input type="text" class="text" name="views" id="views" size="10" value="{?$row.views?}" />&nbsp;
			点赞次数：<input type="text" class="text" name="tops" id="tops" size="10" value="{?$row.tops?}" />&nbsp;
			收藏次数：<input type="text" class="text" name="favs" id="favs" size="10" value="{?$row.favs?}" />&nbsp;
			下载次数：<input type="text" class="text" name="downs" id="downs" size="10" value="{?$row.downs?}" />
		</td>
	</tr>
	{?if $isexpand==1?}{?include file = "/data/adminform/$row.cid"?}{?/if?}
	{?if '1'==$row.status || '4'==$row.status?}<input type="hidden" name="status" value="{?$row.status?}">{?else?}
	<tr>
		<td class="tdleft">状态：</td>
		<td>
			<select name="status" id="status">
				<option value="0"{?if '0'==$row.status?} selected{?/if?}>待审核</option>
				<option value="1"{?if ''==$row.status?} selected{?/if?}>审核通过</option>
				<option value="2"{?if '2'==$row.status?} selected{?/if?}>审核不通过</option>
			</select>
		</td>
	</tr>
	{?if $row.uid>0?}
	<tr>
		<td class="tdleft blue">奖励积分：</td>
		<td class="blue">
			<input type="text" class="text" size="10" name="postscore" id="postscore" value="0" maxlength="10" onkeyup="value=value.replace(/[^0-9]/g,'');" />&nbsp;此处奖励是系统“投稿奖励积分”之外的额外奖励
		</td>
	</tr>
	<tr>
		<td class="tdleft blue">奖励资金：</td>
		<td class="blue">
			<input type="text" class="text" size="10" name="postmoney" id="postmoney" value="0" maxlength="10" onkeyup="value=value.replace(/[^0-9\.]/g,'');" />&nbsp;审核通过后奖励才会有效
		</td>
	</tr>
	{?/if?}
	{?/if?}
	<tr>
		<td class="tdleft"></td>
		<td><input type="submit" name="submit" id="submit" class="button" value="提 交"/></td>
	</tr>
</table>
</form>
<br><br>
<script type="text/javascript">
function getimgsrc(htmlstr){
	var reg=/<img.+?src=('|")?([^'"]+)('|")?(?:\s+|>)/gim;
    var arr = [];
    while(tem=reg.exec(htmlstr)){
        arr.push(tem[2]);
    }
    return arr;
}
KindEditor.ready(function(K) {
	var editor = K.editor({
		langType : 'zh_CN',
		urlType  : 'domain',
		uploadJson : '{?$saxue_url?}/api/upload_json.php?timeline={?$saxue_time?}',
		fileManagerJson : '{?$saxue_url?}/api/file_manager_json.php',
		allowFileManager : true
	});
	// 图集选取
	K('#albumDialog').click(function() {
		if (K('#albumDialog').hasClass('w_albumn')) {
			return false;
		}
		editor.loadPlugin('filemanagers', function() {
			editor.plugin.filemanagerDialog({
				viewType : 'VIEW',
				dirName : 'image',
				clickFn : function(pics) {
					editor.hideDialog();
					if (pics.length>1) {
						pics = pics.substr(1);
						var picarr = pics.split('|');
						for (var i = 0; i < picarr.length; i++) {
							UpImageShowBar.addImg({url:picarr[i]}, true);
						}
					}
				}
			});
		});
	});
	// 标题图片
	K('#imagethumb').click(function() {
		editor.loadPlugin('image', function() {
			editor.plugin.imageDialog({
				imageUrl : K('#thumb').val(),
				clickFn : function(url, title, width, height, border, align) {
					K('#thumb').val(url);
					editor.hideDialog();
				}
			});
		});
	});
});
$(function(){
	// 选择TAG
	$('#changetag').click(function() {
		doDialog('{?$saxue_url?}/tag/admin/changetag.php?cid={?$row.cid?}&isframe=1','选择TAG','700','500');
	});
	// 自动TAG
	$('#autotag').click(function() {
		if($('#tags').length>0 && $('#tagids').length>0) {
			var title = $("#title").val();
			var content = e_content.text();
			content = content.substr(0, 500);
			content = content.replace(/&/ig, '', content);
			$.post("/api/autotag.php", { "title":title, "content":content, "cid":{?$row.cid?} }, function(data){
				if(data.flag==1){
					$('#tags').val(data.tags);
					$('#tagids').val(data.tagids);
				}
			}, "json");
		}
	});
	// 提交表单
	$("#formAdd").ajaxForm({
		beforeSubmit : function(){
			if ($("#title").val()=='') {
				doTip('请输入标题');
				$("#title").focus();
				return false;
			} 
		},
        dataType: "json",
        success : function(data){
			if(data.flag == 0){
				doTip(data.msg);
			}else{
				if(confirm("内容保存成功！是否继续添加文章？\n\n选择“确定”继续添加\n选择“取消”返回文章列表页面")){
					location.href='addarticle.php';
				}else{
					{?if '0'==$row.status?}location.href='pending.php?cid={?$row.cid?}&status=0';{?elseif '2'==$row.status?}location.href='pending.php?cid={?$row.cid?}&status=2';{?else?}location.href='article.php?cid={?$row.cid?}';{?/if?}
				}
			}
        }
    });
	// 初始化图集控件
	var upimgs = [];
	{?section name=i loop=$row['slide']?}upimgs.push({'url' : "{?$row['slide'][i].url?}", 'label' : "{?$row['slide'][i].tag?}", 'detail' : "{?$row['slide'][i].desc?}"});{?/section?}
	UpImageShowBar.initBar({
		container:'uploadImgcontainer',
		flashName:'PictureUpload',
		images:upimgs,
		hazDetail:true,
		hazLabel:true,
		maxFilsSize:1024*{?$Saxue.SAXUE_ATTACHS_MAXSIZE?},
		imgMax:{?$configs.spics?}
	});
	// 内容中提取图集
	$('#conFrom').click(function() {
		var con = e_content.html();
		var imgs = getimgsrc(con);
		for (var i = 0; i < imgs.length; i++) {
			UpImageShowBar.addImg({url:imgs[i]}, true);
		}
	});
});
// 图集配置
try { 
	var ____jsoncfg = { 
		maxsize:'{?$Saxue.SAXUE_ATTACHS_MAXSIZE?}', 
		flashurl:'{?$saxue_skin_server?}/swfupload', 
		posturl:'{?$saxue_url?}/api/swfupload.php?timeline={?$saxue_time?}'
	} 
} catch (e) {}; 
</script>
<script type="text/javascript" src="{?$saxue_skin_server?}/swfupload/upload.js"></script>
<link type="text/css" rel="stylesheet" href="{?$saxue_skin_server?}/swfupload/upload.css">