<!--#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, ToUrl
ToUrl = CmsFun.LoadToUrl()
'=============================================================================
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 "pageload"
        Call PageLoad()
    Case "savemain"
        Call SaveMain()
    Case Else
        Call PageLoad()
End Select
CmsAdmin.LoadFooter()
Set CmsAdmin = Nothing

Sub PageLoad()
    ChkSysAdminLevel "sys_config", "show"
    '=====================================================================
    If Not Easp.Fso.IsFolder(CmsTemplates) Then
        CmsAdmin.JscriptMsg "对不起，模板文件夹："& CmsTemplates &",不存在！", "", "Error", "null"
    End If
%>
<div class="navigation">控制面板 &gt; 系统模板选择</div>
<div class="tools_box">
  <div class="tools_bar">
    <ul>
      <li><a href="Admin.Tpl.Asp" class="tools_btn"><span><b class="refresh">刷新列表</b></span></a></li>
    </ul>
  </div>
</div>
<form id="myform" action="?action=savemain" method="post">
  <input type="hidden" name="TempSkin" id="TempSkin" value="<%=CmsTempSkin%>" />
  <div class="photo_list2 clearfix">
    <ul>
      <%
      Dim ArrayList, i, CmsTempVal
      CmsTempVal = CmsTemplates & CmsTempSkin
      ArrayList = Easp.Fso.List(CmsTemplates, 2)
      For i = 0 To UBound(ArrayList, 2)
          Easp.Use "xml"
          Dim XmlFile, XmlTemplates, Result, XmlAuthor, XmlPic, XmlInfo, ArrTemplates
          XmlTemplates = CmsTemplates & ArrayList(0, i)
          XmlFile = XmlTemplates & "template.xml"
          Result = Easp.Xml.Open(XmlFile)
          If Result Then
              XmlAuthor = Trim(Easp.Xml("template>Author").Value)
              XmlPic = XmlTemplates & Trim(Easp.Xml("template>ScreenShot").Value)
              XmlInfo = Trim(Easp.Xml("template>description").Value)
          Else
              XmlAuthor = ""
              XmlPic = ""
              XmlInfo = ""
          End If
          If Trim(CmsTempVal) = Trim(XmlTemplates) Then
              ArrTemplates = "正在使用此模板"
          Else
              ArrTemplates = "<input type=""submit"" value=""使用此模板"" class=""btnSearch"" onClick=""InnerVal('TempSkin','"& ArrayList(0, i) &"');"" />"
          End If
      %>
      <li>
        <div class="box"> <img src="<%=XmlPic%>" width="96" height="96" class="cover" />
          <dl>
            <dt><%=Easp.IIf(Result, XmlInfo, "模板皮肤目录中的template.xml配置文件不存在")%></dt>
            <dd>模板作者：<%=XmlAuthor%></dd>
            <dd>模板大小：<%=ArrayList(1,i)%></dd>
            <dd>加入时间：<%=CmsFun.TimeToString(ArrayList(2,i),"yyyy-mm-dd hh:ii:ss")%></dd>
            <dd class="btns"><span class="right"><%=ArrTemplates%></span></dd>
          </dl>
          <div class="clear"></div>
        </div>
      </li>
      <%
      Next
      %>
    </ul>
  </div>
</form>
<%
End Sub

Sub SaveMain()
    ChkSysAdminLevel "sys_config", "edit"
    '=====================================================================
    Dim TempSkin
    TempSkin = Trim(Easp.Post("TempSkin:s"))
    '=====================================================================
    Dim List, ResultVal
    Easp.Use "list"
    Set List = Easp.List.New
    List("TempSkin") = TempSkin
    '=====================================================================
    ResultVal = Easp.db.UR(TablePrefix & "Config", " Id = 1 ", List.Hash)
    '=====================================================================
    Easp.RemoveApp "Sys_Config"
    Easp.C List
    If ResultVal <> 0 Then
        CmsAdmin.LoadCreateIndex()
        CmsAdmin.JscriptMsg "选择模板成功！", "Admin.Tpl.Asp", "Success", "null"
    End If
    '=====================================================================
End Sub
%>