<!--#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,id,classid,labelArr
dim i
'获得参数
id=cint(request("id"))
classid=Cint(request.QueryString("classid"))
set rs=server.CreateObject("adodb.recordset")
sql="select labelname,content,demons,classid,labeltype from label where id="&id
rs.open sql,conn,3,1
if not rs.eof then
	labelArr=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
first=rs.GetRows()
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")=labelArr(3,0)) 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,demons
id=Cint(request("id"))
act=request.QueryString("act")
newsclass=Cint(request.Form("newsclass"))
TempName=trim(request.Form("tempname"))
demons=request.Form("demons")
TempContent = TempContent & Request.Form("content1") 
if(act="modi") then
	call Modilabel()
	response.Write("成功修改标签~!")
	response.Write("<br><input type=button value='继续修改' onclick='history.go(-2)'> &nbsp;")
else
%>
<FORM method="POST" name="form1" action="label_modi.asp?act=modi" style="margin:0 0 0 0; " onSubmit="document.form1.content1.value=doc_html.Composition.document.body.innerHTML">
  <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#F5F5F5">
  <TD><div align="center">所 属 类 别：</div></TD>
  <TD><select name="newsclass" >
  <option value="0" <%if(classid=0) then response.Write("selected") end if%>>所有</option>
  <%
  for i=0 to ubound(first,2)
 			if(first(0,i)=labelArr(3,0)) 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="<%=labelArr(0,0)%>"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="center">标 签 作 用：</div></TD>
  <TD><textarea name="demons" cols="40" rows="3" id="demons"><%=labelArr(2,0)%></textarea></TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD><div align="center">标 签 内 容：</div></TD>
	<TD>		
		<%
		if(labelArr(4,0)=0) then
		%>
    <textarea name="content1" cols="80" rows="20" style="display:none; "><%=labelArr(1,0)%></textarea>		
		<textarea name="tempcontent" style="display:none; "><%=labelArr(1,0)%></textarea>
		<iframe src="editor/editor.htm" id="doc_html" name="doc_html" width="100%" height="325"></iframe>
    <%
		else
		%>
    在此输入查询的Sql语句：<br>
    <textarea rows="12" name="content1" cols="70"><%=labelArr(1,0)%></textarea><input type="button" value="测试Sql" onClick="popupWindow('sql_test.asp?sql='+escape(document.form1.content1.value),'sql_test',true)" />
    <%
		end if
		%>
	  </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="重填">
    </div></TD>
</TR>
</TABLE>
</FORM>
<%
end if
sub Modilabel
	set rs=server.createobject("adodb.recordset")
	rs.open "select * from label where labelname='"&TempName&"' and id<>"&id,conn,3,1
	if not rs.eof then
		response.Write("<script>alert(""该标签已存在!"");history.back();</script>")
		response.End()
	end if
	rs.close
	sql="select * from label where id="&id
	rs.open sql,conn,3,3	
	rs("classid")=newsclass
	rs("labelname")=TempName
	rs("demons")=demons
	rs("content")=TempContent
	rs("moditime")=now
	rs.update
	rs.close
	set rs=nothing
end sub
%>
</BODY>
</HTML>
<%
call connclose()
%>