<%@ Page Language="c#" Inherits="TopWinCMS.WebUI.Admin.ArticleGather_Add" CodeBehind="ArticleGather_Add.aspx.cs" %>

<%@ Register Src="../UC_AjaxLoading.ascx" TagName="UC_AjaxLoading" TagPrefix="uc1" %>
<%@ Register TagPrefix="cc1" Namespace="TopWinCMS.WebControls" Assembly="TopWinCMS.WebControls" %>
<!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 runat="server">
    <title>添加采集任务</title>
    <meta http-equiv="Pragma" content="No-cach" />
    <link href="../Style.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript" src="../../Images/skysoft.js"></script>
    <script language="javascript" type="text/javascript" src="../TopWin.js"></script>
    <script type="text/javascript" language="javascript">
        function CheckForm()
        {
            if (document.getElementById("DDL_ArticleClass").value == 0)
            {
                alert("请选择栏目！");
                document.getElementById("DDL_ArticleClass").focus();
                return false;
            }
            if (document.getElementById("TB_StartUrl").value == "")
            {
                alert("请填写列表开始地址！");
                document.getElementById("TB_StartUrl").focus();
                return false;
            }
            if (document.getElementById("NT_Num").value == "")
            {
                alert("请填写采集数目！");
                document.getElementById("NT_Num").focus();
                return false;
            }
            if (document.getElementById("TB_ClassArea").value == "")
            {
                alert("扫描栏目页范围！");
                document.getElementById("TB_ClassArea").focus();
                return false;
            }
            if (document.getElementById("TB_ShowArticleUrl").value == "")
            {
                alert("文章页链接！");
                document.getElementById("TB_ShowArticleUrl").focus();
                return false;
            }
            if (document.getElementById("TB_Title").value == "")
            {
                alert("文章标题！");
                document.getElementById("TB_Title").focus();
                return false;
            }
            if (document.getElementById("TB_Content").value == "")
            {
                alert("文章内容！");
                document.getElementById("TB_Content").focus();
                return false;
            }
        }

        function show_ln()
        {
            var iadd = 1;

            if (event.srcElement == $("TB_Filter"))
            {
                var x = $("TB_Filter").value.split('\n').length + iadd;

                var str = '';
                for (var i = 1; i < x; i++)
                    str += i + '\n';

                $("txt_ln").value = str;
                $("txt_ln").scrollTop = $("TB_Filter").scrollTop;
            }
            if (event.srcElement == $("TB_Replace"))
            {
                var x = $("TB_Replace").value.split('\n').length + iadd;

                var str = '';
                for (var i = 1; i < x; i++)
                    str += i + '\n';

                document.getElementById('txt_ln2').value = str;
            }
        }

        function toDoc(cID, str)
        {
            $(cID).value = $(cID).value + str;
        }
        function ToLineNum()
        {
            for (var i = 0; i < ($("TB_Filter").value.split('\n').length); i++)
                document.getElementById('txt_ln').value += (i + 1) + '\n';
            for (var i = 0; i < ($("TB_Replace").value.split('\n').length); i++)
                document.getElementById('txt_ln2').value += (i + 1) + '\n';
        }
 
    </script>
    <style type="text/css">
        .style1
        {
            color: #ff0000;
        }
    </style>
</head>
<body bgcolor="#ffffff">
    <form id="Form1" method="post" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server">
        <ProgressTemplate>
            <uc1:UC_AjaxLoading ID="UC_AjaxLoading1" runat="server" />
        </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <fieldset>
                &nbsp;<legend><strong>基本设置</strong></legend>
                <table cellpadding="3" width="98%" align="center">
                    <tr>
                        <td align="right" style="width: 146px">
                            任务名称：
                        </td>
                        <td>
                            <asp:TextBox ID="TB_GatherName" runat="server" Width="200px"></asp:TextBox>
                            <span class="style1">*</span>
                        </td>
                        <td>
                            <img title="复制相似的采集规则" height="16" src="../../Images/help.gif" width="16" alt="" />复制任务：
                            <asp:DropDownList ID="DDL_Gather" runat="server" AutoPostBack="True" OnSelectedIndexChanged="Ddl_Gather_SelectedIndexChanged"
                                onchange="ToLineNum();">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            列表开始地址：
                        </td>
                        <td colspan="2">
                            <asp:TextBox ID="TB_StartUrl" runat="server" Width="528px"></asp:TextBox>
                            <span class="style1">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <img title="“0”为无限多" height="16" src="../../Images/help.gif" width="16">
                            采集数目：
                        </td>
                        <td colspan="2">
                            <cc1:NumericTextBox ID="NT_Num" runat="server" Width="88px">0</cc1:NumericTextBox>
                            <span class="style1">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <img title="“专家模式”为支持正则表达式" height="16" src="../../Images/help.gif" width="16">是否为专家模式：
                        </td>
                        <td colspan="2">
                            <asp:CheckBox ID="CB_IsExpert" runat="server" Checked="True" /><br />
                            “专家模式”是使用正则表达式为采集规则的，使用者需要熟练掌握正则；<br />
                            非专家模式是用普通的HTML作采集规则；<br />
                            当选择了“专家模式”时可以使用一下<a href="ArticleGather_Rule.aspx" target="_blank"><strong>规则生成器</strong></a>作为辅助。
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            是否采集含图的文章：
                        </td>
                        <td colspan="2">
                            <asp:RadioButtonList ID="RBL_GatherPicArticle" runat="server" RepeatDirection="Horizontal">
                                <asp:ListItem Value="是" Selected="True">是</asp:ListItem>
                                <asp:ListItem Value="否" Selected="True">否</asp:ListItem>
                            </asp:RadioButtonList>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            下载站外图片：
                        </td>
                        <td colspan="2">
                            <asp:RadioButtonList ID="RBL_DownImg" runat="server" RepeatDirection="Horizontal">
                                <asp:ListItem Value="是">是</asp:ListItem>
                                <asp:ListItem Value="否" Selected="True">否</asp:ListItem>
                            </asp:RadioButtonList>
                            当上面选择"是",如果不下载站外图片,则保持外链别人的图片.
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <img title="当且仅当选择了下载图片的时候生效" height="16" src="../../Images/help.gif" width="16">是否加水印：
                        </td>
                        <td colspan="2">
                            <asp:RadioButtonList ID="RBL_DrawWaterMark" runat="server" RepeatDirection="Horizontal">
                                <asp:ListItem Value="是">是</asp:ListItem>
                                <asp:ListItem Value="否" Selected="True">否</asp:ListItem>
                            </asp:RadioButtonList>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            通过审核：
                        </td>
                        <td colspan="2">
                            <asp:RadioButtonList ID="RBL_Pass" runat="server" RepeatDirection="Horizontal">
                                <asp:ListItem Value="是">是</asp:ListItem>
                                <asp:ListItem Value="否" Selected="True">否</asp:ListItem>
                            </asp:RadioButtonList>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            采往哪个栏目：
                        </td>
                        <td colspan="2">
                            <asp:DropDownList ID="DDL_ArticleClass" runat="server">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            倒序采集：
                        </td>
                        <td colspan="2">
                            <asp:CheckBox ID="CB_IsReverse" runat="server" />
                        </td>
                    </tr>
                </table>
            </fieldset>
            &nbsp;
            <br>
            <fieldset>
                <legend><strong>栏目匹配规则</strong></legend>
                <table cellpadding="3" width="98%" align="center">
                    <tr>
                        <td align="right" style=" width: 140px">
                            扫描栏目页范围：
                        </td>
                        <td>
                            <asp:TextBox ID="TB_ClassArea" runat="server" Width="528px" TextMode="MultiLine"></asp:TextBox>
                            <span class="style1">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            文章页链接：
                        </td>
                        <td>
                            <asp:TextBox ID="TB_ShowArticleUrl" runat="server" Width="528px" TextMode="MultiLine"></asp:TextBox>
                            <span class="style1">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            栏目下一页：
                        </td>
                        <td>
                            <asp:TextBox ID="TB_ClassNextPage" runat="server" Width="528px" TextMode="MultiLine"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            栏目上一页：
                        </td>
                        <td>
                            <asp:TextBox ID="TB_ClassPrePage" runat="server" TextMode="MultiLine" Width="528px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            最后一页：
                        </td>
                        <td>
                            <asp:TextBox ID="TB_ClassLastPage" runat="server" TextMode="MultiLine" Width="528px"></asp:TextBox>
                            <asp:CheckBox ID="CB_IsLastPageUrl" runat="server" Text="直接为网址而非规则" />
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            &nbsp;
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </fieldset>
            <br>
            <fieldset>
                <legend><strong>文章匹配规则</strong></legend>
                <table cellpadding="3" width="98%" align="center">
                    <tr>
                        <td align="right"  style=" width: 140px">
                            标题：
                        </td>
                        <td colspan="2">
                            <asp:TextBox ID="TB_Title" runat="server" Width="528px" TextMode="MultiLine"></asp:TextBox>
                            <span class="style1">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            内容：
                        </td>
                        <td colspan="2">
                            <asp:TextBox ID="TB_Content" runat="server" Width="528px" TextMode="MultiLine"></asp:TextBox>
                            <span class="style1">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            作者：
                        </td>
                        <td colspan="2">
                            <asp:TextBox ID="TB_Author" runat="server" Width="528px" TextMode="MultiLine"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            来源：
                        </td>
                        <td colspan="2">
                            <asp:TextBox ID="TB_From" runat="server" Width="528px" TextMode="MultiLine"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            日期：
                        </td>
                        <td colspan="2">
                            <asp:TextBox ID="TB_Date" runat="server" Width="528px" TextMode="MultiLine"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            文章页下一页地址：
                        </td>
                        <td colspan="2">
                            <asp:TextBox ID="TB_ShowArticleNextUrl" runat="server" Width="528px" TextMode="MultiLine"></asp:TextBox>
                        </td>
                    </tr>
                </table>
            </fieldset>
            <br>
            <fieldset>
                <legend><strong>内容过滤与替换</strong></legend>
                <table cellpadding="3" width="98%" align="center">
                    <tr>
                        <td align="right" style="width: 110px">
                            <img title="每项设置用回车键分割" alt="" height="16" src="../../Images/help.gif" width="16" />过滤内容：
                        </td>
                        <td style="width: 500px">
                            <textarea id='txt_ln' name='content' rows='10' cols='4' style='overflow: hidden;
                                height: 200px; border-right: 0px; text-align: right; background: #d0d0d0;' readonly="readonly"></textarea>
                            <asp:TextBox ID="TB_Filter" runat="server" ToolTip="支持正则表达式" Rows="10" TextMode="MultiLine"
                                Style="overflow: auto; height: 200px; padding-left: 5px; border-left: 0px" Columns="70"
                                Wrap="False" onkeyup="onchange();" onpropertychange="onchange()" onchange="show_ln();"></asp:TextBox>
                        </td>
                        <td style="width: auto">
                            <table style="width: 100%;">
                                <tr>
                                    <td>
                                        <a href="#" onclick="toDoc('TB_Filter','<IFRAME[^>]*?>[\s\S]*?</IFRAME>')">IFRAME</a>
                                    </td>
                                    <td>
                                        <a href="#" onclick="toDoc('TB_Filter','<TABLE[^>]*?>[\s\S]*?</TABLE>')">TABLE</a>
                                    </td>
                                    <td>
                                        <a href="#" onclick="toDoc('TB_Filter','<FORM[^>]*?>[\s\S]*?</FORM>')">FORM</a>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <a href="#" onclick="toDoc('TB_Filter','<OBJECT[^>]*?>[\s\S]*?</OBJECT>')">OBJECT</a>
                                    </td>
                                    <td>
                                        <a href="#" onclick="toDoc('TB_Filter','<SCRIPT[^>]*?>[\s\S]*?</SCRIPT>')">SCRIPT</a>
                                    </td>
                                    <td>
                                        <a href="#" onclick="toDoc('TB_Filter','<STYLE[^>]*?>[\s\S]*?</STYLE>')">STYLE</a>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <a href="#" onclick="toDoc('TB_Filter','<FONT[^>]*?>[\s\S]*?</FONT>')">FONT</a>
                                    </td>
                                    <td>
                                        <a href="#" onclick="toDoc('TB_Filter','<SPAN[^>]*?>[\s\S]*?</SPAN>')">FONT</a>
                                    </td>
                                    <td>
                                        <a href="#" onclick="toDoc('TB_Filter','<A[^>]*?>[\s\S]*?</A>')">FONT</a>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <img alt="" title="每项设置要跟上面的一一对应。" height="16" src="../../Images/help.gif" width="16" />被替换为：
                        </td>
                        <td>
                            <textarea id='txt_ln2' name='content' rows='10' cols='4' style='overflow: hidden;
                                height: 200px; border-right: 0px; text-align: right; background: #d0d0d0;'></textarea>
                            <asp:TextBox ID="TB_Replace" runat="server" ToolTip="支持正则表达式" Rows="10" TextMode="MultiLine"
                                Style="overflow: auto; height: 200px; padding-left: 5px; border-left: 0px" Columns="70"
                                onkeyup="onchange();" onpropertychange="onchange()" onchange="show_ln();" Wrap="False"></asp:TextBox>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td align="center" colspan="2" height="30">
                            <asp:Button ID="Bt_GatherAdd" runat="server" Text="提交" OnClick="Bt_GatherAdd_Click"
                                CssClass="btn"></asp:Button>
                        </td>
                        <td align="center" height="30">
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </fieldset>
        </ContentTemplate>
    </asp:UpdatePanel>
    <script language="javascript" type="text/javascript">
        ToLineNum();
    </script>
    </form>
</body>
</html>
