<!--#include file="function.asp"-->
<%
checkLogin()

header("基本信息 &gt; 网站页面设置")
select case Request.QueryString("action")
case "new"
	call new_()
case "submit"

	p_id=request.Form("p_id")
	p_title=request.Form("p_title")
	p_content=request.Form("p_content")
	
	if p_title="" then
	p3t ErrMsg("请输入页面标题")
	elseif p_content="" then
	p3t ErrMsg("请输入页面内容")
	end if
	
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from p3t_page where p_id="&p_id,conn,1,3
	if rs.eof and rs.bof then
	rs.addnew
	end if
	rs("p_title")=p_title
	rs("p_content")=p_content
	rs.update
	rs.close
	set rs=nothing
	
	p3t "<script>alert('操作成功');parent.location.href='?';</script>"
	p3t_end
	
case "del"
	
	p_id=request.QueryString("p_id")
	if p_id="" then p_id=request.QueryString("val")
	conn.execute("delete from p3t_page where p_id in ("&p_id&")")	
	p3t "<script>parent.location.reload();</script>"
	p3t_end
	
case else
	call main_()
end select
footer()

sub main_()
%>
<script type="text/javascript" src="images/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
	$("table tr").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
});
function checkAll(){
	$("table input:checkbox").each(function(){
		this.checked = !this.checked; 
	});
}
function edit(){
	var val = $("table input:checkbox:checked").map(function(data){return this.value}).get().join(",");
	if (val == "")
		alert("请至少选择一条信息");
	else if (val.split(",").length > 1)
		alert("请选择一条信息");
	else
		location.href = "?action=new&val=" + val;
}
function del(){
	var val = $("table input:checkbox:checked").map(function(data){return this.value}).get().join(",");
	if (val == "")
		alert("请至少选择一条信息");
	else
		if(confirm("您确定要删除这 " + val.split(",").length + " 条信息吗？"))yukiiak.location.href = "?action=del&val=" + val;
}
</script>
<div class="main_ctrl">
	<p><a>操作选项：</a>
    <a href="javascript:edit()"><img src="images/btn_edit.gif" />编辑</a>
    </p>
</div>
<div class="main_body">
	<table cellspacing="1">
      <tr>
        <th width="20"><input type="checkbox" onclick="checkAll()" title="全选/反选" /></th>
        <th>页面标题</th>
        <th width="100">参数</th>
        <th width="100">基本操作</th>
      </tr>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from p3t_page order by p_order asc,p_id asc"
rs.open sql,conn,1,1
if rs.eof then 
p3t "<tr><td class=""center"" colspan=""10"">暂无信息</td></tr>"
else
PageSize=10
NowPage=Request.QueryString("Page")
If NowPage="" Then:NowPage=1:Else:NowPage=Int(NowPage):End If
rs.PageSize=PageSize
rs.AbsolutePage=NowPage
i=0:PageList=0
'分页
pages=getPages(rs,NowPage,PageSize,PageList,"?")
do while not rs.eof
%>
      <tr>
        <td class="center"><input name="p_id" type="checkbox" value="<%=rs("p_id")%>" /></td>
        <td><%=rs("p_title")%></td>
        <td class="center"><%=rs("p_txt")%></td>
        <td class="center">
        	<a href="?action=new&p_id=<%=rs("p_id")%>">编辑</a>
        </td>
      </tr>
<%
i=i+1
if i=PageSize Then Exit Do  
rs.movenext
LOOP
end if
rs.close
set rs=nothing
%>
    </table>
    <div class="pager"><%=pages%></div>
</div>
<%
end sub
sub new_()
p_id=request.QueryString("p_id")
if p_id="" then p_id=request.QueryString("val")
if p_id="" or isnumeric(p_id)=false then p_id=0
if p_id<>0 then
set rs=conn.execute("select * from p3t_page where p_id="&p_id)
if not rs.eof then
p_title=rs("p_title")
p_content=rs("p_content")
end if
set rs=nothing
end if
%>
<div class="main_ctrl">
	<p><a>操作选项：</a>
    <a href="javascript:history.back()"><img src="images/btn_list.gif" />返回列表</a>
    </p>
</div>
<div class="main_body">
	<table cellspacing="1">
    <form name="form1" action="?action=submit" method="post" target="yukiiak">
      <tr>
        <th colspan="2" class="left"><%if p_id=0 then p3t "新建" else p3t "编辑ID："&p_id%></th>
      </tr>
      <tr>
        <td width="100" class="right">页面标题</td>
        <td><input type="text" name="p_title" class="input" size="40" value="<%=p_title%>" /></td>
      </tr>
      <tr>
        <td class="right">页面内容</td>
        <td><textarea name="p_content" style="display:none"><%=p_content%></textarea>
        <iframe id="p_content" src="../ewebedit/ewebeditor.asp?id=p_content&style=standard1" frameborder="0" scrolling="no" width="555" height="350"></iframe></td>
      </tr>
      <tr>
        <td></td>
        <td>
			<input name="p_id" type="hidden" value="<%=p_id%>">
        	<input type="submit" name="submit" class="button" value=" 提 交 " />
        </td>
      </tr>
    </form>
    </table>
</div>
<%
end sub
%>