<%
errorMsg = ""
sql = ""
id = Request("id")
subaction = Request("subaction")
urlParam = "functions.asp?action="&action&LOGINPROPAGATEGET
set mrs = server.createobject("adodb.recordset")
if trim(Request("page")) <> "" then
	iCurrentPage = clng(request("page"))
else
	iCurrentPage = 1
end if

if session("articelsCondition") = "" then
	session("articelsCondition") = "where 1=1 "
end if
if subaction = "delSelect" then
	idList = split(trim(Request("SID")),",")
	for i=0 to UBound(idList)
		idList(i) = Trim(idList(i))
		sql = "delete from my_articles where id="& idList(i)
		conn.Execute(sql)
	next
	errorMsg = errorMsg &"批量删除成功！<br>"
elseif subaction = "del" then
	sql = "delete from my_articles where id="& id
	conn.Execute(sql)
	errorMsg = errorMsg &"操作成功！<br>"
elseif subaction = "search" then
	session("articelsCondition") = "where 1=1 "
	session("articelsConditionDesc") = ""
	strBeginDate = trim(Request("beginDate"))
	strEndDate = trim(Request("endDate"))
	if strBeginDate = "起始时间" then
		strBeginDate = ""
	end if
	if strEndDate = "终止时间" then
		strEndDate = ""
	end if
	if Request("keyword") <> "" and Request("keyword") <> "关键字" then
		if Request("searchType") = "0" then
			session("articelsCondition") = session("articelsCondition") &" AND title like '%"& trim(Request("keyword")) &"%'"
			session("articelsConditionDesc") = session("articelsConditionDesc") &"关键字="& Request("keyword") &"(包括)"
		else
			session("articelsCondition") = session("articelsCondition") &" AND title='"& trim(Request("keyword")) &"'"
			session("articelsConditionDesc") = session("articelsConditionDesc") &"关键字="& Request("keyword") &"(等于)"
		end if
	end if
	if ((strBeginDate <> "") and (strEndDate <> "")) then
		session("articelsCondition") = session("articelsCondition") &" AND writeDate BETWEEN '"& strBeginDate &"' AND '"& strEndDate &"'"
		session("articelsConditionDesc") = session("articelsConditionDesc") &",发布日期从"& strBeginDate &"至"+ strEndDate
	elseif (strBeginDate <> "") then
		session("articelsCondition") = session("articelsCondition") &" AND writeDate BETWEEN '"& strBeginDate &"' AND '"& now &"'"
		session("articelsConditionDesc") = session("articelsConditionDesc") &",发布日期从"& strBeginDate &"至今"
	elseif (strEndDate <> "") then
		session("articelsCondition") = session("articelsCondition") &" AND writeDate BETWEEN '1900-01-01' AND '"& strEndDate &"'"
		session("articelsConditionDesc") = session("articelsConditionDesc") &",发布日期至"& strEndDate
	end if
	if Request("status") <> "0" and Request("status") <> "" then
		session("articelsCondition") = session("articelsCondition") &" AND status="& trim(Request("status"))
		session("articelsConditionDesc") = session("articelsConditionDesc") &"状态="& newsStatus(Request("status"))
	end if
	if session("articelsConditionDesc") <> "" then
		session("articelsConditionDesc") = "<tr><td colspan=""13"">条件："& session("articelsConditionDesc") &"</td></tr>"
	end if
end if

if subaction = "preAdd" then
	subaction = "add"
end if

if errorMsg <> "" then
	DisplayMessage errorMsg,True
end if
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#E5EFE7">
<form method="post" action="functions.asp" name="searchForm">
<input type="hidden" name="action" value="<%=action%>">
<input type="hidden" name="subaction" value="search">
<input type="hidden" name="LOGINID" value="<%=LOGINID%>">
  <tr>
    <td height="4"></td>
  </tr>
  <tr>
    <td nowrap valign="middle">
      <span class="Search">
        <input type="radio" name="searchType" value="0" checked>模糊查询
        <input type="radio" name="searchType" value="1">精确查询
        <input type="text" name="keyword" size="6" class="ButtonEdit" value="关键字" onFocus="javascript:if (keyword.value=='关键字') {keyword.value=''}" onBlur="javascript:if (keyword.value==''){keyword.value='关键字'}">
        <select name="status">
          <option value="">不限</option>
<%
		for j=1 to ubound(newsStatus)-1
			Response.Write "          <option value="""& j &""">"& newsStatus(j) &"</option>"& vbCrLf
		next
%>
        </select>
        &nbsp;发表日期从
        <input type="text" name="beginDate" class="ButtonEdit" size="10" value="起始时间" onFocus="javascript:if (beginDate.value=='起始时间') {beginDate.value=''}" onBlur="javascript:if (beginDate.value==''){beginDate.value='起始时间'}">
        <input type="text" name="endDate" class="ButtonEdit" size="10" value="终止时间" onFocus="javascript:if (endDate.value=='终止时间') {endDate.value=''}" onBlur="javascript:if (endDate.value==''){endDate.value='终止时间'}">
        <input type="image" src="images/IconSearch.gif" border="0">
      </span>
    </td>
  </tr>
  <tr>
    <td height="5"></td>
  </tr>
  <tr>
    <td height="5"><font color="RED"></a></td>
  </tr>
</form>
</table>
<br>
<table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF">
  <form name="listForm" action="functions.asp" method="post">
  <input type="hidden" name="action" value="<%=action%>">
  <input type="hidden" name="subaction" value="">
  <input type="hidden" name="LOGINID" value="<%=LOGINID%>">
  <input type="hidden" name="iPage" value="<%=iCurrentPage%>">
  <tr class="ListTableHeader">
    <td nowrap background="images/TableHeaderBg.gif" width="24" align="center"><input type="checkBox" name="checkAll" value="on" OnClick="OnCheckAll(this.form)"></td>
    <td width="520" align="center" background="images/TableHeaderBg.gif">标题</td>
    <td background="images/TableHeaderBg.gif" width="165" align="center">作者</td>
    <td background="images/TableHeaderBg.gif" width="102" align="center">发布日期</td>
    <td nowrap background="images/TableHeaderBg.gif" width="62" align="center">评论</td>

    <td background="images/TableHeaderBg.gif" width="44"></td>
    <td background="images/TableHeaderBg.gif" width="42"></td>
  </tr>
<%
set rs=nothing
if trim(Request("page")) <> "" then
	iCurrentPage = clng(request("page"))
else
	iCurrentPage = 1
end if
Set cmd=Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection=conn
cmd.CommandType = 4
cmd.CommandText="pagelist"
cmd.Parameters.Append cmd.CreateParameter("@a_TableList",200,1,300)
cmd.Parameters("@a_TableList").Value ="*"
cmd.Parameters.Append cmd.CreateParameter("@a_TableName",200,1,100)
cmd.Parameters("@a_TableName").Value ="my_articles"
cmd.Parameters.Append cmd.CreateParameter("@a_SelectWhere",200,1,100)
cmd.Parameters("@a_SelectWhere").Value = session("articelsCondition")
cmd.Parameters.Append cmd.CreateParameter("@a_SelectOrderId",200,1,100)
cmd.Parameters("@a_SelectOrderId").Value ="id"
cmd.Parameters.Append cmd.CreateParameter("@a_SelectOrder",200,1,100)
cmd.Parameters("@a_SelectOrder").Value ="order by id desc"
cmd.Parameters.Append cmd.CreateParameter("@a_intPageNo",3,1)
cmd.Parameters("@a_intPageNo").Value =iCurrentPage
cmd.Parameters.Append cmd.CreateParameter("@a_intPageSize",3,1)
cmd.Parameters("@a_intPageSize").Value =iRowsPerPage
cmd.Parameters.Append cmd.CreateParameter("@RecordCount",200,2,100)
cmd.execute
iMaxRowCount=cmd.Parameters("@RecordCount").Value
set rs=cmd.execute
	if iMaxRowCount mod iRowsPerPage = 0 then
		iMaxPage = iMaxRowCount \ iRowsPerPage
	else
		iMaxPage = iMaxRowCount \ iRowsPerPage+1
	end if
if rs.State<>AdStateClosed then


 while not rs.Eof 
		strWordsNum = ""
			if CLng(rs("replynum")) > 0 then
				strWordsNum = "<a href=""#"" onclick=""javascript:setRowFocus(Row"& rs("id") &",false,"& rs("id") &");doEditWords("& rs("id") &")"">"& rs("replynum") &"条</a>"
			else
				strWordsNum = "暂无"
			end if

%>
  <tr class="InputTableRow" id="Row<%=rs("id")%>" onclick="javascript:setRowFocus(this,false,<%=rs("id")%>)">
    <td nowrap align="center"><input type="checkBox" name="SID" value="<%=rs("id")%>"></td>
    <td>&nbsp;<%=rs("title")%></td>
    <td>&nbsp;<%=rs("username")%></td>
    <td align="center"><%=year(rs("writeDate")) %>-<%=month(rs("writeDate")) %>-<%=day(rs("writeDate")) %></td>
    <td align="center"><%=strWordsNum%>&nbsp;</td>

    <td nowrap align="center"><span class="OperateIcon" onclick="javascript:setRowFocus(Row<%=rs("id")%>,false,<%=rs("id")%>);if (confirm('您正要删除【<%=Replace(rs("title"),"'","\'")%>】。\n本操作将删除该记录。请确认！')) document.URL='<%=urlParam%>&subaction=del&page=<%=iCurrentPage%>&id=<%=rs("id")%>'; return false;" title="删除"><img src="images/IconDelete.gif" border="0" width="16" height="16" alt="删除"></span></td>
    <td align="center"><span class="OperateIcon" onclick="javascript:setRowFocus(Row<%=rs("id")%>,false,<%=rs("id")%>); clickHandler(); " title="展开"><img src="images/IconIssue.gif" border="0" width="16" height="16" alt="展开" id="editPic<%=rs("id")%>" class="Outline"></span></td>
  </tr>
  <tr id="editPic<%=rs("id")%>details" style="display:None">
    <td colspan="5">
      <table width="90%" border="0" cellspacing="1" cellpadding="2" align="center">
        <tr> 
          <td class="a1"><%=ToHTMLSpecialChars(rs("content"))%></td>
        </tr>
      </table>
    </td>
  </tr> 
<%
		if bFirst = false then
%>
  <script LANGUAGE="javascript">
  <!--
	setRowFocus(Row<%=rs("id")%>,true,<%=rs("id")%>);
  //-->
  </script>
<%
			bFirst = true
		end if
		rs.MoveNext
		i = i + 1
wend
end if
%>
  </form>
</table>
<!-- #include file="pageRobot.inc.asp" //-->
<script language="javascript">
<!--//
function doEditWords(id)
{
  window.showModalDialog("frame.asp?action=words&subaction=note&LOGINID=<%=LOGINID%>&id="+ id,null,"dialogwidth=480pt;dialogheight=450pt;toolbar=no;status=no;resizable=no");
  return;
}
function doEditPhotos(id)
{
  window.showModalDialog("frame.asp?action=photos&subaction=preEdit&LOGINID=<%=LOGINID%>&id="+ id,null,"dialogwidth=480pt;dialogheight=450pt;toolbar=no;status=no;resizable=no");
  return;
}
function getDate(target)
{
  myDate = window.showModalDialog("tools/calendar.htm",null,"dialogwidth:155pt;dialogheight:190pt,toolbar=no,status=no,resizable=no");
  target.value = myDate;
  if (target.value == "undefined")
  {
    target.value = "";
  }
  return;
}
function clickHandler()
{
  var targetId;
  var srcElement = window.event.srcElement;
  var targetElement;
  if (srcElement.className == "Outline")
  {
    targetId = srcElement.id + "details";
    targetElement = document.all(targetId);

    if (targetElement.style.display == "none")
    {
      targetElement.style.display = "";
    }
    else
    {
      targetElement.style.display = "none";
    }
 }
}
//-->
</script>