<!--#include file="../inc/config.asp" -->
<!--#include file="../inc/conn.asp" -->
<!-- #include file="inc/Session.asp" -->
<!--#include file="inc/function.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p01")
'''''''''''''''''''''''''''''''''''''''''''''''
Dim act,CatalogId,ParID,CatalogName,ParentName,rs,G_templet,G_savedir,iscatalog,modiTime,ReturnCheckInfo,domainurl,c_keywords,c_desc,sortid
if not isempty(request("ClassId")) then
	CatalogId=Clng(request("ClassId"))
else
	response.Write("<script>alert(""错误的ID号"");</script>")
	response.End()
end if
act = Request("act")
if(act<>"mod") then
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from catalogs where id="&CatalogId,conn,3,1
	if rs.eof or rs.bof then
		CatalogName = "栏目不存在，请重新加载"
		response.End()
	else
		CatalogName = rs("title")
		ParID =rs("parentid")
		G_templet=rs("templet")
		G_savedir=rs("savedir")
		domainurl=rs("domainurl")
		iscatalog=rs("flag")
		modiTime=rs("moditime")
		c_keywords=rs("keywords")
		c_desc=rs("description")
		sortid=rs("sortid")
	end if
	rs.close
	Set rs = Nothing
	ParentName=getCatalogName(ParID)
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>栏目修改</title>
<style type="text/css">
<!--
.style1 {color: #FFFFFF;
	font-weight: bold;
}
-->
</style>
</head>
<link href="Class.css" rel="stylesheet">
<script language="JavaScript" src="../js/PublicJS.js"></script>
<script type="text/javascript">
function check(obj)
{
	if(obj.CatalogName.value==""){
		alert("栏目名称不能为空!");
		obj.CatalogName.focus();
		obj.CatalogName.select();
		return false;
	}
	if(obj.CatalogTemplate.value==""){
		alert("栏目模板不能为空!");
		obj.CatalogTemplate.focus();
		obj.CatalogTemplate.select();
		return false;
	}
	if(obj.SavePathType.value==0 && obj.SaveFilePath.value==""){
		alert("栏目保存路径不能为空!");
		obj.SaveFilePath.focus();
		obj.SaveFilePath.select();
		return false;
	}
}
function $(id) {
	return document.getElementById(id);
}
function resizeup(obj) {
	var newheight = parseInt($(obj).style.height, 10) + 50;
	$(obj).style.height = newheight + 'px';
}
function resizedown(obj) {
	var newheight = parseInt($(obj).style.height, 10) - 50;
	if(newheight > 0) {
		$(obj).style.height = newheight + 'px';
	}
}
</script>
<body>
<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>
<table width="100%" height="22"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FF9900" style="border-left:1px solid #000000;border-right:1px solid #000000;border-top:1px solid #000000;">
  <tr>
    <td><div align="center" class="style1">修改栏目</div></td>
  </tr>
</table>
<table width="98%" border="0" cellspacing="5" cellpadding="0" style="border:1px solid #000000; ">
    <form action="?act=mod" 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="<%=CatalogName %>" name="CatalogName" type="text" id="CatalogName" style="width:100%;">
          </div></td>
      </tr>
      <tr> 
        <td><div align="center">父 栏 目</div></td>
        <td>  
		  <div align="left">
		    <select name="parent_id" >
		    <%			
			if(ParID=0) then
				response.Write("<option value=""0"">根目录</option>")
			else
				response.Write("<option value="&ParID&">"&ParentName&"</option>"&Chr(10))    		
			end if
			%>
	        </select>&nbsp;&nbsp;<a href="#" onClick="addParentOption();">＋</a>            
          </div></td>
      </tr>
      <tr> 
        <td><div align="center">栏目模板</div></td>
        <td nowrap> <div align="left"> 
            <input name="CatalogTemplate" type="text" style="width:78%;" value="<%=G_templet%>"><input type="button" name="Submit" value="选择模板" onClick="OpenWindowAndSetValue('Inc/SelectFileFrame.asp?CurrPath=<%=TempletDir %>',400,300,window,document.ClassForm.CatalogTemplate);document.ClassForm.CatalogTemplate.focus();">
            <input type="button" name="t_edit" value="编辑" onClick="location.href='file_mod.asp?file=<%=server.URLEncode(server.mappath(G_templet))%>'" />
          </div></td>
      </tr>
      <tr> 
        <td><div align="center">保存路径</div></td>
        <td nowrap> <div align="left"> 
            <input value="<%=G_savedir%>" type="text" style="width:78%;" name="CatalogSavePath"><input type="button" name="Submit" value="选择路径" onClick="OpenWindowAndSetValue('Inc/SelectPathFrame.asp?CurrPath=<%=WebRootDir%>',400,300,window,document.ClassForm.CatalogSavePath);document.ClassForm.CatalogSavePath.focus();">
          </div></td>
      </tr>
      <tr>
        <td><div align="center">添加日期</div></td>
        <td><div align="left">
            <input readonly value="<%If modiTime="" then Response.Write(Now()) else Response.Write(modiTime) %>" type="text" style="width:77%;" name="AddTime"><input name="sdaf" type="button" id="sdaf" onClick="OpenWindowAndSetValue('Inc/SelectDate.asp',280,120,window,document.ClassForm.AddTime);document.ClassForm.AddTime.focus();" value="选择日期">
        </div></td>
      </tr>
      <tr>
        <td><div align="center">是否频道</div></td>
        <td><input name="iscatalog" type="checkbox" id="iscatalog" value="1" <%if(iscatalog=1) then response.Write("checked") end if%>></td>
      </tr>
	  <tr id="domainset">
        <td><div align="center">域名或栏目链接地址</div></td>
        <td><input name="domainurl" type="text" id="domainurl" size="30" value="<%=domainurl%>">
        <input type="button" name="Submit3" value="同保存路径" onClick="this.form.domainurl.value=this.form.CatalogSavePath.value"></td>
      </tr>
	  <tr>
        <td><div align="center">栏目关键词</div></td>
        <td><textarea style="width:100%; height:50px;" name="keywords" id="keywords"><%=c_keywords%></textarea><B><A onClick="resizeup('keywords');" href="###">[+]</A> 
<A onClick="resizedown('keywords');" href="###">[-]</A></B></td>
      </tr>
	  <tr>
        <td><div align="center">栏目描述</div></td>
        <td><textarea style="width:100%; height:50px;" name="description" id="description"><%=c_desc%></textarea><B><A onClick="resizeup('description');" href="###">[+]</A> 
<A onClick="resizedown('description');" href="###">[-]</A></B></td>
      </tr>
	  <tr>
        <td><div align="center">栏目排序</div></td>
        <td><input type="text" name="sortid" value="<%=sortid%>" /></td>
      </tr>
      <tr> 
        <td colspan="2">
		<div align="center"> 
                  <input type="Submit" name="Submit" onClick="check(document.ClassForm);" value=" 确 定 ">                  
                  <input name="ClassId" value="<%=CatalogId %>" type="hidden" id="ClassId">                  
                  <input type="button" name="Submit2" onClick="history.back();" value=" 返 回">
        </div></td>
      </tr>
    </form>
  </table>
</body>
</html>
<%
end if
if act = "mod" then	
	CatalogName=request.Form("CatalogName")
	parent_id=Cint(request.Form("parent_id")	)
	AddTime=request.Form("AddTime")
	CatalogTemplate=request.Form("CatalogTemplate")
	SaveDir=request.Form("CatalogSavePath")
	if(CatalogName="") then
		response.Write("<script>alert('类别名称不能为空!');</script>")
		response.End()
	end if	
	iscatalog=Cint(request.Form("iscatalog"))
	domainurl=request.form("domainurl")
	c_keywords=request.Form("keywords")
	c_desc=request.Form("description")
	sortid=Cint(request.Form("sortid"))
	if(domainurl="" or len(domainurl)<1) then
		domainurl=SiteUrl&SaveDir
	end if
	ReturnCheckInfo =ModifyClass(CatalogId,parent_id,CatalogName,iscatalog,AddTime,CatalogTemplate,SaveDir,domainurl,c_keywords,c_desc,sortid)
	if (ReturnCheckInfo =true) then
		response.Write("<script>location.href=""tree.asp?CatalogId=0"";</script>")
	else
		response.Write("<script>alert('修改类别时出错！');history.back();</script>")
	end if
end if
%>
<script language="JavaScript">
function check(obj)
{
	if(obj.CatalogName.value==""){
		alert("类别名称不能为空!");
		obj.CatalogName.select();
		obj.CatalogName.focus();
		return false;
	}
	if(obj.CatalogTemplate.value==""){
		alert("栏目模板不能为空!");
		obj.CatalogTemplate.select();
		obj.CatalogTemplate.focus();
		return false;
	}
	if(obj.CatalogSavePath.value==""){
		alert("保存路径不能为空!");
		obj.CatalogSavePath.select();
		obj.CatalogSavePath.focus();
		return false;
	}	
	return true;
}
function checkDomain(){
	if(document.ClassForm.iscatalog.checked==true){
		document.getElementById('domainset').style.display='';
	}else{
		document.ClassForm.domainurl.value='';
		document.getElementById('domainset').style.display='none';
	}
}
function addParentOption()
{
	var arr = showModalDialog("tree_container.asp", "", "dialogWidth:410px; dialogHeight:420px; status:0");
  	if (arr != null){  
   		document.ClassForm.parent_id.options[0]=new Option(arr[1],arr[0]);
  	}
	
}
</script>
<%
call connclose()
Function ModifyClass(CatalogId,ParentID,CatalogName,IsCatalog,AddTime,CatalogTemplate,SaveDir,DomainUrl,KeyWords,Desc,SortId)
	on error resume next
	dim rs
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from catalogs where id="&CatalogId,conn,3,3
	if not rs.eof then
		rs("parentid")=ParentID
		rs("title")=CatalogName
		rs("flag")=IsCatalog
		rs("moditime")=AddTime
		rs("templet")=CatalogTemplate
		rs("savedir")=SaveDir
		rs("domainurl")=domainurl
		rs("keywords")=KeyWords
		rs("description")=Desc
		rs("sortid")=sortid
		rs.update
	else
		response.Write("error,没有找到ID为"&CatalogId&"的栏目")
	end if
	rs.close
	set rs=nothing
	if Err.Number <> 0 then
		ModifyClass=false
	else
		ModifyClass=true
	end if
end Function
%>