<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include.jsp"%>
<%@ include file="session.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<title>欢迎光临<%=title%></title>
<link rel="stylesheet" href="../css/news.css" type="text/css" media="screen">
</head>
<body>
<script Language="JavaScript">
<!--
function check_input(theForm)
{

   if (theForm.subject.value == "")
  {
    alert("请输入文章标题.");
    theForm.subject.focus();
    return (false);
  }

   if (theForm.Content.value == "")
  {
    alert("请输入贴子的内容.");
    theForm.Content.focus();
    return (false);
  }
  
   if (theForm.classid.value == "")
  {
    alert("请选择栏目.");
    theForm.classid.focus();
    return (false);
  }
	
  if (theForm.subject.value.length > 100)
    {
    alert("文章标题长度应小于50个字符或数字.");
    theForm.subject.focus();
    return (false);
  }

  if (theForm.pic.value.length > 100)
    {
    alert("图片链接地址应小于50个字符或数字.");
    theForm.pic.focus();
    return (false);
  }
}
//-->
</script>
<TABLE bgColor=<%=tablebgcolor%> border=0 cellPadding=0 cellSpacing=1 width=<%=tablewidth%> align=CENTER>
	<TR><TD align=middle background=../img/index/topback.gif height=10>
	</TD></TR>
</TABLE>
	<%int id =(null==request.getParameter("id")?1:(Integer.parseInt(request.getParameter("id"))));
	NewsMgr newsMgr = new NewsMgr();
	News news = newsMgr.getById(id);
	MasterMgr masterMgr = new MasterMgr();
	Master master =masterMgr.getByUsername(session.getAttribute("username").toString());
	if(news.getCategoryid()!=master.getCategoryid() && !userName.equals("admin")){response.sendRedirect("error1.jsp");}%>
<TABLE border="0" width=<%=tablewidth%> align=center cellpadding=0 cellspacing=1  bgcolor=<%=tablebgcolor%>>
<form method="POST" action="/News/EditNewsServlet?id=<%=id%>" onsubmit="return check_input(this)">
	<TR bgcolor=<%=trbgcolor%> height=25>
		<TD colspan=2><FONT COLOR="#ffffff"><FONT SIZE="5" COLOR="#ffcc00"><B>编辑新闻</B></FONT><B>  **为必填项目</B></FONT></TD>
	</TR>
	<TR><TD width="30%" bgColor=<%=tdbgcolor%>>&nbsp;<B>文章标题</B></TD>
		<TD width="70%" bgColor=<%=tdbgcolor%>>
		<input TYPE="text" name=subject size=70 maxlength=255 value=<%=news.getTopic()%>>&nbsp;**不得超过 50 个汉字</TD>
	</TR>
	<TR><TD bgColor=<%=tdbgcolor%>>&nbsp;<B>内容</B><BR><BR><li>请在此填写新闻的内容。<BR></TD>
		<TD bgColor=<%=tdbgcolor%>><textarea class="smallarea" cols="60" name="Content" rows="20" wrap="VIRTUAL" title="请在此填写新闻的内容。"><%=news.getContent()%></textarea>  **</TD>
	</TR>
	<TR><TD bgColor=<%=tdbgcolor%>>&nbsp;<B>图片链接地址</B></TD><TD bgColor=<%=tdbgcolor%>>
		<input TYPE="text" name=pic size=70 maxlength=100 value=<%=news.getPicture()%>></TD>
	</TR>
	<TR><TD bgColor=<%=tdbgcolor%>>&nbsp;<B>所在栏目</B></TD><TD bgColor=<%=tdbgcolor%>>
		<SELECT NAME="classid">
			<option value="">请选择新闻所的栏目</option>
			<%CategoryMgr categoryMgr = new CategoryMgr();
			Collection c = categoryMgr.getAll();
			Iterator iterator = c.iterator();
			while (iterator.hasNext()) {
				Category category = (Category) iterator.next();
			if (news.getCategoryid()==category.getId()){%>
			<option value="<%=category.getId()%>" selected><%=category.getName()%></option><%} else{%>
			<option value="<%=category.getId()%>"><%=category.getName()%></option>
			<%}}%>
		</SELECT></TD>
	</TR>
	<TR><TD bgColor=<%=tdbgcolor%> colspan=2 align=center><FONT color=#000000>
		<INPUT name=Submit type=submit value="发 表"> &nbsp;&nbsp;     
		<INPUT name=Submit2 type=reset value="清 除"></FONT></TD>
	</TR>
	<form>
</TABLE>
<%@ include file="foot.jsp"%>

