<% Option Explicit %>
<!--#include file="../../Inc/Const.asp" -->
<!--#include file="../../Inc/Cls_DB.asp" -->
<!--#include file="../../Inc/Function.asp" -->
<%
Dim DBC,Conn
Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
Dim NewsSql,RsNewsObj,RsClassObj,RsChildClassObj,ClassID,ClassCName,NewsType,NewsTypeStr,PicStr,SunNumAsp
ClassID = Request("ClassID")
if Not JudgePopedomTF(Session("Name"),""&ClassID&"") then Call ReturnError1()
if ClassID <> "" then
	Set RsClassObj = Conn.Execute("Select ClassCName,ClassEName from NewsClass where ClassID='" & ClassID & "' and DelFlag=0")
	if Not RsClassObj.Eof then
		ClassCName = RsClassObj("ClassCName")
	else
		if ClassID = "0" then
			ClassCName = "根栏目"
		else
			ClassCName = "栏目不存在，请重新加载"
		end if
	end if
	Set RsChildClassObj = Conn.Execute("Select * from NewsClass where ParentID='" & ClassID & "' and DelFlag=0")
else
	ClassCName = "参数传递错误，请重新加载"
end if
if request.Form("KeyWords")<>"" then
	if ClassID<>"0" then
		NewsSql = "Select * from News where ClassID='" & ClassID & "'and Title like '%"&request.Form("Keywords")&"%' and DelTF=0 and AuditTF=0 order by AddDate asc"
	else
		NewsSql = "Select * from News where DelTF=0 and Title like '%"&request.Form("Keywords")&"%' and AuditTF=0 order by AddDate asc"
	end if
else
	if ClassID<>"0" then
		NewsSql = "Select * from News where ClassID='" & ClassID & "' and DelTF=0 and AuditTF=0 order by AddDate asc"
	else
		NewsSql = "Select * from News where DelTF=0 and AuditTF=0 order by AddDate asc"
	end if
end if
Set RsNewsObj = Server.CreateObject("Adodb.RecordSet")
	RsNewsObj.Open NewsSql,Conn,3,3
	SunNumAsp = RsNewsObj.RecordCount
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新闻列表</title>
</head>
<link href="../../CSS/css.css" rel="stylesheet">
<script src="../JS/PublicJS.js" language="JavaScript"></script>
<body topmargin="0" leftmargin="0" ondragstart="return false;" onselectstart="return false;" oncontextmenu="ClickClassOrNews(document.all('MainTable'));showMenu(MouseRightMenu);return false;">
<table id="MainTable" onclick="ClickClassOrNews(this);" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="100%" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="1">
        <tr> 
          <td width="5%" class="ButtonList"><div align="center">选择</div></td>
          <td width="43%" class="ButtonList"><div align="center">名称</div></td>
          <td width="16%" class="ButtonList"><div align="center">类型</div></td>
          <td width="21%" class="ButtonList"><div align="center">时间</div></td>
          <td width="15%" class="ButtonList"><div align="center">大小( byte)</div></td>
        </tr>
<%
if RsNewsObj.eof then
%>
        <tr> 
          <td colspan="5"><div align="center"><font color=red>此栏目内暂无未审核信息</font></div></td>
        </tr>
<%
end if
if not  RsNewsObj.Bof And not RsNewsObj.Eof  then 
	Dim Page_Size,Page_No,Page_Total,Record_All
	Page_Size=20
	Page_No = Request.Querystring("Page_No")
    if Page_No <= 1 or Page_No = "" then Page_No = 1
	If Request.QueryString("Page_No") = "" then
		Page_No = 1
	end if
	RsNewsObj.PageSize = Page_Size
	page_total=RsNewsObj.PageCount
	if (Cint(Page_No)>Page_Total) then Page_No = Page_Total
	RsNewsObj.AbsolutePage = Page_No
	Record_All = RsNewsObj.RecordCount
	Dim i
  	for i=1 to RsNewsObj.PageSize
    	if RsNewsObj.eof then exit for

	if RsNewsObj("HeadNewsTF")<>"1" and RsNewsObj("PicNewsTF")<>"1" then
	   NewsType = 1
	   NewsTypeStr = "文字新闻"
	   PicStr = "../Images/WordNews.gif"
	elseif RsNewsObj("HeadNewsTF")="1" then
	   NewsType = 2
	   NewsTypeStr = "标题新闻"
	   PicStr = "../Images/TitleNews.gif"
	else
	   NewsType = 3
	   NewsTypeStr = "图片新闻"
	   PicStr = "../Images/PicNews.gif"
	end if
%>
        <tr> 
          <td height="22"><div align="center">
            <input type="checkbox" name="CheckNewsID" onclick="ClickFlag();" value="<% = RsNewsObj("NewsID") %>">
          </div></td>
          <td height="22"> <table border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td height="20"><img src="<% = PicStr %>" width="18" height="18"></td>
                <td height="20"><span NewsType="<% = NewsType %>" class="TempletItem" NewsID="<% = RsNewsObj("NewsID") %>" align="center"> 
                  <% = GotTopic(RsNewsObj("Title"),40) %>
                </span> </td>
              </tr>
            </table>
            <span class="TempletItem" onclick="ClickNews(this);" NewsID="<% = RsNewsObj("NewsID") %>" align="center"> 
          </span></td>
          <td height="22"> <div align="center" class="TempletItem"> 
              <% = NewsTypeStr %>
            </div></td>
          <td height="22"> <div align="center" class="TempletItem"> 
              <% = RsNewsObj("AddDate") %>
            </div></td>
          <td height="22"><div align="center" class="TempletItem"> 
              <% = Len(RsNewsObj("Content")) %>
            </div></td>
        </tr>
        <%
	RsNewsObj.MoveNext
	Next
end if
%>
      </table>
    </td>
  </tr>
  <tr><td height="30" colspan="2" valign="bottom">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td valign="middle" class="ButtonList"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                 <form name="form1" method="post" action="">
                  <td width="62%"><table width="99%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="78%"><div align="right">
                            <input name="KeyWords" type="text" id="KeyWords" size="15">
                          </div></td>
                        <td width="22%" valign="bottom"><div align="center">
                            <input name="imageField" type="image" src="../Images/Search.gif" width="57" height="21" border="0">
                          </div></td>
                      </tr>
                    </table> </td>
                </form>
                <td valign="top"> <div align="right">
                    <% =  "NO.<b>"& page_no &"</b>,&nbsp;&nbsp;" %>
                    <% = "Totel:<b>"& page_total &"</b>,&nbsp;RecordCounts:<b>" & record_all &"</b>&nbsp;&nbsp;&nbsp;"%>
                    <%
if Page_Total=1 then
		response.Write "&nbsp;<img src=../images/First1.gif border=0 alt=首页></img>&nbsp;"
		response.Write "&nbsp;<img src=../images/prePage.gif border=0 alt=上一页></img>&nbsp;"
		response.Write "&nbsp;<img src=../images/nextPage.gif border=0 alt=下一页></img>&nbsp;"
		response.Write "&nbsp;<img src=../images/endPage.gif border=0 alt=尾页></img>&nbsp;"
else
	if cint(Page_No)<>1 and cint(Page_No)<>Page_Total then
		response.Write "&nbsp;<a href=?ClassID="&ClassID&"&page_no=1&Keywords="&Request("Keywords")&"><img src=../images/First1.gif border=0 alt=首页></img></a>&nbsp;"
		response.Write "&nbsp;<a href=?ClassID="&ClassID&"&page_no="&cstr(cint(Page_No)-1)&"&Keywords="&Request("Keywords")&"><img src=../images/prePage.gif border=0 alt=上一页></img></a>&nbsp;"
		response.Write "&nbsp;<a href=?ClassID="&ClassID&"&page_no="&cstr(cint(Page_No)+1)&"&Keywords="&Request("Keywords")&"><img src=../images/nextPage.gif border=0 alt=下一页></img></a>&nbsp;"
		response.Write "&nbsp;<a href=?ClassID="&ClassID&"&page_no="& Page_Total &"&Keywords="&Request("Keywords")&"><img src=../images/endPage.gif border=0 alt=尾页></img></a>&nbsp;"
	elseif cint(Page_No)=1 then
		response.Write "&nbsp;<img src=../images/First1.gif border=0 alt=首页></img></a>&nbsp;"
		response.Write "&nbsp;<img src=../images/prePage.gif border=0 alt=上一页></img>&nbsp;"
		response.Write "&nbsp;<a href=?ClassID="&ClassID&"&page_no="&cstr(cint(Page_No)+1)&"&Keywords="&Request("Keywords")&"><img src=../images/nextPage.gif border=0 alt=下一页></img></a>&nbsp;"
		response.Write "&nbsp;<a href=?ClassID="&ClassID&"&page_no="& Page_Total &"&Keywords="&Request("Keywords")&"><img src=../images/endpage.gif border=0 alt=尾页></img></a>&nbsp;"
	else
		response.Write "&nbsp;<a href=?ClassID="&ClassID&"&page_no=1&Keywords="&Request("Keywords")&"><img src=../images/First1.gif border=0 alt=首页></img>&nbsp;"
		response.Write "&nbsp;<a href=?ClassID="&ClassID&"&page_no="&cstr(cint(Page_No)-1)&"&Keywords="&Request("Keywords")&"><img src=../images/prePage.gif border=0 alt=上一页></img></a>&nbsp;"
		response.Write "&nbsp;<img src=../images/nextPage.gif border=0 alt=下一页></img></a>&nbsp;"
		response.Write "&nbsp;<img src=../images/endpage.gif border=0 alt=尾页></img>&nbsp;"
	end if
end if
%>
                    <select onChange="ChangePage(this.value);" style="width:50;" name="select">
                      <% for i=1 to Page_Total %>
                      <option <% if cint(Page_No) = i then Response.Write("selected")%> value="<% = i %>"> 
                      <% = i %>
                      </option>
                      <% next %>
                    </select>
                  </div></td>
              </tr>
            </table></td>
</tr>
</table>
  </td></tr>
</table>
</body>
</html>
<!-- 鼠标右键菜单 -->
<div id=MouseRightMenu onclick="ClickMenu(this);" onmouseover="MouseOverRightMenu();" onmouseout="MouseOverRightMenu();" class="menu"> 
  <div class="MouseRightItem" id="Edit" ExeFunction="EditNews();">修改</div>
  <div class="MouseRightItem" id="Del" ExeFunction="DelNewsClass();">删除</div>
  <div class="MouseRightItem" id="ChooseAll" ExeFunction="SelectA();">全选</div>
  <div class="MouseRightItem" id="UnChoose" ExeFunction="SelectB();">取消选择</div>
  <hr id="HR1">
  <div class="MouseRightItem" id="CheckOne" ExeFunction="DelSelected();">审核</div>
  <div class="MouseRightItem" id="CheckPage" ExeFunction="CheckThisPage();">审核本页</div>
  <div class="MouseRightItem" id="CheckAll" ExeFunction="CheckAll();">审核全部</div>
  <hr id="HR3">
  <div class="MouseRightItem" id="Cut" ExeFunction="CutOperation();">剪切</div>
  <div class="MouseRightItem" id="Copy" ExeFunction="CopyOperation();">拷贝</div>
  <div class="MouseRightItem" id="Paste" ExeFunction="PasteOperation();">粘帖</div>
  <hr id="HR5">
  <div class="MouseRightItem" id="UnCheck" ExeFunction="UnCheck();">已审核信息</div>
  <hr id="HR6">
  <div class="MouseRightItem" id="Read1" ExeFunction="Read();">预览</div>
   <hr id="HR7">
  <div class="MouseRightItem" id="Refresh" ExeFunction="window.location.reload();">刷新</div>
   <hr id="HR8">
  <div class="MouseRightItem" id="Pros" ExeFunction="javascript:window.prompt('本页面路径属性' , '<%=Request.ServerVariables("SCRIPT_NAME")%>');">路径属性</div>
</div>
<%
Set RsChildClassObj = Nothing
Set RsNewsObj = Nothing
Set RsClassObj = Nothing
Set Conn = Nothing
%>
<script language="javascript">
var AllSelect=false;
var NoneSelect=true;
UnChoose.className='MenuItemDisable';
CheckOne.className='MenuItemDisable';
var CurrPageIndex='<% = page_no %>';
var TotalPageNum='<% = page_total %>';
var SunNum = '<% = SunNumAsp %>';
var NewsID='';
var NewsType='';
var ClassID = '<% = ClassID %>';
var ReClassID = ClassID;
parent.MoveOrCopyObjectClass=ClassID;
var DisableOrActiveMenuArray=new Array();
DisableOrActiveMenuArray[0]=Edit;
DisableOrActiveMenuArray[1]=Del;
DisableOrActiveMenuArray[2]=Cut;
DisableOrActiveMenuArray[3]=Copy;
DisableOrActiveMenuArray[4]=Read1;
if ((parent.MoveOrCopySourceClass!='')||(parent.MoveOrCopySourceNews!=''))
{
	if (parent.MoveOrCopySourceNews!='')
	{
		if (ClassID=='0') Paste.className='MenuItemDisable';
		else  Paste.className='MouseRightItem';
	}
	else  Paste.className='MouseRightItem';
}
else Paste.className='MenuItemDisable';
DisableMenu(DisableOrActiveMenuArray);
function ClickClassOrNews(Obj)
{
	Paste.className='MouseRightItem';
	parent.MoveOrCopyObjectClass=ClassID;
	for (var i=0;i<Obj.all.length;i++) if (Obj.all(i).className=='TempletSelectItem') Obj.all(i).className='TempletItem';
	var el=event.srcElement;
	if (el.tagName.toLowerCase()=='font') el=el.parentElement;
	if ((el.ClassID!=null)||(el.NewsID!=null))
	{
		el.className='TempletSelectItem';
		if (el.ClassID!=null)
		{
			ClassID=el.ClassID;
			parent.MoveOrCopyObjectClass=ClassID;
			if ((parent.MoveOrCopySourceClass!='')||(parent.MoveOrCopySourceNews))	Paste.className='MouseRightItem';
			else Paste.className='MenuItemDisable';
			NewsID='';
		}
		if (el.NewsID!=null)
		{
			ClassID='';
			parent.MoveOrCopyObjectClass=ClassID;
			Paste.className='MenuItemDisable';
			NewsID=el.NewsID;
			NewsType=el.NewsType
		}
	}
	else
	{
		if ((parent.MoveOrCopySourceClass!='')||(parent.MoveOrCopySourceNews!=''))
		{
			if (parent.MoveOrCopySourceNews!='')
			{
				if (ClassID=='0') Paste.className='MenuItemDisable';
				else  Paste.className='MouseRightItem';
			}
			else  Paste.className='MouseRightItem';
		}
		else Paste.className='MenuItemDisable';
		ClassID='';
		NewsID='';
	}
	if ((ClassID!='')||(NewsID!=''))
	{
		ActiveMenu(DisableOrActiveMenuArray);
		if (ClassID!='')
		{
			Copy.className='MenuItemDisable';
			Edit.className='MenuItemDisable';
			ToJs.className='MenuItemDisable';
			ChildPicJS.className='MenuItemDisable';
			ChildWordJS.className='MenuItemDisable';
			ToSpecial.className='MenuItemDisable';
		}
	}
	else DisableMenu(DisableOrActiveMenuArray);
	if (SunNum<=0)
	{
	 ChooseAll.className = 'MenuItemDisable';
	 CheckPage.className = 'MenuItemDisable';
	 CheckAll.className = 'MenuItemDisable';
	 }
}

function CutOperation()
{
	parent.MoveTF=true;
	if (ClassID!='')
	{
		parent.MoveOrCopySourceClass=ClassID;
		parent.MoveOrCopySourceNews='';
		parent.OperationType='Class';
	}
	if (NewsID!='')
	{
		parent.MoveOrCopySourceClass='';
		parent.MoveOrCopySourceNews=NewsID;
		parent.OperationType='News';
	}
}

function CopyOperation()
{
	parent.MoveTF=false;
	if (ClassID!='')
	{
		parent.MoveOrCopySourceClass=ClassID;
		parent.MoveOrCopySourceNews='';
		parent.OperationType='Class';
	}
	if (NewsID!='')
	{
		parent.MoveOrCopySourceClass='';
		parent.MoveOrCopySourceNews=NewsID;
		parent.OperationType='News';
	}
}

function PasteOperation()
{
	var MoveOrCopyClassPara='OperationType:'+parent.OperationType+';MoveTF:'+parent.MoveTF+';SourceClass:'+parent.MoveOrCopySourceClass+';SourceNews:'+parent.MoveOrCopySourceNews+';ObjectClass:'+parent.MoveOrCopyObjectClass+';';
	OpenWindow('Frame.asp?FileName=MoveOrCopyNewsClass.asp&MoveOrCopyClassPara='+MoveOrCopyClassPara,300,150,window);
}


function UnCheck()
{
  if (ReClassID!='') parent.frames['OpreateWindow'].location='NewsList.asp?ClassID='+ReClassID ;
 }
function Read()
{
  if (NewsID!='') window.open('Read.asp?NewsID='+NewsID);
  else alert('错误的参数');
 }

function EditNews()
{
	if (NewsID!='')
	{
		switch (NewsType)
		{
			case '1':
				OpenWindow('NewsModify.asp?NewsID='+NewsID,620,535,window);
				break;
			case '2':
				OpenWindow('NewsModify.asp?NewsID='+NewsID,620,295,window);
				break;
			case '3':
				OpenWindow('NewsModify.asp?NewsID='+NewsID,620,540,window);
				break;
			default:
				return;
		}
	}
}

function ChangePage(PageNum)
{
	if (ReClassID!='') window.location.href='?ClassID='+ReClassID+'&page_no='+PageNum;
}

function DelNewsClass()
{
	if (NewsID!='') OpenWindow('Frame.asp?FileName=DelNewsClass.asp&Titles=删除新闻&NewsID='+NewsID,300,110,window);
}

function SetMenu()
{
	if (AllSelect==true)
	{
		UnChoose.className='MouseRightItem';
		ChooseAll.className='MenuItemDisable';
		CheckOne.className='MouseRightItem';
	}
	else
	{
		if (NoneSelect==true)
		{
			ChooseAll.className='MouseRightItem';
			UnChoose.className='MenuItemDisable';
			CheckOne.className='MenuItemDisable';
		}
		else
		{
			ChooseAll.className='MouseRightItem';
			UnChoose.className='MouseRightItem';
		}
	}
}

function SelectA()
{
	for (var i=0;i<=document.all.CheckNewsID.length-1;i++)
	{
		document.all.CheckNewsID(i).checked=true;
	}
	if (SunNum==1) document.all.CheckNewsID.checked=true;
	else document.all.CheckNewsID(0).onclick();
	AllSelect=true;
	NoneSelect=false;
	SetMenu();
}
function SelectB()
{
	for (var i=0;i<=document.all.CheckNewsID.length-1;i++)
	{
		document.all.CheckNewsID(i).checked=false;
	}
	if (SunNum==1) document.all.CheckNewsID.checked=false;
	else document.all.CheckNewsID(0).onclick();
	AllSelect=false;
	NoneSelect=true;
	SetMenu();
}

function ClickFlag()
{
	var TempStr=GetFlagValue();
	if (TempStr=='') CheckOne.className='MenuItemDisable';
	else CheckOne.className='MouseRightItem';
	AllSelect=false;
	NoneSelect=false;
	SetMenu();
}

function GetFlagValue()
{
	var TempStr='';
	if (SunNum==1)
	{
		if (document.all.CheckNewsID.checked==true) TempStr=document.all.CheckNewsID.value;
	 }
	else
	{
		for (var i=0;i<=document.all.CheckNewsID.length-1;i++)
		{
			if (document.all.CheckNewsID(i).checked==true)
			{
				if (TempStr=='') TempStr=document.all.CheckNewsID(i).value;
				else  TempStr=TempStr+'*'+document.all.CheckNewsID(i).value;
			}
		}
	 }
	return TempStr
}

function DelSelected()
{
	var NewsID='';
	NewsID=GetFlagValue();
	OpenWindow('CheckNews.asp?NewsID='+NewsID,100,100,window);
	window.location.reload();
	ChangePage(CurrPageIndex);
}

function CheckThisPage()
{
	var NewsID='';
	NewsID=GetPageValue();
	OpenWindow('CheckNews.asp?NewsID='+NewsID,100,100,window);
	window.location.reload();
	ChangePage(CurrPageIndex);
}
function CheckAll()
{
	OpenWindow('CheckNews.asp?CA=All',100,100,window);
	window.location.reload();
	ChangePage(CurrPageIndex);
}

function GetPageValue()
{
	var TempStr='';
	if (SunNum==1)
		{
			TempStr=document.all.CheckNewsID.value;
		 }
	else
	{
		for (var i=0;i<=document.all.CheckNewsID.length-1;i++)
		{
			if (TempStr=='') TempStr=document.all.CheckNewsID(i).value;
			else  TempStr=TempStr+'*'+document.all.CheckNewsID(i).value;
		}
	 }
	return TempStr
}

</script>