<!--#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;
}
</style>

</HEAD>
<BODY>
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p04")
'''''''''''''''''''''''''''''''''''''''''''''''
'获得大类
dim first,classid
dim i,ftype,ftitle
ftype=request.QueryString("ftype")
if(ftype<>"") then
	ftype=Cint(ftype)
else
	ftype=0
end if
if(ftype=0) then
	ftitle="标签"
elseif(ftype=1) then
	ftitle="函数"
end if
classid=Cint(request("classid"))
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()

'response.Write("bigclass-----------------------"&ubound(first,2)&"----------------<br>")

'获得所有par_id=<>的类别------主类：par_id=0
	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,demons
act=request.QueryString("act")

if(act="add") then
	newsclass=cint(request.Form("newsclass"))
	LabelName=trim(request.Form("labelname"))
	demons=request.Form("demons")
	LabelContent=Request.Form("content") 
	call Addlabel()
	response.Write("成功添加标签~!")
	response.Write("<br><a href=""label_add.asp"">继续添加-></a>")
else
%>
<FORM method="POST" name="form1" action="label_add.asp?act=add&ftype=<%=ftype%>" style="margin:0 0 0 0; " onSubmit="document.form1.content.value=doc_html.Composition.document.body.innerHTML">
<TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#F5F5F5">
  <TD height="24" colspan="2" bgcolor="#FF9900"><div align="center" class="style1">添加<%=ftitle%></div></TD>
  </TR>
<TR bgcolor="#F5F5F5">
  <TD width="14%"><div align="center">所 属 类 别：</div></TD>
  <TD width="86%"><select name="newsclass" >
  <option value="0">所有</option>
  <%
	catalogcache=application(CachePrefix&"_catalogoption_"&classid)
	if(catalogcache="" or isempty(catalogcache) or len(catalogcache)<1) then
  		application.Lock()
		application(CachePrefix&"_catalogoption_"&classid)=getcatalogoption()
		application.UnLock()
		response.Write(application(CachePrefix&"_catalogoption_"&classid))
	else
		response.Write(catalogcache)
	end if
	%>
    </select></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="center"><%=ftitle%> 名 字：</div></TD>
  <TD><input name="labelname" type="text" size="30">
    (只能使用字母和数字)</TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="center"><%=ftitle%> 作 用：</div></TD>
  <TD><textarea name="demons" cols="40" rows="3" id="demons"></textarea></TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD><div align="center"><%=ftitle%> 内 容：</div></TD>
	<TD>
		<%
		if(ftype=0) then
		%>
		<textarea rows="12" name="content" cols="70" style="display:none; "></textarea>
		<textarea name="tempcontent" style="display:none; ">添加标签...</textarea>
		<iframe src="editor/editor.htm" id="doc_html" name="doc_html" width="100%" height="325"></iframe>
		<%
		else
		%>
    在此输入查询的Sql语句：<br>
    <textarea rows="12" name="content" cols="70"></textarea><input type="button" value="测试Sql" onClick="popupWindow('sql_test.asp?sql='+escape(document.form1.content.value),'sql_test',true)" />
    <%
		end if
		%>
</TR>
<TR bgcolor="#F5F5F5">
	<TD align=right>&nbsp;	  </TD>
    <TD align=right><div align="left"> 
        <input type=submit name=b1 value="提 交">&nbsp;&nbsp;
        <input type=reset name=b2 value="重 填">       
    </div></TD>
</TR>
</TABLE>
</FORM>
<%
end if
sub Addlabel
	if(len(LabelName)<1) then
		response.Write("<script>alert(""请输入名称!"");history.back();</script>")
		response.End()
	end if
	set rs=server.createobject("adodb.recordset")
	sql="select top 1 * from label where labelname='"&LabelName&"' order by id desc "
	rs.open sql,conn,3,3
	if not rs.eof then
		response.Write("<script>alert(""该标签已存在!"");history.back();</script>")
		response.End()
	else
		rs.addnew
		rs("classid")=newsclass
		rs("labelname")=LabelName
		rs("demons")=demons
		rs("content")=LabelContent
		rs("moditime")=now
		rs("labeltype")=ftype
		rs.update
	end if
	rs.close
	set rs=nothing
end sub
%>
<script type="text/javascript">
function popupWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
</script>
</BODY>
</HTML>
<%
call connclose()
%>