<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>刀客建站系统   管理中心  - 添加新文章 </title>
<%{include file="header.html"}%>
</head>
<body>
<h1>

<span class="action-span"><a href="index.php?act=article.dlist">文章列表</a></span>
<span class="action-span1"><a href="index.php?act=index.default_page">刀客建站系统   管理中心 </a>  - 添加新文章 &nbsp;&nbsp;<a href="index.php?act=help.get&h=article&width=450"  class="jTip"  name="我希望获得更多帮助"><img src='images/help.png'></a></span>
<span style='float:right;margin-right:10px;'><img src='images/top_help.gif'><a href="http://sitepub.cn/help"> 帮助 </a></span>
<span style='float:right;margin-right:10px;'><img src='images/top_forum.gif'><a href="http://bbs.sitepub.cn"> 论坛 </a></span>
<div style="clear:both"></div>
</h1>
<div class="tab-div">
  <div id="tabbar-div">
    <p>
      <span class="tab-front" id="general-tab">基本信息</span>
		<span class="tab-back" id="rel_software-tab">关联软件</span>
		<span class="tab-back" id="seo-tab">SEO</span>
    </p>
  </div>

  <div id="tabbody-div">
    <form  action="index.php?act=article.save_addarticle" method="post" enctype="multipart/form-data" name="theForm" onsubmit="return validate();">
    <table width="90%" id="general-table">
      <tr>
        <td class="narrow-label">文章名</td>
        <td><input type="text" name="title" size ="40" maxlength="60"  /><span class="require-field">*</span></td>

      </tr>
      <!--  -->
      <tr>
        <td class="narrow-label">分类</td>
        <td>
          <select name=cat_id id='cat_id'>
					 <%{foreach from=$out.category_res item=c_v key=c_k}%>
					<option value="<%{$c_v.parent.cat_id}%>" ><%{$c_v.parent.cat_name|escape:html}%></option>
						<%{foreach from=$c_v.children item=c_v_c key=c_k_c}%>			
						<option value="<%{$c_v_c.cat_id}%>" >&nbsp;&nbsp;&nbsp;&nbsp;<%{$c_v_c.cat_name|escape:html}%></option>
						<%{/foreach}%>
					<%{/foreach}%>
			</select>
         <span class="require-field">*</span>
			<span class=""><a href="javascript:void(0)" onclick='alert_cat_box();' >添加新分类</a></span>
			</td>
      </tr>
     <tr>
        <td class="narrow-label">显示位置</td>
        <td>
			 <input type="checkbox" name="is_article" value=1 checked=true> 文章频道&nbsp;&nbsp; <input type='checkbox' name='is_support' value=1 >Support频道 &nbsp;&nbsp; <input type='checkbox' name='is_news' value=1 >新闻栏目</td>
      </tr> 
     <tr>
        <td class="narrow-label">文章内容</td>
		    <td><%{$FCKeditor}%>
				<p>
					<a href="index.php?act=help.get&h=article_desc&width=450"   class="jTip"  name="我希望获得更多帮助"><img src='images/help.png'></a>	
				</p>
				</td>
	  </tr>
    </table>


    <table width="90%" id="rel_software-table" style="display:none">
      <tr>
      <td colspan="5">

        <img src="images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
        <select id="search_cat_id">
			  <option value="0">所有分类</caption>
		  		<%{foreach from=$out.category_soft_res item=c_v key=c_k}%>
					<option value="<%{$c_v.parent.cat_id}%>" ><%{$c_v.parent.cat_name|escape:html}%></option>
						<%{foreach from=$c_v.children item=c_v_c key=c_k_c}%>			
						<option value="<%{$c_v_c.cat_id}%>" >&nbsp;&nbsp;&nbsp;&nbsp;<%{$c_v_c.cat_name|escape:html}%></option>
						<%{/foreach}%>
					<%{/foreach}%>
		  </select>

        <input type="text" id="search_name" size="30" />
        <input type="button" value=" Search " onclick="search_software()" class="button" />
      <td>
      </tr>
      <tr>
        <th></th>
        <th>操作</th>

        <th></th>
      </tr>
      <tr>
        <td width="45%" align="center">
          <select id="source_select" size="20" style="width:90%" ondblclick="move_item('','source')" multiple="true">
          </select>
        </td>
        <td align="center">
          <p><input type="button" value="&gt;&gt;" onclick="move_item('all','source')" class="button" /></p>

          <p><input type="button" value="&gt;" onclick="move_item('','source')" class="button" /></p>
          <p><input type="button" value="&lt;" onclick="move_item('','target')" class="button" /></p>
          <p><input type="button" value="&lt;&lt;" onclick="move_item('all','target')" class="button" /></p>
        </td>
        <td width="45%" align="center">
          <select  id="target_select" multiple="true" size="20" style="width:90%" ondblclick="move_item('','target')">
           </select>
			 <div style='display:none' id='target_box'>
			 </div>
        </td>
      </tr>
    </table>

	 
	 <!--seo-->
		<table width="90%" id="seo-table" align="center" style='display:none'>
			<tr>
            <td class="label">页面Title:</td>
            <td><input type="text" name="seo_title"  size="40" /><br>
				<span style='color:#9CACAF' onmouseover='this.style.color="#192E32";' onmouseout='this.style.color="#9CACAF";' >默认为文章名称</span>
				</td>
         </tr>	
			<tr>
      	  <td class="narrow-label">页面Keywords</td>
       	 	<td><input type="text" name="seo_keywords" maxlength="60"  /><br>
				<span style='color:#9CACAF' onmouseover='this.style.color="#192E32";' onmouseout='this.style.color="#9CACAF";' >默认为文章名称</span>
				</td>
      	</tr>

			<tr>
            <td class="label">页面Description:</td>
            <td><textarea name='seo_desc' style='width:400px;height:40px;'></textarea><br>
					<span style='color:#9CACAF' onmouseover='this.style.color="#192E32";' onmouseout='this.style.color="#9CACAF";' >默认为文章前100个字符</span>	
				</td>
          </tr>	
			<tr><td></td>
			<td>
				<a href="index.php?act=help.get&h=seo&width=450"  class="jTip"  name="我希望获得更多帮助"><img src='images/help.png'></a>	
			</td>
		</tr>	
	 </table>
	
	 <div class="button-div">
      <input type="hidden" name="act" value="insert" />
      <input type="hidden" name="old_title" value=""/>
      <input type="hidden" name="id" value="" />
      <input type="submit" value=" 确定 " class="button"  />
    </div>
    </form>

  </div>

</div>
<%{include file="add_category_layer.html"}%>
<script>
$(document).ready(function(){
	change_table(['general-tab','rel_software-tab','seo-tab']);	
});

function search_software()
{
	var s_cat_id	=	$("#search_cat_id").val();
	var s_name		=	$("#search_name").val();	
	$.ajax(
		{
			url			:		"index.php?act=soft.search_soft&is_ajax=1&cat_id="+s_cat_id+"&name="+encodeURIComponent(s_name),
			dataType		:		"json",
			type			:		"GET",
			success		:		function(json){
					var source_select	=	$("#source_select");
					source_select[0].options.length=0;	
				if(!json){
					alert(' 搜索结果不存在 ');
				}else{
					for(i in json){
						var option_obj			=		new Option(json[i]['name'],json[i]['software_id']);
						source_select[0].options.add(option_obj);
					}
				}
			}
		}		
	);	
}
function move_item(type,handle)
{
	if(handle=='source'){
		var source_select	=	$("#source_select");
		var target_select =	$("#target_select");
	}else{
		var source_select	=	$("#target_select");
		var target_select =	$("#source_select");
	}
	var length		=	source_select[0].options.length;
	if(!length){
		return;
	}	
	
	if(type=='all'){
		while(this_item	=	source_select[0].options[0]){
			this_item		=	$(this_item);
			var option_obj	=	new Option(this_item[0].text,this_item.val());
			var r	=	handle_taret_input(this_item.val(),handle);
			if(r){
				target_select[0].options.add(option_obj);
			}
			this_item.remove();		
		}
	}else{
		if(!source_select[0].selectedIndex){
			source_select[0].selectedIndex=0;
		}
		var this_item		=	$(source_select[0].options[source_select[0].selectedIndex]);
		var option_obj			=		new Option(this_item[0].text,this_item.val());
		var r	=	handle_taret_input(this_item.val(),handle);
		if(r){
			target_select[0].options.add(option_obj);	
		}
		this_item.remove();	
	
	}
}
function handle_taret_input(id,handle)
{
	var input_obj	=	$("#target_input_"+id);
	if(handle=='source'){
		if(!input_obj[0]){
			$("<input type='hidden' name=target_select[] id='target_input_"+id+"' value='"+id+"'>").appendTo("#target_box");
			return true;
		}else{
			return false;
		}
	}else{
		if(input_obj[0]){
			input_obj.remove();
		}	
			return true;
	}
}
function   validate() 
{
	title_obj	=	$("input[name=title]");
	if(jQuery.trim(title_obj.val())==''){
		alert(' 请填写文章名称 ');
		title_obj[0].focus();
		return false;
	}	
	
	cat_id_obj	=	$("select[name=cat_id]");
	if(cat_id_obj.val()==0||!cat_id_obj.val()){
		alert('请选择文章分类');
		cat_id_obj[0].focus();
		return false;
	
	}


}
</script>

</body>
</html>




