<!--#include file="../../fy.Function.asp"-->
<!--#include file="../../../fy_inc/cls_pageview.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 type="text/javascript" src="../../../fy_inc/js/swfobject.js"></script>
<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("../../../")%>
</head>
<body>
<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 模型管理</div>
    <div class="opers">
    	<a href="?" class="btn<%If request("Action")="" Then echo " btn_primary" %>">查看碎片</a>
    	<a href="?Action=add" class="btn<%If request("Action")="add" Then echo " btn_primary" %>">新建碎片</a>
    </div>
   <% 
	If Not fycms.fycms_QXYZ(0,"label","") Then   Call fycms.Alert("对不起，你没有操作权限！","") 
	Set FsoObj = CreateObject(fycms.FsoName) 

 dim FsoObj,Action,ID,ShowErr
	Action = Request("Action")
	ID = Request("ID")
	Select Case Action
			Case "add","edit" 
				Call edit()
			Case "saveedit","saveadd"
				Call saveedit()
			Case "del"
				Call del()
			Case Else
				Call Main()
	End Select
	
	Sub Del()
		
  	 	Call fycms.DeleteFile(fycms.ThisTheme&"/label/"&fycms.s("file")&".html")
		Set conn=nothing
	 	Call fycms.ActErr("删除成功","Sys_fy/label/Index.asp","")
 		Response.End
    End Sub
 

	Sub saveedit()

	    If action="saveadd" Then 
			If fycms.s("file")="" Then die "请输入碎片名称"
		Call noSaveFile(Request.Form("content"),fycms.ThisTheme&"/label/"&fycms.s("file")&".html")
		Else 
		Call noSaveFile(Request.Form("content"),fycms.ThisTheme&"/label/"&fycms.s("files")&".html")
		End If 
		Call fycms.ActErr("修改成功","Sys_fy/label/Index.asp","")
	End Sub	

	sub Main()
 
 
  
%> <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>碎片名称</th>
	  <th>调用方式</th>
	  <th>常规操作</th>
	  </tr>
    </thead>
	<%
 
	If Not  FsoObj.fileexists(Server.mappath(fycms.ThisTheme&"/label/")) then 
		Call fycms.CreateFolder(fycms.ThisTheme&"/label/")
	End if

 

Dim FileObj,FolderObj,SubFolderObj,FsoItem,FileExtName
Set FolderObj = FsoObj.GetFolder(Server.MapPath(fycms.ThisTheme&"/label/"))
Set SubFolderObj = FolderObj.SubFolders
Set FileObj = FolderObj.Files

for each FsoItem In FileObj
	FileExtName = LCase(Mid(FsoItem.name,InstrRev(FsoItem.name,".")+1))
  	if FileExtName="html" Then
		Dim labelname
		labelname=Split(FsoItem.name,".")(0) 
	%>
    <tr>
      <td ><%=labelname%></td>
      <td >{fytpl:label/<%=FsoItem.name%>}</td>
       <td > <a href="?action=edit&file=<%=labelname%>">修改</a>  
      <a href="?Action=del&file=<%=labelname%>" onclick='return delad();'>删除 </a>
      </td>
    </tr>
	  <%
  	end if
next
%>    </table>
  
  <% end sub
	sub edit()
	Dim DiyPath,Rs,content,filedisabled,frmAction,tempurl
	IF Action = "edit" Then
		 content=LoadTemplate("label/"&fycms.s("file")&".html")
 		frmAction		= "edit"
		filedisabled="disabled"

	Else
		frmAction = "add"
	End IF
  %>
<form name="form1" method="post" action="Index.asp">
     <div class="divtable"> 
        <dl>
            <dt>碎片名称:</dt>
            <dd>
               <input name="file" type="text"  class="Ainput" <%=filedisabled%>  value="<%= fycms.s("file") %>" size="50"> <a href="?action=<%=Action%>&file=<%=fycms.s("file")%>&e=act"><b>加载编辑器</b></a>
             </dd>
         </dl>
        
       
 
	<dl><dt> 内容：</dt>
          <dd>  
  	 <div class="edit">       


  <%If fycms.s("e")<>"act" Then %>
<textarea name="content" id="content1" cols="155" rows="25"><%=content%></textarea>
<%Else
		echo writeeditor(0,"content1","content","",content)

End If 

%>







</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 btn_primary" value="重置">
		 <input name="Action" type="hidden" id="Action" value="save<%=frmAction%>">
		 <input name="ID" type="hidden" id="ID" value="<%=id%>">
		 <input name="files" type="hidden"  value="<%=fycms.s("file")%>">
            </dd>
         </dl>
        
    </div>
    </form>


 
<script language="javascript">
 
function CheckForm()
{ var form=document.form1;
	    <%if  fycms.s("e")="act" then echo checkeditpost(0,1)%>
 	    form.submit();
        return true;
	}</script>  
	<%end sub
CloseConn %>



</div>
</body>
</html>
