<link rel="stylesheet" type="text/css" href="adminCommon.css" />
<!--#include file="adminCommon.asp"-->
<!--#include file="../inc/clsPageRs2.asp"-->
<%
'=============================================
' 新闻资讯管理
'memo :
'2009 /12 /22 00:51
'=============================================

'-------Get Value-----
Dim action   : action   = Lcase(rq("action"))
Dim newsID   : newsID   = GetInt(rq("id"))
'//-------Get Value-----

htmlHead
connOpen
topNav "<a href="""& gCurUrl_noQueryString &""">新闻资讯管理</a>"
Select Case action
  Case "add","edit" AddForm
  Case "save" Save
  Case "del","delbatch" Del
  Case "recommend" Recommend
  Case Else Default
End Select
connClose
htmlFoot

Sub AddForm
  Dim title,content,addTime,titleColor
  Dim keyword,label,seoDescription
  Dim sql,rs
  If newsID>0 Then
    sql = "SELECT newsID,title,[content],titleColor,keyword,label,seoDescription FROM [tblNews] WHERE newsID="& newsID
    Set rs = conn.Execute(sql)
    If Not rs.EOF Then
      title      = rs("title")
      content    = rs("content")
      titleColor = rs("titleColor")
      keyword    = rs("keyword")
      label      = rs("label")
	  seoDescription= rs("seoDescription")
    End If
  End If
%>
<script language="JavaScript" src="/js/datePicker/WdatePicker.js"></script>
<form method="post" action="?action=save&id=<%=newsID%>">
 <input type="hidden" name="refer" value="<%=gReferUrl%>">
 <table width="100%" align="center" border="1" cellpadding="2" cellspacing="0" style="border-collapse:collapse;" class="frmTable">
  <tr>
   <td class="tdTitle" width="100">标题：</td>
   <td><input type="text" name="title" value="<%=title%>" class="sInput" style="width:550px;"></td>
  </tr>
  <tr>
   <td class="tdTitle" width="100">标题样式：</td>
   <td>
    颜色：<select name="titleColor"><% sltColor titleColor%></select>
   </td>
  </tr>
  <tr>
   <td class="tdTitle" width="100">标签:</td>
   <td>
    <input type="text" name="label" id="label" class="sInput" maxlength="100" value="<%=label%>">
    <span class="red">与新闻、图片、产品等根据标签进行关联,可以空格" "、半角逗号","、全角逗号"，"或 "|" 进行 </span>
   </td>
  </tr>
  <tr style="background:#D5E6EE;" title="在具体页META区域中显示，利于搜索引擎收录">
   <td class="tdTitle speTd" width="100">关键词:</td>
   <td>
    <input name="keyword" id="keyword" type="text" class="sInput ll" maxlength="200" value="<%=keyword%>">
   </td>
  </tr>
  <tr style="background:#D5E6EE;" title="在具体页META区域中显示，利于搜索引擎收录">
   <td class="tdTitle speTd" width="100">页面内容描述:</td>
   <td>
    <input name="seoDescription" type="text" class="sInput ll" maxlength="200" value="<%=seoDescription%>">
   </td>
  </tr>
  <tr>
   <td class="tdTitle" width="100">内容：</td>
   <td>
    <textarea name="content" id="content" style="display:none;"><%=content%></textarea>
    <script type="text/javascript" src="/fckeditor/fckeditor.js"></script>
    <script language="javascript" type="text/javascript">
    <!--
    var oFCKeditor = new FCKeditor('content','100%','350px','Basic' );
    oFCKeditor.BasePath	= "/fckeditor/";
    oFCKeditor.ReplaceTextarea();
    -->
    </script>
   </td>
  </tr>
 </table>
 <div class="btmBtnWrap">
  <input type="submit" value="提  交(S)" accesskey="s" class="btn">
  <input type="button" value="返  回(B)" accesskey="b" onClick="history.go(-1)" class="btn">
 </div>
</form>
<%
End Sub

Sub Save
  Dim sql,rs
  Dim title,content,addTime
  Dim titleColor
  Dim keyword,label,seoDescription

  title      = Server.HTMLEncode(rf("title"))
  content    = rf("content")
  addTime    = Now
  titleColor = rf("titleColor")
  keyword    = Replace(Replace(Replace(rf("keyword"),"，",",")," ",","),"　",",")
  label      = Replace(rf("label"),"，",",")
  seoDescription= Replace(rf("seoDescription"),"，",",")

  sql = "SELECT * FROM [tblNews] WHERE newsID="& newsID
  Set rs = Server.CreateObject("ADODB.RecordSet")
  rs.Open sql,conn,1,3
  If rs.EOF Then rs.AddNew
  rs("title")      = title
  rs("titleColor") = titleColor
  rs("content")    = content
  rs("addTime")    = addTime
  rs("keyword")    = keyword
  rs("label")      = label
  rs("seoDescription")= seoDescription
  rs.Update
  rs.Close
  Set rs = Nothing

  BuildCache_IndexNews
  refer = rf("refer")
  If Instr(LCase(refer), "index.asp")>0 Then refer = "news.asp"
  SuccessTip "保存成功！", "news.asp"
End Sub

Sub Del
  If newsID<1 Then newsID = rf("cbxID")
  If Len(newsID)>0 Then conn.Execute("DELETE FROM [tblNews] WHERE newsID IN ("& newsID&")")
  BuildCAche_IndexNews
  successTip "删除成功！", gReferUrl
End Sub

Sub Default
  Dim sqlWhere
  Dim notActiveStyle    : notActiveStyle   ="down"
  Dim AllInofsStyle     : AllInofsStyle    ="down"
  Dim overTimeStyle     : overTimeStyle    ="down"
  '---------------------get value
  Dim viewOption : viewOption = LCase(rq("v"))
  'END---------------------get value

  Select Case viewOption
    Case "notactive"    '未启用新闻资讯
      notActiveStyle  ="up"
      sqlWhere = sqlWhere&" AND isActive=0"
    Case "all"
      AllInofsStyle   = "up"
    Case "overtime"
      overTimeStyle   = "up"
      sqlWhere = sqlWhere&" AND endDate<=getDate()"
  End Select
%>
<div class="headZone">
 <div>
  <table width="100%" cellpadding="2" cellspacing="0" border="1" bordercolor="white" class="navTable">
   <tr>
    <td width="70" class="title">快捷操作：</td>
    <td>
     <a href="?action=add">添加新闻资讯</a>&nbsp;|&nbsp;
     <a href="?action=delOvertimenewss">删除过期新闻资讯</a>&nbsp;|&nbsp;
    </td>
   </tr>
  </table>
 </div>
</div>
<!-- news list table -->
<%
 Set oPage = New clsPageRs2
 With oPage
   .sltFld  = "newsID,title,addTime,clickCount"
   .fromTbl = "[tblNews]"
   .sqlOrder= "ORDER BY newsID DESC"
   .sqlWhere= "WHERE 1=1 "& sqlWhere
   .keyFld  = "newsID"
   .pageSize= 20
   .frmJumpStyle ="select"
   .showMultiPageNum = 5
   .toPageLinkStyle = ""
   .getConn = conn
   Set rs  = .pageRs
 End With

 If rs.EOF Then
   w "<div class=""noRecordTip"">暂无相关记录</div>"
   Set rs = Nothing
   Set oPage = Nothing
   Exit Sub
 End If
%>
<form method="post" name="frmMain">
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" class="listTable">
 <thead>
  <th width="35">选择</th>
  <th>标&nbsp;题</th>
  <th>点击数</th>
  <th>添加日期</th>
  <th>管理操作</th>
 </thead>
 <%
 Dim title,addTime,clickCount
 Set addTime = rs("addTime")
 Do While Not rs.EOF
   newsID    = rs("newsID")
   title     = rs("title")
   clickCount= GetInt(rs("clickCount"))
 %>
 <tr onMouseOver="chgBgColor(this,1)" onMouseOut="chgBgColor(this,0)">
  <td><input type="checkbox" name="cbxID" value="<%=newsID%>"/></td>
  <td align="left"><a href="?action=edit&id=<%=newsID%>"><%=title%></a></td>
  <td><%=clickCount%></td>
  <td><%=addTime%></td>
  <td>
   <a href="?action=edit&id=<%=newsID%>">修改</a>
   <a onClick="javascript:return confirm('是否确认删除该新闻资讯？删除后不可恢复')" href="?action=del&id=<%=newsID%>">删除</a>
  </td>
 </tr>
 <%
 rs.MoveNext
 Loop
 Set addTime = Nothing
 rs.Close
 Set rs = Nothing
 %>
</table>
</form>
<!-- end of list form -->
<script type="text/javascript">
<!--
function sltAll() {
 var e = $c('cbxAll')||event.srcElement;
 var es = document.getElementsByName('cbxID');
 for(var i=0;i<es.length;i++){es[i].checked=e.checked;}
}

function delSlted() {if(!chkSlted('cbxID')) return;$c('frmMain').action='?action=delbatch';$c('frmMain').submit();}
//-->
</script>
<div id="btmOpZone" class="item">
 <span class="l" style="width:120px;"><input type="checkbox" id="cbxAll" onClick="sltAll()" /><label for="cbxAll">全选</label></span>
 <span style="text-align:center;" class="r">
  <input type="button" value="删除" onClick="delSlted()" />
 </span>
</div>
<div class="pager"><%oPage.pageNav%></div>
<!--// newss list table -->
<%
  Set oPage = Nothing
End Sub
%>