<!--#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;
}
.style2 {color: #999999}
</style>

</HEAD>
<BODY>
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p03")
'''''''''''''''''''''''''''''''''''''''''''''''
'获得大类
dim first
dim i
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 and not rs.bof then
	first=rs.GetRows()
	rs.close
	set rs=nothing
else
	response.Write("暂时没有分类")
	rs.close
	set rs=nothing
	response.End()
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
		getcatalogs = getcatalogs &"<option value="&rstemp("id")&">│"&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
act=request.QueryString("act")

if(act="add") then
	newsclass=cint(request.Form("newsclass"))
	TempName=trim(request.Form("tempname"))
	TempContent=Request.Form("content1") 
	if(len(TempContent)<1) then
		response.Write("<script>alert(""模板内容不能为空!"");history.back();</script>")
		response.End()
	end if
	call AddTemplet()
	response.Write("成功添加模板~!")
else
%>
<FORM method="POST" name="form1" action="templet_add.asp?act=add" style="margin:0 0 0 0; " onSubmit="return check(this);">
  <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" >
  <option>点击右边＋号选择栏目</option>
  </select>
	&nbsp;&nbsp;<a href="#" onClick="addParentOption();">＋</a>  
	</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="content1" 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>	
	  <br>
	  <span class="style2">注：建议使用“代码”模式，将你在“Dreamweaver”等软件中设计好的模板复制上来。</span></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
%>
<script language="JavaScript">
function check(obj)
{
	if(obj.tempname.value==""){
		alert("模板名称不能为空!");
		obj.tempname.select();
		obj.tempname.focus();
		return false;
	}	
}
function addParentOption()
{
	var arr = showModalDialog("tree_container.asp", "", "dialogWidth:410px; dialogHeight:420px; status:0");
  	if (arr != null){  
   		document.form1.newsclass.options[0]=new Option(arr[1],arr[0]);
  	}
	
}
</script>
</BODY>
</HTML>
<%
call connclose()
%>