<!--#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,classid
classid=0
dim i
set rs=server.CreateObject("adodb.recordset")
sql="select id,title from catalogs where parentid="&classid&" order by id asc"
rs.open sql,conn,3,1
if not rs.eof then
	first=rs.GetRows()
	if(ubound(first,2)<0) then
	response.Write("暂时没有分类")
	end if
else
	response.Write("暂时没有分类,请先添加分类!")
	response.End()
end if
rs.close
set rs=nothing

Function getcatalogs(parentid,str)
	Dim Sql,rstemp,TemptempStr,tempStr	
	tempStr=str&"&nbsp;"
	sql="select id,title from catalogs where parentid="&parentid
	Set rstemp = Conn.Execute(Sql)
	do while Not rstemp.Eof
		getcatalogs = getcatalogs &"<option value="&rstemp(0)&">│"&tempStr&"└"&rstemp(1)&"</option>"&Chr(10)
		getcatalogs = getcatalogs & getcatalogs(rstemp(0),tempStr)
		rstemp.MoveNext
	loop
	rstemp.close
	Set rstemp = Nothing
End Function
Function getcatalogoption()
	dim ret
	ret=""
	for i=0 to ubound(first,2)
		ret=ret&"<option value="&first(0,i)&">├"&first(1,i)&"</option>"&Chr(10)
    	ret=ret&getcatalogs(first(0,i),"")
	next
	getcatalogoption=ret
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
act=request.QueryString("act")

if(act="add") then
	newsclass=cint(request.Form("newsclass"))
	TempName=trim(request.Form("tempname"))
	TempContent=Request.Form("content") 
	call AddTemplet()
	response.Write("成功添加模板~!")
else
%>
<FORM method="POST" name="form1" action="templet_add.asp?act=add" 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" >
  <%
	catalogcache=application(CachePrefix&"_catalogoption_0")
	if(catalogcache="" or isempty(catalogcache) or len(catalogcache)<1) then
  		application.Lock()
		application(CachePrefix&"_catalogoption_0")=getcatalogoption()
		application.UnLock()
		response.Write(application(CachePrefix&"_catalogoption_0"))
	else
		response.Write(catalogcache)
	end if
	%></select></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="center">模 板 标 题：</div></TD>
  <TD><input name="tempname" type="text" size="60"></TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD><div align="center">模 板 内 容：</div></TD>
	<TD>
		<INPUT type="hidden" name="content" value="">
		<!--<textarea name="content1" style="display:none ;" value="aaa"></textarea>-->
	  <IFRAME ID="eWebEditor1" src="webedit/editor.html" 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=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 AddTemplet
	set rs=server.createobject("adodb.recordset")
	sql="select top 1 * from templet order by id desc "
	rs.open sql,conn,3,3
	rs.addnew
	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()
%>