<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Conn.asp"-->
<!--#include file="Ex_Cls/Ex_SkinCls.asp"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<link rel="stylesheet" href="Admin_Style.css">
<script src="inc/main.js"></script>
<script>
function Check()
{	
	var orderX=g("orderx").value;
	if (g('eid').value=="") return msg('模板ID必须填写','eid');
	if (g('title').value=="") return msg('模板标题必须填写','title');
	if (orderX=="" || isNumber(orderX)==false) return msg('模板排列序号必须填写,并且为数字','orderx');
	if (g('content').value=="") return msg('模板内容必须填写','content');
}
</script>
</head>
<body>
<%
Dim Action,ExComm
Set ExComm=new Ex_CommonCls
ExComm.IsAdLogin 
ExComm.IsIpAllow
Action=Request.QueryString("action")
Select Case Action
	Case "addform"
	PostForm
	Case "add"
	Add
	Case "show"
	Show
	Case "modi"
	PostForm
	Case "change"
	change
	Case "modiall"
	modiall
	Case "del"
	Del
End Select
'从新生成模板
Function RefreshTxtSkin
	Dim ExSkin
	Set ExSkin=new Ex_SkinCls
	ExSkin.RefreshSkinCache
	Set ExSkin=Nothing 
End Function 
sub Del
	Conn.execute "delete * from Ex_pannel where id="&request.QueryString("id")
	RefreshTxtSkin
	ExComm.ShowMsg "删除成功",request.ServerVariables("HTTP_REFERER")
End Sub
Sub PostForm
	Dim Ac,Rs,eid,title,pposition,isshow,orderx,content,Sql
	if action="addform" then 
		Ac="add"
	else
		Ac="change"
		Sql="select * from Ex_Pannel where id="&ExComm.G(Request.Querystring("id"))
		Set Rs=Conn.Execute(Sql)
		eid=Replace(Replace(Rs("eid"),"$u_",""),"$","")
		title=Rs("title")
		pposition=Rs("pposition")
		isshow=Rs("isshow")
		orderx=Rs("orderx")
		Content=Rs("content")
	end if 
%>
<form id="form1" name="form1" method="post" action="?action=<%=Ac%>&id=<%=Request.QueryString("id")%>" onSubmit="return Check()">
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="border tablebg">
    <tr>
      <th colspan="10" class="topbg">模块添加</th>
    </tr>
    <tr>
      <td width="7%" class="tdbg"><div align="center">模ID：</div></td>
      <td width="15%" class="tdbg">$u_
        
        <input name="eid" type="text" id="eid" title="英文" value="<%=eid%>" size="10" />
      $</td>
      <td width="11%" class="tdbg"><div align="center">模块标题：</div></td>
      <td width="14%" class="tdbg"><input name="title" type="text" id="title" title="用于显示在侧栏模块顶部的文字，例如 最新日志。" value="<%=title%>" size="15"/></td>
      <td width="9%" class="tdbg"><div align="center">显示位置：</div></td>
      <td width="8%" class="tdbg"><select name="pposition" id="pposition">
		  <option value="侧栏" <%if pposition="侧栏" then response.Write("selected")%>>侧栏</option>
          <option value="头部"<%if pposition="头部" then response.Write("selected")%>>头部</option>
      </select>      </td>
      <td width="8%" class="tdbg">是否显示：</td>
      <td width="7%" class="tdbg"><select name="isshow" id="isshow">
        <option value="显示" <%if isshow="显示" then response.Write("selected")%>>显示</option>
        <option value="隐藏" <%if isshow="隐藏" then response.Write("selected")%>>隐藏</option>
      </select></td>
      <td width="9%" class="tdbg">显示序号：</td>
      <td width="12%" class="tdbg"><input name="orderx" type="text" id="orderx" title="数字越小越靠前显示" value="<%=cint(orderx)%>" size="5" /></td>
    </tr>
    <tr>
      <td colspan="2" class="tdbg">模块内容：</td>
      <td colspan="8" class="tdbg"><textarea name="content" cols="50" rows="8" id="content"><%=content%></textarea></td>
    </tr>
    <tr>
      <td colspan="2" class="tdbg">&nbsp;</td>
      <td class="tdbg">&nbsp;</td>
      <td colspan="7" class="tdbg"><input type="submit" name="Submit" value="提交" /></td>
    </tr>
  </table>
</form>
注:用户自定义的模块调用的标记为$u_模块id$.例如模块id为search,那么调用标记为$u_search$.
<%
End Sub
Sub Add
	Dim EId,Title,PPosition,IsShow,Orderx,Content,Sql
	EId=ExComm.G(Request.Form("eid"))
	Sql="select count(*) from Ex_pannel where eid='$u_"&Trim(eid)&"$'"
	if Conn.Execute(Sql)(0)<>0 then 
		ExComm.ShowMsg "模块ID已经存在,请更换",""
	end if 
	Title=ExComm.G(Request.Form("Title"))
	PPosition=ExComm.G(Request.Form("PPosition"))
	IsShow=ExComm.G(Request.Form("IsShow"))
	Orderx=ExComm.G(Request.Form("orderx"))
	Content=ExComm.G(Request.Form("content"))
	Sql="insert into Ex_pannel(eid,title,pposition,isshow,orderx,content,ptype) values('$u_"&eid&"$','"&title&"','"&pposition&"','"&isshow&"',"&orderx&",'"&content&"','用户')"
	Conn.Execute Sql
	RefreshTxtSkin
	ExComm.ShowMsg "模块添加成功","?action=addform"
End Sub
Sub Change
	Dim EId,Title,PPosition,IsShow,Orderx,Content,Sql
	EId=ExComm.G(Request.Form("eid"))
	Title=ExComm.G(Request.Form("Title"))
	PPosition=ExComm.G(Request.Form("PPosition"))
	IsShow=ExComm.G(Request.Form("IsShow"))
	Orderx=ExComm.G(Request.Form("orderx"))
	Content=ExComm.G(Request.Form("content"))
	Sql="update Ex_pannel set eid='$u_"&eid&"$',title='"&title&"',pposition='"&pposition&"',isshow='"&isshow&"',content='"&content&"',orderx="&orderx&" where id="&ExComm.G(request.QueryString("id"))
	Conn.Execute Sql
	RefreshTxtSkin
	ExComm.ShowMsg "修改成功",""
End Sub
Sub Show
Dim Rs,Sql,t
t=request.QueryString("t")
select case t
	case "head"
		Sql="select * from Ex_pannel where pposition='头部' order by orderx asc"
	case "heads"
		Sql="select * from Ex_pannel where pposition='头部' and isshow='显示' order by orderx asc"
	case "ce"
		Sql="select * from Ex_pannel where pposition='侧栏' order by orderx asc"
	case "ces"
		Sql="select * from Ex_pannel where pposition='侧栏' and isshow='显示' order by orderx asc"
	case else
		Sql="select * from Ex_pannel where ptype<>'广告' order by orderx asc"
end select

Set Rs=Conn.Execute(Sql)
%>
<form id="form2" name="form2" method="post" action="?action=modiall">
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="border tablebg">
    <tr>
      <th class="topbg" colspan="10">模块管理</th>
    </tr>
	<tr>
      <td class="tdbg">&nbsp;</td>
      <td class="tdbg"><a href="?action=show&amp;t=head">显示所有头部模块</a></td>
      <td class="tdbg">&nbsp;</td>
      <td class="tdbg"><a href="?action=show&amp;t=ce">显示所有侧栏模块</a></td>
      <td class="tdbg">&nbsp;</td>
      <td colspan="2" class="tdbg"><a href="?action=show&amp;t=heads">只显示头部可显模块</a></td>
      <td class="tdbg">&nbsp;</td>
      <td colspan="2" class="tdbg"><a href="?action=show&amp;t=ces">只显示侧栏可显模块</a></td>
    </tr>
    
	<%
	if not rs.eof and not rs.bof then 
		dim id
		do while not rs.eof 
		id=Rs("id")
		if Rs("ptype")="用户" then
	%><tr>
      <td width="6%" class="tdbg"><div align="center">模ID：</div></td>
      <td width="14%" class="tdbg">$u_
        <input name="eid<%=id%>" type="text" id="eid<%=id%>" title="英文" value="<%=Replace(Replace(Rs("eid"),"$u_",""),"$","")%>" size="10" readonly/>
      $</td>
      <td width="10%" class="tdbg"><div align="center">模块标题：</div></td>
      <td width="11%" class="tdbg"><input name="title<%=id%>" type="text" id="title<%=id%>" title="用于显示在侧栏模块顶部的文字，例如 最新日志。" value="<%=Rs("title")%>" size="15"/></td>
      <td width="9%" class="tdbg"><div align="center">显示位置：</div></td>
      <td width="8%" class="tdbg"><select name="pposition<%=id%>" id="pposition<%=id%>">
		  <option value="侧栏" <%if Rs("pposition")="侧栏" then response.Write("selected")%>>侧栏</option>
          <option value="头部"<%if Rs("pposition")="头部" then response.Write("selected")%>>头部</option>
      </select>      </td>
      <td width="9%" class="tdbg">是否显示：</td>
      <td width="8%" class="tdbg"><select name="isshow<%=id%>" id="isshow<%=id%>">
        <option value="显示" <%if Rs("isshow")="显示" then response.Write("selected")%>>显示</option>
        <option value="隐藏" <%if Rs("isshow")="隐藏" then response.Write("selected")%>>隐藏</option>
      </select></td>
      <td width="9%" class="tdbg">显示序号：</td>
      <td width="16%" class="tdbg"><input name="orderx<%=id%>" type="text" id="orderx<%=id%>" title="数字越小越靠前显示" value="<%=cint(Rs("orderx"))%>" size="3" />
        <input type="hidden" value="<%=Rs("id")%>" name="ids" />
		<input type="hidden" value="<%=Rs("ptype")%>" name="ptype<%=id%>" />
		<a href="?action=del&id=<%=Rs("id")%>"onclick="return confirm('是否要删除?')">删除</a>
      |&nbsp;<a href="?action=modi&amp;id=<%=Rs("id")%>">修改</a></td>
    </tr>
	<%
		else
	%>
	<tr>
      <td width="6%" class="tdbg"><div align="center">模ID：</div></td>
      <td width="14%" class="tdbg"><input name="eid<%=id%>" id="eid<%=id%>" value="<%=Rs("eid")%>" size="10" readonly/></td>
      <td width="10%" class="tdbg"><div align="center">模块标题：</div></td>
      <td width="11%" class="tdbg"><input name="title<%=id%>" id="title<%=id%>" value="<%=Rs("title")%>" size="15" readonly/></td>
      <td width="9%" class="tdbg"><div align="center">显示位置：</div></td>
      <td width="8%" class="tdbg"><select name="pposition<%=id%>" id="pposition<%=id%>">
          <option value="头部"<%if Rs("pposition")="头部" then response.Write("selected")%>>头部</option>
          <option value="侧栏" <%if Rs("pposition")="侧栏" then response.Write("selected")%>>侧栏</option>
      </select>      </td>
      <td width="9%" class="tdbg">是否显示：</td>
      <td width="8%" class="tdbg"><select name="isshow<%=id%>" id="isshow<%=id%>">
        <option value="显示" <%if Rs("isshow")="显示" then response.Write("selected")%>>显示</option>
        <option value="隐藏" <%if Rs("isshow")="隐藏" then response.Write("selected")%>>隐藏</option>
      </select></td>
      <td width="9%" class="tdbg">显示序号：</td>
      <td width="16%" class="tdbg"><input name="orderx<%=id%>" type="text" id="orderx<%=id%>" title="数字越小越靠前显示" value="<%=cint(Rs("orderx"))%>" size="3" />
      &nbsp;&nbsp;<input type="hidden" name="ids" value="<%=Rs("id")%>" />
	  <input type="hidden" name="ptype<%=id%>" value="<%=Rs("ptype")%>" />
	  </td>
    </tr>
	<%
		end if
		Rs.movenext
	loop 
end if 
	%>
    <tr>
      <td colspan="10" class="tdbg"><div align="center">
        <input type="submit" name="Submit2" value="批量修改" />
      </div></td>
    </tr>
  </table>
</form>
<%
End Sub 
Sub modiall
	dim ids,eid,title,isshow,pposition,orderx,ptype,sql,i
	ids=Request.Form("ids")
	ids=split(ids,",")

	for i=0 to ubound(ids)
		title=ExComm.G(Request.Form("title"&trim(ids(i))))
		eid=Replace(Request.Form("eid"&trim(ids(i))),"'","''")
		isshow=ExComm.G(Request.Form("isshow"&trim(ids(i))))
		pposition=ExComm.G(Request.Form("pposition"&trim(ids(i))))
		orderx=ExComm.G(Request.Form("orderx"&trim(ids(i))))
		ptype=ExComm.G(Request.Form("ptype"&trim(ids(i))))
		If Trim(title)="" Then 
			ExComm.ShowMsg "模块标题必须填写",""
		End If 
		If Trim(eid)="" Then 
			ExComm.ShowMsg "模块ID不能为空",""
		End If 
		If Trim(orderx)="" Or IsNumeric(orderx)=False Then
			ExComm.ShowMsg "显示序号不能为空,并且为数字",""
		End If 
		If eid="$show_subject_l$" Then 
			pposition="头部"
		End If 
		if ptype="用户" then 
		Sql="update Ex_pannel set eid='$u_"&eid&"$',title='"&title&"',isshow='"&isshow&"',pposition='"&pposition&"',orderx="&orderx&" where id="&ids(i)
		else 
		Sql="update Ex_pannel set eid='"&eid&"',title='"&title&"',isshow='"&isshow&"',pposition='"&pposition&"',orderx="&orderx&" where id="&ids(i)
		end if
		Conn.Execute Sql
	Next
	RefreshTxtSkin
	ExComm.ShowMsg "批量修改成功",""
End Sub
%>
</body>
</html>
