<!--#include file="../../fy.Function.asp"-->
<!--#include file="../../../fy_inc/cls_pageview.asp"-->
<!--#include file="../../fycms.asp"-->
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>单页系统管理</title>
<link rel="stylesheet" type="text/css" href="../../css/base.css">
<link rel="stylesheet" type="text/css" href="../../css/content.css">
 <SCRIPT LANGUAGE='JavaScript'>
 var fyuser="<%=fycms.strToAsc(RSQL(Trim(Request.Cookies(fycmsN)("AdminName"))))%>";
var fypass="<%=fycms.strToAsc(RSQL(Trim(Request.Cookies(fycmsN)("AdminPassword"))))%>";
</SCRIPT>
<!--#include file="../../../editor/index.asp"-->
<%=writejs("../../../")%>
<script type='text/javascript' src='../../js/main.js'></script>
<script type="text/javascript" src="../../../fy_inc/js/jquery.js"></script>
<script type='text/javascript' src='../../../fy_inc/js/lhg/lhgdialog.min.js'></script>
</head>
<body>
<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 单页管理</div>
    <div class="opers">

选项：<a href="?Action=add" class="btn<%If request("Action")="add" Then echo " btn_primary" %>">新建单页</a>
<a href="?" class="btn<%If request("Action")="" Then echo " btn_primary" %>">查看单页</a>
<a href="fy.diy.asp?RefreshFlag=All" class="btn">生成全部单页</a>


    </div>
   <% 
	If Not fycms.fycms_QXYZ(0,"dyxt_fy","") Then   Call fycms.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_fy Where ID=" & ChkNumeric(Request.QueryString("ID")))		
		Set conn=nothing
		Call fycms.ActErr("删除成功","Sys_fy/DiyPage/Index.asp","")
 		Response.End
    End Sub
	Sub saveadd()
	%>

	<%Dim DiyPath,Rs,content,title

		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_fy",Conn,1,3
		Rs.addnew
		Rs("DiyPath")= DiyPath
		Rs("content")= Request.Form("content")
		Rs("title")= Request.Form("title")
 		Rs("tempurl")= Request.Form("tempurl")
		Rs.update
		Rs.Close:Set Rs=Nothing
 		Call fycms.ActErr("添加成功","Sys_fy/DiyPage/Index.asp","")
 		Response.End
	End Sub	


	Sub saveedit()
	%> 

	<%Dim DiyPath,Rs,content,title,sql
		SQL = "Select * From DiyPage_fy 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("title")= Request.Form("title")
		Rs("tempurl")= Request.Form("tempurl")
 		Rs.update
		Rs.Close:Set Rs=Nothing
 		Call fycms.ActErr("修改成功","Sys_fy/DiyPage/Index.asp","")
 		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
 	Dim arrinfo, i
	Dim sql, sqlCount,Sqls,ChannelID
	sql = "SELECT [ID],[title],[DiyPath]" & _
		" FROM [DiyPage_fy]" & _
		"ORDER BY [ID] DESC"
	sqlCount = "SELECT Count([ID])" & _
			" FROM [DiyPage_fy] "
		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		
		arrinfo = clsRecordInfo.arrinfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
	 %>   <form name="Article" method="post" action="?Action="><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>ID</th>
	  <th>模板名称</th>
	  <th>生成路径</th>
	  <th>常规管理操作</th>
	  </tr>
    </thead>
    	 <%
		Dim bgColor
		If IsArray(arrinfo) Then
			For i = 0 to UBound(arrinfo, 2)
	%>
    <tr>
      <td><%= arrinfo(0,i) %></td>
      <td><a target="_blank" href="<%=fycms.actsys&"plus/page.asp?ID="&arrinfo(0,i)%>"><%= arrinfo(1,i) %></a> </td>
      <td><%= arrinfo(2,i) %></td>
      <td>
	 <a href="fy.diy.asp?RefreshFlag=ID&ID=<%= arrinfo(0,i) %>">生成&nbsp;</a>┆
<a href="?Action=edit&ID=<%= arrinfo(0,i) %>">编辑&nbsp;</a>┆
	 <a href="?Action=del&ID=<%= arrinfo(0,i) %> " onClick="return confirm('确认删除此模板吗?此操作不可恢复!')">删除</a></td>
    </tr>
	<% 
	Next
	End If
	%>
  
    </table>
    <div class="pagelist">
    	<%= strPageInfo%>
   </div> </form>


    <% end sub
	sub edit()
	Dim DiyPath,Rs,content,title,frmAction,tempurl
	IF Action = "edit" Then
		Set Rs=Conn.Execute("Select * from DiyPage_fy Where ID=" & ID)
			if Rs.Bof And Rs.EOF then
				 echo "不存在！"
				Exit Sub
			End IF	
		DiyPath = Rs("DiyPath")	
		title = Rs("title")
		If RS("Content") <> "" Then Content=RS("Content")
		tempurl=Rs("tempurl")
 		frmAction		= "edit"
	Else
		DiyPath = "html/"
		title = "fycms.htm"
		content = ""
		title=""
		frmAction = "add"
	End IF
  %>
 
    <form name="form1" method="post" action="Index.asp">
    <div class="divtable"> 
 

        


        <dl>
            <dt>单页名称:</dt>
            <dd>
              <input name="title" type="text"  class="Ainput" id="title" value="<%= title %>" size="50">    
            </dd>
         </dl>
        
        <dl>
            <dt>单页模板地址:</dt>
            <dd>
                <input name="tempurl" type="text"  class="Ainput" id="tempurl" value="<%= tempurl %>" size="50">
				<input id="PicUrls3" class="btn " onClick="javascript:stemp('<%=fycms.actsys&fycms.adminurl%>/include/TempLate/Select.asp?ShowPath=<%=fycms.ThisTheme%>&iname=tempurl');" name="button" type="button"   value="选择模板">
             </dd>
         </dl>
        
        <dl>
            <dt>单页路径:</dt>
            <dd>
               <input name="DiyPath" type="text"  class="Ainput" id="DiyPath" value="<%= DiyPath %>" size="50">
	  不能以/开始,不熟悉系统.不建议修改.以免覆盖系统文件
             </dd>
         </dl>
    


	<dl><dt> 内容：{info:content} <input name="button"  type="button"  class="btn " style="cursor:pointer" onClick="insertHTMLToEditor('[NextPage]','Content1');" value="[NextPage]">注：手动分页符标记为：点击插入，注意大小写</dt>
          <dd>  
  	 <div class="edit">	<%=writeeditor(0,"content1","Content","basic",Content)%></div>
             </dd>
         </dl>
 
           
 
            <dl>
            <dt class="vhid">提交：</dt>
            <dd>
			<input type=button onclick=CheckForm() class="btn btn_primary"  name=Submit1 value="保存" />
			<input name="Submit2" type="reset" class="btn" value="重置">
			<input name="Action" type="hidden" id="Action" value="save<%=frmAction%>">
			<input name="ID" type="hidden" id="ID" value="<%=id%>">
             </dd>
         </dl>
        
    </div>
    </form>
 
<script language="javascript">
<%=insertjs("content1")%>
 function CheckForm()
{ var form=document.form1;
	 if (form.title.value=='')
		{ alert("请输入单页名称!");   
		  form.title.focus();    
		   return false;
		} 
	 if (form.DiyPath.value=='')
		{ alert("请输入单页路径!");   
		  form.DiyPath.focus();    
		   return false;
		} 
		<%=checkeditpost(0,1)%>
 	    form.submit();
        return true;
	}</script>  
	<%end sub
CloseConn %>
</body>
</div>
</body>
</html>
