📄 admin_linkclass.asp
字号:
else
ClassID=Cint(ClassID)
end if
if MoveNum="" then
FoundErr=true
ErrMsg=ErrMsg & "<br /><li>错误参数!</li>"
exit sub
else
MoveNum=Cint(MoveNum)
if MoveNum=0 then
FoundErr=True
ErrMsg=ErrMsg & "<br /><li>请选择要下降的数字!</li>"
exit sub
end if
end if
dim oldorders,ii,trs,tOrderID
'要移动的栏目信息
set rs=Cl.Execute("select ParentID,OrderID,ParentPath,child,PrevID,NextID From Cl_LinkClass where ClassID="&ClassID)
ParentID=rs(0)
OrderID=rs(1)
ParentPath=rs(2) & "," & ClassID
child=rs(3)
PrevID=rs(4)
NextID=rs(5)
rs.close
set rs=Nothing
'先修改上一栏目的NextID和下一栏目的PrevID
if PrevID>0 then
Cl.Execute "Update Cl_LinkClass set NextID=" & NextID & " where ClassID=" & PrevID
end if
if NextID>0 then
Cl.Execute "Update Cl_LinkClass set PrevID=" & PrevID & " where ClassID=" & NextID
end if
'和该栏目同级且排序在其之下的栏目------更新其排序,范围为要下降的数字
sql="select ClassID,OrderID,child,ParentPath,PrevID,NextID From Cl_LinkClass where ParentID="&ParentID&" and OrderID>"&OrderID&" order by OrderID"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,Conn,1,3
i=0 '同级栏目
ii=0 '同级栏目和子栏目
do while not rs.eof
Cl.Execute("Update Cl_LinkClass set OrderID="&OrderID+ii&" where ClassID="&rs(0))
if rs(2)>0 then
set trs=Cl.Execute("select ClassID,OrderID From Cl_LinkClass where ParentPath like '%"&rs(3)&","&rs(0)&"%' order by OrderID")
if not (trs.eof and trs.bof) then
do while not trs.eof
ii=ii+1
Cl.Execute("Update Cl_LinkClass set OrderID="&OrderID+ii&" where ClassID="&trs(0))
trs.movenext
loop
end if
trs.close
set trs=Nothing
end if
ii=ii+1
i=i+1
if i>=MoveNum then
Cl.Execute("Update Cl_LinkClass set NextID=" & ClassID & " where ClassID=" & rs(0))
Cl.Execute("Update Cl_LinkClass set PrevID=" & rs(0) & " where ClassID=" & ClassID)
exit do
end if
rs.movenext
loop
rs.movenext
if rs.eof then
Cl.Execute("Update Cl_LinkClass set NextID=0 where ClassID=" & ClassID)
else
Cl.Execute("Update Cl_LinkClass set PrevID=" & ClassID & " where ClassID=" & rs(0))
Cl.Execute("Update Cl_LinkClass set NextID=" & rs(0) & " where ClassID=" & ClassID)
end if
rs.close
set rs=Nothing
'更新所要排序的栏目的序号
Cl.Execute("Update Cl_LinkClass set OrderID="&OrderID+ii&" where ClassID="&ClassID)
'如果有下属栏目,则更新其下属栏目排序
if child>0 then
i=1
set rs=Cl.Execute("select ClassID From Cl_LinkClass where ParentPath like '%"&ParentPath&"%' order by OrderID")
do while not rs.eof
Cl.Execute("Update Cl_LinkClass set OrderID="&OrderID+ii+i&" where ClassID="&rs(0))
i=i+1
rs.movenext
loop
rs.close
set rs=Nothing
end if
Cl.SaveAdminLog
response.Redirect FileName & "?Action=OrderN"
end sub
sub SaveReset()
dim SuccessMsg,iCount,PrevID,NextID
sql="select ClassID From Cl_LinkClass order by RootID,OrderID"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,Conn,1,1
iCount=rs.recordcount
i=1
PrevID=0
do while not rs.eof
rs.movenext
if rs.eof then
NextID=0
else
NextID=rs(0)
end if
rs.moveprevious
Cl.Execute("Update Cl_LinkClass set RootID=" & i & ",OrderID=0,ParentID=0,Child=0,ParentPath='0',Depth=0,PrevID=" & PrevID & ",NextID=" & NextID & " where ClassID=" & rs(0))
PrevID=rs(0)
i=i+1
rs.movenext
loop
rs.close
set rs=Nothing
Cl.SaveAdminLog
Call Cl.ShowSuc("复位成功!请返回 <a href='"&FileName&"'>栏目管理首页</a> 做栏目的归属设置。")
end sub
sub SaveUnite()
dim ClassID,TargetClassID,ParentPath,iParentPath,Depth,iParentID,Child,PrevID,NextID
dim rs,trs,SuccessMsg
ClassID=Trim(request("ClassID"))
TargetClassID=Trim(request("TargetClassID"))
if ClassID="" then
FoundErr=True
ErrMsg=ErrMsg & "<br /><li>请指定要合并的栏目!</li>"
else
ClassID=CLng(ClassID)
end if
if TargetClassID="" then
FoundErr=True
ErrMsg=ErrMsg & "<br /><li>请指定目标栏目!</li>"
else
TargetClassID=CLng(TargetClassID)
end if
if ClassID=TargetClassID then
FoundErr=True
ErrMsg=ErrMsg & "<br /><li>请不要在相同栏目内进行操作</li>"
end if
if FoundErr=True then
exit sub
end if
'判断目标栏目是否有子栏目,如果有,则报错。
set rs=Cl.Execute("select Child from Cl_LinkClass where ClassID=" & TargetClassID)
if rs.bof and rs.eof then
FoundErr=True
ErrMsg=ErrMsg & "<br /><li>目标栏目不存在,可能已经被删除!</li>"
else
if rs(0)>0 then
FoundErr=True
ErrMsg=ErrMsg & "<br /><li>目标栏目中含有子栏目,不能合并!</li>"
end if
end if
if FoundErr=True then
exit sub
end if
'得到当前栏目信息
set rs=Cl.Execute("select ClassID,ParentID,ParentPath,PrevID,NextID,Depth from Cl_LinkClass where ClassID="&ClassID)
iParentID=rs(1)
Depth=rs(5)
if iParentID=0 then
ParentPath=rs(0)
else
ParentPath=rs(2) & "," & rs(0)
end if
iParentPath=rs(0)
PrevID=rs(3)
NextID=rs(4)
'判断是否是合并到其下属栏目中
set rs=Cl.Execute("select ClassID from Cl_LinkClass where ClassID="&TargetClassID&" and ParentPath like '"&ParentPath&"%'")
if not (rs.eof and rs.bof) then
FoundErr=true
ErrMsg=ErrMsg & "<br /><li>不能将一个栏目合并到其下属子栏目中</li>"
exit sub
end if
'得到当前栏目的下属栏目ID
set rs=Cl.Execute("select ClassID from Cl_LinkClass where ParentPath like '"&ParentPath&"%'")
i=0
if not (rs.eof and rs.bof) then
do while not rs.eof
iParentPath=iParentPath & "," & rs(0)
i=i+1
rs.movenext
loop
end if
if i>0 then
ParentPath=iParentPath
else
ParentPath=ClassID
end if
'先修改上一栏目的NextID和下一栏目的PrevID
if PrevID>0 then
Cl.Execute "Update Cl_LinkClass set NextID=" & NextID & " where ClassID=" & PrevID
end if
if NextID>0 then
Cl.Execute "Update Cl_LinkClass set PrevID=" & PrevID & " where ClassID=" & NextID
end if
'更新数据及评论所属栏目
Cl.Execute("Update Cl_LinkSite set ClassID="&TargetClassID&" where ClassID in ("&ParentPath&")")
'删除被合并栏目及其下属栏目
Cl.Execute("delete from Cl_LinkClass where ClassID in ("&ParentPath&")")
'更新其原来所属栏目的子栏目数,排序相当于剪枝而不需考虑
if Depth>0 then
Cl.Execute("Update Cl_LinkClass set Child=Child-1 where ClassID="&iParentID)
end if
Cl.SaveAdminLog
SuccessMsg="栏目合并成功!已经将被合并栏目及其下属子栏目的所有数据转入目标栏目中。<br /><br />同时删除了被合并的栏目及其子栏目。"
Call Cl.ShowSuc(SuccessMsg)
set rs=Nothing
set trs=Nothing
end sub
sub UpDateClassData()
dim rs,arrChildID,trs,TempClassDir,TempPath,ParentDir,sOuter
dim arrParentID(20),arrParentDir(20),arrPrevID(20),arrNextID(20)
Dim sClassID
set rs=server.createobject("adodb.recordset")
rs.open "select * from Cl_LinkClass order by RootID Desc,OrderID Desc",Conn,1,3
if rs.bof and rs.eof then
rs.Close:Set rs=Nothing
Exit Sub
end if
for i=0 to 19
arrParentID(i)=0
arrParentDir(i)=""
arrPrevID(i)=0
arrNextID(i)=0
next
do while not rs.eof
sClassID=rs("ClassID")
arrParentID(rs("Depth"))=sClassID
arrParentDir(rs("Depth"))=rs("ClassDir")
if rs("ParentID")=0 then
rs("ParentPath")="0"
rs("ParentDir")="/"
else
ParentPath="0"
ParentDir="/"
for i=0 to rs("Depth")-1
ParentPath=ParentPath & "," & arrParentID(i)
ParentDir=ParentDir & arrParentDir(i) & "/"
next
rs("ParentPath")=ParentPath
rs("ParentDir")=ParentDir
end if
if rs("PrevID")<>0 then
rs("PrevID")=arrPrevID(rs("Depth"))
end if
rs("NextID")=0
if arrNextID(rs("Depth"))>0 then
Cl.Execute("update Cl_LinkClass set NextID=" & sClassID & " where ClassID=" & arrPrevID(rs("Depth")))
end if
arrPrevID(rs("Depth"))=sClassID
arrNextID(rs("Depth"))=rs("NextID")
rs.update
rs.movenext
loop
rs.movefirst
do while not rs.eof
if rs("Child")=0 then
rs("arrChildID")=rs("ClassID")
else
arrChildID=rs("ClassID")
set trs=Cl.Execute("select ClassID from Cl_LinkClass where (ParentID=" & rs("ClassID") & " or ParentPath like '%" & rs("ParentPath") & "," & rs("ClassID") & ",%')")
do while not trs.eof
arrChildID=arrChildID & "," & trs(0)
trs.movenext
loop
set trs=Nothing
rs("arrChildID")=arrChildID
end if
rs.update
rs.movenext
loop
rs.Close:Set rs=Nothing
end sub
Function ShowLinkClass_Option(ShowType,CurrentID)
dim rsClass,sqlClass,strTemp,tmpDepth,i
if ShowType=0 then
strTemp="<option value='0'"
if CurrentID=0 then strTemp=strTemp & " selected"
strTemp=strTemp & ">无(作为一级栏目)</option>"
end if
dim arrShowLine(20)
for i=0 to ubound(arrShowLine)
arrShowLine(i)=False
next
sqlClass="Select * From Cl_LinkClass order by RootID,OrderID"
set rsClass=Cl.Execute(sqlClass)
'rsClass.open sqlClass,Conn,1,1
if rsClass.bof and rsClass.eof then
strTemp=strTemp & "<option value=''>请先添加栏目</option>"
else
do while not rsClass.eof
tmpDepth=rsClass("Depth")
if rsClass("NextID")>0 then
arrShowLine(tmpDepth)=True
else
arrShowLine(tmpDepth)=False
end if
if ShowType=2 then
strTemp=strTemp & "<option value='" & rsClass("ClassID") & "'"
else
strTemp=strTemp & "<option value='" & rsClass("ClassID") & "'"
end if
if CurrentID>0 and rsClass("ClassID")=CurrentID then
strTemp=strTemp & " selected"
end if
strTemp=strTemp & ">"
if tmpDepth>0 then
for i=1 to tmpDepth
strTemp=strTemp & " "
if i=tmpDepth then
if rsClass("NextID")>0 then
strTemp=strTemp & "├ "
else
strTemp=strTemp & "└ "
end if
else
if arrShowLine(i)=True then
strTemp=strTemp & "│"
else
strTemp=strTemp & " "
end if
end if
next
end if
strTemp=strTemp & rsClass("ClassName")
strTemp=strTemp & "</option>"
'response.write strTemp
rsClass.movenext
loop
end if
rsClass.close:set rsClass=Nothing
ShowLinkClass_Option=strTemp
End Function
%>
<%
'<!--
'┌───────────────────────────────────────────────────────┐
'│ │
'│ CreateLive CMS Version 4.0 │
'│ Powered by Aspoo.CN │
'│ │
'│ 邮箱: support@aspoo.cn Info@aspoo.cn │
'│ QQ: 3315263 596197794 │
'│ 网站: www.aspoo.cn www.aspoo.com │
'│ 论坛: bbs.aspoo.cn bbs.aspoo.com │
'│ │
'│ Copyright (C) 2005-2007 Aspoo.CN All Rights Reserved. │
'└───────────────────────────────────────────────────────┘
'-->
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -