<!--#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()
%>
<script src="<%=CmsAdminMapPath%>js/check/free.tpl.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain" onsubmit="return CheckForm();">
  <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" />
              <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" />
              <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" />
              <label> *,默认生成在根目录下，不写加：.html,如：test/a就等于：/test/a.html</label></td>
          </tr>
          <tr>
            <th> SEO关健字： </th>
            <td class="td2"><textarea name="MetaKey" id="MetaKey" class="w450"></textarea></td>
          </tr>
          <tr>
            <th> SEO描述： </th>
            <td class="td2"><textarea name="MetaDesc" id="MetaDesc" class="w450"></textarea></td>
          </tr>
          <tr>
            <th>其它：</th>
            <td class="td2"><input name="MetaVal" id="MetaVal" type="text" class="txtInput w350" autocomplete="off" maxlength="100" /></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", "add"
    '=====================================================================
    Dim Title, TemplateView, HtmlFile, MetaVal, MetaKey, MetaDesc
    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"))
    '=====================================================================
    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
    List("AddTime") = Now()
    ResultVal = Easp.db.AR(TablePrefix & "FreeTpl:id", List.Hash)
    Easp.C List
    If ResultVal <> 0 Then
        CmsAdmin.LoadCreatePage "../create/Admin.Pc.Html.Asp?action=freetpl&id=" & ResultVal & ""
        CmsAdmin.JscriptMsg "添加自定义模板成功！", "Admin.Tpl.List.Asp", "Success", "null"
    End If
    '=====================================================================
End Sub
%>
