<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<HTML>
<HEAD>
<TITLE>添加新闻</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<style>
body,td,input,textarea {font-size:9pt}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style1 {	color: #FFFFFF;
	font-weight: bold;
}
</style>

</HEAD>
<BODY>
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p03")
'''''''''''''''''''''''''''''''''''''''''''''''
'获得大类
dim first,id,classid,TempletArr
dim i
'获得参数
id=cint(request("id"))
classid=Cint(request.QueryString("classid"))
set rs=server.CreateObject("adodb.recordset")
sql="select templetname,content from templet where id="&id
rs.open sql,conn,3,1
if not rs.eof then
	TempletArr=rs.GetRows()
else
	response.Write("没有找到记录")
	response.end()
end if
rs.close
set rs=nothing
'获取 分类
set rs=server.CreateObject("adodb.recordset")
sql="select * from catalogs where parentid=0 order by id asc"
rs.open sql,conn,3,1
if not rs.eof then
	first=rs.GetRows()
else
	response.write("没有分类，请先<a href=""tree.asp"">添加</a>栏目分类再进行此操作。")
	response.end()
end if
rs.close
set rs=nothing
'response.Write("bigclass-----------------------"&ubound(first,2)&"----------------<br>")

'获得所有par_id=<>的类别------主类：par_id=0
if(ubound(first,2)<0) then
response.Write("暂时没有分类")
end if

Function getcatalogs(parentid,str)
	Dim Sql,rstemp,TemptempStr,tempStr	
	tempStr=str&"&nbsp;"
	sql="select * from catalogs where parentid="&parentid
	Set rstemp = Conn.Execute(Sql)
	do while Not rstemp.Eof
		if(rstemp("id")=classid) then
				sele=" selected"
			else
				sele=""
		end if
		getcatalogs = getcatalogs &"<option value="&rstemp("id")&sele&">│"&tempStr&"└"&rstemp("title")&"</option>"&Chr(10)
		getcatalogs = getcatalogs & getcatalogs(rstemp("id"),tempStr)
		rstemp.MoveNext
	loop
	rstemp.close
	Set rstemp = Nothing
End Function
%>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<%
dim act,TempName,TempContent,newsclass
id=Cint(request("id"))
act=request.QueryString("act")
newsclass=Cint(request.Form("newsclass"))
TempName=trim(request.Form("tempname"))
TempContent = TempContent & Request.Form("content1") 
if(act="modi") then
	call ModiTemplet()
	response.Write("成功修改模板~!")
else
%>
<FORM method="POST" name="form1" action="templet_modi.asp?act=modi" style="margin:0 0 0 0; ">
  <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#FF9900">
  <TD height="22" colspan="2"><div align="center"><span class="style1">◆ 模板修改 ◆</span></div></TD>
  </TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="center">所 属 类 别：</div></TD>
  <TD><select name="newsclass" >
  <%
  for i=0 to ubound(first,2)
 			if(first(0,i)=classid) then
				sele=" selected"
			else
				sele=""
			end if			
		response.Write("<option value="&first(0,i)&sele&">├"&first(2,i)&"</option>"&Chr(10))	
    	response.Write(getcatalogs(first(0,i),""))		
next	
%>
        
    </select></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="center">模 板 标 题：</div></TD>
  <TD><input name="tempname" type="text" size="60" value="<%=TempletArr(0,0)%>"></TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD><div align="center">模 板 内 容：</div></TD>
	<TD>		
		<textarea name="content1" cols="100" rows="25"><%=replace(replace(TempletArr(1,0),"<","&lt;"),">","&gt;")%></textarea>
		<!--<IFRAME ID="eWebEditor1" src="webedit/ewebeditor.asp?id=content1&style=standard_coolblue" frameborder="0" scrolling="no" width="550" height="350"></IFRAME>	-->
	  </TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD align=right>&nbsp;	  </TD>
    <TD align=right><div align="left">
		<input type="hidden" name="id" value="<%=id%>">
        <input type=submit name=b1 value="提交">
        <input type=reset name=b2 value="重填">
        <input type=button name=b3 value="查看源文件" onClick="location.replace('view-source:'+location)">
    </div></TD>
</TR>
</TABLE>
</FORM>
<%
end if
sub ModiTemplet
	set rs=server.createobject("adodb.recordset")
	sql="select * from templet where id="&id
	rs.open sql,conn,3,3	
	rs("classid")=newsclass
	rs("templetname")=TempName
	rs("content")=TempContent
	rs("moditime")=now
	rs.update
	rs.close
	set rs=nothing
end sub
%>
</BODY>
</HTML>
<%
call connclose()
%>