<!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=soft.dlist">软件列表</a></span>
<span class="action-span1"><a href="index.php?act=index.default_page">刀客建站系统   管理中心 </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">

    <!-- tab bar -->
    <div id="tabbar-div">
      <p>
        <span class="tab-front" id="general-tab">基本信息</span>
		  <span class="tab-back" id="detail-tab">详细描述</span>
		  <span class="tab-back" id="img-tab">软件相册</span>
		  <span class="tab-back" id="rel_software-tab"> 关联软件</span>
		  <span class="tab-back" id="seo-tab">SEO</span>
		  <span class="tab-back" id="faq-tab">FAQ</span>
      </p>
    </div>

    <!-- tab body -->
    <div id="tabbody-div">
      <form enctype="multipart/form-data" action="index.php?act=soft.save_addsoft" method="post" name="theForm" id='submit_form_id' >
        <!-- max file -->
        <input type="hidden" name="MAX_FILE_SIZE" value="2097152" />
		  <table width="90%" id="general-table" align="center" >

          <tr>
            <td class="label">软件名称:</td>
            <td><input type="text" name="software_name"  style="float:left;" size="30" id='software_name_id'/>&nbsp;
            <span class="require-field">*</span></td>
          </tr>
          <tr>
            <td class="label">软件版本:</td>
            <td><input type="text" name="software_version" id='software_version_id'  size="20" /><span class="require-field">*</span></td>
          </tr>
         <tr>
            <td class="label">发布日期:</td>
            <td><input type="text" name="add_time" id='add_time_id'  size="20" /></td>
          </tr> 
			 <tr>
            <td class="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="label">软件license</td>
            <td><input type="text" name="license"  size="20" />
				</td>
          </tr>			
			<tr>
            <td class="label">软件价格</td>
            <td><input type="text" name="price"  size="5" /><br><span style='color:#9CACAF' onmouseover='this.style.color="#192E32";' onmouseout='this.style.color="#9CACAF";' >建议格式:￥30.99或$30.99</span></td>
          </tr>			

			<tr>
            <td class="label">软件大小</td>
            <td><input type="text" name="size"  size="5" /><br>
				<span style='color:#9CACAF' onmouseover='this.style.color="#192E32";' onmouseout='this.style.color="#9CACAF";' >建议格式：12.6MB或5943KB</span>
				</td>
          </tr> 
			
			 <tr>
            <td class="label">使用限制说明</td>
            <td><input type="text" name="limitations"  size="20" /><br>
					<span style='color:#9CACAF' onmouseover='this.style.color="#192E32";' onmouseout='this.style.color="#9CACAF";'>产品试用版的限制说明</span>	
				</td>
          </tr> 
			 
			 <tr>
            <td class="label">PAD文件</td>
            <td><input type='radio' name='pad_check' value='url' checked=true  onclick='$("#pad_2_id").hide();$("#pad_3_id").hide();$("#pad_1_id").show();'> External Links &nbsp;&nbsp;<input type='radio' name='pad_check' value='file'  onclick='$("#pad_1_id").hide();$("#pad_3_id").hide();$("#pad_2_id").show();'>Upload Files &nbsp;&nbsp;</td>
  			</tr>	
			 <tr>
			 <td class="label"></td>
			 <td id='pad_1_id'><input name='padlink' size='40' value='http://'></td>
			 <td id='pad_2_id' style='display:none;'><input name='padlink' size='40' type='file'></td>
			 <!--td id='pad_3_id' style='display:none;'></td-->
			 </tr>
			 <tr>
            <td class="label">操作系统</td>
            <td><input type="text" name="os"  size="20" /><br>
					<span style='color:#9CACAF' onmouseover='this.style.color="#192E32";' onmouseout='this.style.color="#9CACAF";'>建议格式：win98/winXP/win2003/其他</span>	
				</td>
          </tr>	

			 <tr>
            <td class="label">简短描述:</td>
            <td><textarea name='software_brief' style='width:400px;height:40px;'></textarea><br>
				<span style='color:#9CACAF' onmouseover='this.style.color="#192E32";' onmouseout='this.style.color="#9CACAF";'>在列表页以及软件产品页中显示</span>	
				</td>			
          </tr>
			 <tr id='new_features_box'><td class="label">版本特点:  &nbsp;<a href="javascript:void(0);" onclick='add_new_features()'>[+]</a></td><td>
				<span style='color:#9CACAF' onmouseover='this.style.color="#192E32";' onmouseout='this.style.color="#9CACAF";'>描述当前版本软件的最新特性和功能，点击[+]可以增加条目，用来填写更多历史版本信息</span>	 
			 </td></tr>
			 <tr >
				 <td class="label"> 1  </td>
            <td><textarea name='new_features[]' style='width:400px;height:30px;'></textarea>
          </tr> 	
			<tr>
            <td class="label">系统需求:</td>
            <td><textarea name='requirements' style='width:400px;height:40px;'></textarea></td>
          </tr>
         <tr>	
			 <tr>
            <td class="label">下载链接:</td>
            <td><input type="text" name="downlink"  size="40" value='http://' id='downlink_id'/>
				<span class="require-field">*</span>
				</td>
         </tr> 
			<tr>
            <td class="label">购买链接:</td>
            <td><input type="text" name="buylink"  size="40" value='http://'/><br>
				<span style='color:#9CACAF' onmouseover='this.style.color="#192E32";' onmouseout='this.style.color="#9CACAF";'>如果您的软件为免费软件，此项可以留空</span>	 
				</td>
         </tr>
			<tr>
            <td class="label">软件Icon:</td>
            <td><input type="file" name="software_icon" />&nbsp;&nbsp;<a href="index.php?act=help.get&h=icon&width=450"   class="jTip"  name="我希望获得更多帮助"><img src='images/help.png'></a><br>
				<span style='color:#9CACAF' onmouseover='this.style.color="#192E32";' onmouseout='this.style.color="#9CACAF";'>建议尺寸 32x32尺寸 .png.jpg.gif图片（如上传其他尺寸图片系统自动调整到适合尺寸）</span>	 
				</td>
         </tr>  

			<tr>
            <td class="label">列表页图片:</td>
            <td><input type="file" name="software_list_image"  />&nbsp;&nbsp;<a href="index.php?act=help.get&h=list_image&width=450"   class="jTip"  name="我希望获得更多帮助"><img src='images/help.png'></a></td>
			</tr>	

			<tr>
            <td class="label">作者</td>
            <td><input type="text" name="developer"  size="20" /></td>
          </tr>	
			<tr>
            <td class="label">主页</td>
            <td><input type="text" name="home_page"  size="40" value='http://'/></td>
          </tr>	
			<tr>
            <td class="label">推荐显示</td>
            <td><input type='checkbox' value=1 name='is_index_commend' >首页推荐 &nbsp;&nbsp;<input type='checkbox' value=1 name='is_cat_commend' >分类页推荐&nbsp;&nbsp;<input type='checkbox' value=1 name='is_channel_commend' >频道页推荐 &nbsp;&nbsp; <input type='checkbox' value=1  name='is_elite_commend'> 精品推荐 </td>
          </tr>	
		</table>

        <table width="90%" id="detail-table" style="display:none">

          <tr>
            <td><%{$FCKeditor}%>
				<p><span style='color:#9CACAF' onmouseover='this.style.color="#192E32";' onmouseout='this.style.color="#9CACAF";' ><a href="index.php?act=help.get&h=software_desc&width=450"   class="jTip"  name="我希望获得更多帮助"><img src='images/help.png'></a></span></p>
				</td>
          </tr>
        </table>

      <table width="90%" id="img-table" style="display:none" align="center">
			<tr><td>&nbsp;</td></tr>
		 <tr>
		  		 <td>
              <a href="javascript:;" onclick="addimg()">[+]</a>
              图片描述<input type="text" name="software_img_bewrite[]" size="20" />
              上传文件 <input type="file" name="software_img_url[]" /> &nbsp; 排序<input name='image_sort_order[]' size=4>
         	  <div style='height:30px;'>自动生成缩略图<input type='checkbox' name='software_auto_thumb[]' value=1 checked=true onclick='auto_thumb(this)'></div>
				  </td>
       </tr>
		 <tr>
		 <td><a href="index.php?act=help.get&h=software_img&width=450"  class="jTip"  name="我希望获得更多帮助"><img src='images/help.png'></a></td>
		 <td></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">所有分类</option>
		  		<%{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>

        <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="label">页面Keywords:</td>
            <td><input type="text" name="seo_keywords"   size="40" /><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";' >默认为软件简短描述</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>
		
		<!--faq-->
		<table width="100%" id="faq-table" align="center" style='display:none' cellspacing="0" cellpadding="0">
		
			<tr style="background:#eeeeee">
				<input type='hidden' name='software_faq_tr_name'>
				<td class="label"><a href="javascript:void(0);" onclick='del_faq_tr(this);'>[-]删除</a></td>
	            <td>
	            	<p><strong>问题 1</strong> <textarea name='software_faq[question][]'  style='width:70%;height:30px;vertical-align:top;padding:3px'><%{$v.question|escape:html}%></textarea></p>
	            	<p><strong>回答 1</strong> <textarea style='width:70%;height:40px;vertical-align:top;padding:3px' name='software_faq[answer][]'><%{$v.answer|escape:html}%></textarea> </p>
	            </td>
			</tr>	
			<tr id='add_faq_tr_id'>
				<td class="label" ><a href='javascript:void(0);' onclick='add_faq_tr()'>[+]添加</a></td>
				<td calss="label"></td>
			</tr>	
		</table>


        <div class="button-div">
			 <input type="submit" value=" 提交 " class="button" />
        </div>
        <input type="hidden" name="act" value="insert" />
      </form>
    </div>
</div>
<%{include file="add_category_layer.html"}%>
<script>
$(document).ready(function(){
	change_table(['detail-tab','general-tab','img-tab','rel_software-tab','seo-tab','faq-tab']);
});
	function addimg()
	{
		html_str	=	'<tr><td><a href="javascript:void(0);" onclick="delimg(this)">[-]</a>图片描述 <input type="text" name="software_img_bewrite[]" size="20" /> 上传文件 <input type="file" name="software_img_url[]" /> &nbsp; 排序<input name="image_sort_order[]" size=4><div style="height:30px;">自动生成缩略图<input type="checkbox" name="software_auto_thumb[]" value=1 checked=true onclick="auto_thumb(this)"></div></td></tr>';
		$(html_str).appendTo("#img-table");
	}
	
	function delimg(obj)
	{
		$(obj).parent().parent().remove();
	}

	$("#submit_form_id").submit(
	function(){
		if(jQuery.trim($("#software_name_id").val())==''){
			alert('请输入软件名称');	
			$("#general-tab").click();
			$("#software_name_id")[0].focus();
			return false;
		}
		
		
		if(jQuery.trim($("#software_version_id").val())==''){
			alert('请填写软件版本');	
			$("#general-tab").click();
			$("#software_version_id")[0].focus();
			return false;
		}


		cat_id_obj	=	$("select[name='cat_id']");
		if(cat_id_obj.val()==0||!cat_id_obj.val()){
			alert('请选择软件分类');
			$("#general-tab").click();
			cat_id_obj[0].focus();
			return false;
		}

		if(jQuery.trim($("#downlink_id").val())==''||$("#downlink_id").val()=='http://'){
			alert('请填写下载链接');	
			$("#general-tab").click();
			$("#downlink_id")[0].focus();
			return false;	
		}	
		x		=	true;
		$(":file").each(function(i){
			if(this.value&&this.name!='padlink'){
				var tmp_arr	=	this.value.split(".");
				var ext		=	tmp_arr[tmp_arr.length-1];
				if(ext!='jpeg'&&ext!='gif'&&ext!='jpg'&&ext!='png'){
					$("#img-tab").click();
					alert('图片类型必须为jepg,gif,jpg,png');
					this.focus();
					x		=	false;
					return false;
				}
			}
		});	
		if(!x){
			return false;
		}
		
	});
function auto_thumb(obj)
{
	if(obj.checked){
		$(obj).parent().html("自动生成缩略图<input type='checkbox' name='software_auto_thumb[]' value=1 checked=true onclick='auto_thumb(this)'>");	
	}else{
		$(obj).parent().html("自动生成缩略图<input type='checkbox' name='software_auto_thumb[]' value=1  onclick='auto_thumb(this)'> 上传缩略图 <input type='file' name='software_thumb_url[]' />");	
	
	}
}

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 add_faq_tr()
{
	var faq_arr  		=  document.getElementsByName("software_faq[question][]");
	var f_max   		=  faq_arr.length;
	f_max++;
	var tr_html	='<tr><input type="hidden" name="software_faq_tr_name" ><td class="label"><a href="javascript:void(0);" onclick="del_faq_tr(this);">[-] 删除</a></td>	<td><p><strong>问题 '+f_max+' </strong><textarea name="software_faq[question][]"  style="width:70%;height:30px;vertical-align:top;padding:3px"></textarea></p><p><strong>回答 '+f_max+' </strong> <textarea style="width:70%;height:30px;vertical-align:top;padding:3px" name="software_faq[answer][]"></textarea></p></td></tr>';
	
	$(tr_html).insertBefore("#add_faq_tr_id");
	$('#faq-table tr:odd').css("background","#eeeeee");
	$('#faq-table tr:even').css("background","#ffffff");
}
function del_faq_tr(obj)
{
	$(obj).parent().parent().remove();
}

function add_new_features()
{
	var features_arr	=	document.getElementsByName("new_features[]");
	var n_max	=	features_arr.length;
	n_max			=	n_max+1;
	var tr_html	=	'<tr name="software_new_features"><td class="label">&nbsp;<a href="javascript:void(0);" onclick="del_new_features(this)">[-]</a> &nbsp; '+n_max+'</td><td><textarea name="new_features[]" style="width:400px;height:30px;"></textarea><td></tr>';
	if(n_max!=1){
		$(tr_html).insertAfter($(features_arr[n_max-2]).parent().parent());
	}else{
		$(tr_html).insertAfter("#new_features_box");
	}	

}

function del_new_features(obj)
{
	$(obj).parent().parent().remove();
}

$(function(){
	 $("#add_time_id").datepicker({ dateFormat: 'yy-mm-dd',dayNamesMin: ['一', '二', '三', '四', '五', '六', '日'] ,monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']});
});

</script>
</body>
</html>
