<%@ Page Title="" Language="C#" MasterPageFile="~/Management/SiteManage.Master" AutoEventWireup="true" CodeBehind="TranslateRule.aspx.cs" Inherits="Amr.SuperSiteGroup.Web.Management.TranslateRule" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="right" style="text-align: center; margin-top: 10px;">
        <table width="100%" border="0" cellspacing="1" cellpadding="1" class="edit">
            <tr>
                <td class="title_edit">
                    <h1 style="float: left">
                        翻译规则设置</h1>
                </td>
            </tr>
            <tr>
                <td class="edit_main">
                            <table width="100%" border="0" cellspacing="1" cellpadding="1" class="table_list">
                                <tr class="tr1">
                                    <td colspan="2">
                                        <asp:Label ID="laTitle" runat="server" Text="添加翻译规则"></asp:Label><br />
                                        <asp:Label ID="laErrorInfo" runat="server" ForeColor="Red"></asp:Label>
                                        <asp:Label ID="laSuccessInfo" runat="server" ForeColor="Green"></asp:Label>
                                    </td>
                                        </tr>
                                <tr>
                                    <td>
                                        <div align="right">
                                            翻译规则名称<font color="red">*</font>：</div></td>
                                    <td align="left">
                                                    <asp:TextBox ID="tbName" runat="server" Width="80" Wrap="False" />
                                                    <validation targetid="<%=tbName.ClientID%>" targetname="节点规则名称" type="text" />
                                                </td>
                                        </tr>
                                <tr style="display:none">
                                    <td>
                                        <div align="right">
                                            翻译站点网址<font color="red">*</font>：</div></td>
                                    <td align="left">
                                        <asp:TextBox ID="tbSiteUrl" runat="server" CausesValidation="True"
                                            EnableViewState="False" Width="100%" Wrap="False" 
                                            ValidationGroup="checkAdd" />
                                             <validation targetid="<%=tbSiteUrl.ClientID%>" targetname="翻译站点网址" type="text" />
                                                </td>
                                        </tr>
                                <tr style="display:none">
                                    <td width="20%">
                                        <div align="right">
                                            原始网址提取表达式：</div>
                                    </td>
                                    <td align="left">
                                        <asp:TextBox ID="tbRawUrlExpression" runat="server" CausesValidation="True"
                                            EnableViewState="False" Width="100%" Wrap="False" 
                                            ValidationGroup="checkAdd" />

                                        <br />
                                        此处填写正则表达式,目的是还原翻译站点的翻译结果里面的链接,需要将指向翻译结果的链接转换成原始网址, 如 
                                        http://translate.baiducontent.com/transpage?cb=translateCallback&amp;ie=utf8&amp;source=url&amp;query=<span 
                                            class="red">http%3A%2F%2Ftv.sohu.com%2Fvoice%2F</span>&amp;from=zh&amp;to=en&amp;token=&amp;monLang=zh,这里的红色部分为原始网址</td>
                                </tr>
                                <tr style="display:none">
                                    <td>
                                        <div align="right">
                                            页面跳转表达式：</div>
                                    </td>
                                    <td align="left">
                                        <asp:TextBox ID="tbRedirectExpression" runat="server" CausesValidation="True"
                                            EnableViewState="False" Width="100%" Wrap="False" 
                                            ValidationGroup="checkAdd" />
                                            <br />
                                                    此处填写的是当翻译网站会发生跳转的时候,提取跳转目标的表达式,此处表达式为xpath,主要是为了应对如谷歌翻译一样的需要进行几次跳转才能得到最终网址的情况,xpath格式如xpath1<%=ExpressionKeyDelimiter%>attribute1<%=ExpressionDelimiter%>xpath2<%=ExpressionKeyDelimiter%>attribute2.如果提取的是属性值，那么请将属性名称填写上，否则将直接提取节点的文本值</td>
                                </tr>
                                <tr style="display:none">
                                    <td>
                                        <div align="right">
                                            操作表达式：</div>
                                    </td>
                                    <td align="left">
                                        <asp:TextBox ID="tbOperationExpression" runat="server" CausesValidation="True"
                                            EnableViewState="False" Width="100%" Wrap="False" 
                                            ValidationGroup="checkAdd" />
                                            <br />
                                                    此处填写的是翻译网站翻译完毕后，需要清理的内容，为正则表达式操作，格式为regex1<%=ExpressionKeyDelimiter%>operation1<%=ExpressionDelimiter%>regex2<%=ExpressionKeyDelimiter%>operation2,其中regex1是匹配正则表达式，operation1是替换表达式，如果不指定，那默认即为替换成空白，相当于删除</td>
                                </tr>
                                <tr>
                                    <td>
                                        <div align="right">
                                            优先级<font color="red">*</font>：</div>
                                    </td>
                                    <td align="left">
                                                    <asp:TextBox ID="tbPriority" runat="server" Width="80" Wrap="False" >10</asp:TextBox>
                                                    <validation targetid="<%=tbPriority.ClientID%>" targetname="优先级" type="number" />
                                                    <br />
                                                    请指定优先级，优先级高的规则先生效，数字越小代表优先级越高。</td>
                                </tr>
                                <tr>
                                    <td>
                                        <div align="right">
                                            选项：</div>
                                    </td>
                                    <td align="left">
                                        <asp:CheckBox ID="cbIsEnable" CssClass="checkbox" runat="server" 
                                            Text="是否激活" Checked="True" />
                                        </td>
                                </tr>
                                <tr>
                            <td>
                                <div align="right">
                                    页面匹配：</div>
                            </td>
                            <td align="left">
                                <fieldset>
                                    <legend>指定页面匹配</legend>
                                    <asp:CheckBox ID="cbMatchUrl" CssClass="checkbox" runat="server" onclick="$('#matchUrlParameter').toggle()"
                                        Text="规则用于指定页面（当前规则只对指定的页面生效）" />
                                    <br />
                                    <div id="matchUrlParameter" style="display: <%=cbMatchUrl.Checked?string.Empty:"none"%>">
                                        <asp:CheckBox ID="cbExactMatch" CssClass="checkbox" runat="server" Text="是否精确匹配指定网址（对指定页面地址采取精确匹配或者模糊匹配，模糊匹配只要页面网址包含指定网址【这里是指原网页地址】，则规则生效）" />
                                        <br />
                                        指定地址：
                                        <asp:TextBox ID="tbUrl" runat="server" Width="80%" Wrap="False" />
                                    </div>
                                </fieldset>
                            </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <asp:LinkButton ID="lbSubmit" runat="server" 
                                            Text="【提交】" onclick="lbSubmit_Click"  OnClientClick="return validateForm()" />
                                        &nbsp;<asp:LinkButton ID="lbCancel" runat="server" Text="【取消】" onclick="lbCancel_Click"/>
                                    </td>
                                </tr>
                            </table>
                </td>
            </tr>
        </table>
    </div>
    <div class="clear">
    </div>
        <div class="right" style="text-align: center; margin-top: 10px;">
        <div class="clear">
        </div>
        <table width="100%" border="0" cellspacing="1" cellpadding="1" class="edit">
            <tr>
                <td class="title_edit">
                    <h1 style="float: left">
                        翻译规则列表</h1>
                </td>
            </tr>
            <tr>
                <td class="edit_main">
                    <asp:GridView ID="gvTranslateRules" runat="server" AutoGenerateColumns="False" 
                        GridLines="None" CssClass="table_list" Width="100%" 
                        EnableModelValidation="True">
                        <Columns>
                            <asp:TemplateField HeaderText="操作" ShowHeader="False">
                                <ItemTemplate>
                                <asp:LinkButton ID="lbCopy" runat="server" CausesValidation="False"
                                        Text="【复制】" CommandArgument='<%# Bind("RuleId") %>' onclick="lbCopy_Click"></asp:LinkButton>
                                    &nbsp;
                                    <asp:LinkButton ID="lbEdit" runat="server" CausesValidation="False"
                                        Text="【编辑】" CommandArgument='<%# Bind("RuleId") %>' onclick="lbEdit_Click"></asp:LinkButton>
                                    &nbsp;<asp:LinkButton ID="lbDelete" runat="server" CausesValidation="False" CommandArgument='<%# Bind("RuleId") %>'
                                        Text="【删除】" onclick="lbDelete_Click" OnClientClick="if(confirm('确认删除记录?')){eval(this.attributes['href'].value)}else{return false}"></asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="RuleId" HeaderText="编号" 
                                SortExpression="RuleId" />
                        <asp:CheckBoxField DataField="IsEnable" HeaderText="是否激活" SortExpression="IsEnable" />
                        <asp:BoundField DataField="Priority" HeaderText="优先级" SortExpression="Priority" />
                        <asp:BoundField DataField="Name" HeaderText="规则名称" SortExpression="Name" />
                            <asp:TemplateField HeaderText="原始网址提取表达式" SortExpression="RawUrlExtractExpression" Visible="false">
                                <ItemTemplate>
                                    <asp:TextBox ID="rawUrlExtractExpression" runat="server" Text='<%# Bind("RawUrlExtractExpression") %>' ReadOnly="true"
                                        TextMode="MultiLine" Width="300px" Wrap="False"></asp:TextBox>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="页面跳转表达式" SortExpression="RedirectExpression" Visible="false">
                                <ItemTemplate>
                                    <asp:TextBox ID="redirectExpression" runat="server" 
                                        Text='<%# Bind("RedirectExpression") %>' ReadOnly="true"
                                        TextMode="MultiLine" Width="300px" Wrap="False"></asp:TextBox>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <HeaderStyle CssClass="tr1" />
                        <RowStyle CssClass="tr_a" />
                        <AlternatingRowStyle CssClass="tr_b" />
                        <EmptyDataTemplate>
                            没有数据，请先添加！
                        </EmptyDataTemplate>
                        <FooterStyle CssClass="dg_header" />
                    </asp:GridView>
                </td>
            </tr>
        </table>
    </div>
    <div class="clear" style="margin-top: 10px;">
    </div>
</asp:Content>
