<!--#include file="system_manage.asp"-->
  <Script Language=JavaScript>
  function doChange(objText, objDrop){
    if (!objDrop) return;
    var str = objText.value;
    var arr = str.split("|");
    var nIndex = objDrop.selectedIndex;
    objDrop.length=1;
    for (var i=0; i<arr.length; i++){
      objDrop.options[objDrop.length] = new Option(arr[i], arr[i]);
    }
    objDrop.selectedIndex = nIndex;
  }
  function doSubmit(){
    if (document.myform.title.value==""){
      alert("文章标题不能为空！");
      return false;
    }
    // getHTML()为eWebEditor自带的接口函数，功能为取编辑区的内容
    if (eWebEditor1.getHTML()==""){
      alert("文章内容不能为空！");
      return false;
    }
    document.myform.submit();
  }
  </Script>
<%
Dim postid,stitle,stitlecolor,stopicid,d_picture,ssortid,d_originalfilename,d_savefilename,d_savepathfilename,if_tj,if_hot,sgroup,saddtime,contentindex,scontent,wstr,sqls,sif_focus
   Call DBConnBegin()
	  Set rs = server.createobject("adodb.recordset")
Select Case Request("action")
Case "del"
id=tx_common.checkstr(request.querystring("id"),1)
sql="delete from tx_news where id="&id
tx_common.execute sql
 Call tx_common.message("·文章删除成功<br>·如果你的浏览器不支持跳转，<a href='admin_news.asp'>点击这里返回</a><meta http-equiv=refresh content='3;URL=admin_news.asp'>",1)
  Case "addsave"
  postid=request("id")
stitle=request.form("title")
stitlecolor=request.form("titlecolor")
d_picture=request.form("d_picture")
stopicid=request.form("topicid")
ssortid=request.form("sortid")
d_originalfilename=request.form("d_originalfilename")
d_savefilename=request.form("d_savefilename")
d_savepathfilename=request.form("d_savepathfilename")
if_tj=request.form("if_tj")
if_hot=request.form("if_hot")
sgroup=request.form("group")
saddtime=request.form("addtime")
contentindex=request.form("contentindex")
scontent=request.form("content")
sif_focus=request.form("if_focus")
'if ssortid="0" then 
' Call tx_common.message("·请选择您的分类！<br>·如果你的浏览器不支持跳转，<a href='admin_news.asp'>点击这里返回</a><meta http-equiv=refresh content='3;URL=admin_news.asp'>",1)
'end if 
    'Save
	  If postid<>"" Then 
	   rs.open "select title,titlecolor,d_picture,sortid,d_originalfilename,d_savefilename,d_savepathfilename,if_tj,if_hot,group,addtime,contentindex,content,topicid,if_focus from tx_news where id="&postid,conn,1,3
	 else
	 rs.open "select title,titlecolor,d_picture,sortid,d_originalfilename,d_savefilename,d_savepathfilename,if_tj,if_hot,group,addtime,contentindex,content,topicid,if_focus from tx_news",conn,1,3
	  rs.AddNew
	  End If 
   rs(0)=stitle
   rs(1)=stitlecolor
   rs(2)=d_picture
   rs(3)=ssortid
   rs(4)=d_originalfilename
   rs(5)=d_savefilename
   rs(6)=d_savepathfilename
   rs(7)=if_tj
   rs(8)=if_hot
   rs(9)=sgroup
   rs(10)=saddtime
   rs(11)=contentindex
   rs(12)=scontent
   rs(13)=stopicid
   rs(14)=sif_focus
	  rs.update
	  rs.close
	  Call tx_common.message("·文章内容添加/修改成功<br>·如果你的浏览器不支持跳转，<a href='admin_news.asp'>点击这里返回</a><meta http-equiv=refresh content='3;URL=admin_news.asp'>",1)
Case "add"
content=tx_tables.formtop("?action=addsave","添加文章")

  content = content &"<input type=hidden name=d_originalfilename>"
content =content  &"<input type=hidden name=d_savefilename>"
content =content&"  <input type=hidden name=d_savepathfilename onChange=""doChange(this,document.myform.d_picture)"">"
content =content &  tx_tables.inputs("文章标题","title","text","")
'content = content & "<tr class=td2><td nowap>文章标题</td><td><select size=""1"" name=""titlecolor"">"
'content = content &"	<option selected value="""">标题颜色</option>"
'	content = content &"<option value=""#ff0000"">红色</option>"
'	content = content &"<option value=""#0066CC"">蓝色</option>"
'content = content &"	<option value=""#25B825"">绿色</option>"
'content = content &"	</select><input type=""text"" name=""title"" value="""" size=65></td></tr>"
content = content & tx_master.sortselect("所属分类","sortlist=0","sortid",0)
content = content & tx_master.topicselect("所属专题","","topicid",0)
content = content & "<tr class=td2><td nowap>标题图片</td><td><select name=""d_picture"" size=1><option value=''>无</option></select></td></tr> "
content = content & tx_tables.yesno("是否推荐","if_tj",0)
content = content & tx_tables.yesno("是否热门","if_hot",0)
content = content & tx_tables.yesno("是否幻灯推荐","if_focus",0)
content = content & tx_master.userselect("查看权限","","group",0)
content = content & tx_tables.inputs("添加时间","addtime","text",now())
content =content & tx_tables.textarea("内容简介","contentindex","")
content =content & tx_tables.ewebtext("内容","content","","550","350")
content =content & tx_tables.formfoot
Case "edit"
	 rs.open "select * from tx_news where id="&tx_common.checkstr(request.querystring("id"),1),conn,1,3
  Dim aSavePathFileName
  aSavePathFileName = Split(rs("d_SavePathFileName"), "|")
  Dim sOptionSavePath
  sOptionSavePath = tx_tables.InitSelect("标题图片","d_picture", aSavePathFileName, aSavePathFileName, rs("d_picture"), "", "无")
content=tx_tables.formtop("?action=addsave&id="&rs("id"),"添加文章")

  content = content &"<input type=hidden name=d_originalfilename value="&rs("d_originalfilename")&">"
content =content  &"<input type=hidden name=d_savefilename value="&rs("d_savefilename")&">"
content =content&"  <input type=hidden name=d_savepathfilename value="&rs("d_savepathfilename")&" onChange=""doChange(this,document.myform.d_picture)"">"
content =content &  tx_tables.inputs("文章标题","title","text",tx_common.inHTML(rs("title")))
'content = content & "<tr class=td2><td nowap>文章标题</td><td><select size=""1"" name=""titlecolor"">"
'content = content &"	<option selected value="""">标题颜色</option>"
'	content = content &"<option value=""#ff0000"">红色</option>"
'	content = content &"<option value=""#0066CC"">蓝色</option>"
'content = content &"	<option value=""#25B825"">绿色</option>"
'content = content &"	</select><input type=""text"" name=""title"" value="&rs("title")&" size=65></td></tr>"
content = content & tx_master.sortselect("所属分类","sortlist=0","sortid",rs("sortid"))
content = content & tx_master.topicselect("所属专题","","topicid",rs("topicid"))
content = content & soptionsavepath

content = content & tx_tables.yesno("是否推荐","if_tj",rs("if_tj"))
content = content & tx_tables.yesno("是否热门","if_hot",rs("if_hot"))
content = content & tx_tables.yesno("是否幻灯","if_focus",rs("if_focus"))
content = content & tx_master.userselect("查看权限","","group",rs("group"))
content = content & tx_tables.inputs("添加时间","addtime","text",rs("addtime"))
content =content & tx_tables.textarea("内容简介","contentindex",rs("contentindex"))
content =content & tx_tables.ewebtext("内容","content",Server.HtmlEncode(rs("content")),"550","350")
content =content & tx_tables.formfoot
  Case Else
wstr="where title like '%"&request("keyword&")&"%' "
content =  "<table width='100%' cellpadding=3 cellspacing=1 class=td1>"
content = content & "<form action='' method='post'><tr class=td2><td colspan=4>文章标题搜索:<input name='keyword' type=text value=""""><input type=submit value='搜索'></td></tr></form>"
content = content & "<tr class=td4><td colspan=4><strong>文章列表&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HRef='?action=add'>发布文章</a></strong></td></tr>"
content =content & "<tr class=td2><td nowap>ID</td><td width='40%'>标题</td><td width='20%'>分类</td><td width='10%'>操作</td></tr>"
sqls= "select * from tx_news "&wstr&"  order by id desc"
	                 tx_pages.getconn=conn
					 tx_pages.getsql=sqls
                     tx_pages.pagesize=15
	                 set rso=tx_pages.getrs()
                 for i=1 to tx_pages.pagesize
				   if not rso.eof then 
sql="select title from tx_catasort where id="&rso("sortid")
temps=tx_common.query(sql)
If IsArray(temps) Then
sortid=temps(0,0)
else
sortid="暂未分类"
End If 
content =content & "<tr class=td2><td>"&rso("id")&"</td><td>"&rso("title")&"</td><td>"&sortid&"</td><td><a href=?action=edit&id="&rso("id")&">编辑</a> | <a href=?action=del&id="&rso("id")&">删除</a></td></tr>"
rso.movenext
Else 
exit for
content = content & "<tr class=td2><td colspan=4>暂时没有任何信息，请添加！</td></tr>"
End If 
next
content = content & "<tr class=td4><td colspan=4>"&tx_pages.showpage()&"</td></tr>"
content = content & tx_tables.tablesfoot
rso.close 
End Select
Call ClassEnd()
Call DBConnEnd()
response.write content
Call GetBottom()
%>
