<%@language=vbscript codepage=936 %>
<%
option explicit
response.buffer=true	
Const PurviewLevel=2    '操作权限
%>
<!--#include file="Admin_ChkPurview.asp"-->
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/admin_code.asp"-->

<%
dim Action,ClassID,sql,rsClass,i,FoundErr,ErrMsg
dim SkinCount,LayoutCount
Action=trim(Request("Action"))
ClassID=trim(request("ClassID"))
if ClassID="" then
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>参数不足！</li>"
	call WriteErrMsg()
	call CloseConn()
else
	ClassID=CLng(ClassID)
	sql="select * From ArticleClass where ClassID=" & ClassID
	set rsClass=server.CreateObject ("Adodb.recordset")
	rsClass.open sql,conn,1,3
	if rsClass.bof and rsClass.eof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>找不到指定的栏目！</li>"
	else
		if Action="Modify" then
			call ModifyClass()
		else
			call main()
		end if
	end if
	rsClass.close
	set rsClass=nothing
	if FoundErr=True then
		call WriteErrMsg()
	end if
end if
call CloseConn()


sub ModifyClass()
	dim ClassName,Readme,IsElite,ClassMaster,ClassPicUrl,LinkUrl,SkinID,LayoutID,BrowsePurview,AddPurview
	dim trs,rs
	ClassName=trim(request("ClassName"))
	IsElite=trim(request("IsElite"))
	ClassMaster=trim(request("ClassMaster"))
	Readme=trim(request("Readme"))
	ClassPicUrl=trim(request("ClassPicUrl"))
	LinkUrl=trim(request("LinkUrl"))
	SkinID=Trim(request("SkinID"))
	LayoutID=trim(request("LayoutID"))
	BrowsePurview=trim(request("BrowsePurview"))
	AddPurview=trim(request("AddPurview"))
	if ClassName="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>栏目名称不能为空！</li>"
	end if
	if rsClass("Child")>0 and LinkUrl<>"" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>本栏目有子栏目，所以不能设为外部链接地址。</li>"
	end if
	if IsElite="Yes" then
		IsElite=True
	else
		IsElite=False
	end if
	if SkinID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定栏目配色模板</li>"
	else
		SkinID=Clng(SkinID)
	end if
	if LayoutID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定版面设计模板</li>"
	else
		LayoutID=CLng(LayoutID)
	end if

	if ClassMaster<>"" and ClassMaster<>rsClass("ClassMaster") then
		call AddMaster(ClassMaster)
	end if
	if FoundErr=True then
		exit sub
	end if
   	rsClass("ClassName")=ClassName
	rsClass("IsElite")=IsElite
	rsClass("ClassMaster")=ClassMaster
	rsClass("Readme")=Readme
	rsClass("ClassPicUrl")=ClassPicUrl
	rsClass("LinkUrl")=LinkUrl
	rsClass("SkinID")=SkinID
	rsClass("LayoutID")=LayoutID
	rsClass("BrowsePurview")=Cint(BrowsePurview)
	rsClass("AddPurview")=Cint(AddPurview)
	rsClass.update
	rsClass.close
	set rsClass=nothing
	
set rs=nothing
set trs=nothing
	
    call CloseConn()
	Response.Redirect "Admin_ClassManage.asp"  
end sub

sub main()
%>
<html>
<head>
<title>修改栏目</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="Admin_Style.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
function check()
{
  if (document.form1.ClassName.value=="")
  {
    alert("栏目名称不能为空！");
	document.form1.ClassName.focus();
	return false;
  }
}
</script>

</head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
  <tr class="topbg"> 
    <td height="22" colspan="2" align="center"><strong>栏 目 管 理</strong></td>
  </tr>
  <tr class="tdbg"> 
    <td width="70" height="30"><strong>管理导航：</strong></td>
    <td height="30"><a href="Admin_ClassManage.asp">栏目管理首页</a> | <a href="Admin_ClassAdd.asp">添加一级栏目</a>&nbsp;|&nbsp;<a href="Admin_ClassOrder.asp">一级栏目排序</a>&nbsp;|&nbsp;<a href="Admin_ClassOrderN.asp">N级栏目排序</a>&nbsp;|&nbsp;<a href="Admin_ClassReset.asp">复位所有栏目</a>&nbsp;|&nbsp;<a href="Admin_ClassUnite.asp">栏目合并</a></td>
  </tr>
</table>
<form name="form1" method="post" action="Admin_ClassModify.asp" onsubmit="return check()">
  <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
    <tr class="title"> 
      <td height="22" colspan="2" align="center"><strong>修 改 栏 目</strong></td>
    </tr>
    <tr class="tdbg"> 
      <td width="350"><strong>所属栏目：</strong><br>
        如果你想改变所属栏目，请<a href='Admin_ClassMove.asp'>点此移动栏目</a></td>
      <td> <%
	if rsClass("ParentID")<=0 then
	  	response.write "无（作为一级栏目）"
	else
    	dim rsParentClass,sqlParentClass
		sqlParentClass="Select * From ArticleClass where ClassID in (" & rsClass("ParentPath") & ") order by Depth"
		set rsParentClass=server.CreateObject("adodb.recordset")
		rsParentClass.open sqlParentClass,conn,1,1
		do while not rsParentClass.eof
			for i=1 to rsParentClass("Depth")
				response.write "&nbsp;&nbsp;&nbsp;"
			next
			if rsParentClass("Depth")>0 then
				response.write "└"
			end if
			response.write "&nbsp;" & rsParentClass("ClassName") & "<br>"
			rsParentClass.movenext
		loop
		rsParentClass.close
		set rsParentClass=nothing
	end if
	%> </select></td>
    </tr>
    <tr class="tdbg"> 
      <td width="350"><strong>栏目名称：</strong></td>
      <td><input name="ClassName" type="text" value="<%=rsClass("ClassName")%>" size="37" maxlength="20"> 
        <input name="ClassID" type="hidden" id="ClassID" value="<%=rsClass("ClassID")%>"></td>
    </tr>
    <tr class="tdbg"> 
      <td width="350"><strong>栏目说明：<br>
        </strong> 鼠标移至栏目名称上时将显示设定的说明文字（不支持HTML）</td>
      <td><textarea name="Readme" cols="30" rows="4" id="Readme"><%=rsClass("ReadMe")%></textarea></td>
    </tr>
    <tr class="tdbg">
      <td><strong>是否是推荐栏目：</strong><br>
        推荐栏目将在首页及此栏目的父栏目上显示文章列表</td>
      <td> <input name="IsElite" type="radio" value="Yes" <%if rsClass("IsElite")=True then response.write " checked"%>>
        是&nbsp;&nbsp;&nbsp;&nbsp; <input type="radio" name="IsElite" value="No" <%if rsClass("IsElite")=False then response.write " checked"%>>
        否 </td>
    </tr>
    <tr class="tdbg"> 
      <td width="350"><strong>栏目配色模板：</strong><br>
        相关模板中包含CSS、颜色、图片等信息</td>
      <td><%call Admin_ShowSkin_Option(rsClass("SkinID"))%></td>
    </tr>
    <tr class="tdbg"> 
      <td width="350"><strong>版面设计模板：</strong><br>
        相关模板中包含了版面设计的版式等信息，如果是自行添加的设计模板，可能会导致“栏目配色模板”失效。 </td>
      <td><%call Admin_ShowLayout_Option(2,rsClass("LayoutID"))%></td>
    </tr>
    <tr class="tdbg"> 
      <td width="350"><strong>栏目图片地址：</strong><br>
        图片会显示在栏目前面。注意图片大小。</td>
      <td><input name="ClassPicUrl" type="text" id="ClassPicUrl" value="<%=rsClass("ClassPicUrl")%>" size="37" maxlength="255">
        （预留功能）</td>
    </tr>
    <tr class="tdbg"> 
      <td width="350"><strong>栏目编辑：</strong><br>
        多个编辑请用“|”分隔，如：3NIAO|dilys|sws2000<br>
        无需添加“文章总编”以上级别的管理员<br>
        管理员权限采用权限继承制度</td>
      <td><input name="ClassMaster" type="text" id="ClassMaster" value="<%=rsClass("ClassMaster")%>" size="37" maxlength="100"> 
      </td>
    </tr>
    <tr class="tdbg"> 
      <td width="350"><strong>栏目链接地址：</strong><br>
        如果想将栏目链接到外部地址，请输入完整的URL地址，否则请保持为空。</td>
      <td><input name="LinkUrl" type="text" id="LinkUrl" value="<%=rsClass("LinkUrl")%>" size="37" maxlength="255"></td>
    </tr>
    <tr class="tdbg"> 
      <td width="350"><strong>栏目浏览权限：</strong><br>
        只有具有相应权限的人才能浏览此栏目中的文章。</td>
      <td><select name="BrowsePurview" id="BrowsePurview">
          <option value="9999" <%if rsClass("BrowsePurview")=9999 then response.write " selected"%>>游客</option>
          <option value="999" <%if rsClass("BrowsePurview")=999 then response.write " selected"%>>注册用户</option>
          <option value="99" <%if rsClass("BrowsePurview")=99 then response.write " selected"%>>收费用户</option>
          <option value="9" <%if rsClass("BrowsePurview")=9 then response.write " selected"%>>VIP用户</option>
          <option value="5" <%if rsClass("BrowsePurview")=5 then response.write " selected"%>>管理员</option>
        </select></td>
    </tr>
    <tr class="tdbg"> 
      <td width="350"><strong>栏目发表文章权限：</strong><br>
        只有具有相应权限的人才能在此栏目中发表文章。</td>
      <td><select name="AddPurview" id="AddPurview">
          <option value="999" <%if rsClass("AddPurview")=999 then response.write " selected"%>>注册用户</option>
          <option value="99" <%if rsClass("AddPurview")=99 then response.write " selected"%>>收费用户</option>
          <option value="9" <%if rsClass("AddPurview")=9 then response.write " selected"%>>VIP用户</option>
          <option value="5" <%if rsClass("AddPurview")=5 then response.write " selected"%>>管理员</option>
        </select></td>
    </tr>
    <tr class="tdbg"> 
      <td height="40" colspan="2" align="center"><input name="Action" type="hidden" id="Action" value="Modify"> 
        <input name="Submit" type="submit" value=" 保存修改结果 " <%if SkinCount=0 or LayoutCount=0 then response.write " disabled"%> style="cursor:hand;"> 
        &nbsp; <input name="Cancel" type="button" id="Cancel" value=" 取 消 " onClick="window.location.href='Admin_ClassManage.asp'" style="cursor:hand;"> 
        <%if SkinCount=0 then response.write "<li><font color=red>请先添加栏目配色模板</font></li>"
		if SkinCount=0 then response.write "<li><font color=red>请先添加栏目版面设计模板</font></li>" %></td>
    </tr>
  </table>
</form>
</body>
</html>
<%
end sub
%>
