<%@language=vbscript codepage=936 %> <% option explicit response.buffer=true Const PurviewLevel=2 Const CheckChannelID=0 Const PurviewLevel_Others="Layout" %> <% dim rs, sql dim Action,LayoutID,LayoutType,FoundErr,ErrMsg Action=trim(request("Action")) LayoutID=trim(request("LayoutID")) LayoutType=trim(request("LayoutType")) if LayoutType="" then LayoutType=session("LayoutType") end if if LayoutType="" then LayoutType=2 else LayoutType=CLng(LayoutType) end if session("LayoutType")=LayoutType %> 版面设计模板管理
版 面 设 计 模 板 管 理
管理导航: 添加版面设计模板 | 文章栏目模板 | 文章内容页模板 | 专题文章模板 | 软件栏目模板 | 图片栏目模板
<% select case Action case "Add","Modify" call ShowLayoutSet() case "SaveAdd" call SaveAdd() case "SaveModify" call SaveModify() case "Set" call SetDefault() case "Del" call DelLayout() case else call main() end select if FoundErr=True then call WriteErrMsg() end if call CloseConn() sub main() sql="select * from Layout where LayoutType=" & LayoutType Set rs=Server.CreateObject("Adodb.RecordSet") rs.Open sql,conn,1,1 %>
<% response.write "您现在的位置:版面设计模板管理 >> " select case LayoutType case 2 response.write "文章栏目模板" case 3 response.write "文章内容页模板" case 4 response.write "专题文章模板" case 5 response.write "软件栏目模板" case 6 response.write "图片栏目模板" case else response.write "错误的参数" end select response.write "
" %> <%if not(rs.bof and rs.eof) then do while not rs.EOF %> <% rs.MoveNext loop %> <%end if%>
选择 ID 模板名称 模板文件名 效果图 设计者 模板类型 操作
" <%if rs("IsDefault")=true then response.write " checked"%> name="LayoutID"> <%=rs("LayoutID")%> <%=rs("LayoutName")%> <%=rs("LayoutFileName")%> <%response.write ""%> <%response.write "" & rs("DesignerName") & ""%> <%if rs("DesignType")=1 then response.write "用户自定义" else response.write "系统提供"%> <% response.write "修改模板设置 " if rs("DesignType")=1 and rs("IsDefault")=False then response.write "删除模板" else response.write "        " end if %>
<% rs.close set rs=nothing end sub sub ShowLayoutSet() if Action="Add" then sql="select * from Layout where IsDefault=True and LayoutType=" & LayoutType elseif Action="Modify" then if LayoutID="" then FoundErr=True ErrMsg=ErrMsg & "
  • 请指定LayoutID
  • " exit sub else LayoutID=Clng(LayoutID) end if sql="select * from Layout where LayoutID=" & LayoutID end if Set rs=Server.CreateObject("Adodb.RecordSet") rs.Open sql,conn,1,1 if rs.bof and rs.eof then FoundErr=True ErrMsg=ErrMsg & "
  • 数据库出现错误!
  • " rs.close set rs=nothing exit sub end if %>
    <%if Action="Add" then%> 添加新版面设计模板 <%else%> 修改模板设置 <%end if%>
    版面设计模板基本信息
    模板类型: <%if Action="Modify" then%> "> <%end if%>
    版面设计模板名称: <%if Action="Modify" and rs("DesignType")=0 then%> "> <%=rs("LayoutName")%> <%else%> " size="50" maxlength="50"> <%end if%>
    模板文件名: <%if Action="Modify" and rs("DesignType")=0 then%> "> <%=rs("LayoutFileName")%> <%else%> " size="50" maxlength="100"> <%end if%>
    版面设计模板预览图: <%if Action="Modify" and rs("DesignType")=0 then%> "> <%=rs("PicUrl")%> <%else%> " size="50" maxlength="100"> <%end if%>
    设计者姓名: <%if Action="Modify" and rs("DesignType")=0 then%> "> <%=rs("DesignerName")%> <%else%> " size="50" maxlength="30"> <%end if%>
    设计者Email: <%if Action="Modify" and rs("DesignType")=0 then%> "> <%=rs("DesignerEmail")%> <%else%> " size="50" maxlength="100"> <%end if%>
    设计者主页: <%if Action="Modify" and rs("DesignType")=0 then%> "> <%=rs("DesignerHomepage")%> <%else%> " size="50" maxlength="100"> <%end if%>
    <%if Action="Add" then%> <%else%> <%end if%>
    <% rs.close set rs=nothing end sub %> <% sub SaveAdd() call CheckLayout() if FoundErr=True then exit sub sql="select top 1 * from Layout" Set rs=Server.CreateObject("Adodb.RecordSet") rs.Open sql,conn,1,3 rs.addnew rs("IsDefault")=False rs("DesignType")=1 call SaveLayout() rs.close set rs=nothing call WriteSuccessMsg("成功添加新的版面设计模板:"& trim(request("LayoutName"))) end sub sub SaveModify() if LayoutID="" then FoundErr=True ErrMsg=ErrMsg & "
  • 请指定LayoutID
  • " else LayoutID=Clng(LayoutID) end if call CheckLayout() if FoundErr=True then exit sub sql="select * from Layout where LayoutID=" & LayoutID Set rs=Server.CreateObject("Adodb.RecordSet") rs.Open sql,conn,1,3 if rs.bof and rs.eof then FoundErr=True ErrMsg=ErrMsg & "
  • 找不到指定的版面设计模板!
  • " else call SaveLayout() call WriteSuccessMsg("保存版面设计模板设置成功!") end if rs.close set rs=nothing end sub sub SetDefault() if LayoutID="" then FoundErr=True ErrMsg=ErrMsg & "
  • 请指定LayoutID
  • " exit sub else LayoutID=Clng(LayoutID) end if conn.execute("update Layout set IsDefault=False where IsDefault=True and LayoutType=" & LayoutType) conn.execute("update Layout set IsDefault=True where LayoutID=" & LayoutID) call WriteSuccessMsg("成功将选定的模板设置为默认模板") end sub sub CheckLayout() if trim(request("LayoutName"))="" then FoundErr=True ErrMsg=ErrMsg & "
  • 模板名称不能为空!
  • " end if if trim(request("LayoutFileName"))="" then FoundErr=True ErrMsg=ErrMsg & "
  • 模板文件名不能为空!
  • " end if if trim(request("PicUrl"))="" then FoundErr=True ErrMsg=ErrMsg & "
  • 模板预览图地址不能为空!
  • " end if if trim(request("DesignerName"))="" then FoundErr=True ErrMsg=ErrMsg & "
  • 模板设计者姓名不能为空!
  • " end if if trim(request("DesignerEmail"))="" then FoundErr=True ErrMsg=ErrMsg & "
  • 模板设计者邮箱不能为空!
  • " end if end sub sub SaveLayout() rs("LayoutType")=LayoutType rs("LayoutName")=trim(request("LayoutName")) rs("LayoutFileName")=trim(request("LayoutFileName")) rs("PicUrl")=trim(request("PicUrl")) rs("DesignerName")=trim(request("DesignerName")) rs("DesignerEmail")=trim(request("DesignerEmail")) rs("DesignerHomePage")=trim(request("DesignerHomepage")) rs.update end sub sub DelLayout() '********************新增加的代码******************** dim LayoutType '********************新增代码结束******************** if LayoutID="" then FoundErr=True ErrMsg=ErrMsg & "
  • 请指定LayoutID
  • " exit sub else LayoutID=Clng(LayoutID) end if sql="select * from Layout where LayoutID=" & LayoutID Set rs=Server.CreateObject("Adodb.RecordSet") rs.Open sql,conn,1,3 if rs.bof and rs.eof then FoundErr=True ErrMsg=ErrMsg & "
  • 找不到指定的版面设计模板!
  • " else if rs("DesignType")=0 then FoundErr=True ErrMsg=ErrMsg & "
  • 不能删除系统自带的模板!
  • " elseif rs("IsDefault")=True then FoundErr=True ErrMsg=ErrMsg & "
  • 当前模板为默认模板,不能删除。请先将默认模板改为其他模板后再来删除此模板。
  • " else '********************新增加的代码******************** LayoutType=rs("LayoutType") '********************新增代码结束******************** rs.delete rs.update dim trs '********************原始代码屏蔽******************** ' set trs=conn.execute("select LayoutID from Layout where IsDefault=True and LayoutType=" & rs("LayoutType")) '********************新增加的代码******************** set trs=conn.execute("select LayoutID from Layout where IsDefault=True and LayoutType=" & LayoutType) '********************新增代码结束******************** conn.execute("update ArticleClass set LayoutID=" & trs(0) & " where LayoutID=" & LayoutID) conn.execute("update Article set LayoutID=" & trs(0) & " where LayoutID=" & LayoutID) set trs=nothing end if end if rs.close set rs=nothing if FoundErr=True then exit sub call WriteSuccessMsg("成功删除选定的模板。并将使用此模板的栏目和文章改为使用默认模板。") end sub %>