<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312" />
<TITLE>编辑新闻</TITLE>
<link rel="stylesheet" href="../Images/CssAdmin.css">
<script language="javascript" src="../inc/Admin.js"></script>
<script type="text/javascript" src="../../js/jquery-1.4.4.min.js"></script>
<link rel="stylesheet" href="../../kindeditor4110/themes/default/default.css" />
<link rel="stylesheet" href="../../kindeditor4110/plugins/code/prettify.css" />
<script charset="utf-8" src="../../kindeditor4110/kindeditor.js"></script>
<script charset="utf-8" src="../../kindeditor4110/lang/zh_CN.js"></script>
<script charset="utf-8" src="../../kindeditor4110/plugins/code/prettify.js"></script>

<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>

</HEAD>
<!--#include file="../../Include/Const.asp" -->
<!--#include file="../../Include/Conn1.asp" -->
<!--#include file="../CheckAdmin.asp"-->
<BODY>
<% 
dim Result
Result=request.QueryString("Result")
dim ID,ArticleName,ViewFlag,ArticleNameEn,ViewFlagEn,SortID,Content,ContentEn,CommendFlag,NewFlag,KeyWord,LDescription,Angel_languageid,n
ID=request.QueryString("ID")
call ArticleEdit() 
%>
<%If Result = "Add" then%>
<div id="Language">
<div style="height:37px;background:#ffffff;border:1px #628ae1 solid;padding-top:5px; width:100%; padding-left:10px;clear:both;">
<h2>简体中文</h2>
</div>
<%end if%>
<br />
<%
  set rs = server.createobject("adodb.recordset")
  sql="select * from Angel_Language order by Lorder desc"
  rs.open sql,conn,1,3
  n=0
  do while not rs.eof
  if request("m")<>"" then
  showm=request("m")
  else
  showm=n
  end if
  if Result = "Add" then
  mLid=rs("id")
  Angel_languageid=rs("id")
  else
  mLid=Angel_languageid
  end if
%>
<script type="text/javascript">
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="content<%=rs("id")%>"]', {
				cssPath : '../../kindeditor4110/plugins/code/prettify.css',
				uploadJson : '../../kindeditor4110/asp/upload_json.asp',
				fileManagerJson : '../../kindeditor4110/asp/file_manager_json.asp',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form[name=editForm<%=rs("id")%>]')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form[name=editForm<%=rs("id")%>]')[0].submit();
					});
				}
			});
			prettyPrint();
		});
</script>
<ul>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#628AE1">
  <tr>
    <td height="24" nowrap><font color="#FFFFFF"><img src="../Images/Explain.gif" width="18" height="18" border="0" align="absmiddle">&nbsp;<strong>添加，修改新闻信息</strong></font></td>
  </tr>
  <tr>
    <td height="24" align="center" nowrap  bgcolor="#FFFFFF"><a href="ArticleEdit.asp?Result=Add" >添加新闻信息</a><font color="#0000FF">&nbsp;|&nbsp;</font><a href="ArticleList.asp" >查看所有新闻信息</a></td>
  </tr>
</table>
<br>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#628AE1">
  <form name="editForm<%=mLid%>" method="post" action="ArticleEdit.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>&m=<%=showm%>">
  <tr>
    <td height="24" nowrap bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="0" cellspacing="0" id=editArticle idth="100%">

      <tr>
        <td width="90" height="20" align="right">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td height="30" align="right">新闻标题：</td>
        <td><input name="ArticleName" type="text" class="textfield" id="ArticleName" style="WIDTH: 380px" value="<%=ArticleName%>" maxlength="100">
          <span class="STYLE1">*</span></td>
      </tr>
	  <tr>
        <td height="30" align="right">关键词：</td>
        <td><input name="KeyWord" type="text" class="textfield" id="KeyWord" style="WIDTH: 380px" value="<%=KeyWord%>" maxlength="100">
          </td>
      </tr>
	  <tr>
        <td height="100" align="right">优化描述：</td>
        <td>
		<textarea name="Description" id="Description" cols="50" rows="6"><%=LDescription%></textarea>
          </td>
      </tr>
	        <tr>
        <td height="30" align="right">所属类别：</td>
        <td>
		<select name="SortID" id="SortID" style="width:200px;">
          <option value="">请选择分类</option>
          <% 
		  dim rsc,sqlc
	  Set rsc=server.CreateObject("adodb.recordset")
	  sqlc="Select * From Angel_ArticleSort where Angel_languageid="&Angel_languageid&" order by id asc"
	  rsc.open sqlc,conn,1,1
	  if rsc.eof then
        response.write "No Content"
      else
	    while not rsc.eof
	  %>
          <option value="<%=rsc("id")%>" <%if SortID=rsc("id") then response.Write("selected='selected'")%>><%=rsc("SortName")%></option>
		   <%
	    rsc.movenext
		wend
	  end if
	  rsc.close
	  set rsc=nothing
	  %> 
        </select>
		<span class="STYLE1">*</span> </td>
      </tr>
	  
	  <tr>
        <td height="25" align="right">标　　记：</td>
        <td><input name="CommendFlag" type="checkbox" id="CommendFlag" style="HEIGHT: 13px;WIDTH: 13px; " value="1" <%if CommendFlag then response.write ("checked")%>> 首页显示&nbsp;&nbsp;(<font color="#FF0000">将在首页优先展示</font>)</td>
      </tr>
	  
	  <tr>
        <td height="25" align="right">标　　记：</td>
        <td>
  <input name="NewFlag" id="NewFlag" type="checkbox" style="HEIGHT: 13px;WIDTH: 13px;" value="1" <%if NewFlag then response.write ("checked")%>>
推荐 &nbsp;&nbsp;(<font color="#FF0000">推荐将在首页“精彩推荐”展示</font>)</td>
      </tr>
	  
      <tr>
        <td height="30" align="right" valign="top">详细内容：<br>
        <td>
	<textarea name="content<%=rs("id")%>" style="width:680px;height:300px;" id="content<%=rs("id")%>"><%=Content%></textarea>
       </td>
      </tr>
      <tr>
        <td height="30" align="right">是否发布：</td>
        <td><input name="ViewFlag" type="checkbox" id="ViewFlag" style='HEIGHT: 13px;WIDTH: 13px;' value="1" checked <%if ViewFlag then response.write ("checked")%>></td>
      </tr>
      <tr>
        <td height="30" align="right">&nbsp;<input name="Angel_languageid" type="hidden" value="<%=Angel_languageid%>" /></td>
        <td valign="bottom"><input name="submitSaveEdit" type="submit" class="button"  id="submitSaveEdit" value="保存" style="WIDTH: 80;" ></td>
      </tr>
      <tr>
        <td height="20" align="right">&nbsp;</td>
        <td valign="bottom">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  </form>
</table>
</ul>
<%
rs.movenext
n=n+1
If Result = "Modify" then
if n>0 then exit do
end if
loop
rs.close%>
<%If Result = "Add" then%>
</div>
<%dim m
m=request.QueryString("m")
if m="" then m=0
%>
<script>
function $(id){return document.getElementById(id);}
function $tag(id,tagName){return $(id).getElementsByTagName(tagName)}
var onum=<%=m%>;//用于控制默认打开的标签
var Ds=$tag("Language","ul");
var Ts=$tag("Language","h2");
for(var i=0; i<Ds.length;i++){
if(i==onum){
Ds[i].style.display="block";
Ts[i].className = "title_current";
}
else{
Ds[i].style.display="none";
Ts[i].className = "title_normal";
}
Ts[i].value=i;
Ts[i].onmousedown=function(){
if(onum==this.value){return false;};
Ts[onum].className="title_normal";
Ts[this.value].className="title_current";
Ds[onum].style.display="none";
Ds[this.value].style.display="block";
onum=this.value;
}
}
</script>
<%end If%>
</BODY>
</HTML>
<%
sub ArticleEdit()
  dim Action,rsRepeat,rs,sql
  Action=request.QueryString("Action")
  if Action="SaveEdit" then '保存编辑产品信息
    set rs = server.createobject("adodb.recordset")
    if len(trim(request.Form("ArticleName")))<1 then
      response.write ("<script language=javascript> alert('新闻名称为必填项目！');history.back(-1);</script>")
      response.end
	end if

    if Result="Add" then '创建产品信息
	  sql="select * from Angel_Article"
      rs.open sql,conn,1,3
      rs.addnew
	  id=GetID("id","Angel_Article")
	  rs("id")=id
      rs("ArticleName")=trim(Request.Form("ArticleName"))
	  rs("KeyWord")=trim(Request.Form("KeyWord"))
	  rs("Description")=trim(Request.Form("Description"))
	  if Request.Form("ViewFlag")=1 then
        rs("ViewFlag")=Request.Form("ViewFlag")
	  else
        rs("ViewFlag")=0
	  end if
	  
	  if Request.Form("CommendFlag")=1 then
        rs("CommendFlag")=Request.Form("CommendFlag")
	  else
        rs("CommendFlag")=0
	  end if
	  
	  if Request.Form("NewFlag")=1 then
        rs("NewFlag")=Request.Form("NewFlag")
	  else
        rs("NewFlag")=0
	  end if
	  
	  if Request.Form("SortID")="" then
        response.write ("<script language=javascript> alert('请选择所属分类！');history.back(-1);</script>")
        response.end
	  else
	    rs("SortID")=Request.Form("SortID")
	  end if
	  rs("Content")=trim(Request.Form("Content"&Request.Form("Angel_languageid")))
	  rs("UserName")= Request.Cookies("Angelasp")("UserName")
	  rs("UserID")	= Request.Cookies("Angelasp")("UserId")
	  rs("AddTime")=now()
	end if  
	if Result="Modify" then '修改产品信息
      sql="select * from Angel_Article where ID="&ID
      rs.open sql,conn,1,3
      rs("ArticleName")=trim(Request.Form("ArticleName"))
	  rs("KeyWord")=trim(Request.Form("KeyWord"))
	  rs("Description")=trim(Request.Form("Description"))
	  if Request.Form("ViewFlag")=1 then
        rs("ViewFlag")=Request.Form("ViewFlag")
	  else
        rs("ViewFlag")=0
	  end if
	  
	  if Request.Form("CommendFlag")=1 then
        rs("CommendFlag")=Request.Form("CommendFlag")
	  else
        rs("CommendFlag")=0
	  end if
	  
	  if Request.Form("NewFlag")=1 then
        rs("NewFlag")=Request.Form("NewFlag")
	  else
        rs("NewFlag")=0
	  end if
	  
	  if Request.Form("SortID")<>"" then
	    rs("SortID")=Request.Form("SortID")
	  else
        response.write ("<script language=javascript> alert('请选择所属分类！');history.back(-1);</script>")
        response.end
	  end If
	  rs("Content")=trim(Request.Form("Content"&Request.Form("Angel_languageid")))
	  If rs("UserName")<>"" Or rs("UserID")<>"" Then 
	  Else 
	  rs("UserName")= Request.Cookies("Angelasp")("UserName")
	  rs("UserID")	= Request.Cookies("Angelasp")("UserId")
	  End If 
	  rs("AddTime")=now()
	end If
	rs("Angel_languageid")=trim(request.Form("Angel_languageid"))
	rs.update
	rs.close
    set rs=nothing
	'response.redirect "createhtml/createhtml.asp?id="&ID '生成静态
    response.write "<script language=javascript> alert('成功编辑新闻信息！');location.replace('ArticleList.asp?m="&request("m")&"');</script>" '不需生成静态
	response.End()
  else '提取产品信息
	if Result="Modify" then
      set rs = server.createobject("adodb.recordset")
      sql="select * from Angel_Article where ID="& ID
      rs.open sql,conn,1,1
      if rs.bof and rs.eof then
        response.write ("数据库读取记录出错！")
        response.end
      end if
	  ArticleName=rs("ArticleName")
	  ViewFlag=rs("ViewFlag")
	  SortID=rs("SortID")
      Content=rs("Content")
	  KeyWord=rs("KeyWord")
	  LDescription=rs("Description")
	  NewFlag=rs("NewFlag")
	  CommendFlag=rs("CommendFlag")
	  Angel_languageid=rs("Angel_languageid")
	  rs.close
      set rs=nothing 
    end if
  end if
end sub
%>