<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../inc/Cls_Channel.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 ChannelId, ChannelName, BriefName, TabName, ChannelPath
Dim objType, TypeArrayList, SelectList
ChannelId = Easp.Get("ChannelId:n:0")
If ChannelId = 0 Then
    CmsAdmin.JscriptMsg "频道参数错误！", "", "Error", "null"
End If
' 读取频道信息
Dim ArrayChannel
ArrayChannel = GetCaCheChannelInfo("Channel", ChannelId, ChannelField)
If Easp.IsN(ArrayChannel) Then
    CmsAdmin.JscriptMsg "不存在的频道！", "", "Error", "null"
Else
    ChannelName = ArrayChannel(0)
    BriefName = ArrayChannel(1)
    TabName = ArrayChannel(2)
    ChannelPath = ArrayChannel(4)
    objChannel.CreateChannelView ChannelId, TabName
End If
'=============================================================================
Dim Action
'=============================================================================
Action = Easp.Get("action")
Select Case Action
    Case "pageload"
        Call PageLoad()
    Case "px"
        Call Px()
    Case "delall"
        Call DelAll()
    Case "uptime"
        Call UpTime()
    Case "yd"
        Call YdData()
    Case Else
        Call PageLoad()
End Select
CmsAdmin.LoadFooter()
Set CmsAdmin = Nothing

Sub PageLoad()
    ChkChannelAdminLevel ChannelId, "show"
    '=====================================================================
    ' 搜索
    Dim Keywords, DataId, ClassId, DataClassVal
    Dim PageNum, TypeId, OrderId, TopicId
    Keywords = Trim(Easp.Get("Keywords:s"))
    DataId = Easp.Get("DataId:n:0")
    ClassId = Easp.Get("ClassId:n:0")
    TypeId = Easp.Get("TypeId:n:0")
    OrderId = Easp.Get("OrderId:n:0")
    PageNum = Easp.Get("PageNum:n:0")
    PageNum = Easp.IIf(PageNum = 0, 20, PageNum)
    TopicId = Easp.Get("TopicId:n:0")
    ' 读取分类
    Set objType = New Cls_Type
    SelectList = objType.ShowSelectList("选择分类", ChannelId, ClassId, 0)
    Set objType = Nothing
%>
<div class="navigation"> 频道管理 &gt; <%=BriefName%>管理</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="javascript:void(0);" onclick="return ExePostBack('确定要批量更新吗？','myform','?action=uptime&ChannelId=<%=ChannelId%>');" class="tools_btn"><span><b class="stop">更新时间</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">
    <div class="left">
      <form id="searchType" action="" method="get">
        <input type="hidden" name="ChannelId" value="<%=ChannelId%>" />
        <%=SelectList%>
        <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>
          <option value="4"<%=Easp.IIF(TypeId = 4," selected=""selected""","")%>>推荐</option>
          <option value="5"<%=Easp.IIF(TypeId = 5," selected=""selected""","")%>>热门</option>
        </select>
        <select name="OrderId" class="select2">
          <option value="0"<%=Easp.IIF(OrderId = 0," selected=""selected""","")%>>选择排序[添加时间]</option>
          <option value="1"<%=Easp.IIF(OrderId = 1," selected=""selected""","")%>>更新时间</option>
          <option value="2"<%=Easp.IIF(OrderId = 2," selected=""selected""","")%>>指定排序</option>
          <option value="3"<%=Easp.IIF(OrderId = 3," selected=""selected""","")%>>人气</option>
          <option value="4"<%=Easp.IIF(OrderId = 4," selected=""selected""","")%>>评论</option>
        </select>
        <select name="PageNum" class="select2">
          <option value="0"<%=Easp.IIF(PageNum = 0," selected=""selected""","")%>>默认[20记录数/页]</option>
          <option value="5"<%=Easp.IIF(PageNum = 5," selected=""selected""","")%>>5记录数/页</option>
          <option value="10"<%=Easp.IIF(PageNum = 10," selected=""selected""","")%>>10记录数/页</option>
          <option value="15"<%=Easp.IIF(PageNum = 15," selected=""selected""","")%>>15记录数/页</option>
          <option value="25"<%=Easp.IIF(PageNum = 25," selected=""selected""","")%>>25记录数/页</option>
          <option value="30"<%=Easp.IIF(PageNum = 30," selected=""selected""","")%>>30记录数/页</option>
          <option value="40"<%=Easp.IIF(PageNum = 40," selected=""selected""","")%>>40记录数/页</option>
          <option value="50"<%=Easp.IIF(PageNum = 50," selected=""selected""","")%>>50记录数/页</option>
          <option value="100"<%=Easp.IIF(PageNum = 100," selected=""selected""","")%>>100记录数/页</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 class="right">
      <form id="ydform" action="?action=yd&ChannelId=<%=ChannelId%>" method="post" onSubmit="return ChkYdData();">
      <input type="hidden" name="dataId" id="dataId" value="" />
        <%=SelectList%>
        <input type="submit" value="数据移动" class="btnSearch" />
      </form>
    </div>
  </div>
</div>
<script>
function ChkYdData() {
    var ClassId = parseInt($('#ydform > select').val());
    if (ClassId == 0) {
        $.ligerDialog.warn("对不起，未选择分类！");
        return false;
    }
    var d = GetChkBoxVal('chkId');
    if (d == '') {
        $.ligerDialog.warn("对不起，请选中您要操作的记录！");
        return false;
    } else {
        $('#dataId').val(d);
    };
}
</script>
<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="10%">属性 </th>
      <th width="10%">更新时间</th>
      <th width="10%">操作</th>
    </tr>
    <%
    Dim ShowPage, oRs, TempField, TempOrder, TempWhere
    Dim ArrayList, i, UrlLinks, ShowImagesInfo, ShowInfoIcon, ShowAttrList, ShowTitle
    ShowPage = ""
    '============================ TempWhere
    TempWhere = " ChannelId = "& ChannelId &" "
    If Not Easp.IsN(Keywords) Then
        TempWhere = TempWhere & " And Title Like '%"& Keywords &"%' "
    End If
    If DataId > 0 Then
        TempWhere = TempWhere & " And Id = "& DataId &" "
    End If
    If ClassId > 0 Then
        DataClassVal = CmsFun.GetClassVal(ChannelId, ClassId)
        If Not Easp.IsN(DataClassVal) Then
            TempWhere = TempWhere & " And ClassId in("& DataClassVal &") "
        Else
            TempWhere = TempWhere & " And ClassId = " & ClassId & " "
        End If
    End If
    If TypeId > 0 Then
        Select Case TypeId
            Case 1
                TempWhere = TempWhere & " And DataIsMsg = 1 "
            Case 2
                TempWhere = TempWhere & " And DataIsSlide = 1 "
            Case 3
                TempWhere = TempWhere & " And DataIsTop = 1 "
            Case 4
                TempWhere = TempWhere & " And DataIsBest = 1 "
            Case 5
                TempWhere = TempWhere & " And DataIsHot = 1 "
        End Select
    End If
    If TopicId > 0 Then
        TempWhere = TempWhere & " And TopicId = "& TopicId &" "
    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:*")
    '============================ TempField
    TempField = "Id,ClassId,Title,ColorMode,FontMode,DataIsTop,DataIsBest,DataIsHot,ImageUrl,UrlLink,"
    TempField = TempField & "Hits,UpTime,CnName,ViewHtmlPath,ViewHtmlPrefix,HtmlFile,Px,"
    TempField = TempField & "DataIsMsg,DataIsSlide,MsgNum"
    '============================ OrderId
    Select Case OrderId
        Case 1
            TempOrder = " UpTime Desc,Id Desc "
        Case 2
            TempOrder = " Px Asc,Id Desc "
        Case 3
            TempOrder = " Hits Desc,Id Desc "
        Case 4
            TempOrder = " MsgNum Desc,Id Desc "
        Case Else
            TempOrder = " AddTime Desc,Id Desc "
    End Select
    Set oRs = Easp.db.GPR("0", Array("View_" & TabName & ":" & TempField, TempWhere, TempOrder, " 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)
            ShowInfoIcon = CmsFun.DateToInfo(ArrayList(11, i), " <img src=""../images/g-new.gif"" border=""0"" />")
            ShowAttrList = ""
            ShowTitle = CmsFun.Highlight(CmsFun.ReadFontMode(ArrayList(2, i), ArrayList(3, i), ArrayList(4, i)), Keywords)
            If Not Easp.IsN(ArrayList(9, i)) Then
                UrlLinks = ArrayList(9, i)
            Else
                UrlLinks = CmsFun.HtmlFileUrl(ArrayList(13, i) & ArrayList(14, i), ArrayList(15, i), ArrayList(0, i))
            End If
            ShowImagesInfo = Easp.IIf(Not Easp.IsN(ArrayList(8, i)), CmsFun.ShowColor("[图]", "red"), "")
            ' Ico
            ShowInfoIcon = ShowInfoIcon & Easp.IIf(ArrayList(5, i) = 1, " <img src=""../images/g-top.gif"" border=""0"" />", "")
            ShowInfoIcon = ShowInfoIcon & Easp.IIf(ArrayList(6, i) = 1, " <img src=""../images/g-best.gif"" border=""0"" />", "")
            ShowInfoIcon = ShowInfoIcon & Easp.IIf(ArrayList(7, i) = 1, " <img src=""../images/g-hot.gif"" border=""0"" />", "")
            ' Edit
            ShowAttrList = ShowAttrList & GetShowIcon(ChannelId, ArrayList(0, i), "DataIsMsg", ArrayList(17, i), 1, "评论")
            ShowAttrList = ShowAttrList & GetShowIcon(ChannelId, ArrayList(0, i), "DataIsTop", ArrayList(5, i), 3, "置顶")
            ShowAttrList = ShowAttrList & GetShowIcon(ChannelId, ArrayList(0, i), "DataIsBest", ArrayList(6, i), 4, "推荐")
            ShowAttrList = ShowAttrList & GetShowIcon(ChannelId, ArrayList(0, i), "DataIsHot", ArrayList(7, i), 5, "热门")
            ShowAttrList = ShowAttrList & GetShowIcon(ChannelId, ArrayList(0, i), "DataIsSlide", ArrayList(18, i), 2, "幻灯片")
    %>
    <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><%=ShowInfoIcon%></td>
      <td><a href="?ChannelId=<%=ChannelId%>&ClassId=<%=ArrayList(1,i)%>"><%=ArrayList(12,i)%></a></td>
      <td><%=ArrayList(10,i)%>/<%=ArrayList(19,i)%></td>
      <td><input type="hidden" name="hidId" value="<%=ArrayList(0,i)%>" />
        <input type="text" class="txtInput2 w50" name="Px" value="<%=ArrayList(16,i)%>" maxlength="5" onfocus="ChkNumEric(this)" autocomplete="off" /></td>
      <td><%=ShowAttrList%></td>
      <td><%=CmsFun.TimeToString(ArrayList(11,i),"yyyy-mm-dd")%></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 TabName, " Id = "& spHidId(i) &" ", Array("px:" & spPx(i))
    Next
    CmsAdmin.JscriptMsg "批量排序成功！", ToUrl, "Success", "null"
End Sub

Sub UpTime()
    ChkChannelAdminLevel ChannelId, "edit"
    '=====================================================================
    Dim hidId
    hidId = Replace(Easp.Post("hidId:s"), ", ", ",")
    If Easp.IsN(hidId) Then
        CmsAdmin.JscriptMsg "对不起，请选中您要操作的记录！", "back", "Error", "null"
    End If
    Easp.db.UR TabName, " Id In("& hidId &") ", Array("UpTime:" & Now())
    CmsAdmin.JscriptMsg "批量更新时间成功！", ToUrl, "Success", "null"
End Sub

Sub YdData()
    Dim dataId, ClassId
    dataId = Easp.Post("dataId:s")
    ClassId = Easp.Post("ClassId:n:0")
    If ClassId = 0 Then
        CmsAdmin.JscriptMsg "对不起，对不起，未选择分类！", "back", "Error", "null"
    End If
    If Easp.IsN(dataId) Then
        CmsAdmin.JscriptMsg "对不起，请选中您要操作的记录！", "back", "Error", "null"
    End If
    Easp.db.UR TabName, " Id In("& dataId &") ", Array("ClassId:" & ClassId)
    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
        CmsAdmin.ExeDelHtmlFile ChannelId, TabName, chkId
        ResultVal = Easp.db.DR(TabName, "Id:" & chkId)
        If ResultVal <> 0 Then
            ' 删除评论
            Easp.db.DR TablePrefix & "Comment", " ChannelId = "& ChannelId &" And DataId in("& chkId &") "
            CmsAdmin.JscriptMsg "批量删除成功！", ToUrl, "Success", "null"
        End If
    End If
End Sub
%>
