<%@ codepage ="936" %>
<%charset="gb2312"%>
<%Session.CodePage=936%>
<!--#include file="Admin.asp"-->
<!--#include file="Conn.asp"-->
<!--#include file="../Inc/Ubbcode.asp"-->
<!--#include file="Inc/Function.asp"-->
<%
dim strFileName
const MaxPerPage=20
dim totalPut,CurrentPage,TotalPages
dim i,j
dim ArticleID
dim keyword
dim sql,rs
dim BigClassID,SmallClassID
dim PurviewChecked
dim strAdmin,arrAdmin
PurviewChecked=false

keyword=Trim(request("keyword"))
ArticleID=Request("ArticleID")
BigClassID=Trim(request("BigClassID"))
SmallClassID=Trim(request("SmallClassID"))
tw=Trim(request("tw"))
rd=Trim(request("rd"))

if BigClassID<>"" then
  bigClassName=conn.execute("select bigclassname From NewsBigClass where bigClassID="&CLng(BigClassID))(0)
End if
if SmallClassID<>"" then
  SmallClassName=conn.execute("select Smallclassname from NewsSmallClass where smallClassID="&CLng(SmallClassID))(0)
End if
strFileName="News_Manage.asp?BigClassID=" & BigClassID & "&SmallClassID=" & SmallClassID & "&tw=" & tw & "&rd=" & rd & "&keyword=" & keyword & "&orders=" & request("orders")

if request("page")<>"" then
    currentPage=cint(request("page"))
else
	currentPage=1
end if

sql="select * from conews where ArticleID>0"
if keyword<>"" then 
	If IsNumeric(keyword) Then
		sql=sql & " and Articleid = " & keyword & ""
	Else
		sql=sql & " and Title like '%" & keyword & "%' "
	End if
end if
if BigClassID<>"" then
	sql=sql & " and BigClassID=" & BigClassID & " "
	if SmallClassID<>"" then
		sql=sql & " and SmallClassID=" & SmallClassID & " "
	end if
end If
If tw="yes" Then sql=sql & " and Passed=true"   '筛选图文推荐
If rd="yes" Then sql=sql & " and Elite=true"    '筛选热点推荐

If request("orders")="hits" Then
	sql=sql & " order by hits desc,ArticleID DESC"
else
	sql=sql & " order by ArticleID DESC"
End If

Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
%>
<SCRIPT language=javascript>
function unselectall()
{
    if(document.del.chkAll.checked){
	document.del.chkAll.checked = document.del.chkAll.checked&0;
    } 	
}

function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "chkAll")
       e.checked = form.chkAll.checked;
    }
  }
function ConfirmDel(form)
{
   if(confirm("确定要对选中的频道执行此操作吗？"))
     return true;
   else{
	 if (form.Action.value="Orders")
	 {
	    form.chkAll.checked=false;
	    CheckAll(form);
	 }
     return false;
   }
	 
}
function Changefrom(form)
{
  form.Action.value="Elite";
}
function Changefrom1(form)
{
  form.Action.value="Reset";
}
function Changefrom2(form)
{
  form.Action.value="tjshow";
}
function Changefrom3(form)
{
  form.Action.value="Reshow";
}
function Changefrom4(form)
{
  form.chkAll.checked=true;
  CheckAll(form);
  form.Action.value="Orders";
}
</SCRIPT>

<!-- #include file="Inc/Head.asp" -->
<div align=center>
<TABLE class=tableBorder1 style="WIDTH: 100%" cellSpacing=0 cellPadding=3 
align=center border=0>
  <TBODY>
  <TR>
    <TD height=20></TD></TR></TBODY></TABLE>
<TABLE class=tableBorder cellSpacing=0 cellPadding=0 width="95%" align=center border=0>
	<tr> 
		<TH align=left height=23 class="tableHeaderText"><div align="center"><font color=white>频 道 管 理</font></div></TH>
	</tr>
	<tr> 
	  <td height="25" class=forumRow>
      <table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" class="border">
        <tr> 
          <td bgcolor="#C0C0C0" height="25" class=forumRow_hui style="line-height:180%">|&nbsp; 
            <%
dim sqlBigClass,sqlSmallClass,rsBigClass,rsSmallClass,sqlSpecial,rsSpecial
sqlBigClass="select * From NewsBigClass order by orders desc,BigClassid asc"
Set rsBigClass= Server.CreateObject("ADODB.Recordset")
rsBigClass.open sqlBigClass,conn,1,1
if rsBigClass.eof then 
	response.Write("还没有任何栏目，请首先添加栏目。")
end if
do while not rsBigClass.eof
	if rsBigClass("BigClassID")=BigClassID then
		response.Write("<a href='News_Manage.asp?BigClassID=" & rsBigClass("BigClassID") & "&tw="&tw&"&rd="&rd&"'><font color='red'>" & rsBigClass("BigClassName") & "</font></a>　|　")
	Else
		mycolor=""
		If rsBigClass("show")>0 Then mycolor=" style='color:#0033CC'"
		response.Write("<a "&mycolor&" href='News_Manage.asp?BigClassID=" & rsBigClass("BigClassID") & "&tw="&tw&"&rd="&rd&"'>" & rsBigClass("BigClassName") & "</a>　|　")
	end if
	rsBigClass.movenext
loop
rsBigClass.close
set rsBigClass=nothing
%>　
          </td>
        </tr>
        <%
if BigClassID<>"" then
	sqlSmallClass="select * from NewsSmallClass where BigClassID=" & BigClassID & " order by orders desc,SmallClassid asc"
	Set rsSmallClass= Server.CreateObject("ADODB.Recordset")
	rsSmallClass.open sqlSmallClass,conn,1,1
	if not (rsSmallClass.bof and rsSmallClass.eof) then
		response.write "<tr class='tdbg'><td bgcolor='#C0C0C0' height=30>"
		do while not rsSmallClass.eof
			if rsSmallClass("SmallClassID")=SmallClassID then
				response.Write("&nbsp;<a href='News_Manage.asp?BigClassID=" & rsSmallClass("BigClassID") & "&SmallClassID=" & rsSmallClass("SmallClassID") & "&tw="&tw&"&rd="&rd&"'><font color='red'>" & rsSmallClass("SmallClassName") & "</font></a>&nbsp;&nbsp;")
			else
				response.Write("&nbsp;<a href='News_Manage.asp?BigClassID=" & rsSmallClass("BigClassID") & "&SmallClassID=" & rsSmallClass("SmallClassID") & "&tw="&tw&"&rd="&rd&"'>" & rsSmallClass("SmallClassName") & "</a>&nbsp;&nbsp;")
			end if
			rsSmallClass.movenext
		loop
		response.write "</td></tr>"
	end if
	rsSmallClass.close
	set rsSmallClass=nothing
end if
%>
      </table>
      <form name="del" method="Post" action="News_Del.asp?bigclassid=<%=bigclassid%>&smallclassid=<%=smallclassid%>&keyword=<%=keyword%>&tw=<%=tw%>&rd=<%=rd%>&page=<%=currentPage%>" onsubmit="return ConfirmDel(this.form);">
        <table width="100%" border="0" cellpadding="0" cellspacing="1">
          <tr> 
            <td height="25" class=forumHeaderBackgroundAlternate><a href="News_Manage.asp">&nbsp;频道管理</a> 
              &gt;&gt; 
              <%
if request.querystring="" then
	response.write "所有频道"
else
	if request("Query")<>"" then
		if keyword<>"" then
			response.write "名称中含有“<font color=blue>" & keyword & "</font>”的频道"
		else
			response.Write("所有频道")
		end if
 	else
		if BigClassID<>"" then
			response.write "<a href='News_Manage.asp?BigClassID=" & BigClassID & "'>" & bigClassName & "</a>&nbsp;&gt;&gt;&nbsp;"
			if SmallClassID<>"" then
				response.write "<a href='News_Manage.asp?BigClassID=" & BigClassID & "&SmallClassID=" & SmallClassID & "'>" & SmallClassName & "</a>"
			else
				response.write "所有小类"
			end if
		end if
	end if
end if
%>
            </td>
            <td width="150" class=forumHeaderBackgroundAlternate>&nbsp;
            <%
  	if rs.eof and rs.bof then
		response.write "共找到 0 个频道</td></tr></table>"
	else
    	totalPut=rs.recordcount
		if currentpage<1 then
       		currentpage=1
    	end if
    	if (currentpage-1)*MaxPerPage>totalput then
	   		if (totalPut mod MaxPerPage)=0 then
	     		currentpage= totalPut \ MaxPerPage
		  	else
		      	currentpage= totalPut \ MaxPerPage + 1
	   		end if

    	end if
		response.Write "共找到 " & totalPut & " 个频道"
%>
            </td>
          </tr>
        </table>
        <%		
	    if currentPage=1 then
        	showContent
        	showpage strFileName,totalput,MaxPerPage,true,false,"个频道"
   	 	else
   	     	if (currentPage-1)*MaxPerPage<totalPut then
         	   	rs.move  (currentPage-1)*MaxPerPage
         		dim bookmark
           		bookmark=rs.bookmark
            	showContent
            	showpage strFileName,totalput,MaxPerPage,true,false,"个频道"
        	else
	        	currentPage=1
           		showContent
           		showpage strFileName,totalput,MaxPerPage,true,false,"个频道"
	    	end if
		end if
	end if
%>
        <%  
sub showContent
   	dim i
    i=0
%>
        <table class="border" border="0" cellspacing="1" width="100%" cellpadding="0" style="word-break:break-all">
          <tr bgcolor="#C0C0C0"> 
            <td class=forumRow_hui width="50" height="25" align="center"><strong>选中</strong></td>
            <td class=forumRow_hui width="50"  height="25" align="center" bgcolor="#C0C0C0"><strong>ID</strong></td>
            <td class=forumRow_hui align="center" bgcolor="#C0C0C0" ><strong>频道名称</strong></td>
            <td class=forumRow_hui width="60" align="center" bgcolor="#C0C0C0" ><strong>显示顺序</strong></td>
			<td class=forumRow_hui width="60" align="center" bgcolor="#C0C0C0" ><strong><a href="?bigclassid=<%=bigclassid%>&smallclassid=<%=smallclassid%>&xinghao=<%=xinghao%>&tw=<%=tw%>&rd=<%=rd%>&orders=hits">访问量</a></strong></td>
            <td class=forumRow_hui width="120" align="center" ><strong>所属栏目</strong></td>
            <td class=forumRow_hui width="120" align="center" ><strong>推荐情况</strong></td>
            <td class=forumRow_hui width="70" align="center" ><strong>操作</strong></td>
          </tr>
          <%do while not rs.eof
			  if rs("SmallClassID")<>"" And rs("SmallClassID")>0 then
				connect=" - "
			  else 
				connect=""
			  end If
			  mybigClassName=""
			  mySmallClassName=""
			  if rs("BigClassID")<>"" And rs("BigClassID")>0 then
			    mybigClassName=conn.execute("select bigclassname From NewsBigClass where bigClassID="&CLng(rs("BigClassID")))(0)
			  End if
			  if rs("SmallClassID")<>"" And rs("SmallClassID")>0 then
				mySmallClassName=conn.execute("select Smallclassname from NewsSmallClass where smallClassID="&CLng(rs("SmallClassID")))(0)
			  End if
		  %>
          <tr class="tdbg"> 
            <td height="22" align="center" bgcolor="#C0C0C0"> <input name='ArticleID' type='checkbox' onclick="unselectall()" id="ArticleID" value='<%=cstr(rs("articleID"))%>'> 
            </td>
            <td align="center" bgcolor="#E3E3E3"><%=cstr(rs("articleID"))%></td>
            <td bgcolor="#E3E3E3">&nbsp;<a href="../NewsMore.asp?<%=rs("articleid")%>.html" target="_blank"><%=rs("Title")%></a></td>
			<td align="center" bgcolor="#E3E3E3" ><input name="orders" value="<%=rs("orders")%>" size="3"></td>
			<td align="left" bgcolor="#E3E3E3">&nbsp;&nbsp;<%=rs("hits")%></td>
            <td align="left" bgcolor="#E3E3E3">&nbsp;&nbsp;<%=myBigClassName & connect & mySmallClassName%></td>
            <td align="center" bgcolor="#E3E3E3"> 
              <%if rs("Passed")=true then%>
              &nbsp;推荐&nbsp;
              <%end if%>
              <%if rs("Elite")=true then%>
              &nbsp;图文&nbsp;
              <%end if%>
            </td>
            <td width="80" align="center" bgcolor="#E3E3E3"> 
              <a href="News_Modify.asp?ArticleID=<%=rs("articleid")%>">修改</a> 
              <a href="News_Del.asp?ArticleID=<%=rs("ArticleID")%>&Action=Del" onclick="return ConfirmDel();">删除</a> 
            </td>
          </tr>
          <%
	i=i+1
	      if i>=MaxPerPage then exit do
	      rs.movenext
	loop
%>
        </table>
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr> 
            <td width="200" height="30"><input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
              选中本页显示的所有频道</td>
            <td><input name="submit" type='submit' value='删除选定的'>　<input type="submit" name="button1" onclick="Changefrom(this.form);" value="推荐">　<input type="submit" name="button1" onclick="Changefrom1(this.form);" value="撤消推荐">　<input type="submit" name="button1" onclick="Changefrom2(this.form);" value="图文">　<input type="submit" name="button1" onclick="Changefrom3(this.form);" value="撤消图文">　<input type="submit" name="button1" onclick="Changefrom4(this.form);" value="设置顺序"><input name="Action" type="hidden" id="Action" value="Del"></td>
          </tr>
        </table>
        <%
   end sub 
%>
      </form>
      <br> 
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="border">
        <tr class="tdbg">
          <form name="searchsoft" method="get" action="News_Manage.asp">
            <td height="30"> <strong>查找频道：</strong> 
              <input name="keyword" type="text" class=smallInput id="Title3" size="20" maxlength="50">&nbsp;<input type="checkbox" name="tw" value="yes"<%If tw="yes" Then response.write " checked"%>>推荐&nbsp;<input type="checkbox" name="rd" value="yes"<%If rd="yes" Then response.write " checked"%>>热门
              <input name="Query" type="submit" id="Query" value="查 询">
              &nbsp;&nbsp;请输入频道名称、ID。如果为空，则查找所有频道。</td>
          </form>
        </tr>
      </table></td>
  </tr>
</table>
<!-- #include file="Inc/Foot.asp" -->
</div>
<%
rs.close
set rs=nothing  
call CloseConn()
%>