<% Option Explicit %>
<!--#include file="../../Inc/Const.asp" -->
<!--#include file="../../Inc/Cls_DB.asp" -->
<!--#include file="../Refresh/Function.asp" -->
<!--#include file="../Refresh/RefreshFunction.asp" -->
<!--#include file="../Refresh/SelectFunction.asp" -->
<%
Dim DBC,Conn
Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
'==============================================================================
'软件名称：风讯网站信息管理系统
'当前版本：Foosun Content Manager System 2.0 
'最新更新：2004.12
'==============================================================================
'商业注册联系：028-85098980-601,602 技术支持：028-85098980-606、607,客户支持：608
'产品咨询QQ：159410,655071,66252421
'技术支持:所有程序使用问题，请提问到bbs.foosun.net我们将及时回答您
'程序开发：风讯开发组 & 风讯插件开发组
'论坛支持：风讯在线论坛(http://bbs.foosun.net)
'官方网站：www.Foosun.net  演示站点：test.cooin.com    
'网站建设专区：www.cooin.com
'==============================================================================
'免费版本请在新闻首页保留版权信息，并做上本站LOGO友情连接
'==============================================================================
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
    Dim TempClassID,OldClassObj,OldClassEName,TTempExtStr,i,RsNewsModObj,TempNewsID,TempSpecialID,SpecialArr,SpecialTextArr,SpecialTextObj
		TempNewsID = Request("NewsID")
		Set RsNewsModObj = Conn.Execute("Select * From News where NewsID='"&TempNewsID&"'")
		if Not JudgePopedomTF(Session("Name"),""&RsNewsModObj("ClassID")&"") then Call ReturnError()
		if Not JudgePopedomTF(Session("Name"),"P0110") then Call ReturnError()
		If RsNewsModObj.eof then
		   Response.Write("<script>alert(""参数传递错误"");dialogArguments.location.reload();window.close();</script>")
		   Response.End
	    End If
	    TempClassID = RsNewsModObj("ClassID")
		TempSpecialID = RsNewsModObj("SpecialID")
		TTempExtStr = RsNewsModObj("FileExtName")
		if TempSpecialID<>"" or isnull(TempSpecialID)=false then
			SpecialArr = array("")
			SpecialArr = split(TempSpecialID,",")
			SpecialTextArr = ""
			For i=0 to Ubound(SpecialArr)
				Set SpecialTextObj = Conn.Execute("Select CName From Special where SpecialID='"&SpecialArr(i)&"'")
				if Not SpecialTextObj.Eof then
					If SpecialTextArr <> "" then
						SpecialTextArr = SpecialTextArr &","& SpecialTextObj("CName")
					Else
						SpecialTextArr = SpecialTextArr & SpecialTextObj("CName")
					End if
				end if
				SpecialTextObj.Close
			Next
		else
			SpecialTextArr = ""
		end if
	
    Set OldClassObj = Conn.Execute("select ClassID,ClassEName from NewsClass where ClassID='"&TempClassID&"'")
	if Not OldClassObj.Eof then
		OldClassEName = OldClassObj("ClassEName")
	end if
	OldClassObj.Close
	Set OldClassObj = Nothing
	
dim TempClassListStr
TempClassListStr = ClassList
Function ClassList()
	Dim ClassListObj,SelectStr
	Set ClassListObj = Conn.Execute("select * from newsclass where ParentID = '0'")
	do while Not ClassListObj.Eof
		if OldClassEName = ClassListObj("ClassEName") then
			SelectStr = "selected"
		else
			SelectStr = ""
		end if
		ClassList = ClassList & "<option " & SelectStr & " value="&ClassListObj("ClassID")&"" & ">" & ClassListObj("ClassCName") & "</option><br>"
		ClassList = ClassList & ChildClassList(ClassListObj("ClassID"),"")
		ClassListObj.MoveNext	
	loop
	ClassListObj.Close
	Set ClassListObj = Nothing
End Function

Function ChildClassList(ClassID,Temp)
	Dim TempRs,TempStr,SelectStr
	Set TempRs = Conn.Execute("Select * from NewsClass where ParentID = '" & ClassID & "'")
	TempStr = Temp & " - "
	do while Not TempRs.Eof
		if OldClassEName = TempRs("ClassEName") then
			SelectStr = "selected"
		else
			SelectStr = ""
		end if
		if TempRs("ChildNum") = 0 then
			ChildClassList = ChildClassList & "<option " & SelectStr & " value="&TempRs("ClassID")&"" & ">" & TempStr & TempRs("ClassCName") & "</option><br>"
		else
			ChildClassList = ChildClassList & "<option " & SelectStr & " value="&TempRs("ClassID")&"" & ">" & TempStr & TempRs("ClassCName") & "</option><br>"
		end if
		ChildClassList = ChildClassList & ChildClassList(TempRs("ClassID"),TempStr)
		TempRs.MoveNext
	loop
	TempRs.Close
	Set TempRs = Nothing
End Function
	
%>
<html>
<head>
<link href="../Inc/ModeWindow.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新闻修改</title>
</head>
<script language="JavaScript" src="../JS/PublicJS.js"></script>
<body>
<form action="" name="NewsForm" method="post">
  <table width="98%" border="0" align="center" cellpadding="0" cellspacing="5">
    <tr>
      <td height="5" colspan="2"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="4">
          <tr>
            <td><div align="center">图片新闻
                <input name="PicNewsTF" type="checkbox" id="PicNewsTF2" value="1" onClick="ChoosePic();" <%If RsNewsModObj("PicNewsTF")=1 then Response.Write("checked")%>>
            </div></td>
            <td><div align="center">滚动新闻
                <input name="MarqueeNews" type="checkbox" id="MarqueeNews" value="1" <%if RsNewsModObj("MarqueeNews")=1 then Response.Write("checked")%>>
            </div></td>
            <td><div align="center">允许评论
                <input name="ReviewTF" type="checkbox" id="ReviewTF" value="1" onClick="ChooseRiview();" <%if RsNewsModObj("ReviewTF")=1 then Response.Write("checked")%>>
            </div></td>
            <td><div align="center">显示评论
                <input name="ShowReviewTF" type="checkbox" id="ShowReviewTF" value="1" disabled <%if RsNewsModObj("ShowReviewTF")="1" then Response.Write("checked") end if%>>
            </div></td>
            <td><div align="center">公告新闻
                <input name="ProclaimNews" type="checkbox" id="ProclaimNews" value="1" <%if RsNewsModObj("ProclaimNews")="1" then Response.Write("checked") end if%>>
            </div></td>
          </tr>
          <tr>
            <td width="10%"><div align="center">推荐新闻
                <input name="RecTF" type="checkbox" id="RecTF" value="1" <%if RsNewsModObj("RecTF")="1" then Response.Write("checked") end if%>>
            </div></td>
            <td width="10%"><div align="center">需要审核
                <input name="AuditTF" type="checkbox" id="AuditTF2" value="1" <%if RsNewsModObj("AuditTF")="1" then Response.Write("checked") end if%>>
            </div></td>
            <td width="14%"><div align="center">并排新闻
                <input name="SBSNews" type="checkbox" id="SBSNews2" value="1" <%if RsNewsModObj("SBSNews")="1" then Response.Write("checked") end if%>>
            </div></td>
            <td width="11%"><div align="center">今日头条
                <input name="TodayNewsTF" type="checkbox" id="TodayNewsTF2" value="1" <%if RsNewsModObj("TodayNewsTF")="1" then Response.Write("checked") end if%>>
            </div></td>
            <td width="9%"><div align="center">幻灯新闻
                <input name="FilterNews" type="checkbox" disabled id="FilterNews" value="1" <%if RsNewsModObj("FilterNews")="1" then Response.Write("checked") end if%>>
            </div></td>
          </tr>
      </table></td>
    </tr>
    <tr>
      <td width="14%"><div align="right">新闻标题</div></td>
      <td width="86%"><input name="Title" type="text" id="Title" style="width:50%" value="<%=RsNewsModObj("Title")%>">
        标题颜色 <select name="TitleColor" id="select"">
          <option value="#UUUUUU" <%if InStr(1, RsNewsModObj("TitleStyle"),"#UUUUUU" ,1)<>0 then response.Write("selected") %>>字体颜色</option>
          <option value="#ff0000" style="background-color:#ff0000;color: #ffffff" <%if InStr(1, RsNewsModObj("TitleStyle"),"#ff0000" ,1)<>0 then response.Write("selected") %>>#ff0000</option>
          <option value="#000000" style="background-color:#000000;color: #ffffff" <%if InStr(1, RsNewsModObj("TitleStyle"),"#000000" ,1)<>0 then response.Write("selected") %>>#000000</option>
          <option value="#FFFFFF" style="background-color:#ffffff;color: #000000" <%if InStr(1, RsNewsModObj("TitleStyle"),"#FFFFFF" ,1)<>0 then response.Write("selected") %>>#FFFFFF</option>
          <option value="#000099" style="background-color:#000099;color: #ffffff" <%if InStr(1, RsNewsModObj("TitleStyle"),"#000099" ,1)<>0 then response.Write("selected") %>>#000099</option>
          <option value="#660066" style="background-color:#660066;color: #ffffff" <%if InStr(1, RsNewsModObj("TitleStyle"),"#660066" ,1)<>0 then response.Write("selected") %>>#660066</option>
          <option value="#FF6600" style="background-color:#FF6600;color: #ffffff" <%if InStr(1, RsNewsModObj("TitleStyle"),"#FF6600" ,1)<>0 then response.Write("selected") %>>#FF6600</option>
          <option value="#666666" style="background-color:#666666;color: #ffffff" <%if InStr(1, RsNewsModObj("TitleStyle"),"#666666" ,1)<>0 then response.Write("selected") %>>#666666</option>
          <option value="#009900" style="background-color:#009900;color: #ffffff" <%if InStr(1, RsNewsModObj("TitleStyle"),"#009900" ,1)<>0 then response.Write("selected") %>>#009900</option>
          <option value="#0066CC" style="background-color:#0066CC;color: #ffffff" <%if InStr(1, RsNewsModObj("TitleStyle"),"#0066CC" ,1)<>0 then response.Write("selected") %>>#0066CC</option>
          <option value="#990000" style="background-color:#990000;color: #ffffff" <%if InStr(1, RsNewsModObj("TitleStyle"),"#990000" ,1)<>0 then response.Write("selected") %>>#990000</option>
          <option value="#CC9900" style="background-color:#CC9900;color: #ffffff" <%if InStr(1, RsNewsModObj("TitleStyle"),"#CC9900" ,1)<>0 then response.Write("selected") %>>#CC9900</option>
          <option value="#CCCCCC" style="background-color:#CCCCCC;color: #000000" <%if InStr(1, RsNewsModObj("TitleStyle"),"#CCCCCC" ,1)<>0 then response.Write("selected") %>>#CCCCCC</option>
          <option value="#99FF00" style="background-color:#99FF00;color: #000000" <%if InStr(1, RsNewsModObj("TitleStyle"),"#99FF00" ,1)<>0 then response.Write("selected") %>>#99FF00</option>
          <option value="#0000FF" style="background-color:#0000FF;color: #FFFFFF" <%if InStr(1, RsNewsModObj("TitleStyle"),"#0000FF" ,1)<>0 then response.Write("selected") %>>#0000FF</option>
          <option value="#9966CC" style="background-color:#9966CC;color: #FFFFFF" <%if InStr(1, RsNewsModObj("TitleStyle"),"#9966CC" ,1)<>0 then response.Write("selected") %>>#9966CC</option>
        </select>
        　 加粗 
        <input name="TitleBold" type="checkbox" id="TitleBold" value="1" <%if Mid(RsNewsModObj("TitleStyle"),8,1)="1" then response.Write("checked")%>>
        斜体 
        <input name="Titles" type="checkbox" id="Titles" value="1" <%if Right(trim(RsNewsModObj("TitleStyle")),1)="1" then response.Write("checked")%>></td>
    </tr>
    <tr>
      <td><div align="right">所属栏目</div></td>
      <td><select name="ClassID" id="select2" style="width:95%">
        <% =TempClassListStr %>
      </select></td>
    </tr>
    <tr>
      <td><div align="right">所属专题</div></td>
      <td><input name="SpecialIDText" type="text" style="width:74% " readonly value="<%=SpecialTextArr%>">
        <input type="hidden" name="SpecialID" value="<%=TempSpecialID%>">
        <select name="SelSpecialID" style="width:18%" onChange=ChooseSpecial(this.options[this.selectedIndex].value)>
          <option value="" selected> </option>
          <option value="<%=""&"***"&"Clean"%>" style="color:red">清空</option>
          <%
		Dim SpecialIDObj
		set SpecialIDObj = Conn.Execute("Select CName,SpecialID from Special order by ID desc")
		while not SpecialIDObj.eof
		%>
          <option value="<%=SpecialIDObj("CName")&"***"&SpecialIDObj("SpecialID")%>"><%=SpecialIDObj("CName")%></option>
          <%
		SpecialIDObj.Movenext
		Wend
		SpecialIDObj.Close
		Set SpecialIDObj = Nothing
		%>
        </select></td>
    </tr>
    <tr>
      <td><div align="right">图片地址</div></td>
      <td><input name="PicPath" type="text" disabled id="PicPath" style="width:74% " value="<%=RsNewsModObj("PicPath")%>">&nbsp;
        <input type="button" name="PicChooseButton" value="选择图片" disabled onClick="OpenWindowAndSetValue('../inc/SelectPic.asp',550,290,window,document.NewsForm.PicPath);"></td>
    </tr>
    <tr>
      <td><div align="right"><font color="#FF0000">链接地址</font></div></td>
      <td><input name="HeadNewsPath" type="text" id="HeadNewsPath2" style="width:95%" value="<%=RsNewsModObj("HeadNewsPath")%>"></td>
    </tr>
    <tr>
      <td><div align="right">添加日期</div></td>
      <td><input name="AddDate" readonly type="text" id="AddDate2" style="width:74% " value="<% if RsNewsModObj("AddDate")="" then Response.Write(now()) else Response.Write(RsNewsModObj("AddDate")) end if%>">&nbsp;
        <input type="button" name="Submit42" value="选择日期" onClick="OpenWindowAndSetValue('../Inc/SelectDate.asp',280,110,window,document.NewsForm.AddDate);document.NewsForm.AddDate.focus();"></td>
    </tr>
    <tr>
      <td><div align="right">导航文字</div></td>
      <td><input name="NaviWords" type="text" disabled id="NaviWords2" style="width:95%" value="<%=RsNewsModObj("NaviWords")%>"></td>
    </tr>
    <tr>
      <td colspan="2"></td>
    </tr>
    <tr>
      <td height="21" colspan="2"><div align="center">
          <input type="submit" name="Submit2" value=" 修 改 ">
          <input name="action" type="hidden" id="action" value="add">
&nbsp;
<input type="reset" name="Submit" value=" 还 原 ">
&nbsp;&nbsp;&nbsp;
        <input type="button" name="Submit3" value=" 取 消 " onClick="window.close();">
      </div></td>
    </tr>
  </table>
</form></body>
</html>
<script language="javascript">
 function ChooseRiview()
   {
      if (document.NewsForm.ReviewTF.checked==true)
	      {
		    document.NewsForm.ShowReviewTF.disabled=false;
		   }
      else
	      {
	        document.NewsForm.ShowReviewTF.disabled=true;
		   }
	}
 function ChoosePic()
   {
      if (document.NewsForm.PicNewsTF.checked==true)
	      {
		    document.NewsForm.PicPath.disabled=false;
		    document.NewsForm.PicChooseButton.disabled=false;
		    document.NewsForm.NaviWords.disabled=false;
		    document.NewsForm.FilterNews.disabled=false;
		   }
	   else
	      {
		    document.NewsForm.PicPath.disabled=true;
		    document.NewsForm.PicChooseButton.disabled=true;
		    document.NewsForm.NaviWords.disabled=true;
		    document.NewsForm.FilterNews.disabled=true;
		   }
    }
	
function SubmitFun()
{
	document.NewsForm.submit();
}
ChooseRiview();
ChoosePic();
</script>
<%
  if Request.Form("action")="add" then
     Dim ITitle,IClassID,INewsTemplet,IClickNum,IAddDate,INewsAddObj,INewsAddSql,TitleBoldstr,TitleUstr
     if Request.Form("Title")<>"" then
		ITitle = Replace(Replace(Request.Form("Title"),"""",""),"'","")
	 else
	    Response.Write("<script>alert('请输入新闻标题');</script>")
		Response.End
	 end if
     if Request.Form("ClassID")<>"" then
		IClassID = Replace(Replace(Request.Form("ClassID"),"""",""),"'","")
	 else
	    Response.Write("<script>alert('栏目参数传递错误');</script>")
		Response.End
	 end if
	 if IsDate(Request.Form("AddDate")) then
	 	IAddDate = Formatdatetime(Request.Form("AddDate"))
	 else
	    Response.Write("<script>alert('新闻添加时间类型错误,请重新输入');</script>")
		Response.End
	 end if
	 if Request.Form("HeadNewsPath") = "" or Request.Form("HeadNewsPath")="http://" then
	    Response.Write("<script>alert('新闻链接地址不能为空');</script>")
		Response.End
	 end if
	  set INewsAddObj=server.createobject("adodb.recordset")
	  INewsAddSql="select * from News where NewsID='"&TempNewsID&"'"
	  INewsAddObj.open INewsAddSql,Conn,1,3
	  INewsAddObj("Title") =  ITitle
	  INewsAddObj("SubTitle") = Replace(Replace(Request.Form("SubTitle"),"""",""),"'","")
	  If request.form("TitleBold")<>"" then
	   		TitleBoldstr="1"		
	   else
	   		TitleBoldstr="0"		
	  end if
	  If request.form("Titles")<>"" then
	   		TitleUstr="1"		
	  else
	   		TitleUstr="0"		
	  end if
	  INewsAddObj("Titlestyle") =  Request.Form("TitleColor")&TitleBoldstr&TitleUstr
	  INewsAddObj("ClassID") =  IClassID
	  if Request.Form("TodayNewsTF")<>"" then
		  INewsAddObj("TodayNewsTF") = 1
	  else
		  INewsAddObj("TodayNewsTF") = 0
	  end if
	  INewsAddObj("AddDate") =  IAddDate
	  if Request.Form("RecTF") = "1" then
		  INewsAddObj("RecTF") =  "1"
	  else
		  INewsAddObj("RecTF") =  "0"
	  end if
	  INewsAddObj("SpecialID") = Replace(Replace(Request.Form("SpecialID"),"""",""),"'","")
	  if Request.Form("PicNewsTF")="1" then
		  INewsAddObj("PicNewsTF") =  "1"
	  else
		  INewsAddObj("PicNewsTF") =  "0"
	  end if
	  if Request.Form("AuditTF") = "1" then
		  INewsAddObj("AuditTF") =  "0"
	  else
		  INewsAddObj("AuditTF") =  "1"
	  end if
	  if Request.Form("ShowReviewTF") = "1" then
		  INewsAddObj("ShowReviewTF") =  "1"
	  else
		  INewsAddObj("ShowReviewTF") =  "0"
	  end if
	  if Request.Form("ReviewTF") = "1" then
		  INewsAddObj("ReviewTF") =  "1"
	  else
		  INewsAddObj("ReviewTF") =  "0"
	  end if
	  if Request.Form("SBSNews") = "1" then
		  INewsAddObj("SBSNews") =  "1"
	  else
		  INewsAddObj("SBSNews") =  "0"
	  end if
	  if Request.Form("MarqueeNews") = "1" then
		  INewsAddObj("MarqueeNews") =  "1"
	  else
		  INewsAddObj("MarqueeNews") =  "0"
	  end if
	  if Request.Form("ProclaimNews") = "1" then
		  INewsAddObj("ProclaimNews") =  "1"
	  else
		  INewsAddObj("ProclaimNews") =  "0"
	  end if
	  if Request.Form("LinkTF") = "1" then
		  INewsAddObj("LinkTF") =  "1"
	  else
		  INewsAddObj("LinkTF") =  "0"
	  end if
	  if Request.Form("FilterNews") = "1" then
		  INewsAddObj("FilterNews") =  "1"
	  else
		  INewsAddObj("FilterNews") =  "0"
	  end if
	  INewsAddObj("HeadNewsPath") =  Request.Form("HeadNewsPath")
	  INewsAddObj("NaviWords") =  Request.Form("NaviWords")
	  INewsAddObj("PicPath") =  Request.Form("PicPath")
	  INewsAddObj.Update
	  INewsAddObj.Close
	  Set INewsAddObj = Nothing
	  Response.Write("<script>alert(""标题新闻修改成功"");dialogArguments.location.reload();window.close();</script>")
	  Response.End
  end if
%>