<%@ Page Language="C#" AutoEventWireup="true" Inherits="PowerEasy.Module.General.WebSite.Admin.Template.ModelTemplateManage"
    MasterPageFile="~/Admin/MasterPage.master" Title="生成模型模板管理" CodeBehind="ModelTemplateManage.aspx.cs"
    ValidateRequest="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CphNavigation" runat="Server">
    <pe:ExtendedSiteMapPath ID="SmpNavigator" SiteMapProvider="AdminMapProvider" runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CphContent" runat="Server">
    <asp:ScriptManager ID="SmTemplateManage" runat="server">
    </asp:ScriptManager>

    <script language="javascript" type="text/javascript">
    <!--
        function setFileType(num) {
            if (num == 0) {
                document.getElementById('EntiretyMatching').style.display = '';
            }
            else {
                document.getElementById('EntiretyMatching').style.display = 'none';
            }
        }
        function ShowTabs(ID) {
            for (i = 0; i < 2; i++) {
                if (i == ID) {
                    document.getElementById("TabTitle" + i).className = "titlemouseover";
                    document.getElementById("Tabs" + i).style.display = "";
                }
                else {
                    document.getElementById("TabTitle" + i).className = "tabtitle";
                    document.getElementById("Tabs" + i).style.display = "none";
                }
            }
        } 
    
    -->
    
    </script>

    <asp:Literal ID="LitMessageText" runat="server" Visible="false"></asp:Literal>
    <pe:ExtendedGridView ID="EgvFiles" runat="server" SerialText="" AutoGenerateColumns="False"
        AutoGenerateCheckBoxColumn="True" DataKeyNames="Name" OnRowCommand="EgvFiles_RowCommand"
        CheckBoxFieldHeaderWidth="3%" OnRowDataBound="EgvFiles_RowDataBound">
        <Columns>
            <pe:TemplateField HeaderText="名称">
                <ItemStyle HorizontalAlign="Left" />
                <ItemTemplate>
                    <img alt="" src=' <%# Convert.ToInt32(Eval("type")) == 1 ? "../../Admin/Images/Node/closefolder.gif" :"../../Admin/Images/Node/singlepage.gif" %>' />
                    <a href="<%# Convert.ToInt32(Eval("type")) == 1 ?  "ModelTemplateEdite.aspx?Dir=" + Server.UrlEncode(Request.QueryString["Dir"] +"/"+ Eval("Name")):"ModelTemplateEdit.aspx?Action=Modify&Dir="+ Server.UrlEncode(Request.QueryString["Dir"] +"/"+ Eval("Name")) %>">
                        <%# Eval("Name") %>
                    </a>
                </ItemTemplate>
            </pe:TemplateField>
            <pe:TemplateField HeaderText="大小">
                <HeaderStyle Width="60px" />
                <ItemTemplate>
                    <%# GetSize(Eval("size").ToString()) %>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Right" />
            </pe:TemplateField>
            <pe:TemplateField HeaderText="类型">
                <HeaderStyle Width="60px" />
                <ItemTemplate>
                    <asp:HiddenField ID="HdnFileType" Value='<%#Eval("type") %>' runat="server" />
                    <%# Convert.ToInt32(Eval("type")) == 1 ? "文件夹" : Eval("content_type") + "文件" %>
                </ItemTemplate>
            </pe:TemplateField>
            <pe:BoundField DataField="lastWriteTime" HeaderText="最后修改时间" SortExpression="lastWriteTime"
                DataFormatString="{0:yyyy-MM-dd HH:mm:ss}" HtmlEncode="False">
                <HeaderStyle Width="120px" />
            </pe:BoundField>
            <pe:TemplateField HeaderText="操作">
                <HeaderStyle Width="150px" />
                <ItemTemplate>
                    <pe:ExtendedAnchor ID="EahTemplateEdit" IsChecked="true" href='<%# "ModelTemplateEdit.aspx?Action=Modify&Dir="+ Server.UrlEncode(Request.QueryString["Dir"] +"/"+ Eval("Name")) %>'
                        runat="server" Visible='<%# Convert.ToInt32(Eval("type")) == 1 ? false:true %>'>
                        编辑</pe:ExtendedAnchor>
                    <pe:ExtendedLinkButton ID="ELbtnDel" Text="删除" IsChecked="true" runat="server" CommandArgument='<%# Eval("Name").ToString()%>'
                        CommandName='<%# Convert.ToInt32(Eval("type")) == 1 ? "DelDir":"DelFiles" %>'
                        OnClientClick="return confirm('确定要删除此文件吗？');" />
                    <pe:ExtendedAnchor ID="EahReName" IsChecked="true" href="javascript:" onclick='<%# "ReName(\"" + Eval("type")+"\",\""+ Eval("Name").ToString().Replace("\\","\\\\") + "\");"%>'
                        runat="server">
                        重命名</pe:ExtendedAnchor>
                    <pe:ExtendedLinkButton ID="ELbtnCopy" Text="复制" IsChecked="true" runat="server" CommandName='<%# Convert.ToInt32(Eval("type")) == 1 ? "CopyDir":"CopyFiles" %>'
                        CommandArgument='<%# Eval("Name").ToString()%>' />
                </ItemTemplate>
            </pe:TemplateField>
        </Columns>
    </pe:ExtendedGridView>
    <table border="0" cellpadding="2" width="100%" cellspacing="0">
        <tr>
            <td align="center">
                <pe:AspNetPager ID="Pager" runat="server" PageSize="20" OnPageChanged="Pager_PageChanged">
                </pe:AspNetPager>
            </td>
        </tr>
    </table>
    <br />
    <asp:Panel ID="PanButton" runat="server">
        <table width="100%">
            <tr>
                <td style="width: 11%;">
                    <input id="ChkAll" onclick="javascript:CheckAll(this);" type="checkbox" /><label
                        for="ChkAll">选中所有</label>
                </td>
                <td>
                    <pe:ExtendedButton ID="EBtnCreateTemplate" runat="server" Text="新建生成模型模板" IsChecked="true"
                        OnClick="EBtnCreateTemplate_Click" />
                    <pe:ExtendedLiteral HtmlEncode="false" ID="LitParentDirButton" runat="server"></pe:ExtendedLiteral>
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:HiddenField ID="HdnType" runat="server" />
    <asp:HiddenField ID="HdnName" runat="server" />
    <asp:Panel ID="PnlFileRename" runat="server" Style="width: 300px; display: none;
        background-color: Gray; text-align: center; padding-top: 1px;">
        <table width="100%" border="0" cellpadding="1" cellspacing="1" class="border">
            <tr>
                <td class="spacingtitle">
                    重命模板文件名
                </td>
            </tr>
            <tr>
                <td class="tdbgleft" align="left">
                    <asp:TextBox ID="TxtFileName" ValidationGroup="TxtFileName" Width="290px" runat="server"></asp:TextBox>
                    <pe:RequiredFieldValidator ID="ValrTxtFileName" runat="server" ErrorMessage="模板名不能为空"
                        Display="Dynamic" ControlToValidate="TxtFileName" ValidationGroup="TxtFileName"></pe:RequiredFieldValidator><asp:RegularExpressionValidator
                            ID="ValeTxtFileName" ValidationGroup="TxtFileName" ControlToValidate="TxtFileName"
                            Display="Dynamic" runat="server" ErrorMessage='模板格式应为***.html，不能包含\/:*?"<>|.和空格等字符！'></asp:RegularExpressionValidator>
                    <br />
                    <center>
                        <pe:ExtendedButton ID="EBtnFileReName" runat="server" ValidationGroup="TxtFileName"
                            IsChecked="true" Text="重命模板文件名" OnClick="EBtnModifyName_Click" /><asp:Button ID="BtnHiddenFileRename"
                                Text="取消" runat="server" />
                    </center>
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel ID="PnlCopyFile" runat="server" Style="width: 300px; display: none; background-color: Gray;
        text-align: center; padding-top: 1px;">
        <table width="100%" border="0" cellpadding="1" cellspacing="1" class="border">
            <tr>
                <td class="spacingtitle">
                    复制文件
                </td>
            </tr>
            <tr>
                <td class="tdbgleft">
                    复制目标文件<asp:Label ForeColor="red" ID="LblCopyFile" runat="server"></asp:Label>已经存在了，请重命名，如果不重命名，则覆盖现有文件
                    <asp:TextBox ID="TxtCopyFile" ValidationGroup="TxtCopyFile" runat="server"></asp:TextBox>
                    <pe:RequiredFieldValidator ID="ValrTxtCopyFile" runat="server" ErrorMessage="文件名不能为空"
                        Display="Dynamic" ControlToValidate="TxtCopyFile" ValidationGroup="TxtCopyFile"></pe:RequiredFieldValidator><asp:RegularExpressionValidator
                            ID="ValeTxtCopyFile" ValidationGroup="TxtCopyFile" Display="Dynamic" ControlToValidate="TxtCopyFile"
                            runat="server" ErrorMessage='文件格式应为***.html，不能包含\/:*?"<>|.和空格等字符！'></asp:RegularExpressionValidator>
                    <br />
                    <pe:ExtendedButton ID="EBtnCopyFile" runat="server" IsChecked="true" ValidationGroup="TxtCopyFile"
                        Text="复制" OnClick="EBtnCopyFile_Click" /><asp:Button ID="BtnHiddenCopyFile" runat="server"
                            Text="取消" />
                    <asp:HiddenField ID="HdnCopyFile" runat="server" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:HiddenField ID="HdnTemplateManage" runat="server" />
    <ajaxToolkit:ModalPopupExtender ID="MpeFileRename" runat="server" TargetControlID="HdnTemplateManage"
        Y="60" PopupControlID="PnlFileRename" CancelControlID="BtnHiddenFileRename" BackgroundCssClass="modalBackground"
        DropShadow="true" />
    <ajaxToolkit:ModalPopupExtender ID="MpeCopyFile" runat="server" TargetControlID="HdnTemplateManage"
        Y="60" PopupControlID="PnlCopyFile" CancelControlID="BtnHiddenCopyFile" BackgroundCssClass="modalBackground"
        DropShadow="true" />

    <script language="javascript" type="text/javascript">
    <!--

        function ShowCopyFile() {
            var copyFilePopup = $find('<%= MpeCopyFile.ClientID %>');
            copyFilePopup.show();
        }


        function ReName(type, name) {
            var txtFileName = "<%= TxtFileName.ClientID %>";
            document.getElementById('<%= HdnName.ClientID %>').value = name;
            document.getElementById(txtFileName).value = name;
            var showFileRenamePopup = $find('<%= MpeFileRename.ClientID %>');
            showFileRenamePopup.show();
        }
    -->
    </script>

</asp:Content>
