{template 'phpcms','header'}
<script type="text/javascript">
// 表单提交检测
function doCheck(){

	// 检测表单的有效性
	// 如：标题不能为空，内容不能为空，等等....
	if ($('catid').value=='0'){
		alert('指定的栏目不允许添加文章！只允许在其子栏目中添加文章。');
		$('catid').focus();
		return false;
	}
	if ($('title').value=='') {
		alert('对不起，标题不能为空！');
        $('title').focus();
		return false;
	}
	if(FCKeditorAPI.GetInstance('content').GetXHTML()=='')
	{
		alert('对不起，文章内容不能为空！');
		return false;
	}

	{if $MOD['check_code']}
	if ($('checkcodestr').value=='') {
		alert("请输入验证码!");
		$('checkcodestr').focus();
		return false;
	}
	{/if}

}
</script>

<table cellspacing="0" cellpadding="0" border="0" width="980">
<tr>
<td valign="top" class="left">
{template "member","left"}</td>
<td width="10" valign="top">
</td>
<td valign="top" class="right">
<div class="membercatslist">
<ul>
<li><a href="{$channelurl}myitem.php?action=add"><span>发表文章</span></a></li>
<li><a href="{$channelurl}myitem.php?action=manage&status=3"><span>已通过</span></a></li>
<li><a href="{$channelurl}myitem.php?action=manage&status=1"><span>待审核</span></a></li>
<li><a href="{$channelurl}myitem.php?action=manage&status=0"><span>草稿</span></a></li>
<li><a href="{$channelurl}myitem.php?action=manage&status=2"><span>退稿</span></a></li>
</ul>
</div>
<div class="clearboth"></div>
<div class="memberborder_1">
<div class="memberborder_2">
{if $action=='add'}
<h1>欢迎投稿</h1>
   <form action="{$channelurl}myitem.php?action=add" method="post" name="myform" onsubmit="return doCheck();">
<table cellpadding="2" cellspacing="1" class="righttable">
<tbody>
    <tr> 
      <td class="td_right" width="15%"> <strong>所属栏目</strong> </td>
      <td class="td_left" width="85%">{$category_select}<font color='red'>*</font></td>
    </tr>

    <tr> 
      <td class="td_right"><strong>标题</strong></td>
      <td class="td_left">{$type_select} <input name="title" type="text" id="title" size="50"><font color="#FF0000">*</font></td>
    </tr>
    <tr> 
      <td class="td_right"><strong>关键词</strong> </td>
      <td class="td_left"><input name="keywords" type="text" id="keywords" size="50"> 多个关键词之间请用半角逗号“,”隔开</td>
    </tr>
    <tr> 
      <td class="td_right"><strong>作者</strong> </td>
      <td class="td_left"><input name="author" type="text" id="author" size="50" value="{$_username}"></td>
    </tr>
    <tr> 
      <td class="td_right"><strong>来源</strong> </td>
      <td class="td_left"><input name="copyfrom" type="text" id="copyfrom" size="50" value="{$PHPCMS['sitename']}|{$PHPCMS['siteurl']}">  格式：“网站名称|网站地址”
	</td>
    </tr>
    <tr> 
      <td class="td_right"><strong>内容简介</strong> </td>
      <td class="td_left"><textarea name="introduce" cols="70" rows="5"></textarea></td>
    </tr>
    <tr> 
      <td class="td_right"><strong>内容</strong> </td>
      <td class="td_left">
		<textarea name="content" id="content" cols="100" rows="25"></textarea>
		{$editor("content",$MOD['editor_mode'],$MOD['editor_width'],$MOD['editor_height'])}
   </td>
    </tr>
    <tr> 
      <td class="td_right"><strong>标题图片</strong> </td>
      <td class="td_left"><input name="thumb" type="text" id="thumb" size="50"> <input type="button" value="上传图片" onclick="javascript:openwinx('{PHPCMS_PATH}uppic.php?channelid={$channelid}&uploadtext=thumb&type=thumb&width={$MOD[thumb_width]}&height={$MOD[thumb_height]}','upload','360','300')"></td>
    </tr>
    {$fields}
{if $MOD['check_code']}
    <tr> 
      <td class="td_right"><strong>验证码</strong></td>
      <td class="td_left"><input name="checkcodestr" type="text" size="15" id="checkcodestr">
	  <img src="<?=PHPCMS_PATH?>checkcode.php" id="checkcode" onclick="this.src='{PHPCMS_PATH}checkcode.php?id='+Math.random()*5;" style="cursor:pointer;" alt="验证码,看不清楚?请点击刷新验证码" align="absmiddle"/></td>
    </tr>
{/if}
	<tr> 
      <td class="td_right"><strong>文章状态</strong></td>
      <td class="td_left">
		<input name="status" type="radio" value="3" {if $status==3}checked{/if} {if $disabled}disabled{/if}> 已通过
		<input name="status" type="radio" value="1" {if !isset($status) || $status==1}checked{/if} > 待审核
		<input name="status" type="radio" value="0" {if isset($status) && $status==0}checked{/if}>草稿
	</td>
    </tr>
    <tr> 
      <td class="td_center" colspan="2">
	  <input type="submit" name="dosubmit" value=" 发表 "> 
	  <input type="reset" name="reset" value=" 重置 "></td>
    </tr>
  </tbody>
</table>
</form>
<!--//--->

{elseif $action=='edit'}
<h1>欢迎投稿</h1>
<form action="{$channelurl}myitem.php?action=edit&articleid={$articleid}" method="post" name="myform" onsubmit="return doCheck();">
<table cellpadding="2" cellspacing="1" class="righttable">
 <tbody>
    <tr> 
      <td class="td_right" width="15%"> <strong>所属栏目</strong> </td>
      <td class="td_left" width="85%">
{$category_select}
<font color='#FF0000'>*</font>
</td>
    </tr>
    <tr> 
      <td class="td_right"><strong>标题</strong></td>
      <td class="td_left">{$type_select} 
<input name="title" type="text" id="title" size="50" value="{$title}">
<font color="#FF0000">*</font>
    </td>
    </tr>
    <tr> 
      <td class="td_right"><strong>关键词</strong> </td>
      <td class="td_left"><input name="keywords" type="text" id="keywords" size="50" value="{$keywords}"> 多个关键词之间请用半角逗号“,”隔开</td>
    </tr>
    <tr> 
      <td class="td_right"><strong>作者</strong> </td>
      <td class="td_left"><input name="author" type="text" id="author" size="50" value="{$author}"></td>
    </tr>
    <tr> 
      <td class="td_right"><strong>来源</strong> </td>
      <td class="td_left"><input name="copyfrom" type="text" id="copyfrom" size="50" value="{$copyfrom}">  格式：“网站名称|网站地址”
	</td>
    </tr>
    <tr> 
      <td class="td_right"><strong>内容简介</strong> </td>
      <td class="td_left"><textarea name="introduce" cols="70" rows="5">{$introduce}</textarea></td>
    </tr>
    <tr> 
      <td class="td_right"><strong>内容</strong> </td>
      <td class="td_left">
		<textarea name="content" id="content" cols="100" rows="25">{$content}</textarea>
		{$editor("content",$MOD['editor_mode'],$MOD['editor_width'],$MOD['editor_height'])}
   </td>
    </tr>
    <tr> 
      <td class="td_right"><strong>标题图片</strong> </td>
      <td class="td_left">
         <input name="thumb" type="text" id="thumb" size="50" value="{$thumb}"> <input type="button" value="上传图片" onclick="javascript:openwinx('{PHPCMS_PATH}uppic.php?channelid={$channelid}&uploadtext=thumb&type=thumb&width=150&height=150','upload','360','300')">          </td>
    </tr>

    {$fields}

{if $MOD['check_code']}
    <tr> 
      <td class="td_right"><strong>验证码</strong></td>
      <td class="td_left"><input name="checkcodestr" type="text" size="15" id="checkcodestr">
	  <img src="{PHPCMS_PATH}checkcode.php" id="checkcode" onclick="this.src='{PHPCMS_PATH}checkcode.php?id='+Math.random()*5;" style="cursor:pointer;" alt="验证码,看不清楚?请点击刷新验证码" align="absmiddle"/></td>
    </tr>
{/if}

	<tr> 
      <td class="td_right"><strong>文章状态</strong></td>
      <td class="td_left">
		<input name="status" type="radio" value="3" {if $status==3}checked{/if} {if $disabled}disabled{/if}> 已通过&nbsp;
		<input name="status" type="radio" value="1" {if !isset($status) || $status==1}checked{/if} > 待审核&nbsp;
		<input name="status" type="radio" value="0" {if isset($status) && $status==0}checked{/if}>草稿&nbsp;
		<input name="status" type="radio" value="2"  {if $status==2}checked{else}disabled{/if}> 退槁&nbsp;
	</td>
    </tr>
    <tr> 
      <td class="td_center" colspan="2"><input type="submit" name="dosubmit" value=" 发表 "> &nbsp; <input type="reset" name="reset" value=" 重置 "></td>
    </tr>
 </tbody>
</table>
 </form>
{elseif $action=='preview'}
<h1>{$title}</h1>
<table cellpadding="2" cellspacing="1" class="righttable">
<tbody>
  <tr>
    <td class="td_right" width="15%"><strong>栏目</strong></td>
	<td class="td_left">{$catname}</td>
  </tr>
  <tr>
    <td class="td_right"><strong>标题</strong></td>
	<td class="td_left">{$title}</td>
  </tr>
  <tr>
    <td class="td_right"><strong>关键词</strong></td>
    <td class="td_left">{$keywords}</td>
  </tr>
  <tr>
    <td class="td_right"><strong>日期</strong></td>
    <td class="td_left">{$adddate}</td>
  </tr>
  <tr>
    <td class="td_right"><strong>标题图片</strong></td>
    <td class="td_left"><a href="{$thumb}" target="_blank">{$thumb}</td>
  </tr>
  <tr>
    <td class="td_right"><strong>作者</strong></td>
    <td class="td_left">{$author}</td>
  </tr>
  <tr>
    <td class="td_right"><strong>来源</strong></td>
    <td class="td_left">{$copyfrom}</td>
  </tr>
  
  <tr>
    <td class="td_right"><strong>内容简介</strong></td>
    <td class="td_left">{$introduce}</td>
  </tr>
  <tr>
    <td class="td_right"><strong>内容</strong></td>
    <td class="td_left">{$content}</td>
  </tr>
{loop $fields $f}
    <tr>
    <td class="td_right"><strong>{$f[title]}</strong></td>
    <td class="td_left">{$f[value]}</td>
  </tr>
  {/loop}
  <tr>
   <td class="td_right"> </td>
    <td class="td_left" align="right">
	<a href="#" onclick="javascript:history.go(-1);">返回</a>
	<a href="{$channelurl}myitem.php?action=edit&articleid={$articleid}">编辑</a>
	<a href="{$channelurl}myitem.php?action=delete&articleid={$articleid}">删除</a>	
	</td>
  </tr>
 </tbody>
</table>

{elseif $action=='manage'}
<h1>文章管理 [ {if $status==3}已通过{elseif $status==1}待审核{elseif $status==0}草稿{elseif $status==2}退稿{/if} ]</h1>
<table cellpadding="2" cellspacing="1" class="righttable">
<tbody>
<tr>
<td width="8%" class="td_center">ID</td>
<td width="43%" class="td_center">标题</td>
<td width="15%" class="td_center">栏目</td>
<td width="12%" class="td_center">发表时间</td>
<td width="10%" class="td_center">点击</td>
<td width="12%" class="td_center">管理操作</td>
</tr>

{loop $articles  $article}
<tr onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#EBF6FB'" bgColor="#ffffff">
<td class="td_center">{$article[articleid]}</td>
<td class="td_left">&nbsp;{if $article[type]}{$article[type]} {/if}{if $article['status']==3}<a href="{$article['linkurl']}" target="_blank">{else}<a href="{$channelurl}myitem.php?action=preview&articleid={$article[articleid]}">{/if}{$article['title']}</a>
</td>
<td class="td_center"><a href="{$article['catlinkurl']}" target="_blank">{$article['catname']}</a></td>
<td class="td_center">{$article['adddate']}</td>
<td class="td_center">{$article['hits']}</td>
<td class="td_center">{if $article['status']<3}<a href="{$channelurl}myitem.php?action=edit&articleid={$article[articleid]}">编辑</a> | <a href="{$channelurl}myitem.php?action=delete&articleid={$article[articleid]}">删除</a>{else}<span style="color:#C0C0C0">编辑 | 删除</span>{/if}</td>
</tr>
{/loop}
</table>

<table width="100%" height="25" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">{$pages}</td>
  </tr>
</table>
<form name="search" action="{$channelurl}myitem.php">
<table width="100%" cellpadding="0" cellspacing="0" class="righttable">
<tbody>
  <tr>
    <td class="td_center">
    <input name="status" type="hidden" value="{$status}">
	<select name="srchtype">
	<option value="0" {if $searchtype==0}selected{/if}> 标题 </option>
	<option value="2" {if $searchtype==1}selected{/if}> 作者 </option>
	</select>&nbsp;
	<input name="keywords" type="text" size="30" value="{$keywords}">&nbsp;
	{$category_select}
	<select name="ordertype">
	<option value="0" {if $ordertype==0}selected{/if}>文章排序排序</option>
	<option value="1" {if $ordertype==1}selected{/if}>更新时间降序</option>
	<option value="2" {if $ordertype==2}selected{/if}>更新时间升序</option>
	<option value="3" {if $ordertype==3}selected{/if}>浏览次数降序</option>
	<option value="4" {if $ordertype==4}selected{/if}>浏览次数升序</option>
	</select>
	<input type="submit" value="文章搜索"></td>
  </tr>
 </tbody>
</table>
</form>
{/if}
</div></div>
</td>
</tr>
 </tbody>
</table>
{template 'phpcms','footer'}