<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../inc/Cls_Type.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, ChannelId
    Dim Cid, Pid, ChildId, ChildIdAll, ChildNum, DeepPath, CnName
    Dim Px, CnTemplateList, EnTemplateList, CnTemplateView, EnTemplateView
    Dim HtmlFilePath, ViewHtmlPath, ViewHtmlPrefix
    Dim TypeImg, MetaKey, MetaDesc, IsShow, MarkVal, UrlLink, DataNum, AddTime
    '=====================================================================
    Id = Easp.Get("id:n:0")
    ChannelId = Easp.Get("ChannelId:n:0")
    If (Id = 0 Or ChannelId = 0) Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    '=====================================================================
    Set oRs = Easp.db.GR(TablePrefix & "Type:1", " ChannelId="& ChannelId &" And Id = "& Id &" ", "")
    If Easp.IsN(oRs) Then
        CmsAdmin.JscriptMsg "错误的分类ID！", "back", "Error", "null"
    Else
        Cid = oRs("Cid")
        Pid = oRs("Pid")
        ChildId = oRs("ChildId")
        ChildIdAll = oRs("ChildIdAll")
        ChildNum = oRs("ChildNum")
        DeepPath = oRs("DeepPath")
        CnName = oRs("CnName")
        Px = oRs("Px")
        CnTemplateList = oRs("CnTemplateList")
        EnTemplateList = oRs("EnTemplateList")
        CnTemplateView = oRs("CnTemplateView")
        EnTemplateView = oRs("EnTemplateView")
        HtmlFilePath = oRs("HtmlFilePath")
        ViewHtmlPath = oRs("ViewHtmlPath")
        ViewHtmlPrefix = oRs("ViewHtmlPrefix")
        TypeImg = oRs("TypeImg")
        MetaKey = oRs("MetaKey")
        MetaDesc = oRs("MetaDesc")
        IsShow = oRs("IsShow")
        MarkVal = oRs("MarkVal")
        UrlLink = oRs("UrlLink")
        DataNum = oRs("DataNum")
        AddTime = oRs("AddTime")
    End If
    Easp.C oRs
    '=====================================================================
    Dim ArrayList, objType, SelectList
    Set objType = New Cls_Type
    ArrayList = objType.TypeList(ChannelId)
    SelectList = objType.ShowOption(0, ArrayList, Pid)
    Set objType = Nothing
%>
<script src="<%=CmsAdminMapPath%>js/check/type.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain">
  <input type="hidden" name="ChannelId" value="<%=ChannelId%>" />
  <input type="hidden" name="id" value="<%=Id%>" />
  <input type="hidden" name="ToUrl" value="<%=CmsFun.LoadToUrl()%>" />
  <div class="navigation"><a href="Admin.Index.Asp?ChannelId=<%=ChannelId%>" 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>
        <li><a onclick="tabs(this);" 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 type="text" name="CnName" id="CnName" class="txtInput w300" autocomplete="off" datatype="*2-100" nullmsg="分类名称必须填写" errormsg="至少4个字符,最多100个字符!" value="<%=CnName%>" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 所属分类： </th>
            <td class="td2"><select name="Pid" id="Pid" class="select2" datatype="select1" errormsg="请选择所属分类">
                <option value="0">作为一级分类</option>
                <%=SelectList%>
              </select>
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 分类列表模版[电脑端]： </th>
            <td class="td2"><input type="text" name="CnTemplateList" id="CnTemplateList" class="txtInput w350" autocomplete="off" datatype="*0-35" errormsg="最多35个字符!" value="<%=CnTemplateList%>" />
              <input type="button" value="选择模版" class="btnSearch" onclick="ShowWin('Template001', '选择电脑端分类列表模版', '<%=CmsAdminMapPath%>tpl/Admin.Index.Asp?action=sf&ReturnId=CnTemplateList', SetDialog.SpecialWidth, SetDialog.SpecialHeight, false);" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 分类列表模版[手机端]： </th>
            <td class="td2"><input type="text" name="EnTemplateList" id="EnTemplateList" class="txtInput w350" autocomplete="off" datatype="*0-35" errormsg="最多35个字符!" value="<%=EnTemplateList%>" />
              <input type="button" value="选择模版" class="btnSearch" onclick="ShowWin('Template001', '选择手机端分类列表模版', '<%=CmsAdminMapPath%>tpl/Admin.Index.Asp?action=sf&ReturnId=EnTemplateList', SetDialog.SpecialWidth, SetDialog.SpecialHeight, false);" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 分类列表生成存放目录： </th>
            <td class="td2"><input type="text" name="HtmlFilePath" id="HtmlFilePath" class="txtInput w350" autocomplete="off" datatype="*0-35" errormsg="最多35个字符!" value="<%=HtmlFilePath%>" />
              <input type="button" value="转换名称首字母" class="btnSearch" id="HtmlFilePath_6" onclick="GetPy('<%=CmsAdminMapPath%>', 'CnName', 'HtmlFilePath', 6, '/', '/');" />
              <input type="button" value="转换名称全拼音" class="btnSearch" id="HtmlFilePath_3" onclick="GetPy('<%=CmsAdminMapPath%>', 'CnName', 'HtmlFilePath', 3, '/', '/');" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 分类内容模版[电脑端]： </th>
            <td class="td2"><input type="text" name="CnTemplateView" id="CnTemplateView" class="txtInput w350" autocomplete="off" datatype="*6-50" nullmsg="分类内容模版[电脑端]必须填写" errormsg="至少6个字符,最多50个字符!" value="<%=CnTemplateView%>" />
              <input type="button" value="选择模版" class="btnSearch" onclick="ShowWin('Template002', '选择电脑端分类内容模版', '<%=CmsAdminMapPath%>tpl/Admin.Index.Asp?action=sf&ReturnId=CnTemplateView', SetDialog.SpecialWidth, SetDialog.SpecialHeight, false);" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 分类内容模版[手机端]： </th>
            <td class="td2"><input type="text" name="EnTemplateView" id="EnTemplateView" class="txtInput w350" autocomplete="off" datatype="*0-100" errormsg="最多100个字符!" value="<%=EnTemplateView%>" />
              <input type="button" value="选择模版" class="btnSearch" onclick="ShowWin('Template002', '选择手机端分类内容模版', '<%=CmsAdminMapPath%>tpl/Admin.Index.Asp?action=sf&ReturnId=EnTemplateView', SetDialog.SpecialWidth, SetDialog.SpecialHeight, false);" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 分类内容生成存放目录： </th>
            <td class="td2"><input type="text" name="ViewHtmlPath" id="ViewHtmlPath" class="txtInput w350" autocomplete="off" datatype="*0-35" nullmsg="分类内容生成存放目录必须填写" errormsg="*,必须以:/ 开头和结尾,如：/news/hangyexinwen/,至少4个字符,最多50个字符!" value="<%=ViewHtmlPath%>" />
              <input type="button" value="转换名称首字母" class="btnSearch" id="ViewHtmlPath_6" onclick="GetPy('<%=CmsAdminMapPath%>', 'CnName', 'ViewHtmlPath', 6, '/', '/');" />
              <input type="button" value="转换名称全拼音" class="btnSearch" id="ViewHtmlPath_3" onclick="GetPy('<%=CmsAdminMapPath%>', 'CnName', 'ViewHtmlPath', 3, '/', '/');" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 分类内容生成文件名前缀： </th>
            <td class="td2"><input type="text" name="ViewHtmlPrefix" id="ViewHtmlPrefix" class="txtInput w350" autocomplete="off" datatype="*0-50" errormsg="最多50个字符!" value="<%=ViewHtmlPrefix%>" />
              <input type="button" value="转换名称首字母" class="btnSearch" id="ViewHtmlPrefix_6" onclick="GetPy('<%=CmsAdminMapPath%>', 'CnName', 'ViewHtmlPrefix', 6, '', '_');" />
              <input type="button" value="转换名称全拼音" class="btnSearch" id="ViewHtmlPrefix_3" onclick="GetPy('<%=CmsAdminMapPath%>', 'CnName', 'ViewHtmlPrefix', 3, '', '_');" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 外部连接URL： </th>
            <td class="td2"><input type="text" name="UrlLink" id="UrlLink" class="txtInput w450" autocomplete="off" datatype="*0-150" errormsg="最多150个字符!" value="<%=UrlLink%>" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 排序： </th>
            <td class="td2"><input type="text" class="txtInput w100" name="Px" id="Px" autocomplete="off" value="<%=Px%>" datatype="px" nullmsg="排序必须填写" errormsg="只能是数字越小越排前,不可为：0,最多5位数" />
              <span class="Validform_checktip">*</span></td>
          </tr>
      </table>
    </div>
    <div class="tab_con">
      <table class="form_table">
        <col width="200px">
        <col>
        <tbody>
          <tr>
            <th> 分类形象图： </th>
            <td class="td2"><input type="text" class="txtInput w350 left" name="TypeImg" id="TypeImg" autocomplete="off" datatype="*0-100" errormsg="最多100个字符!" value="<%=TypeImg%>" />
              <a href="javascript:;" class="files">
              <input type="file" id="FileUpload" name="FileUpload" onchange="Upload('<%=CmsAdminMapPath%>', 'UpFile', <%=ChannelId%>, 1, 'TypeImg', 'FileUpload');" />
              </a> <span class="uploading">正在上传，请稍候...</span>　
              <input type="button" class="btnSearch" value="从已上传中选择" onclick="ShowWin('TypeImg', '从已上传中选择', '<%=CmsAdminMapPath%>Admin_File.Asp?action=sf&ChannelId=<%=ChannelId%>&ReturnId=TypeImg', SetDialog.PublicWidth, SetDialog.PublicHeight, false);" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 分类关键字： </th>
            <td class="td2"><textarea name="MetaKey" id="MetaKey" class="w350" datatype="*0-500" errormsg="最多500个字符!"><%=MetaKey%></textarea>
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 分类描述： </th>
            <td class="td2"><textarea name="MetaDesc" id="MetaDesc" class="w350" datatype="*0-500" errormsg="最多500个字符!"><%=MetaDesc%></textarea>
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 标识值： </th>
            <td class="td2"><input type="text" name="MarkVal" id="MarkVal" class="txtInput w350" autocomplete="off" datatype="*0-100" errormsg="最多100个字符!" value="<%=MarkVal%>" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 是否前台显示： </th>
            <td class="td2"><span>
              <input type="radio" name="IsShow" id="IsShow1" value="1" datatype="n0-1"<%=Easp.IIF(CmsFun.ChkNumEric(IsShow) = 1, " checked=""checked""", "")%> />
              <label for="IsShow1">是</label>
              <input type="radio" name="IsShow" id="IsShow0" value="0"<%=Easp.IIF(CmsFun.ChkNumEric(IsShow) = 0, " checked=""checked""", "")%> />
              <label for="IsShow0">否</label>
              </span><span class="Validform_checktip"></span></td>
          </tr>
      </table>
    </div>
    <div class="foot_btn_box">
      <input type="submit" class="btnSubmit" value="提交保存" />
      &nbsp;
      <input name="重置" type="reset" class="btnSubmit" value="重 置" />
    </div>
  </div>
</form>
<%
End Sub

Sub SaveMain()
    Dim Id, ChannelId
    Dim CnName, Pid, HtmlFilePath, ViewHtmlPath
    Dim CnTemplateList, EnTemplateList, CnTemplateView, EnTemplateView
    Dim ViewHtmlPrefix, Px, TypeImg, MetaKey, MetaDesc, MarkVal, UrlLink, IsShow
    Dim ToUrl
    '=====================================================================
    Id = Easp.Post("id:n:0")
    ChannelId = Easp.Post("ChannelId:n:0")
    ToUrl = Trim(Easp.Post("ToUrl:s"))
    If (Id = 0 Or ChannelId = 0) Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    '=====================================================================
    ChkChannelAdminLevel ChannelId, "edit"
    '=====================================================================
    CnName = Trim(Easp.Post("CnName:s"))
    Pid = Easp.Post("Pid:n:0")
    CnTemplateList = Trim(Easp.Post("CnTemplateList:s"))
    EnTemplateList = Trim(Easp.Post("EnTemplateList:s"))
    HtmlFilePath = Trim(Easp.Post("HtmlFilePath:s"))
    CnTemplateView = Trim(Easp.Post("CnTemplateView:s"))
    EnTemplateView = Trim(Easp.Post("EnTemplateView:s"))
    ViewHtmlPath = Trim(Easp.Post("ViewHtmlPath:s"))
    ViewHtmlPrefix = Trim(Easp.Post("ViewHtmlPrefix:s"))
    Px = Easp.Post("Px:n:0")
    TypeImg = Trim(Easp.Post("TypeImg:s"))
    MetaKey = Trim(Easp.Post("MetaKey:s"))
    MetaDesc = Trim(Easp.Post("MetaDesc:s"))
    MarkVal = Trim(Easp.Post("MarkVal:s"))
    UrlLink = Easp.Post("UrlLink:s")
    IsShow = Easp.Post("IsShow:n:0")
    '=====================================================================
    If Easp.IsN(CnName) Then
        CmsAdmin.JscriptMsg "分类名称必须填写！", "back", "Error", "null"
    End If
    If Easp.IsN(CnTemplateView) Then
        CmsAdmin.JscriptMsg "电脑端分类内容模版必须填写！", "back", "Error", "null"
    End If
    If Easp.IsN(ViewHtmlPath) Then
        CmsAdmin.JscriptMsg "分类内容生成存放目录！", "back", "Error", "null"
    End If
    '=======================================================
    Dim objType, i
    Set objType = New Cls_Type
    objType.ChannelId = ChannelId
    objType.Cid = Id
    objType.Pid = Pid
    objType.CnName = CnName
    objType.CnTemplateList = CnTemplateList
    objType.EnTemplateList = EnTemplateList
    objType.HtmlFilePath = HtmlFilePath
    objType.CnTemplateView = CnTemplateView
    objType.EnTemplateView = EnTemplateView
    objType.ViewHtmlPath = ViewHtmlPath
    objType.ViewHtmlPrefix = ViewHtmlPrefix
    objType.TypeImg = TypeImg
    objType.MetaKey = MetaKey
    objType.MetaDesc = MetaDesc
    objType.IsShow = IsShow
    objType.Px = Px
    objType.MarkVal = MarkVal
    objType.UrlLink = UrlLink
    i = objType.Edit()
    If i = 1 Then
        CmsAdmin.JscriptMsg "编辑分类成功！", Easp.IIf(Easp.IsN(ToUrl), "Admin.Index.Asp?ChannelId="& ChannelId &"", ToUrl), "Success", "null"
    Else
        CmsAdmin.JscriptMsg "编辑分类失败！", Easp.IIf(Easp.IsN(ToUrl), "Admin.Index.Asp?ChannelId="& ChannelId &"", ToUrl), "Success", "null"
    End If
    Easp.C objType
    '=====================================================================
End Sub
%>
