<!--#include file="setup.asp"-->
<%
NC_Admin.AdminChk="52"
NC_Admin.Check
DownsysClass.admin_header 
%>
<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
<tr> 
<th width="100%" class="tableHeaderText" colspan=2 height=25>网站栏目管理</th>
</tr>
<tr>
<td class="forumrow" colspan=2>
<p><B>注意</B>：<BR>①添加网站栏目连接URL,请用绝对路径,如:http://www.DownsysClass.net/index.htm<BR>
②修改删除栏目请点击相应的名称可以对其操作<BR>
③JS文件名称：顶部TopMeun.js 底部FootMeun.js 其它PlusMeun.js<BR>
④JS文件调用方法：&lt;SCRIPT LANGUAGE=JavaScript src=<%=DownsysClass.SetupDir%>js/*.js&gt;&lt;/SCRIPT&gt;</p>
</td>
</tr>
<tr>
<td class="forumrow">
<B>操作选项</B></td>
<td class="forumrow"><a href="admin_plusmenu.asp">栏目管理首页</a> | <a href="admin_plusmenu.asp?typeid=0">顶部栏目管理</a> | <a href="admin_plusmenu.asp?typeid=1">底部栏目管理</a> | <a href="admin_plusmenu.asp?action=add">添加新的栏目</a> | <a href="admin_plusmenu.asp?action=make">生成栏目JS文件</a> 
</td>
</tr>
</table>
<%
dim isEdit,plusTitle
dim plusname,readme,plusurl,isBlank,typeid,compart 
set rs = server.CreateObject ("Adodb.recordset")
select case trim(request("action"))
case "save"
		call savemenu()
case "modify"  
		call savemodify()
case "add"
		call plusmenu()
case "edit"
		isEdit=True
		call plusmenu()
case "del"
		call delmenu()
case "make"
		call MakePlusMeun()
case else               
		call main()
end select 
if FoundErr=True then
	NC_Admin.Error_Msg(ErrMsg)
end if
DownsysClass.admin_footer
NothingObject
Sub main()

%>
<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
<tr> 
<th nowrap>网站栏目名称</th><th>连接URL</th><th nowrap>打开窗口</th><th nowrap>栏目位置</th><th nowrap>栏目管理操作</th>
</tr>
<%
	if request("typeid")<>"" then
      		rs.open "select * from NC_plus where typeid="&cint(request("typeid"))&" order by id",conn,1,1 
   	else
      		rs.open "select * from NC_plus order by id",conn,1,1 
   	end if
         if rs.bof and rs.eof then
		        response.write  "<tr><td colspan=5 class=forumrow>还没有找到任何栏目！</td></tr>"
	           else
	'if not(rs.bof and rs.eof) then
		do while not rs.eof 
%>
<tr>
<td class="forumrow"><%=rs("plusname")%></td>
<td class="forumrow"><%=rs("plusurl")%></td>
<td class="forumrow" align=center><%if rs("isBlank")=1 then %>新窗口<%else%>本窗口<%end if%></td>
<td class="forumrow" align=center><%if rs("typeid")=1 then %>底部<%else%>顶部<%end if%></td>
<td class="forumrow" align=center><a href="admin_plusmenu.asp?action=edit&id=<%=rs("id")%>">编 辑</a> | <a href="admin_plusmenu.asp?action=del&id=<%=rs("id")%>" onclick="{if(confirm('此操作将删除本栏目\n 您确定执行的操作吗?')){this.document.myform.submit();return true;}return false;}">删 除</a></td>
</tr>
<%
	rs.movenext
	loop
	end if
	rs.close
		set rs=nothing
%>
</table>
<BR>
<%
end sub
sub plusmenu()
	if isEdit then
		sql="select * from [NC_plus] where id="&request("id")
		rs.open sql,conn,1,1 
		plusTitle="编辑网站栏目"
       else
		plusTitle="添加网站栏目"
       end if
%>
<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
<tr> 
<th width="100%" class="tableHeaderText" colspan=2 height=25><%=plusTitle%></th>
</tr>
 <form name=myform action ="admin_plusmenu.asp" method=post>
          <input type="Hidden" name="action" value='<% If isedit then%>modify<%Else%>save<% End If %>'>
          <%If isedit then%>
          <input type="Hidden" name="id" value='<%=cstr(request("id"))%>'>
          <%End If%>
<tr>
<td class="forumrow" width="30%">栏目名称:</td>
<td class="forumrow" width="70%"><input name="plusname" size="30" value="<%If isedit then%><%= rs("plusname")%><% end if%>"></td>
</tr>
<tr>
<td class="forumrow">栏目说明:</td>
<td class="forumrow"><textarea name="readme" cols="50" class="tableBorder" rows="3"><%If isedit then%><%= rs("readme")%><% end if%></textarea></td>
</tr>
<tr>
<td class="forumrow">连接URL:</td>
<td class="forumrow"><input name="plusurl" size="50" value="<%If isedit then%><%= rs("plusurl")%><%else%><%=DownsysClass.setting(1)%><% end if%>"></td>
</tr>
<tr>
<td class="forumrow">分隔符:<BR>显示在栏目名称前面</td>
<td class="forumrow"><input name="compart" size="40" value="<%If isedit then%><%= rs("compart")%><%else%>|<% end if%>">
<BR>可以用图片如:&lt;img src="images/bullet.gif" border=0&gt;</td>
</tr>
<tr>
<td class="forumrow">是否在新窗口中打开:</td>
<td class="forumrow">
<input type=radio name="isBlank" value=0 <%If isedit then%><%if cint(rs("isBlank"))=0 then%>checked<%end if%><%else%>checked<% end if%>>否&nbsp;
<input type=radio name="isBlank" value=1 <%If isedit then%><%if cint(rs("isBlank"))=1 then%>checked<%end if%><% end if%>>是&nbsp;</td>
</tr>
<tr>
<td class="forumrow">显示栏目的位置:</td>
<td class="forumrow">
<input type=radio name="typeid" value=0 <%If isedit then%><%if cint(rs("typeid"))=0 then%>checked<%end if%><%else%>checked<% end if%>>顶部显示&nbsp;
<input type=radio name="typeid" value=1 <%If isedit then%><%if cint(rs("typeid"))=1 then%>checked<%end if%><% end if%>>底部显示&nbsp;
<input type=radio name="typeid" value=2 <%If isedit then%><%if cint(rs("typeid"))=2 then%>checked<%end if%><% end if%>>其它位置&nbsp;</td>
</tr>
<tr>
<td class="forumrow" align=center colspan=2>
<%If isedit then%>
<input type="submit" name="Submit" class="button" value="修改栏目">
<%else%>
<input type="submit" name="Submit" class="button" value="添加栏目">
<%end if%>
</td>
</tr></form>
</table>
<BR>
<%
	if isEdit then
		rs.close
	end if
end sub

sub checksave()
	if Len(request.form("plusname"))=0 then
  		founderr=true
  		errmsg=errmsg+"<li>栏目名称不能为空！</li>"
		Exit Sub
	else
		plusname=request.form("plusname")
	end if
	if Len(request.form("readme")) = 0 then
  		founderr=true
  		errmsg=errmsg+"<li>栏目说明不能为空！</li>"
		Exit Sub
	else
		readme=request.form("readme")
	end if
	if len(request.form("plusname"))>25 then
  		founderr=true
  		errmsg=errmsg+"<li>栏目名称不能多于25个字符！</li>"
		Exit Sub
	end if
	if Len(request.form("plusurl"))=0 then
  		founderr=true
  		errmsg=errmsg+"<li>连接URL不能为空！</li>"
		Exit Sub
	else
		plusurl = request.form("plusurl")
	end if
	isBlank = request.form("isBlank")
	typeid = request.form("typeid")
	compart = request.form("compart")
end sub
sub savemenu()
	call checksave()
	if founderr=False then
	   	   sql="select * from [NC_plus] where (id is null)"
	   	   rs.open sql,conn,1,3
	   	   rs.addnew
	   	   	   rs("plusname")=plusname
	   	   	   rs("readme")=readme
	   	   	   rs("plusurl")=plusurl
	   	   	   rs("isBlank")=isBlank
	   	   	   rs("typeid")=typeid
			   rs("compart")=compart
	   	   rs.update
	   	   rs.close
	   	   NC_Admin.Succeed_Msg("恭喜您！添加网站栏目成功。")
	   	   set rs=nothing
	end if
'end if
end sub

sub savemodify()
	call checksave()
	if founderr=False then
	   	   sql="select * from [NC_plus] where id="&request("id")
	   	   rs.open sql,conn,1,3
	   	   	   rs("plusname")=plusname
	   	   	   rs("readme")=readme
	   	   	   rs("plusurl")=plusurl
	   	   	   rs("isBlank")=isBlank
	   	   	   rs("typeid")=typeid
			   rs("compart")=compart
	   	   rs.update
	   	   rs.close
	   	   NC_Admin.Succeed_Msg("恭喜您！修改网站栏目成功。")
	   	   set rs=nothing
	end if
end sub

sub delmenu()
	conn.execute("delete from NC_plus where id="&request.querystring("id"))
	NC_Admin.Succeed_Msg("您选择的网站栏目已成功删除。")
end sub

Sub MakePlusMeun()
        Dim Rsc, SQLC, strTopMeun, strFootMeun, strPlusMeun, File_Name, FSO, Fout, MakeFile
        Set Rsc = server.CreateObject ("adodb.recordset")
        SQLC = "select * from NC_plus order by id "
        Rsc.Open SQLC, conn, 1, 1
        If Not(Rsc.EOF And Rsc.bof) Then
                Do While Not Rsc.EOF
				if Rsc("typeid") = 0 then
                        if Rsc("isBlank")=1 then
                                isBlank="target=_blank"
                        else
                                isBlank=""
                        end if
                        strTopMeun = strTopMeun & "document.write ("&Chr(34)&" "&Rsc("compart")&" <a href='"&Rsc("plusurl")&"' class='TopMeun' title='"&Rsc("Readme")&"' "&isBlank&">"&Rsc("plusname")&"</a>"&Chr(34)&");"& vbCrLf
				elseif Rsc("typeid") = 1 then
                        if Rsc("isBlank")=1 then
                                isBlank="target=_blank"
                        else
                                isBlank=""
                        end if
                        strFootMeun = strFootMeun & "document.write ("&Chr(34)&" "&Rsc("compart")&" <a href='"&Rsc("plusurl")&"' class='FootMeun' title='"&Rsc("Readme")&"' "&isBlank&">"&Rsc("plusname")&"</a>"&Chr(34)&");"& vbCrLf
				else
                        if Rsc("isBlank")=1 then
                                isBlank="target=_blank"
                        else
                                isBlank=""
                        end if
                        strPlusMeun = strPlusMeun & "document.write ("&Chr(34)&" "&Rsc("compart")&" <a href='"&Rsc("plusurl")&"' title='"&Rsc("Readme")&"' "&isBlank&">"&Rsc("plusname")&"</a>"&Chr(34)&");"& vbCrLf
				end if					
                        Rsc.MoveNext
                Loop
        End If
        Rsc.Close
        Set Rsc = Nothing
        'NavMeun = "document.write ("&Chr(34)&strNavMeun&Chr(34)&");"& vbCrLf
        Set FSO = Server.CreateObject(DownsysClass.Script_FSO)
        File_Name = DownsysClass.SetupDir & "js/TopMeun.js"
        MakeFile = Server.MapPath(File_Name)
        Set Fout = FSO.CreateTextFile(MakeFile)
        Fout.WriteLine strTopMeun
        Fout.Close

        File_Name = DownsysClass.SetupDir & "js/FootMeun.js"
        MakeFile = Server.MapPath(File_Name)
        Set Fout = FSO.CreateTextFile(MakeFile)
        Fout.WriteLine strFootMeun
        Fout.Close

        File_Name = DownsysClass.SetupDir & "js/PlusMeun.js"
        MakeFile = Server.MapPath(File_Name)
        Set Fout = FSO.CreateTextFile(MakeFile)
        Fout.WriteLine strPlusMeun
        Fout.Close

        Set Fout = Nothing
        Set FSO = Nothing
        Response.Write "<script>alert('生成网站栏目JS文件成功！');location.replace('admin_plusmenu.asp')</script>"
End Sub
%>