<!--#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 ThemePath, FilePath
    ThemePath = CmsTemplates & CmsTempSkin
    FilePath = CmsMain.GetFilePathList(2, ThemePath, "", "SaveFilePath", "FilePath", "选择文件存放目录", "模版文件目录")
%>
<script src="<%=CmsAdminMapPath%>js/check/tpl.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain">
  <div class="navigation"><a href="Admin.Index.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="150px">
          </col>
        
        <tbody>
          <tr>
            <th> 模板文件名： </th>
            <td class="td2"><input type="text" class="txtInput w350" name="FileName" id="FileName" datatype="html1" nullmsg="模板文件名必须填写" errormsg="至少4个字符,最多35个字符,以：.html结尾!" autocomplete="off" />
              <span class="Validform_checktip">*添加后,不可编辑</span></td>
          </tr>
          <tr>
            <th> 文件存放目录： </th>
            <td class="td2"><input type="text" name="FilePath" id="FilePath" class="txtInput w350 left" datatype="*0-35" errormsg="最多35个字符!" readonly="readonly" />
              <%=FilePath%><span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 模版内容： </th>
            <td class="td2"><textarea name="Info" id="Info" class="bigh850" datatype="*6-100000" nullmsg="模版内容必须填写" errormsg="至少6个字符,最多100000个字符!"></textarea>
              <span class="Validform_checktip">*</span></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_templabel", "add"
    '=====================================================================
    Dim FileName, FilePath, Info, ThemePath, FileNewPath, Result
    FileName = Trim(Easp.Post("FileName:s"))
    FilePath = Trim(Easp.Post("FilePath:s"))
    Info = Easp.Post("Info")
    '=====================================================================
    If Easp.IsN(FileName) Then
        CmsAdmin.JscriptMsg "模板文件名必须填写！", "back", "Error", "null"
    End If
    If Easp.IsN(Info) Then
        CmsAdmin.JscriptMsg "模版内容必须填写！", "back", "Error", "null"
    End If
    '=====================================================================
    ThemePath = CmsTemplates & CmsTempSkin
    FileNewPath = ThemePath & FilePath & FileName
    '=====================================================================
    Easp.Use "fso"
    If Easp.Fso.IsFile(FileNewPath) Then
        CmsAdmin.JscriptMsg "新建模版失败,文件："& FileNewPath &",已经存在！", "back", "Error", "null"
    End If
    '=========================== 开始保存模版文件
    Result = Easp.Fso.CreateFile(FileNewPath, Info)
    If Result Then
        CmsAdmin.JscriptMsg "新建模版："& FileNewPath &"，成功！", "Admin.Index.Asp", "Success", "null"
    Else
        CmsAdmin.JscriptMsg "新建模版："& FileNewPath &"，失败！", "back", "Error", "null"
    End If
    '=====================================================================
End Sub
%>
