<!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>
