<!--#include file=conn.asp-->
<!-- #include file="inc/const.asp" -->
<!-- #include file="inc/DvADChar.asp" -->
<%
	Head()
dim admin_flag,Plus_type
admin_flag=",36,"
if not Dvbbs.master or instr(","&session("flag")&",",admin_flag)=0 then
		Errmsg=ErrMsg + "<BR><li>本页面为管理员专用，请<a href=admin_index.asp target=_top>登录</a>后进入。<br><li>您没有管理本页面的权限。"
		dvbbs_error()
	Else
		call main()
		Footer()
	End if

	sub main()
if request("action")="save" then
call savenew()
elseif request("action")="savedit" then
call savedit()
elseif request("action")="del" then
call del()
else
call gradeinfo()
end if
end sub

sub gradeinfo()
dim trs
Dim PSetting
%>
<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
<tr><th width="100%" class="tableHeaderText" colspan=2>论坛菜单管理
</th>
</tr>
<tr>
<td height="23" colspan="2" class=forumrow>注意：这里所添加内容将自动显示于论坛前台的顶部菜单</td>
</tr>
<%if request("action")="edit" then%>
<%
Set tRs=Dvbbs.Execute("Select * From Dv_Plus Where id="&request("id")&"")
PSetting=Split(tRs("Plus_Setting"),"|")
%>
<tr>
<th height="23" colspan="2" class="tableHeaderText">编辑菜单 | <a href="admin_plus.asp">新建菜单</a></th>
</tr>
<FORM METHOD=POST ACTION="?action=savedit">
<input type=hidden value="<%=trs("id")%>" name="id">
<tr>
<td height="23" colspan="2" class=forumrow>
标题： <input type=text size=50 name="title" value="<%=Server.HtmlEncode(tRs("Plus_name"))%>"> 可用HTML语法
</td></tr>
<tr>
<td height="23" colspan="2" class=forumrow>
分类：
<Select Name="stype" size=1>
<%
Set Rs=Dvbbs.Execute("Select * From Dv_Plus Where Plus_type='0'")
If Rs.Eof And Rs.bof Then
	Response.Write "<option value=0>作为一级菜单</option>"
Else
	If Isnull(tRs("Plus_type")) Or Not Isnumeric(tRs("Plus_type")) Then
		Plus_type=0
	Else
		Plus_type=tRs("Plus_type")
	End if
	If CInt(Plus_type)=0 Then
		Response.Write "<option value=0 selected>作为一级菜单</option>"
	Else
		Response.Write "<option value=0>作为一级菜单</option>"
	End If
	Do While Not Rs.Eof
		Response.Write "<option value="&rs("id")
		If Clng(Plus_type)=Rs("ID") Then Response.Write " selected "
		Response.Write ">"&Server.htmlencode(rs("plus_name"))&"</option>"
	Rs.MoveNext
	Loop
End If
%>
</select>
不选择则将做为一级菜单<BR>
</td>
</tr>
<tr>
<td height="23" colspan="2" class=forumrow>
注释：
<input type=text size=50 name="readme" value="<%=server.htmlencode(trs("plus_copyright"))%>"> 显示于链接上的title注释<BR>
</td>
</tr>
<tr>
<td height="23" colspan="2" class=forumrow>
模式：
<select name="windowtype" size="1">
<option value="0" <%If PSetting(0)=0 Then Response.Write "selected"%>>原窗口</option>
<option value="1" <%If PSetting(0)=1 Then Response.Write "selected"%>>新窗口</option>
<option value="2" <%If PSetting(0)=2 Then Response.Write "selected"%>>固定大小窗口</option>
<option value="3" <%If PSetting(0)=3 Then Response.Write "selected"%>>全屏</option>
</select>&nbsp;&nbsp;
窗口宽：<input type=text name="windowwidth" value="<%=PSetting(1)%>" size=5>
&nbsp;&nbsp;
窗口高：<input type=text name="windowheight" value="<%=PSetting(2)%>" size=5>
</td>
</tr>
<tr>
<td height="23" colspan="2" class=forumrow>
链接：
<input type=text size=50 name="url" value="<%=server.htmlencode(trs("mainpage"))%>"> <BR>
</td>
</tr>
<tr>
<td height="23" colspan="2" class=forumrowHighLight>
<input type=submit name=submit value="提交">
</td></tr>
</FORM>
<%else%>
<tr>
<th height="23" colspan="2">添加菜单</th>
</tr>
<FORM METHOD=POST ACTION="?action=save">
<tr>
<td height="23" colspan="2" class=forumrow>
标题： <input type=text size=50 name="title"> 可用HTML语法
</td></tr>
<tr>
<td height="23" colspan="2" class=forumrow>
分类：
<Select Name="stype" size=1>
<%
Set Rs=Dvbbs.Execute("Select * From Dv_Plus Where Plus_type='0'")
If Rs.Eof And Rs.bof Then
	Response.Write "<option value=0>作为一级菜单</option>"
Else
	Response.Write "<option value=0>作为一级菜单</option>"
	Do While Not Rs.Eof
		Response.Write "<option value="&rs("id")&">"&Server.htmlencode(rs("plus_name"))&"</option>"
	Rs.MoveNext
	Loop
End If
%>
</select>
不选择则将做为一级菜单<BR>
</td>
</tr>
<tr>
<td height="23" colspan="2" class=forumrow>
注释：
<input type=text size=50 name="readme"> 显示于链接上的title注释<BR>
</td>
</tr>
<tr>
<td height="23" colspan="2" class=forumrow>
模式：
<select name="windowtype" size="1">
<option value="0">原窗口</option>
<option value="1">新窗口</option>
<option value="2">固定大小窗口</option>
<option value="3">全屏</option>
</select>&nbsp;&nbsp;
窗口宽：<input type=text name="windowwidth" value=0 size=5>
&nbsp;&nbsp;
窗口高：<input type=text name="windowheight" value=0 size=5>
</td>
</tr>
<tr>
<td height="23" colspan="2" class=forumrow>
链接：
<input type=text size=50 name="url"> <BR>
</td>
</tr>
<tr>
<td height="23" colspan="2" class=forumrowHighLight>
<input type=submit name=submit value="提交">
</td></tr>
</FORM>
<%end if%>
</table><BR>
<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
<tr>
<th height="23">标题</th>
<th>分类</th>
<th>窗口属性</th>
<th>是否使用</th>
<th>操作</th>
</tr>
<%
Set Rs=Dvbbs.Execute("Select * From Dv_Plus Order by ID Desc")
Do While Not Rs.Eof
PSetting=Split(Rs("Plus_Setting"),"|")
%>
<tr>
<td height="23" class=forumrow><%=Rs("Plus_Name")%></td>
<td class=forumrow>
<%
If Isnull(Rs("Plus_type")) Or Not Isnumeric(Rs("Plus_type")) Then
	Plus_type=0
Else
	Plus_type=Cint(Rs("Plus_type"))
End If
If Plus_type=0 Then
	Response.Write "一级菜单"
Else
	Set tRs=Dvbbs.Execute("Select * From Dv_Plus Where id="&Rs("Plus_Type")&"")
	If tRs.Eof And tRs.Bof Then
		Response.Write "该菜单分类有误，请编辑修正"
	Else
		Response.Write tRs("Plus_name")
	End If
End If
Response.Write "</td><td class=forumrow>"

Select Case PSetting(0)
Case 0
	Response.Write "当前窗口"
Case 1
	Response.Write "新窗口"
Case 2
	Response.Write "固定大小窗口，宽"&PSetting(1)&"，高 "&PSetting(2)&""
Case 3
	Response.Write "全屏"
End Select
%>
</td>
<td class=forumrow align=center><%If Rs("isuse")=1 Then%>Yes<%Else%>No<%End If%></td>
<td class=forumrow align=center><a href="?action=edit&id=<%=rs("id")%>">编辑</a> | <a href="?action=del&id=<%=rs("id")%>">删除</a></td>
</tr>
<%
Rs.MoveNext
Loop
Set Rs=Nothing
end sub

sub savenew()
	if request("title")="" then
	Response.Write "请输入菜单的标题！"
	exit sub
	end if
	set rs=server.createobject("adodb.recordset")
	sql="select * from dv_plus"
	rs.open sql,conn,1,3
	rs.addnew
	rs("plus_type")=request("stype")
	rs("plus_name")=replace(request("title"),CHR(34),"")
	rs("isuse")=1
	rs("IsShowMenu")=1
	rs("Mainpage")=replace(request("url"),CHR(34),"")
	rs("plus_Copyright")=replace(request("readme"),CHR(34),"")
	rs("Plus_Setting")=request("windowtype") & "|" & request("windowwidth") & "|" & request("windowheight")
	rs.update
	rs.close
	set rs=nothing
	dv_suc("新建论坛菜单成功")
	DelForumPlusMenuCache
end sub
sub savedit()
	if request("title")="" then
	Response.Write "请输入菜单的标题！"
	exit sub
	end if
	set rs=server.createobject("adodb.recordset")
	sql="select * from dv_plus where id="&request("id")&""
	rs.open sql,conn,1,3
	rs("plus_type")=request("stype")
	rs("plus_name")=replace(request("title"),CHR(34),"")
	rs("isuse")=1
	rs("IsShowMenu")=1
	rs("Mainpage")=replace(request("url"),CHR(34),"")
	rs("plus_Copyright")=replace(request("readme"),CHR(34),"")
	rs("Plus_Setting")=request("windowtype") & "|" & request("windowwidth") & "|" & request("windowheight")
	rs.update
	rs.close
	set rs=nothing
	dv_suc("修改论坛菜单成功")
	DelForumPlusMenuCache
end sub


sub del()
	Dvbbs.Execute("Delete From Dv_Plus Where ID="&Request("id")&"")
	dv_suc("删除论坛菜单成功")
	DelForumPlusMenuCache
end Sub
Sub DelForumPlusMenuCache()
	Dim Templateslist
	Dvbbs.Name="Templateslist"
	If Dvbbs.ObjIsEmpty() Then  Dvbbs.ReloadTemplateslist()
	Templateslist= Dvbbs.Value
	Templateslist=split(Templateslist,"@@@")
	Dim i
	For i=0 to UBound(Templateslist)
		Templateslist(i)=split(Templateslist(i),"|||")
		Dvbbs.DelCahe("ForumPlusMenu"&Templateslist(i)(0))
	Next
End Sub 
%>