<!--#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, FileName, GetFileVal
    ThemePath = CmsTemplates & CmsTempSkin
    FileName = Trim(Easp.Get("f:s"))
    Easp.Use "fso"
    If InStr(FileName, ThemePath) = 0 Then
        CmsAdmin.JscriptMsg "无效的模版文件目录！", "back", "Error", "null"
    End If
    If (Easp.IsN(FileName) Or Not Easp.Fso.IsFile(FileName)) Then
        CmsAdmin.JscriptMsg "模版文件："& FileName &",不存在！", "back", "Error", "null"
    End If
    GetFileVal = Server.HTMLEncode(Easp.Fso.Read(FileName) & "")
%>
<script src="<%=CmsAdminMapPath%>js/check/tpl.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain">
  <input type="hidden" name="ToUrl" value="<%=CmsFun.LoadToUrl()%>" />
  <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结尾!" value="<%=FileName%>" readonly="readonly" />
              <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个字符!"><%=GetFileVal%></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", "edit"
    '=====================================================================
    Dim FileName, Info, ThemePath, Result, ToUrl
    FileName = Trim(Easp.Post("FileName:s"))
    Info = Easp.Post("Info")
    ToUrl = Trim(Easp.Post("ToUrl:s"))
    '=====================================================================
    If Easp.IsN(FileName) Then
        CmsAdmin.JscriptMsg "模板文件名必须填写！", "back", "Error", "null"
    End If
    If Easp.IsN(Info) Then
        CmsAdmin.JscriptMsg "模版内容必须填写！", "back", "Error", "null"
    End If
    '=====================================================================
    Easp.Use "fso"
    '=========================== 开始保存模版文件
    Result = Easp.Fso.CreateFile(FileName, Info)
    If Result Then
        CmsAdmin.JscriptMsg "编辑模版："& FileName &"，成功！", Easp.IIf(Easp.IsN(ToUrl), "Admin.Index.Asp", ToUrl), "Success", "null"
    Else
        CmsAdmin.JscriptMsg "编辑模版："& FileName &"，失败！", "back", "Error", "null"
    End If
    '=====================================================================
End Sub
%>
