<!--#include file="error.asp"-->
<!--#include file="conn.asp"-->
<%
set rs=server.CreateObject("adodb.recordset")
sql="select * from news where id="&request("id")
rs.open sql,conn,1,3
if rs.EOF and rs.BOF then
  response.write "<script language=javascript>"	
		response.write "alert('文章不存在！');"	
		response.write "</script>"
		response.write "<script language=javascript>location='newslist.asp'</script>"
   Response.End
else
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>编辑文章</title>
<link rel="stylesheet" type="text/css" href="css/main.css"/>
<script type="text/javascript" src="js/admin.js"></script>
<script LANGUAGE="javascript">
  subcity = new Array();
<%Dim counti
  set rs4=server.createobject("adodb.recordset")
  sql="Select * From bigclass"
  rs4.open sql,conn,3,3
  counti=0
  Do While Not rs4.Eof
  Response.Write "subcity[" & counti & "] = new Array(""" &rs4("typeid") & """,""" &rs4("classname") & """,""" &rs4("id") & """);" & Chr(10)
  counti=counti+1
rs4.MoveNext
  Loop
%>
 function mychange(provalue) {					
 document.form1.bigclassid.length = 0;				
 document.form1.bigclassid.options[0] = new Option('选择分类','0');
 var i; 
 for (i=0;i < subcity.length; i++)				
 { 
 if (subcity[i][0] == provalue)			
 {  
 document.form1.bigclassid.options[document.form1.bigclassid.length] = new Option(subcity[i][1],subcity[i][2]); 
 }         
 } 
}    
</script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr  bgcolor="#353c44">
        <td height="24" width="18" valign="middle" align="center"><img src="images/tb.gif" width="14" height="14" /></td>
        <td><span class="STYLE1">编辑文章</span></td>
      </tr>
    </table></td>
  </tr>
  <tr bgcolor="#FFFFFF" align="center">
    <td>
          <table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#a8c7ce">
              <form id="form1" name="form1" method="post" onsubmit="return test()" action="news_set.asp?action=edit&id=<%=request("id")%>">
              <tr bgcolor="#ffffff" height="30" onMouseOver="this.bgColor='#CDE6FF'" onMouseOut="this.bgColor='#FFFFFF'">
                  <td width="10%">所属专题：</td>
                  <td width="90%"  align="left" colspan="3">
                     <select name="SpecialID" size="1" class="INPUT">
                            <%			
                            set rss=server.CreateObject ("ADODB.RecordSet")
                            rss.Source="select * from Special"
                            rss.Open rss.source,conn,1,1			
                            %>
                        <option value=0 <%if rs("SpecialID")=0 then Response.Write "selected"%>>不属于任何专题</option>
                            <%if rss.EOF then %>
                        <option value=0>暂无任何专题</option>
                            <%else
                              while not rss.EOF
                            %>
                        <option value="<%=rss("ID")%>" <%if rs("SpecialID")=rss("ID") then Response.Write " selected"%>><%=trim(rss("title"))%></option>
                            <%
                            rss.MoveNext
                            wend
                            end if
                            rss.close	
							set rss=nothing
                            %>
                     </select>                  
                  </td>
              </tr>
              <tr bgcolor="#ffffff" height="30" onMouseOver="this.bgColor='#CDE6FF'" onMouseOut="this.bgColor='#FFFFFF'">  
                  <td width="10%">新闻标题：</td>
                  <td width="20%" align="left"><input type="text" name="title" size="50" value="<%=rs("title")%>" /></td>
                  <td width="10%">所属栏目：</td>
                  <td width="60%" align="left">
                     <select name="typeid" onChange="mychange(this.options[this.selectedIndex].value);">
                        <option value="">请选择大类</option>
                            <%
                            set rss=server.createobject("adodb.recordset")
                            sql="select * from type order by morder"
                            rss.open sql,conn,1,1
                            do until rss.eof
                            %>
                        <option value="<%=rss("id")%>" <%if rss("id")=rs("typeid") then response.Write "selected" end if%>><%=rss("typetitle")%></option>
                            <%
                            rss.movenext
                            loop
							rss.close
							set rss=nothing
                            %>
                    </select>     &nbsp; 
                    <select name="bigclassid">
                        <option value='0'  <%if trim(rs("bigclassid"))=0 then response.Write "selected" end if%>>未设置小类</option>
                          <%
                            set rss=server.createobject("adodb.recordset")
                            sql="select * from bigclass where show<>3 and typeid="&rs("typeid")
                            rss.open sql,conn,3,3
                            do while not rss.eof
                          %>
                        <option value="<%=rss("id")%>" <%if rss("id")=cint(rs("bigclassid")) then response.Write "selected" end if%>><%=rss("classname")%></option>
                          <%rss.movenext
                            loop
                            rss.close
                            set rss=nothing%>
                    </select>
                  </td>  
              </tr>  
              <tr bgcolor="#ffffff" height="30" onMouseOver="this.bgColor='#CDE6FF'" onMouseOut="this.bgColor='#FFFFFF'">
                  <td width="10%">外链地址：</td>
                  <td width="20%" align="left"><input type="text" name="links" size="50" value="<%=rs("links")%>" /></td>
                  <td align="left" colspan="2">&nbsp; &nbsp; <span class="red">提示：</span>即点击新闻标题后转向的地址，此处填写则正文不需要填写</td>
              </tr>  
              <tr bgcolor="#ffffff" height="30" onMouseOver="this.bgColor='#CDE6FF'" onMouseOut="this.bgColor='#FFFFFF'">
                  <td width="10%">其他信息：</td>
                  <td colspan="3" align="left">
                  作者：<input name="author" type="text" id="author"  value="<%=rs("author")%>" />&nbsp;&nbsp;
                  来源：<input name="comefrom" type="text" value="<%=rs("comefrom")%>" />&nbsp;&nbsp;
                  时间：<input name="addtime" type="text" value="<%=rs("addtime")%>" />&nbsp;&nbsp;
                  点击：<input name="hits" type="text" value="<%=rs("hits")%>" />&nbsp;&nbsp;
                  </td>
              </tr>  
              <tr bgcolor="#ffffff">
                  <td colspan="4" align="left">
					  <script charset="utf-8" src="../kindeditor/kindeditor.js"></script>
                      <script>
                              KE.show({
                                      id : 'content',
                                      shadowMode : false,
                                      allowPreviewEmoticons : false,
                                      resizeMode: 0,
                                      urlType : 'relative',
                                      cssPath : '../../skins/editor.css',
                                      allowUpload: false,
                                      filterMode : false,
                                      allowFileManager : true,
                                      fileManagerJson : '../../asp/file_manager_json.asp'
                              });
                      </script>
                      <textarea id="content" name="content" cols="100" rows="8" style="width:700px;height:300px;"><%=rs("content")%></textarea>
                  </td>
              </tr>  
              <tr bgcolor="#ffffff" height="30">   
                  <td width="10%">文件上传：</td>
                  <td colspan="3" align="left">
                  <iframe src="kupload.asp" width="100%" height="24"  scrolling="no" border="0" frameborder="0" marginwidth="0" marginheight="0"></iframe></td>                                         
              </tr>  
              <tr bgcolor="#ffffff" height="30">  
                  <td width="10%">图片新闻：</td>
                  <td  align="left" colspan="3"><input name="IsPic" type="checkbox" id="IsPic" onClick="javascript:ChkIsPic();" value="1" <%if rs("ispic")=1 then%>checked="checked"<%End If%>/>
                  &nbsp; &nbsp;<span id="DisIsPic" style="display:none;"><input name="PicFile" type="text" id="PicFile" size="50" value="<%=rs("picfile")%>" /><a href="#" onClick="Get_Img();">设置当前选中图片</a></span>
                  </td>
              </tr>  
              <tr>
                  <td align="center" bgcolor="#ffffff" colspan="4"><input type="submit" name="Submit"  value="提&nbsp;交" /> &nbsp; &nbsp;
                  <input type="reset" name="Submit2" value="重&nbsp;置" />
                  </td>
              </tr> 
              </form>           
          </table>
    </td>
  </tr>
</table>
<script language="JavaScript" type="text/javascript">
	function test() 
{   
if  (document.form1.title.value.length  ==  0)  {   
alert("请输入标题!"); 
document.form1.title.focus(); 
return  false; 
} 
if  (document.form1.lanmu.value.length  ==  0)  {   
alert("请选择栏目!"); 
document.form1.lanmu.focus(); 
return  false; 
} 

	if(form1.IsPic.checked && document.form1.PicFile.value.length  ==  0)
	{
		alert("文章属性选择了图片，但还没有选择图片,请选择");
		document.form1.PicFile.focus();
		return false;
	}

}

function ChkIsPic()
{
	obj = document.getElementById("DisIsPic");
	var _IsPic = document.getElementById("IsPic").checked;
	if(_IsPic)

	{
		obj.style.display = "";
	}
	else
	{
		obj.style.display = "none";
	}
}

function Get_Img()
{	
	  function  getimgsrc(htmlstrimg){
		  var reg=/<img.+?src=('|")?([^'"]+)('|")?(?:\s+|>)/gim;
		  var arr = [];
		  while(tem=reg.exec(htmlstrimg)){
			  arr.push(tem[2]);
		  }
		  return arr;
	  }
	var htmlStrimg=KE.selectedHtml('content'); 
    var imgs=getimgsrc(htmlStrimg); 
    	if(imgs!="")
	{
	  form1.PicFile.value = imgs;
	}
	else
	{
		alert('没有选择任何图片');
	}
}

ChkIsPic();
</script>
</body>
</html>
<%end if%>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
             