<!--#include file="../../ACT.Function.asp"-->
<!--#include file="../../../ACT_inc/cls_pageview.asp"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>单页系统管理-By ACTCMS</title>
<link href="../../Images/css1/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
  <tr>
    <td  class="bg_tr"><strong>您现在的位置：系统中心 &gt;&gt; 插件管理 &gt;&gt;<a href="?">单页管理</></strong></td>
  </tr>
  <tr>
    <td >
	<strong><a href="?Action=add">单页</a>选项：</strong><strong><a href="?Action=add">新建单页</a></strong>

	┆<strong><a href="?">查看单页</a></strong>
	</td>
    </tr>
</table>
<% 
	If Not ACTCMS.ACTCMS_QXYZ(0,"dyxt_ACT","") Then   Call Actcms.Alert("对不起，你没有操作权限！","") 
dim Action,ID,ShowErr
	Action = Request("Action")
	ID = Request("ID")
	Select Case Action
			Case "add","edit" 
				Call edit()
			Case "saveadd"
				Call saveadd()
			Case "saveedit"
				Call saveedit()
			Case "del"
				Call del()
			Case Else
				Call Main()
	End Select
	
	Sub Del()
		Conn.Execute ("Delete from DiyPage_ACT Where ID=" & ACTCMS.ChkNumeric(Request.QueryString("ID")))		
		Set conn=nothing
		Call Actcms.ActErr("删除成功！&nbsp;&nbsp;<a href=Sys_Act/DiyPage/Index.asp>点击这里返回管理首页</a>","")
		Response.End
    End Sub
	Sub saveadd()
	Dim DiyPath,Rs,content,pagename

		DiyPath=Request.Form("DiyPath")
		If InStr(DiyPath, "//") > 0   Then
			DiyPath = Replace(DiyPath, "//","/")
		End If 

		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open "Select * from DiyPage_ACT",Conn,1,3
		Rs.addnew
		Rs("DiyPath")= DiyPath
		Rs("content")= Request.Form("content")
		Rs("pagename")= Request.Form("pagename")
		Rs("FileName")= Request.Form("FileName")
		Rs("tempurl")= Request.Form("tempurl")
		Rs.update
		Rs.Close:Set Rs=Nothing
		Response.Write ("<script>parent.frame.cols=""180,*"";</script>")
		Call Actcms.ActErr("添加成功!&nbsp;&nbsp;<a href=Sys_Act/DiyPage/Index.asp>点击这里返回管理首页</a>","")
		Response.End
	End Sub	


	Sub saveedit()
	Dim DiyPath,Rs,content,pagename,sql
		SQL = "Select * From DiyPage_ACT Where ID="&ID
		DiyPath=Request.Form("DiyPath")
		If InStr(DiyPath, "//") > 0   Then
			DiyPath = Replace(DiyPath, "//","/")
		End If 
		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open SQL,Conn,1,3
		Rs("DiyPath")= DiyPath
		Rs("content")= Request.Form("content")
		Rs("pagename")= Request.Form("pagename")
		Rs("tempurl")= Request.Form("tempurl")
		Rs("FileName")= Request.Form("FileName")
		Rs.update
		Rs.Close:Set Rs=Nothing
		Response.Write ("<script>parent.frame.cols=""180,*"";</script>")
		Call Actcms.ActErr("修改成功!&nbsp;&nbsp;<a href=Sys_Act/DiyPage/Index.asp>点击这里返回管理首页</a>","")
		Response.End
	End Sub	

	sub Main()
	Dim ShowErr
	ConnectionDatabase
	Dim strLocalUrl
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
	Dim intPageNow
	intPageNow = request.QueryString("page")
	Dim intPageSize, strPageInfo
	intPageSize = 20
	Response.Write ("<script>parent.frame.cols=""180,*"";</script>")
	Dim arrRecordInfo, i
	Dim sql, sqlCount,Sqls,ChannelID
	sql = "SELECT [ID],[pageName],[DiyPath]" & _
		" FROM [DiyPage_ACT]" & _
		"ORDER BY [ID] DESC"
	sqlCount = "SELECT Count([ID])" & _
			" FROM [DiyPage_ACT] "
		Dim clsRecordInfo
		Set clsRecordInfo = New Cls_PageView
			clsRecordInfo.intRecordCount = 2816
			clsRecordInfo.strSqlCount = sqlCount
			clsRecordInfo.strSql = sql
			clsRecordInfo.intPageSize = intPageSize
			clsRecordInfo.intPageNow = intPageNow
			clsRecordInfo.strPageUrl = strLocalUrl
			clsRecordInfo.strPageVar = "page"

		clsRecordInfo.objConn = Conn		
		arrRecordInfo = clsRecordInfo.arrRecordInfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
	 %>
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
   <form name="Article" method="post" action="?Action="> <tr>
      <td width="26" align="center" class="bg_tr">ID</td>
      <td width="524" align="center" class="bg_tr">模板名称</td>
      <td width="202" align="center" class="bg_tr">生成路径</td>
      <td width="200" colspan="2" align="center" class="bg_tr">常规管理操作</td>
    </tr>
	 <%
		Dim bgColor
		If IsArray(arrRecordInfo) Then
			For i = 0 to UBound(arrRecordInfo, 2)
	%>
    <tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
      <td align="center"  ><%= arrRecordInfo(0,i) %></td>
      <td align="center"  ><%= arrRecordInfo(1,i) %></td>
      <td align="center"  ><%= arrRecordInfo(2,i) %></td>
      <td  align="center" >
	 <a href="MakeDiyPage.asp?ID=<%= arrRecordInfo(0,i) %>">生成&nbsp;</a>┆
<a href="?Action=edit&ID=<%= arrRecordInfo(0,i) %>">编辑&nbsp;</a>┆
	 <a href="?Action=del&ID=<%= arrRecordInfo(0,i) %> " onClick="return confirm('确认删除此模板吗?此操作不可恢复!')">删除</a></td>
    </tr>
	<% 
	Next
	End If
	%>
  
    <tr >
      <td height="25" colspan="5" align="center" ><%= strPageInfo%></td>
    </tr>
 </form> </table>

<p>
  <script language="javascript">
function SelectIterm(form,sign){
	for (var i=0; i<form.elements.length;i++ ){
		if (form.elements[i].type == "checkbox"){
				var e=form.elements[i];
					if (sign==0) e.checked= true;
					if (sign==1) e.checked= !e.checked;
					if (sign==2) e.checked= false;
		}
	} 
}
//CSS背景控制
function overColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg1"
		Obj.bgColor="";
	}
	
}
function outColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg";
		Obj.bgColor="";
	}
}
</script>
  <% end sub
	sub edit()
	Dim DiyPath,Rs,content,pagename,frmAction,tempurl,FileName
	IF Action = "edit" Then
		Set Rs=Conn.Execute("Select * from DiyPage_ACT Where ID=" & ID)
			if Rs.Bof And Rs.EOF then
				 Response.Write "不存在！"
				Exit Sub
			End IF	
		DiyPath = Rs("DiyPath")	
		pagename = Rs("pagename")
		If RS("Content") <> "" Then Content=Server.HTMLEncode(RS("Content"))
		tempurl=Rs("tempurl")
		FileName=Rs("FileName")
		frmAction		= "edit"
	Else
		DiyPath = "html/"
		pagename = "actcms.htm"
		content = ""
		pagename=""
		frmAction = "add"
	End IF
  %>
  <script>parent.frame.cols="0,*";</script>

  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <form name="form1" method="post" action="Index.asp">
	
	<tr>
      <td width="19%" >单页名称:</td>
      <td width="81%" ><input name="pagename" type="text" id="pagename" value="<%= pagename %>" size="50"></td>
    </tr>
   

	<tr>
      <td width="19%" >单页模板地址:</td>
      <td width="81%" >
	  <input name="tempurl" type="text" id="tempurl" value="<%= tempurl %>" size="50">
          <input class="ACT_btn" type="button"  onClick="OpenWindowAndSetValue('../../include/print/SelectPic.asp?CurrPath=<%=actcms.actsys%>',500,320,window,document.form1.tempurl);" value="选择模板..."> 
	  </td>
    </tr>
	
	<tr>
      <td >单页路径:</td>
      <td ><input name="DiyPath" type="text" id="DiyPath" value="<%= DiyPath %>" size="50">
	  不能以/开始,不熟悉系统.不建议修改.以免覆盖系统文件</td>
    </tr>


	<tr>
      <td >文件名称:</td>
      <td ><input name="FileName" type="text" id="FileName" value="<%= FileName %>" size="50">
	  文件名为空则表示生成路径是  <font color=green>/路径名/</font> 这种格式
	  </td>
    </tr>

	
	<tr >
      <td colspan="2">
	  
	 <div>
	  <input type="hidden" id="content" name="content" value="<%=Content%>" style="display:none" />
	  <input name="hidden" type="hidden" id="cont___Config" style="display:none" value="" />
	  <iframe id="cont___Frame" src="../../../editor/fckeditor/editor/fckeditor.html?InstanceName=content&amp;Toolbar=UserMode" width="100%" height="450" frameborder="0" scrolling="no"> </iframe>
        </div>		
	  
	  </td>
    </tr>
    <tr>
      <td colspan="2" align="center" >
	<input type=button onclick=CheckForm() class="ACT_btn"  name=Submit1 value="  保存  " />
        &nbsp;&nbsp;&nbsp;&nbsp;<input name="Submit2" type="reset" class="ACT_btn" value="  重置  ">
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		 <input name="Action" type="hidden" id="Action" value="save<%=frmAction%>">
		
		 <input name="ID" type="hidden" id="ID" value="<%=id%>"></td>
    </tr></form>
  </table>


<script language="javascript">
function OpenWindowAndSetValue(Url,Width,Height,WindowObj,SetObj)
{
	var ReturnStr=showModalDialog(Url,WindowObj,'dialogWidth:'+Width+'pt;dialogHeight:'+Height+'pt;status:yes;help:no;scroll:yes;');
	if (ReturnStr!='') SetObj.value=ReturnStr;
	return ReturnStr;
}	
function CheckForm()
{ var form=document.form1;
	 if (form.pagename.value=='')
		{ alert("请输入单页名称!");   
		  form.pagename.focus();    
		   return false;
		} 
	 if (form.DiyPath.value=='')
		{ alert("请输入单页路径!");   
		  form.DiyPath.focus();    
		   return false;
		} 
		form.Submit1.value="正在提交数据,请稍等...";
		form.Submit1.disabled=true;
		form.Submit2.disabled=true;		
	    form.submit();
        return true;
	}</script>  
	<%end sub
CloseConn %>
</body>
</html>

