<!--#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, 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 "px"
        Call Px()
    Case "delall"
        Call DelAll()
    Case Else
        Call PageLoad()
End Select
CmsAdmin.LoadFooter()
Set CmsAdmin = Nothing

Sub PageLoad()
    Dim ChannelId, objType, ArrayList
    ChannelId = Easp.Get("ChannelId:n:0")
    If ChannelId = 0 Then
        CmsAdmin.JscriptMsg "频道参数错误！", "", "Error", "null"
    End If
    '=====================================================================
    ChkChannelAdminLevel ChannelId, "show"
    '=====================================================================
    Set objType = New Cls_Type
    ArrayList = objType.TypeList(ChannelId)
    Set objType = Nothing
%>
<div class="navigation">频道管理 &gt; 分类管理</div>
<div class="tools_box">
  <div class="tools_bar">
    <ul>
      <li><a href="Admin.Add.Asp?ChannelId=<%=ChannelId%>" class="tools_btn"><span><b class="add">添加分类</b></span></a></li>
      <li><a href="javascript:GetSubmit('myform','?action=px')" class="tools_btn"><span><b class="send">保存排序</b></span></a></li>
      <li><a href="javascript:void(0);" onclick="checkAll(this);" class="tools_btn"><span><b class="all">全选</b></span></a></li>
      <li><a href="javascript:void(0);" onclick="return ExePostBack('确定要批量删除吗？','myform','?action=delall');" class="tools_btn"><span><b class="delete">批量删除</b></span></a></li>
      <li><a href="Admin.Index.Asp?ChannelId=<%=ChannelId%>" class="tools_btn"><span><b class="refresh">刷新列表</b></span></a></li>
    </ul>
  </div>
</div>
<form id="myform" action="?action=px" method="post">
  <input type="hidden" name="ChannelId" value="<%=ChannelId%>" />
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="msgtable">
    <tr>
      <th width="5%">选择</th>
      <th width="5%">ID</th>
      <th width="20%" align="left">名称</th>
      <th width="15%" align="left">列表目录</th>
      <th width="15%" align="left">电脑端列表模板</th>
      <th width="15%" align="left">电脑端内容模板</th>
      <th width="5%">排序</th>
      <th width="10%">前台显示</th>
      <th width="10%">操作</th>
    </tr>
    <%
	LoadTypeHtml ChannelId, 0, ArrayList
    %>
  </table>
</form>
<%
End Sub

'递归栏目列表

Sub LoadTypeHtml(ChannelId, Id, ArrayList)
    If IsArray(ArrayList) Then
        ' SQL Val:Id,Pid,ChildId,DeepPath,CnName,Px,CnTemplateList,CnTemplateView,HtmlFilePath,IsShow,ViewHtmlPath,DataNum,UrlLink
        Dim i, j
        Dim ClassId, Pid, ChildId, CnName, Px, CnTemplateList, CnTemplateView
        Dim HtmlFilePath, IsShow, ViewHtmlPath, UrlLink
        Dim LitStyle, LitImg1, LitImg2, ListCss, UrlHtmlPath
        For i = 0 To UBound(ArrayList, 2)
            If ArrayList(1, i) = id Then
                LitStyle = "<span style=""width:{0}px;text-align:right;display:inline-block;"">{1}{2}</span>"
                LitImg1 = "<img src=""../images/folder_open.gif"" align=""absmiddle"" />"
                LitImg2 = "<img src=""../images/t.gif"" align=""absmiddle"" />"
                ClassId = ArrayList(0, i)
                If Id = 0 Then
                    ListCss = LitImg1 & " "
                Else
                    ListCss = Easp.Format(LitStyle, Array(ArrayList(3, i) * 35, LitImg2, LitImg1)) & " "
                End If
                Px = ArrayList(5, i)
                CnTemplateList = ArrayList(6, i)
                CnTemplateView = ArrayList(7, i)
                HtmlFilePath = ArrayList(8, i)
                IsShow = Easp.IIf(ArrayList(9, i) = 1, "显示", "<span style=""color:#3366FF"">不显示</span>")
                ViewHtmlPath = ArrayList(10, i)
                UrlLink = Easp.IIf(Easp.IsN(ArrayList(12, i)), "", CmsFun.ShowColor("[外链]", "red"))
                UrlHtmlPath = Easp.IIf(Easp.IsN(ArrayList(12, i)), ArrayList(8, i), ArrayList(12, i))
                Easp.WF Easp.IIf(i = 0, "", "  ") & "<tr align=""center"">" & vbCrLf
                Easp.WF "    <td><input type=""checkbox"" name=""chkId"" value="""& ClassId &""" /></td>" & vbCrLf
                Easp.WF "    <td>"& ClassId &"</td>" & vbCrLf
                Easp.WF "    <td align=""left"">"& ListCss & UrlLink & "<a href="""& UrlHtmlPath &""" target=""_blank"">" & ArrayList(4, i) &"</a>("& ArrayList(11, i) &")</td>" & vbCrLf
                Easp.WF "    <td align=""left""><a href="""& UrlHtmlPath &""" target=""_blank"">"& UrlHtmlPath &"</a></td>" & vbCrLf
                Easp.WF "    <td align=""left"">"& CnTemplateList &"</td>" & vbCrLf
                Easp.WF "    <td align=""left"">"& CnTemplateView &"</td>" & vbCrLf
                Easp.WF "    <td><input type=""hidden"" name=""hidId"" value="""& ClassId &""" /><input type=""text"" class=""txtInput w50"" name=""Px"" id=""Px"" maxlength=""5"" onfocus=""ChkNumEric(this)"" autocomplete=""off"" value="""& Px &""" /></td>" & vbCrLf
                Easp.WF "    <td>"& IsShow &"</td>" & vbCrLf
                Easp.WF "    <td><a href=""Admin.Edit.Asp?ChannelId="& ChannelId &"&id="& ClassId &""">编辑</a></td>" & vbCrLf
                Easp.WF "  </tr>" & vbCrLf
                Call LoadTypeHtml(ChannelId, ClassId, ArrayList)
            End If
        Next
    End If
End Sub

Sub Px()
    Dim hidId, Px, i, spHidId, spPx, ChannelId
    ChannelId = Easp.Post("ChannelId:n:0")
    If ChannelId = 0 Then
        CmsAdmin.JscriptMsg "频道参数错误！", "back", "Error", "null"
    End If
    hidId = Replace(Easp.Post("hidId:s"), ", ", ",")
    Px = Replace(Easp.Post("Px:s"), ", ", ",")
    If Easp.IsN(hidId) Then
        CmsAdmin.JscriptMsg "对不起，请选中您要操作的记录！", "back", "Error", "null"
    End If
    '=====================================================================
    ChkChannelAdminLevel ChannelId, "edit"
    '=====================================================================
    spHidId = Split(hidId, ",")
    spPx = Split(Px, ",")
    For i = 0 To UBound(spHidId)
        Easp.db.UR TablePrefix & "Type", " Id = "& spHidId(i) &" ", Array("px:" & spPx(i))
    Next
    CmsAdmin.JscriptMsg "批量排序成功！", ToUrl, "Success", "null"
End Sub

Sub DelAll()
    Dim ChannelId, chkId, ResultVal, SpChkId, i, objType
    ChannelId = Easp.Post("ChannelId:n:0")
    If ChannelId = 0 Then
        CmsAdmin.JscriptMsg "频道参数错误！", "back", "Error", "null"
    End If
    '=====================================================================
    ChkChannelAdminLevel ChannelId, "del"
    '=====================================================================
    chkId = Easp.Post("chkId:s")
    If Easp.IsN(chkId) Then
        CmsAdmin.JscriptMsg "对不起，请选中您要操作的记录！", "back", "Error", "null"
    Else
        Set objType = New Cls_Type
        objType.ChannelId = ChannelId
        SpChkId = Split(chkId, ",")
        For i = 0 To UBound(SpChkId)
            objType.Cid = SpChkId(i)
            objType.Del()
        Next
        CmsAdmin.JscriptMsg "删除分类成功！", "Admin.Index.Asp?ChannelId="& ChannelId &"", "Success", "null"
        Set objType = Nothing
    End If
End Sub
%>
