<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../Admin_Check.Asp"-->
<%
Dim CmsAdmin
'=============================================================================
Set CmsAdmin = New Cls_Admin
CmsAdmin.SetAdminTitle = CmsSiteName
CmsAdmin.SetBodyCssName = "mainbody"
CmsAdmin.SetAdminPath = CmsAdminMapPath
CmsAdmin.LoadHead()
'=============================================================================
Dim Action
'=============================================================================
Action = Easp.Get("action")
Select Case Action
    Case "savemain"
        Call SaveMain()
    Case Else
        Call PageLoad()
End Select
CmsAdmin.LoadFooter()
Set CmsAdmin = Nothing

Sub PageLoad()
    Dim oRs, Id, Title, TemplateView, HtmlFile, MetaVal, MetaKey, MetaDesc
    Id = Easp.Get("id:n:0")
    If Id = 0 Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    Set oRs = Easp.db.GR(TablePrefix & "FreeTpl:1", " Id = "& Id &" ", "")
    If Easp.IsN(oRs) Then
        CmsAdmin.JscriptMsg "不存在的数据！", "back", "Error", "null"
    Else
        Title = oRs("Title")
        TemplateView = oRs("TemplateView")
        HtmlFile = oRs("HtmlFile")
        MetaVal = oRs("MetaVal")
        MetaKey = oRs("MetaKey")
        MetaDesc = oRs("MetaDesc")
    End If
    Easp.C oRs
%>
<script src="<%=CmsAdminMapPath%>js/check/free.tpl.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain" onsubmit="return CheckForm();">
  <input type="hidden" name="id" value="<%=Id%>" />
  <input type="hidden" name="ToUrl" value="<%=CmsFun.LoadToUrl()%>" />
  <div class="navigation"><a href="Admin.Tpl.List.Asp" class="back">自定义模板管理</a> 控制面板 &gt; 自定义模板管理 &gt; 编辑模板 </div>
  <div id="contentTab">
    <div class="content-tab">
      <ul class="tab_nav">
        <li><a onclick="tabs(this);" class="selected" href="javascript:void(0);">编辑模板</a></li>
      </ul>
    </div>
    <div class="tab_con" style="display: block;">
      <table class="form_table">
        <col width="200px">
          </col>
        
        <tbody>
          <tr>
            <th>标题名称：</th>
            <td class="td2"><input name="Title" id="Title" type="text" class="txtInput w350" autocomplete="off" maxlength="150" value="<%=Title%>" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 模板文件： </th>
            <td class="td2"><input name="TemplateView" type="text" id="TemplateView" class="txtInput w350" autocomplete="off" maxlength="150" readonly="readonly" value="<%=TemplateView%>" />
              <input type="button" value="选择模版" class="btnSearch" onclick="ShowWin('TemplateFile', '选择内容模版', '<%=CmsAdminMapPath%>tpl/Admin.Index.Asp?action=sf&ReturnId=TemplateView', SetDialog.SpecialWidth, SetDialog.SpecialHeight, false);" /></td>
          </tr>
          <tr>
            <th>生成文件名：</th>
            <td class="td2"><input type="text" name="HtmlFile" id="HtmlFile" class="txtInput w250" autocomplete="off" maxlength="120" value="<%=HtmlFile%>" />
              <label> *,默认生成在根目录下，不写加：.html,如：test/a就等于：/test/a.html</label></td>
          </tr>
          <tr>
            <th> SEO关健字： </th>
            <td class="td2"><textarea name="MetaKey" id="MetaKey" class="w450"><%=MetaKey%></textarea></td>
          </tr>
          <tr>
            <th> SEO描述： </th>
            <td class="td2"><textarea name="MetaDesc" id="MetaDesc" class="w450"><%=MetaDesc%></textarea></td>
          </tr>
          <tr>
            <th>其它：</th>
            <td class="td2"><input name="MetaVal" id="MetaVal" type="text" class="txtInput w350" autocomplete="off" maxlength="100" value="<%=MetaVal%>" /></td>
          </tr>
          <tr>
            <th></th>
            <td><input type="submit" class="btnSubmit" value="提交保存" />
              &nbsp;
              <input name="重置" type="reset" class="btnSubmit" value="重 置" /></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</form>
<%
End Sub

Sub SaveMain()
    ChkSysAdminLevel "sys_free", "edit"
    '=====================================================================
    Dim Id, Title, TemplateView, HtmlFile, MetaVal, MetaKey, MetaDesc, ToUrl
    Id = Easp.Post("id:n:0")
    Title = Trim(Easp.Post("Title:s"))
    TemplateView = Trim(Easp.Post("TemplateView:s"))
    HtmlFile = Trim(Easp.Post("HtmlFile:s"))
    MetaVal = Trim(Easp.Post("MetaVal:s"))
    MetaKey = Trim(Easp.Post("MetaKey:s"))
    MetaDesc = Trim(Easp.Post("MetaDesc:s"))
    ToUrl = Trim(Easp.Post("ToUrl:s"))
    '=====================================================================
    If Id = 0 Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    If Easp.IsN(Title) Then
        CmsAdmin.JscriptMsg "标题名称不能为空！", "back", "Error", "null"
    End If
    If Easp.IsN(TemplateView) Then
        CmsAdmin.JscriptMsg "模板文件不能为空！", "back", "Error", "null"
    End If
    If Easp.IsN(HtmlFile) Then
        CmsAdmin.JscriptMsg "生成文件名不能为空！", "back", "Error", "null"
    End If
    '=====================================================================
    Dim List, ResultVal
    Easp.Use "list"
    Set List = Easp.List.New
    List("Title") = Title
    List("TemplateView") = TemplateView
    List("HtmlFile") = HtmlFile
    List("MetaVal") = MetaVal
    List("MetaKey") = MetaKey
    List("MetaDesc") = MetaDesc
    ResultVal = Easp.db.UR(TablePrefix & "FreeTpl", " Id = "& Id &" ", List.Hash)
    Easp.C List
    If ResultVal <> 0 Then
        CmsAdmin.LoadCreatePage "../create/Admin.Pc.Html.Asp?action=freetpl&id=" & Id & ""
        CmsAdmin.JscriptMsg "编辑自定义模板成功！", Easp.IIf(Easp.IsN(ToUrl), "Admin.Tpl.List.Asp", ToUrl), "Success", "null"
    End If
    '=====================================================================
End Sub
%>
