<!--#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 ChannelId, ChannelName, BriefName, TabName, ChannelPath
Dim objType, TypeArrayList, SelectList
ChannelId = Easp.Get("ChannelId:n:0")
If ChannelId = 0 Then
    CmsAdmin.JscriptMsg "频道参数错误！", "back", "Error", "null"
End If
' 读取频道信息
Dim ArrayChannel
ArrayChannel = GetCaCheChannelInfo("Channel", ChannelId, ChannelField)
If Easp.IsN(ArrayChannel) Then
    CmsAdmin.JscriptMsg "不存在的频道！", "back", "Error", "null"
Else
    ChannelName = ArrayChannel(0)
    BriefName = ArrayChannel(1)
    TabName = ArrayChannel(2)
    ChannelPath = ArrayChannel(4)
End If
'=============================================================================
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()
    ChkChannelAdminLevel ChannelId, "show"
    '==========================================================================
    ' 搜索
    Dim Keywords, TypeId
    Keywords = Trim(Easp.Get("Keywords:s"))
    TypeId = Easp.Get("TypeId:n:0")
%>
<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&ChannelId=<%=ChannelId%>')" 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&ChannelId=<%=ChannelId%>');" 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 class="select_box">
    <form id="searchType" action="" method="get">
      <input type="hidden" name="ChannelId" value="<%=ChannelId%>" />
      <select name="TypeId" class="select2">
        <option value="0"<%=Easp.IIF(TypeId = 0," selected=""selected""","")%>>所有属性</option>
        <option value="1"<%=Easp.IIF(TypeId = 1," selected=""selected""","")%>>置顶</option>
        <option value="2"<%=Easp.IIF(TypeId = 2," selected=""selected""","")%>>推荐</option>
        <option value="3"<%=Easp.IIF(TypeId = 3," selected=""selected""","")%>>热门</option>
      </select>
      <input name="Keywords" type="text" id="Keywords" class="txtInput w200" autocomplete="off" value="<%=Keywords%>" />
      <input type="submit" value="搜索" class="btnSearch" />
    </form>
  </div>
</div>
<form id="myform" action="?action=delall&ChannelId=<%=ChannelId%>" method="post">
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="msgtable">
    <tr>
      <th width="5%">ID</th>
      <th width="5%">选择</th>
      <th width="30%" align="left">标题</th>
      <th width="15%">模版</th>
      <th width="10%">排序</th>
      <th width="10%">属性 </th>
      <th width="15%">更新时间</th>
      <th width="10%">操作</th>
    </tr>
    <%
    Dim ShowPage, oRs, PageNum, FieldList, ArrayList, i, TempWhere
    Dim UrlLinks, ShowImagesInfo, ShowAttrList, ShowTitle
    ShowPage = ""
    PageNum = 20
    '============================ search
    TempWhere = " ChannelId = "& ChannelId &" "
    If Not Easp.IsN(Keywords) Then
        TempWhere = TempWhere & " And Title Like '%"& Keywords &"%' "
    End If
    If TypeId > 0 Then
        Select Case TypeId
            Case 1
                TempWhere = TempWhere & " And DataIsTop = 1 "
            Case 2
                TempWhere = TempWhere & " And DataIsBest = 1 "
            Case 3
                TempWhere = TempWhere & " And DataIsHot = 1 "
        End Select
    End If
    '============================ page
    Easp.db.PageSize = PageNum
    Easp.db.SetPager "default", "<span class=""disableds"">总记录数:{recordcount},每页:{pagesize},页次:{pageindex}/{pagecount}</span> {first}{prev}{list}{next}{last}{jump}", Array("first:首　页", "last:尾　页", "prev:上一页", "next:下一页", "list:*")
    FieldList = "Id,ChannelId,Title,ColorMode,FontMode,DataIsTop,DataIsBest,DataIsHot,"
    FieldList = FieldList & "UrlLink,HtmlFile,BigPic,SmallPic,BannerPic,TemplateView,Px,UpTime"
    Set oRs = Easp.db.GPR("0", Array(TablePrefix & "Topic:" & FieldList, TempWhere, " Px Asc,Id desc ", " Id "))
    If Easp.IsN(oRs) Then
        Easp.C(oRs)
    Else
        ShowPage = Easp.db.GetPager("default")
        ArrayList = oRs.GetRows(PageNum)
    End If
    Easp.C oRs
    If IsArray(ArrayList) Then
        For i = 0 To UBound(ArrayList, 2)
            ShowAttrList = ""
            ShowTitle = CmsFun.Highlight(CmsFun.ReadFontMode(ArrayList(2, i), ArrayList(3, i), ArrayList(4, i)), Keywords)
            If Not Easp.IsN(ArrayList(8, i)) Then
                UrlLinks = ArrayList(8, i)
            Else
                UrlLinks = CmsFun.HtmlFileUrl(TopicPath, ArrayList(9, i), ArrayList(0, i))
            End If
            ShowImagesInfo = Easp.IIf(Not Easp.IsN(ArrayList(10, i)), CmsFun.ShowColor("[图]", "red"), "")
            ShowAttrList = GetShowIcon(ChannelId, ArrayList(0, i), "DataIsTop", ArrayList(5, i), 1, "置顶")
            ShowAttrList = ShowAttrList & GetShowIcon(ChannelId, ArrayList(0, i), "DataIsBest", ArrayList(6, i), 2, "推荐")
            ShowAttrList = ShowAttrList & GetShowIcon(ChannelId, ArrayList(0, i), "DataIsHot", ArrayList(7, i), 3, "热门")
    %>
    <tr align="center">
      <td><%=ArrayList(0,i)%></td>
      <td><input type="checkbox" name="chkId" value="<%=ArrayList(0,i)%>" /></td>
      <td align="left"><%=ShowImagesInfo%><a href="<%=UrlLinks%>" target="_blank"><%=ShowTitle%></a>　<a href="javascript:parent.f_addTab('sys_topic','专题信息查看','info/Admin.Index.Asp?ChannelId=<%=ChannelId%>&TopicId=<%=ArrayList(0,i)%>')">查看信息</a>
        </li></td>
      <td><%=ArrayList(13,i)%></td>
      <td><input type="hidden" name="hidId" value="<%=ArrayList(0,i)%>" />
        <input type="text" class="txtInput2 w50" name="Px" value="<%=ArrayList(14,i)%>" maxlength="5" onfocus="ChkNumEric(this)" autocomplete="off" /></td>
      <td><%=ShowAttrList%></td>
      <td><%=CmsFun.TimeToString(ArrayList(15,i),"yyyy-mm-dd hh:ii:ss")%></td>
      <td><a href="Admin.Edit.Asp?ChannelId=<%=ChannelId%>&id=<%=ArrayList(0,i)%>">编辑</a></td>
    </tr>
    <%
        Next
    End If
    %>
  </table>
  <div class="line15"> </div>
  <div class="page_box">
    <div class="flickr right"><%=ShowPage%></div>
  </div>
</form>
<script>
function GetUpData(ChannelId, DataId, DataType, DataVal) {
    $.getJSON('Admin.Updata.Asp', {
        action: 'updata',
        ChannelId: ChannelId,
        DataId: DataId,
        DataType: DataType,
        DataVal: DataVal,
        n: Math.random()
    },
    function(d) {
        if (d.error == 0) {
            window.location.reload();
        } else {
            alert(d.message);
        }
    })
}
</script>
<%
End Sub

Function GetShowIcon(ByVal ChannelId, ByVal Id, ByVal DataType, ByVal Val, ByVal IconNum, ByVal IconTip)
    Dim ShowImage, ShowTip, TempHtml
    ShowImage = Easp.IIf(CmsFun.ChkNumEric(Val) = 1, CmsAdminMapPath & "images/ico-"& IconNum &".png", CmsAdminMapPath & "images/ico-"& IconNum &"_.png")
    ShowTip = Easp.IIf(CmsFun.ChkNumEric(Val) = 1, "取消"& IconTip &"", "设置"& IconTip &"")
    TempHtml = "<img src="""& ShowImage &""" border=""0"" alt="""& ShowTip &""" title="""& ShowTip &""" class=""cp"""
    TempHtml = TempHtml & " onClick=""GetUpData("& ChannelId &", "& Id &", '"& DataType &"', "& Easp.IIf(CmsFun.ChkNumEric(Val) = 1, 0, 1) &");"" />"
    GetShowIcon = TempHtml
End Function

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

Sub DelAll()
    ChkChannelAdminLevel ChannelId, "del"
    '==========================================================================
    Dim chkId, ResultVal
    chkId = Easp.Post("chkId:s")
    If Easp.IsN(chkId) Then
        CmsAdmin.JscriptMsg "对不起，请选中您要操作的记录！", "back", "Error", "null"
    Else
        ResultVal = Easp.db.DR(TablePrefix & "Topic", " ChannelId = "& ChannelId &" And Id In("& chkId &")")
        If ResultVal <> 0 Then
            CmsAdmin.JscriptMsg "批量删除成功！", ToUrl, "Success", "null"
        End If
    End If
End Sub
%>
