<% Option Explicit %>
<!--#include file="../../Inc/Cls_DB.asp" -->
<!--#include file="../Inc/Cls_Class.asp" -->
<!--#include file="../../Inc/Const.asp" -->
<%
Dim DBC,Conn
Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
'==============================================================================
'软件名称：风讯网站信息管理系统
'当前版本：Foosun Content Manager System 2.0 
'最新更新：2004.12
'==============================================================================
'商业注册联系：028-85098980-601,602 技术支持：028-85098980-606、607,客户支持：608
'产品咨询QQ：159410,655071,66252421
'技术支持:所有程序使用问题，请提问到bbs.foosun.net我们将及时回答您
'程序开发：风讯开发组 & 风讯插件开发组
'论坛支持：风讯在线论坛(http://bbs.foosun.net)
'官方网站：www.Foosun.net  演示站点：test.cooin.com    
'网站建设专区：www.cooin.com
'==============================================================================
'免费版本请在新闻首页保留版权信息，并做上本站LOGO友情连接
'==============================================================================
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),""&Request("ClassID")&"") then Call ReturnError()
if Not JudgePopedomTF(Session("Name"),"P0102") then Call ReturnError()
Dim ClassID,Sql,RsClassEditObj,ClassEName,ClassCName,ClassTemp,Contribution,AddTime,ParentID,ParentIDStr,HaveContTF,BrowPop
Dim SaveFilePath,FileExtName
ClassID = Request("ClassID")
if ClassID <> "" then
	Sql = "Select * from NewsClass where ClassID='" & ClassID & "' and DelFlag=0"
	Set RsClassEditObj = Conn.Execute(Sql)
	if RsClassEditObj.Eof then
		Set RsClassEditObj = Nothing
		Set Conn = Nothing
		Alert "栏目已经被删除"
	else
		Dim RsTempObj
		ClassEName = RsClassEditObj("ClassEName")
		ClassCName = RsClassEditObj("ClassCName")
		ClassTemp = RsClassEditObj("ClassTemp")
		Contribution = RsClassEditObj("Contribution")
		AddTime = RsClassEditObj("AddTime")
		ParentID = RsClassEditObj("ParentID")
		SaveFilePath = RsClassEditObj("SaveFilePath")
		FileExtName = RsClassEditObj("FileExtName")
		BrowPop = RsClassEditObj("BrowPop")
		if ParentID <> "0" then
			Set RsTempObj = Conn.Execute("Select ClassCName,DelFlag from NewsClass where ClassID='" & ParentID & "'")
			if RsTempObj.Eof then
				Alert "父栏目不存在"
			else
				if RsTempObj("DelFlag") = 1 then
					Alert "父栏目在回收站"
				else
					ParentIDStr = RsTempObj("ClassCName")
				end if
			end if
			Set RsTempObj = Nothing
		else
			ParentIDStr = "根栏目"
		end if
		if Contribution = 1 then
			Set RsTempObj = Conn.Execute("Select ContID from Contribution where ClassID='" & ClassID & "'")
			if Not RsTempobj.Eof then
				HaveContTF = True
			else
				HaveContTF = False
			end if
			Set RsTempObj = Nothing
		else
			HaveContTF = False
		end if
	end if
else
	Alert "参数传递错误"
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>栏目修改</title>
</head>
<link href="Class.css" rel="stylesheet">
<script language="JavaScript" src="../JS/PublicJS.js"></script>
<body>
<div align="center">
  <table width="98%" border="0" cellspacing="5" cellpadding="0">
    <form action="" method="post" name="ClassForm">
      <tr> 
        <td height="5" colspan="2"></td>
      </tr>
      <tr> 
        <td width="18%"><div align="center">中文名称</div></td>
        <td> <div align="center">
            <input value="<% = ClassCName %>" name="ClassCName" type="text" id="ClassCName2" style="width:100%;">
          </div></td>
      </tr>
      <tr> 
        <td><div align="center">英文名称</div></td>
        <td> <div align="center"> 
            <input value="<% = ClassEName %>" readonly name="ClassEName" type="text" id="ClassEName" style="width:100%;">
          </div></td>
      </tr>
      <tr> 
        <td><div align="center">父栏目</div></td>
        <td> <div align="center"> 
            <input readonly value="<% = ParentIDStr %>" style="width:100%;" type="text" name="textfield3">
          </div></td>
      </tr>
      <tr> 
        <td><div align="center">栏目模板</div></td>
        <td nowrap> <div align="left"> 
            <input readonly value="<% = ClassTemp %>" type="text" style="width:78%;" name="ClassTemp"><input type="button" name="Submit" value="选择模板" onClick="OpenWindowAndSetValue('../Inc/SelectFileFrame.asp?CurrPath=/<% = TempletDir %>',400,300,window,document.ClassForm.ClassTemp);document.ClassForm.ClassTemp.focus();">
          </div></td>
      </tr>
      <tr> 
        <td><div align="center">保存路径</div></td>
        <td nowrap><input readonly type="text" style="width:78%;" value="<% = SaveFilePath %>" name="SaveFilePath"><input type="button" name="Submit4" value="选择路径" onClick="OpenWindowAndSetValue('../Inc/SelectPathFrame.asp?CurrPath=/<% = ClassDir %>',400,300,window,document.ClassForm.SaveFilePath);document.ClassForm.SaveFilePath.focus();"> 
        </td>
      </tr>
      <tr>
        <td><div align="center">浏览权限</div></td>
        <td nowrap><select name="BrowPop" id="select3" style="width:100%" onChange="CheckFileExtName(this);">
            <option value="" <%if BrowPop = 0 then Response.Write("selected")%>> 
            </option>
            <%
		Dim BrowPopObj
		set BrowPopObj = Conn.Execute("Select Name,PopLevel from MemGroup order by PopLevel asc")
		while not BrowPopObj.eof
		%>
            <option value="<%=BrowPopObj("PopLevel")%>" <%if BrowPop <> "" And IsNull(BrowPop) = False then if BrowPop = Cint(BrowPopObj("PopLevel")) then Response.Write("selected") end if end if%>><%=BrowPopObj("Name")%></option>
            <%
			BrowPopObj.Movenext
		Wend
		BrowPopObj.Close
		Set BrowPopObj = Nothing
		%>
          </select></td>
      </tr>
      <tr> 
        <td><div align="center">扩展名</div></td>
        <td nowrap><select name="FileExtName" style="width:100%;">
            <option value="htm" <%if FileExtName = "htm" then Response.Write("selected")%>>htm</option>
            <option value="html" <%if FileExtName = "html" then Response.Write("selected")%>>html</option>
            <option value="shtml" <%if FileExtName = "shtml" then Response.Write("selected")%>>shtml</option>
            <option value="asp" <%if FileExtName = "asp" then Response.Write("selected")%>>asp</option>
		  </select></td>
      </tr>
      <tr> 
        <td><div align="center">添加日期</div></td>
        <td nowrap><input readonly value="<% = AddTime %>" type="text" style="width:78%;" name="AddTime"><input type="button" name="Submit3" value="选择日期" onClick="OpenWindowAndSetValue('../Inc/SelectDate.asp',280,120,window,document.ClassForm.AddTime);document.ClassForm.AddTime.focus();"> 
        </td>
      </tr>
      <tr> 
        <td><div align="center">允许投稿</div></td>
        <td nowrap><input onClick="CheckHaveContTF(this);" name="Contribution" HaveContTF="<% = HaveContTF %>" type="checkbox" id="Contribution" value="1" <% if Contribution = 1 then Response.Write("checked") %>></td>
      </tr>
      <tr> 
        <td colspan="2"> 
		<div align="center"> 
                  <input type="button" name="Submitsdf" onClick="OK();" value=" 确 定 ">
                  <input name="Result" type="hidden" id="Result" value="Submit">
                  <input name="ClassID" value="<% = ClassID %>" type="hidden" id="ClassID">
                  <input name="ParentID" value="<% = ParentID %>" type="hidden" id="ParentID">
                  <input type="button" name="Submit2" onClick="window.close();" value=" 取 消 ">
        </div></td>
      </tr>
    </form>
  </table>
</div>
</body>
</html>
<%
Dim Result
Result = Request.Form("Result")
if Result = "Submit" then
	Dim CClass,ReturnCheckInfo
	Set CClass = New ClassClass
	CClass.TForm = Request.Form
	ReturnCheckInfo = CClass.AddAndModifyClass()
	Set CClass = Nothing
	if ReturnCheckInfo = "" then
%>
<script>
dialogArguments.location.reload();
window.close();
</script>
<%
	else
%>
<script>alert('<% = ReturnCheckInfo %>');history.back();</script>
<%
	end if
end if
Set Conn = Nothing
Set RsClassEditObj = Nothing
Set Conn = Nothing
Function Alert(InfoStr)
%>
<script language="JavaScript">
alert('<% = InfoStr %>');
dialogArguments.location.reload();
window.close();
</script>
<%
End Function
%>
<script language="JavaScript">
function CheckHaveContTF(Obj)
{
	if (Obj.HaveContTF=='True')
	{
		alert('此栏目中有投稿，不能修改此属性');
		Obj.checked=true;
	}
}
</script>
<script language="JavaScript">
CheckFileExtName(document.all.BrowPop);
function OK()
{
	if (CheckEnglishStr(document.ClassForm.ClassEName,'英文名称')==true)
	{
		document.ClassForm.submit();
	}
}
function CheckFileExtName(Obj)
{
	if (Obj.value!='')
	{
		for (var i=0;i<document.all.FileExtName.length;i++)
		{
			if (document.all.FileExtName.options(i).value=='asp') document.all.FileExtName.options(i).selected=true;
		}
		document.all.FileExtName.disabled=true;
	}
	else
	{
		document.all.FileExtName.disabled=false;
	}
}
</script>