<!--{template 'head'}-->
<!--{template 'collect/head'}-->
<script language="JavaScript">
function fCheck(index) {
	if($('name') != null &&$('name').value.trim() =="") {
		alert("请输入采集器名字");
		$('name').focus();
		return false;
	}
	if($('cid') != null){
		if(parseInt($('cid').value.trim()) == 0){
			alert("请选择一个分类");
			return false;
		}
		var c = $('cid').value.trim().split('-');
		var ch = parseInt(c[1]);
		if(ch > 0){
			alert("所属分类错误，不能使用含有子类的分类");
			return false;
		}
	}
	$('submit-act').disabled = true;
	if(index != 3){
		Form.send('rule_'+index.toString(), function(resp){
			var json = evaljson(resp);
			if(json['status'] == 200){
				if(index == 1){
					var url = "system.php?sys=collect&channelid={$channelid}&work=test_link_work&rules={$rules}";
					qmeCms.dialogView.get("采集链接测试", url, {width:600});
					$('submit-act').disabled = false;
				}else if(index == 2){
					var url = 'system.php?sys=collect&channelid={$channelid}&work=test_work&rules={$rules}&test=1&ceshitqurl=' + encodeURIComponent($('test_link').value.trim());
					qmeCms.dialogView.get('测试提取', url, {type:'abs', width:700});
					$('submit-act').disabled = false;
				}else{
					window.location.href = json.data;
				}
				return;
			}else if(json['status'] == 404){
				alert(json.message);
				$('submit-act').disabled = false;
			}
		});
		return false;
	}
	return true;
}
</script>
<table width='100%'  border='0' align='center' cellpadding='0' cellspacing='0' style="background-color:#F1F3F5">
	<tr align='center'>
		<!--{if $step == 0}--><td class='title6'  height=24 style="cursor:default">基本设置</td><!--{/if}-->
		<!--{if $step == 1}--><td class='title5'  height=24 onclick="window.location.href='system.php?sys=collect&work=edit_rules&rules={$rules}&channelid={$channelid}&step=0';">基本设置</td><td class='title6'  height=24 style="cursor:default">列表属性</td><!--{/if}-->
		<!--{if $step == 2}--><td class='title5'  height=24 onclick="window.location.href='system.php?sys=collect&work=edit_rules&rules={$rules}&channelid={$channelid}&step=0';">基本设置</td><td class='title5'  height=24 onclick="window.location.href='system.php?sys=collect&work=edit_rules&rules={$rules}&channelid={$channelid}&step=1';">列表属性</td><td class='title6'  height=24 style="cursor:default">采集内容</td><!--{/if}-->
		<td>&nbsp;</td>
	</tr>
</table>
<!--{if $step == 0}-->
<form method="POST" name="rule_0" id="rule_0" action="{$action_url}" onSubmit="return fCheck(0)">
	<table class="tableborder border" cellSpacing="1" cellPadding="1" width="100%" border="0">
		<tr>
			<td width="200" class="tablerowl">采集器名字</td>
			<td class="tablerow"><input class="f-text" type="text" name="param[name]" id="name" value="{$name}" size="50" >　</td>
		</tr>
		<tr>
			<td  class="tablerowl"><label for="pic">抓取内容中的图片</label></td>
			<td  class="tablerow"><input type="checkbox" name="param[pic]" id="pic" value="1" <!--{if $pic==1}-->checked<!--{/if}-->>　</td>
		</tr>
		<tr>
			<td  class="tablerowl"><label for="auto_filename">生成自定义文件名</label></td>
			<td  class="tablerow"><input type="checkbox" name="param[auto_filename]" id="auto_filename" value="1" <!--{if $auto_filename==1}-->checked<!--{/if}-->>　</td>
		</tr>
		<tr>
			<td class="tablerowl" >所属分类</td>
			<td class="tablerow">
				<select name="param[cid]" id="cid">
				{$menuTree}
				</select>
			</td>
		</tr>
		<tr>
			<td class="tablerowl" >编码方式</td>
			<td class="tablerow"> 
				<select name="param[charset]">
					<option value="gbk"<!--{if $charset=='gbk'}--> selected<!--{/if}-->>gbk/gb2312</option>
					<option value="utf-8"<!--{if $charset=='utf-8'}--> selected<!--{/if}-->>utf-8</option>
				</select>
			</td>
		</tr>
		<tr>
			<td width="200" class="tablerowl">填写Cookie</td>
			<td class="tablerow">
					<textarea  name="param[cookie]" rows="5" cols="80"  class="f-text">{$cookie}</textarea>
					<p>如果该网站需要登录才能采集的话，请按正规Cookie 格式输入 推荐复制电脑里的Cookie</p>
			</td>
		</tr>
		<tr>
			<td height="25" colspan="2"><input type="hidden" name="step" value="0" /><input id="submit-act" type="submit" class="f-button" value=" 下一步 " style="margin-left:225px;"></td>
		</tr>
	</table>
</form>
<!--{/if}-->
<!--{if $step == 1}-->
<form method="POST" name="rule_1" id="rule_1" action="{$action_url}" onSubmit="return fCheck(1)" >
	<table class="tableborder border" cellSpacing="1" cellPadding="1" width="100%" border="0">
		<tr>
			<td  width="200" class="tablerowl"><input type="radio" value="1" name="param[index_type]" id="_index_type" {$index_type1}> <label for="_index_type">从一个网页</label></td>
			<td class="tablerow">
				<input  class="f-text" style="width:560px;" name="param[onepage]" value="{$onepage}" id="_onepage" /> 
				<p style="color:green">此项必填，即使你选用的不是该方式</p>
			</td>
		</tr>
		<tr>
			<td  class="tablerowl"  ><input class="f-text" type="radio" value="2" name="param[index_type]" id="_index_type_2" {$index_type2}> <label for="_index_type_2">指定多网页</label></td>
			<td class="tablerow"><textarea class="f-text" name="param[manypage]" rows="5" style="width:560px;" value="">{$manypage}</textarea><p style="color:green">在上面的输入框中输入指定的网页连接,一行一个地址</p></td>
		</tr>
		<tr>
			<td class="tablerowl"  ><input type="radio" value="3" name="param[index_type]" id="_index_type_3" {$index_type3}> <label for="_index_type_3">指定范围内</label></td>
			<td class="tablerow">
				<p><input  class="f-text" style="width:560px;" name="param[oneurl]" value="{$oneurl}"></p>
				<p>
					<input  class="f-text" size="3" name="param[url_start]" value="{$url_start}">&nbsp;(可选\任何字符)到&nbsp;
					<input  class="f-text" size="3" name="param[url_end]" value="{$url_end}">&nbsp;(必填\数字)的范围&nbsp;&nbsp;&nbsp; 标签： [分页]
				</p>
			</td>
		</tr>
		<tr>
			<td class="tablerowl">连接</td>
			<td  class="tablerow">
				<p><textarea  name="param[link_rule]" rows="5" style="width:560px;"  class="f-text" wrap="off">{$link_rule}</textarea></p>		
				<p style="color:green">可用标签： [连接] [标题] [变数] </p>
			</td>
		</tr>
		<tr>
			<td class="tablerowl">连接</td>
			<td  class="tablerow">
				<p>
					<select name="link_start">
						<option value="0"<!--{if $link_start == 0}--> selected<!--{/if}-->>包含</option>
						<option value="0"<!--{if $link_start == 1}--> selected<!--{/if}-->>不包含</option>
					</select><input  name="param[link_with]" style="width:480px;"  class="f-text" value="{$link_with}" /></p>		
			</td>
		</tr>
		<tr>
			<td  class="tablerowl">替换链接</td>
			<td class="tablerow">
				<input class="f-text" style="width:560px;" value="{$jclinks}" name="param[jclinks]" class="f-text">
				<p style="color:green">如果为JS Click式的连接，是不完整链接 可以使用[替换链接]在网址前后加以补充<br />可用标签：  [替换链接]  [分页号码]</p>
			</td>
		</tr>
		<tr>
			<td height="25" colspan="2">
				<input type="hidden" name="step" value="1" />
				<input  type="button" class="f-button" value=" 上一步 " style="margin-left:225px;" onclick="window.location.href='system.php?sys=collect&work=edit_rules&rules={$rules}&channelid={$channelid}&step=0';" />
				<input id="submit-act" type="submit" class="f-button" value=" 下一步 "  />
			</td>
		</tr>
	</table>
</form>
<!--{/if}-->
<!--{if $step == 2}-->
<form method="POST" name="rule_2" id="rule_2" action="{$action_url}" onSubmit="return fCheck(2)" >
	<table class="tableborder border" cellSpacing="1" cellPadding="1" width="100%" border="0">
		<tr>
			<td  width="200"  class="tablerowl">内容</td>
			<td class="tablerow"><textarea  name="param[body_rule]" rows="5" cols="80"  class="f-text">{$body_rule}</textarea><p>可用标签： [内容] [变数]</p>
		</td>
		</tr>
		<tr>
			<td  class="tablerowl">作者</td>
			<td class="tablerow"><textarea  name="param[author]" rows="5" cols="80"  class="f-text">{$author}</textarea><p>可用标签： [作者] [变数]</p> </td>
		</tr>
		<tr>
			<td class="tablerowl">来源</td>
			<td class="tablerow">
				<textarea  name="param[source]" rows="5" cols="80"  class="f-text">{$source}</textarea>
				<p>可用标签： [来源] [变数]</p>
			</td>
		</tr>
		<tr>
			<td class="tablerowl">时间</td>
			<td class="tablerow">
				<textarea  name="param[pubtime]" rows="5" cols="80"  class="f-text">{$pubtime}</textarea>
				<p>可用标签： [时间] [变数] </p></td>
		</tr>
		<tr>
			<td class="tablerowl">过滤标签</td>
			<td class="tablerow" class="check-style">
				<input type="checkbox" name="param[filter][]" value='form' id="filter_1"  <!--{if in_array('form', $filter)}--> checked<!--{/if}--> /> <label for="filter_1">Form</label>
				<input type="checkbox" name="param[filter][]" value='input' id="filter_2" <!--{if in_array('input', $filter)}--> checked<!--{/if}-->   /> <label for="filter_2">Input</label>
				<input type="checkbox" name="param[filter][]" value='div' id="filter_3" <!--{if in_array('div', $filter)}--> checked<!--{/if}-->   /> <label for="filter_3">Div</label>
				<input type="checkbox" name="param[filter][]" value='span' id="filter_4" <!--{if in_array('span', $filter)}--> checked<!--{/if}-->  /> <label for="filter_4">Span</label>
			</td>
		</tr>
		<tr>
			<td class="tablerowl">过滤内容</td>
			<td class="tablerow" class="check-style">
				<textarea  name="param[filter_text]" rows="5" cols="80"  class="f-text">{$filter_text}</textarea> 
				<p>一行一条过滤数据 <br />可用标签：  [*] 任意n个字符  [d] 任意n个数字 [a]任意n个大小写的英文字母</p>
			</td>
		</tr>
		<tr>
			<td class="tablerowl">内容简介</td>
			<td class="tablerow"><input class="f-text"  type=text name="param[len]" value="{$len}" >如果大于0，系统将从内容中截取此长度文字(一个汉字两个字节)</td>
		</tr>
		<tr>
			<td class="tablerowl"><input type="radio" value="1" name="param[formss]" id="formss_1" {$formss1} /> <label for="formss_1">全部列出形式导航</label></td>
			<td class="tablerow">
				<textarea  name="param[form_code]" rows="5" cols="80"  class="f-text">{$form_code}</textarea> 
				<p>分页区域内的所有的链接，系统均认为是该文章的页面&nbsp;&nbsp; 可用标签： [分页区域] [变数] </p>
			</td>
		</tr>
		<tr>
			<td height="25" colspan="2">
				<input type="hidden" name="test_link" id="test_link" value="<!--{echo urldecode($_GET['test_link'])}-->" />
				<input type="hidden" name="step" value="2" />
				<input  type="button" class="f-button" value=" 上一步 " style="margin-left:225px;" onclick="window.location.href='system.php?sys=collect&work=edit_rules&rules={$rules}&channelid={$channelid}&step=1';" />
				<input id="submit-act" type="submit" class="f-button" value=" 下一步 "  />
			</td>
		</tr>
	</table>
</form>
<!--{/if}-->

<!--{template 'foot'}-->