<!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>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $cfg_soft_lang; ?>">
<script language="javascript" type="text/javascript" src="js/co.js"></script>
<title>新增采集规则</title>
<link href="css/base.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.STYLE1 {
	color: #660000;
	font-weight: bold;
}
.adline {
	border-bottom:1px solid #cdcdcd;
}
.autotb td{
  padding-left:3px;
}
-->
</style>
</head>
<body>
<div class="bodytitle" style="width:98%">
 <div class="bodytitleleft"></div>
 <div class="bodytitletxt" style="padding-left:10px;"><b>新增采集规则：第二步设置内容字段获取规则</b></div>
</div>
<form name="form1" method="post" action="co_add.php">
<input type='hidden' name='nid' value='<?php echo $nid; ?>' />
<input type='hidden' name='channelid' value='<?php echo $channelid; ?>' />
<input type='hidden' name='step' value='5' />
<table width="98%" border="0" cellpadding="3" cellspacing="1" bgcolor="#D6D6D6" align="center">
  <tr> 
   <td background="images/tbg.gif" bgcolor="#F2F6E5">
   	<table width="400" border="0" cellspacing="0" cellpadding="0">
     <tr class="top" onClick="showHide('sart');" style="cursor:pointer"> 
      <td width="26" align="center"><img src="images/file_tt.gif" width="7" height="8"></td>
      <td width="374"><b>网页内容获取规则</b></td>
     </tr>
    </table>
    </td>
  </tr>
  <tr id="sart"> 
   <td height="113" valign="top" bgcolor="#FFFFFF">
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
     <tr id='achelp' style="display:none">
      <td height="60" colspan="3">１、匹配规则：在匹配区域规则中，规则一般为“<font color="#FF0000">起始无重复HTML</font><span class="STYLE1">[内容]</span><font color="#FF0000">结尾无重复HTML</font>”(普通匹配，非正则)。<br/>
２、字段值：如果指定的字段没有指定区域匹配规则，用这个值作为默认值。<br />
３、过滤规则：如果有多个规则，用<br /><font color='#6B7360'>
{dede:trim replace=&quot;&quot;}规则一{/dede:trim}<br />
{dede:trim replace=&quot;&quot;}规则二{/dede:trim}<br />
...</font>表示，如果要替换成指定的值，在 replace=&quot;&quot;里设置即可
     </td>
     </tr>
     <tr>
      <td height="35">预览网址：</td>
      <td><input type="text" name="previewurl" id="previewurl" style="width:90%" value="<?php echo $previewurl; ?>" /></td>
      <td>&nbsp;</td>
     </tr>
     <tr> 
      <td width="18%" height="60"><a href="#" onclick="showHide('achelp')"><img src="images/help.gif" width="16" height="16" /></a>内容分页导航所在的区域匹配规则：<br/></td>
      <td><textarea name="sppage" rows="3" id="sppage" style="width:90%"></textarea></td>
      <td width="37%">
      	<input name="sptype" type="radio" value="full" class="np" checked='1' />
       全部列出的分页列表<br/>
       <input type="radio" name="sptype" class="np" value="next" />
      上下页形式或不完整的分页列表
      <br />
      <input type="radio" name="sptype" class="np" value="diyrule"/>
      分页列表规则 开始:
      <input name="srul" type="text" value="1" size="4" />
      结束:
      <input name="erul" type="text" value="5" size="4" />
      </td>
     </tr>
     <tr>
      <td height="35" colspan="3" bgcolor="#FBFCE2" id="dyrule">如果设定分页列表规则.可采用地址规则(正则),其中{p}是递增变量,从1开始每次增加1,例如:{path}{file}_{p}{ext}<br />
       <strong>规则说明：{path}</strong>地址+目录 <strong>{file}</strong>文件 <strong>{ext}</strong>文件扩展名<strong>{p}</strong>分页列表数</td>
     </tr>
     <tr> 
      <td height="24" colspan="3" bgcolor="#F9FCEF">
      	&nbsp;<strong>以下为固定的采集项目：</strong>(项目点击可展开/隐藏，内容摘要、关键字、缩略图系统会用正则进行自动匹配)
      </td>
     </tr>
    </table>
     
    <table width="100%" border="0" cellspacing="0" cellpadding="2">
       <tr>
         <td width="50%" valign="top">
         	<table width="98%" border="0" cellspacing="0" cellpadding="0">
           <tr>
             <td height="24">
             	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                 <tr>
                   <td width="18%" height="80">关键字过滤内容：</td>
                   <td height="20" colspan="2">
                   	<textarea name="keywordtrim" rows="4" id="keywordtrim" style="width:90%"></textarea>
                   </td>
                 </tr>
             </table></td>
           </tr>
         </table>
         </td>
         <td valign="top">
         	<table width="98%" border="0" cellspacing="0" cellpadding="0">
           <tr>
             <td height="24">
             	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                 <tr>
                   <td width="18%" height="80">摘要过滤内容：</td>
                   <td height="20" colspan="2">
                   	<textarea name="descriptiontrim" rows="4" id="descriptiontrim" style="width:90%"></textarea>
                   </td>
                 </tr>
             </table></td>
           </tr>
         </table>
         </td>
       </tr>
       <tr>
         <td width="50%" valign="top">
         	<table width="98%" border="0" cellspacing="0" cellpadding="0">
           <tr bgcolor="#F9FCEF">
             <td height="24" class="adline">&nbsp;<a href="#" onclick="showHide('ttitle')"><b><u>文章标题</u></b></a></td>
           </tr>
           <tr>
             <td height="24" id="ttitle">
             	<input type='checkbox' name='fields[]' checked='1'  value='title' style='display:none' />
             	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                 <tr>
                   <td width="18%" height="80">匹配规则：</td>
                   <td height="20" colspan="2">
                   	<textarea name="match_title" rows="4" id="match_title" style="width:90%"><title>[内容]</title></textarea>
                   </td>
                 </tr>
                 <tr>
                   <td height="63">过滤规则：</td>
                   <td width="53%" height="63"><textarea name="trim_title" cols="20" rows="3" id="trim_title" style="width:90%"></textarea>                   </td>
                   <td height="63"><input type="button" name="button" id="button" value="常用规则" onclick="selTrim('trim_title')" />                   </td>
                 </tr>
             </table></td>
           </tr>
         </table>
         </td>
         <td valign="top">
         	<table width="98%" border="0" cellspacing="0" cellpadding="0">
           <tr bgcolor="#F9FCEF">
             <td height="24" class="adline">&nbsp;<a href="#" onclick="showHide('twriter')"><b><u>文章作者</u></b></a> </td>
           </tr>
           <tr id="twriter">
             <td height="24">
             	<input type='checkbox' name='fields[]' checked='1'  value='writer' style='display:none' />
             	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                 <tr>
                   <td width="18%" height="80">匹配规则：</td>
                   <td height="20" colspan="2"><textarea name="match_writer" rows="4" id="match_writer" style="width:90%"></textarea>
                   </td>
                 </tr>
                 <tr>
                   <td height="63">过滤规则：</td>
                   <td width="53%" height="63"><textarea name="trim_writer" cols="20" rows="3" id="trim_writer" style="width:90%"></textarea>
                   </td>
                   <td width="29%" height="63"><input type="button" name="button2" id="button2" value="常用规则" onclick="selTrim('trim_writer')" />
                   </td>
                 </tr>
             </table></td>
           </tr>
         </table>
         </td>
       </tr>
       <tr>
         <td valign="top">
         	<table width="98%" border="0" cellspacing="0" cellpadding="0">
           <tr bgcolor="#EBEFD1">
             <td height="24" bgcolor="#F0F7D9" class="adline">&nbsp;<a href="#" onclick="showHide('tsource')"><b><u>文章来源</u></b></a> </td>
           </tr>
           <tr id="tsource">
             <td height="24">
             	 <input type='checkbox' name='fields[]' checked='1'  value='source' style='display:none' />
             	 <table width="100%" border="0" cellspacing="0" cellpadding="0">
                 <tr>
                   <td width="18%" height="80">匹配规则：</td>
                   <td height="20" colspan="2"><textarea name="match_source" rows="4" id="match_source" style="width:90%"></textarea>
                   </td>
                 </tr>
                 <tr>
                   <td height="63">过滤规则：</td>
                   <td width="53%" height="63"><textarea name="trim_source" cols="20" rows="3" id="trim_source" style="width:90%"></textarea>
                   </td>
                   <td height="63"><input type="button" name="button4" id="button4" value="常用规则" onclick="selTrim('trim_source')" />
                   </td>
                 </tr>
               </table>
             </td>
           </tr>
         </table>
         </td>
         <td valign="top">
         	<table width="98%" border="0" cellspacing="0" cellpadding="0">
           <tr bgcolor="#F9FCEF">
             <td height="24" class="adline">&nbsp;<a href="#" onclick="showHide('tpubdate')"><b><u>发布时间</u></b></a> </td>
           </tr>
           <tr id="tpubdate">
             <td height="24">
             	<input type='checkbox' name='fields[]' checked='1'  value='pubdate' style='display:none' />
             	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                 <tr>
                   <td width="18%" height="80">匹配规则：</td>
                   <td height="20" colspan="2"><textarea name="match_pubdate" rows="4" id="match_pubdate" style="width:90%"></textarea>
                   </td>
                 </tr>
                 <tr>
                   <td height="63">过滤规则：</td>
                   <td width="53%" height="63"><textarea name="trim_pubdate" cols="20" rows="3" id="trim_pubdate" style="width:90%"></textarea>
                   </td>
                   <td width="29%" height="63"><input type="button" name="button3" id="button3" value="常用规则" onclick="selTrim('trim_pubdate')" />
                   </td>
                 </tr>
             </table>
             <input name="function_pubdate" type="hidden" id="function_pubdate" value="@me=GetMkTime(@me);" />
             </td>
           </tr>
         </table>
         </td>
       </tr>
     </table>
     <!-- 固定项目结束，下面为自动项目 -->
     <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
       <td width="55%" height="24" colspan="3" bgcolor="#FBFCE2">
       	&nbsp;<strong>以下是针对模型设置的采集项目：</strong>
       </td>
      </tr>
     </table>
     <?php
     $row = $dsql->GetOne("Select * From `#@__channeltype` where id='$channelid' ");
     $dtp = new DedeTagParse();
     $dtp->SetNameSpace('field','<','>');
     $dtp->LoadString($row['fieldset']);
     foreach($dtp->CTags as $ctag)
     {
     	//采集禁用的字段
     	$notsend = $ctag->GetAtt('notsend');
     	if($notsend==1) continue;
     	
     	$fieldtype = $ctag->GetAtt('type');
     	$tname = $ctag->GetTagName();
     	$iname = $ctag->GetAtt('itemname');
     	
     	//设置转换函数
     	if($fieldtype=='img') $functions = "@me=TurnImageTag(@me);";
     	else if($fieldtype=='softlinks'||$fieldtype=='addon') $functions = "@me=TurnLinkTag(@me);";
     	else if($fieldtype=='dtime') $functions = "@me=GetMkTime(@me);";
     	else $functions = '';
     	
     	//对不同类型设置默认值
      if($ctag->GetAtt('default')!='') {
      	$dfvalue = $ctag->GetAtt('default');
      }
     	else if($fieldtype=='int'||$fieldtype=='float'||$fieldtype=='number') {
     		$dfvalue = '0';
     	}
     	else if($fieldtype=='dtime') {
     		$dfvalue = time();
     	}
     	else {
     		$dfvalue = '';
     	}
     ?>
    <input type='checkbox' name='fields[]' checked='1'  value='<?php echo $tname; ?>' style='display:none' />
    <table width="99%" border="0" cellspacing="0" cellpadding="0" class='autotb' style="margin-top:2px">
     <tr bgcolor="#F9FCEF"> 
      <td width="18%" height="24"  class="adline">
         &nbsp;<a href="#" onclick="showHide('t<?php echo $tname; ?>')"><b><u><?php echo $iname; ?></u></b></a>
      </td>
      <td width="12%" class="adline">&nbsp;</td>
      <td width="10%"  class="adline"><strong>字段默认值：</strong></td>
       <td  class="adline">
      	<input name="value_<?php echo $tname; ?>" type="text" id="value_<?php echo $tname; ?>" value="<?php echo $dfvalue; ?>" size="25" style="width:250px" />
      </td>
     </tr>
     <tr id="t<?php echo $tname; ?>"> 
      <td height="24" colspan="4">
      	<table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
         <td width="16%" height="80">匹配规则：</td>
         <td height="20">
         	<textarea name="match_<?php echo $tname; ?>" rows="4" id="match_<?php echo $tname; ?>" style="width:90%"></textarea>
         </td>
         <td height="20">
         	<?php
         	if($fieldtype=='htmltext' || $fieldtype=='img')
     	    {
     	    ?>
         	<input name="isunit_<?php echo $tname; ?>" type="checkbox" id="isunit_<?php echo $tname; ?>" value="1" class="np" checked='checked' />
         	分页内容字段（规则中只允许单一的该类型字段）<br/>
          <input name="isdown_<?php echo $tname; ?>" type="checkbox" id="isdown_<?php echo $tname; ?>" value="1" class="np" checked='checked' />
          下载字段里的多媒体资源
          <?php
          }
          ?>
         </td>
        </tr>
        <tr> 
         <td height="63">过滤规则：</td>
         <td height="63">
         	<textarea name="trim_<?php echo $tname; ?>" cols="20" rows="3" id="trim_<?php echo $tname; ?>" style="width:90%"></textarea>
         </td>
         <td height="63">
         	<input type="button" name="button<?php echo $tname; ?>" id="button<?php echo $tname; ?>" value="常用规则" onclick="selTrim('trim_<?php echo $tname; ?>')" />
         </td>
        </tr>
        <tr> 
         <td width="18%" height="60">自定义处理接口：</td>
         <td width="52%" height="20">
         	<textarea name="function_<?php echo $tname; ?>" cols="20" rows="3" id="function_<?php echo $tname; ?>" style="width:90%"><?php
         		echo $functions;
         	?></textarea>
         </td>
         <td width="30%" height="20">
         	函数或程序的变量<br />
          @body 表示原始网页 @litpic 缩略图<br />
          @me 表示当前标记值和最终结果
        </td>
        </tr>
       </table>
      </td>
     </tr>
    </table>
    <?php } ?>
   </td>
  </tr>
	 <tr> 
   <td height="52" align="center" bgcolor="#FFFFFF"> 
    <input type="submit" name="b12" value="保存配置并预览" class="coolbg" style="width:150px" />
   </td>
  </tr>
</table>
</form>
</body>
</html>
