<!--#include file="../../fy.Function.asp"-->
<!--#include file="../../../fy_inc/cls_pageview.asp"-->
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>fycms后台管理系统</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("../../../")%>
<script type="text/javascript" src="../../../fy_inc/js/jquery.js"></script>
<script type='text/javascript' src='../../../fy_inc/js/lhg/lhgdialog.min.js'></script>
<script type='text/javascript' src='../../js/main.js'></script>
</head>
<body>
<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 变量管理</div>
    <div class="opers">
	<a href="index.asp" class="btn">管理首页</a>
	<a href="index.asp?Action=add" class="btn">新建变量</a>
	<a href="edit.asp?Action=fuckdz" class="btn btn_primary">修改全部变量内容</a>
    </div>
<% 
	If Not fycms.fycms_QXYZ(0,"variables","") Then   Call fycms.Alert("对不起，你没有操作权限！","") 
	Set FsoObj = CreateObject(fycms.FsoName) 
Dim vname,vtype,vcontent,variablesname,vid,vdescription
Dim FileObj,FolderObj,SubFolderObj,FsoItem,FileExtName,xml
 dim FsoObj,Action,ID,ShowErr,editpost

 	Dim arrs,i,strs

	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 edit()
	End Select
	
	Sub Del()
		
  	 	Call fycms.DeleteFile(Server.mappath(fycms.ThisTheme&"/variables/"&fycms.s("file")&".html"))
		Set conn=nothing
	 	Call fycms.ActErr("删除成功","Sys_fy/variables/Index.asp","")
 		Response.End
    End Sub
 

	Sub saveedit()


		Dim FilePath
 	
 	strs=fycms.s("strs")
	arrs=Split(strs,",")

For i=0 To ubound(arrs)

	FilePath=fycms.ThisTheme&"/variables/"&arrs(i)&".xml"
	 'On Error Resume Next
		Dim XmlDoc,Root,xRoot
		Set XmlDoc = Server.CreateObject("Microsoft.XMLDOM")
			XmlDoc.async = False
			XmlDoc.ValidateOnParse=False
			Set Root = XmlDoc.createProcessingInstruction("xml","version='1.0' encoding='gb2312' standalone='yes'")
			XmlDoc.appendChild(Root)
			Set xRoot = XmlDoc.appendChild(XmlDoc.CreateElement("fycmsv"))
				xRoot.setAttribute "version","1.0"
			Set xRoot = Nothing

			'写入文件信息
			Dim ThemeAuthor,ThemeSource 
			Dim XMLcdata

			  

		
			Set vid = XmlDoc.SelectSingleNode("//fycmsv").AppendChild(XmlDoc.CreateElement("vid"))
				vid.Text = arrs(i)
			Set vid=Nothing

			Set vname = XmlDoc.SelectSingleNode("//fycmsv").AppendChild(XmlDoc.CreateElement("vname"))
				vname.Text = Request.Form("vname"&i)
			Set vname=Nothing

			Set vtype = XmlDoc.SelectSingleNode("//fycmsv").AppendChild(XmlDoc.CreateElement("vtype"))
				vtype.Text = Request.Form("vtype"&i)
			Set vtype=Nothing


			Dim CThemeDescription


 			Set vdescription = XmlDoc.SelectSingleNode("//fycmsv").AppendChild(XmlDoc.CreateElement("vdescription"))
				Set XMLcdata = XmlDoc.createNode("cdatasection", "","")
					XMLcdata.NodeValue = Request.Form("vdescription"&i)
				Set CThemeDescription = vdescription.AppendChild(XMLcdata)
				Set CThemeDescription = Nothing



			Set vcontent = XmlDoc.SelectSingleNode("//fycmsv").AppendChild(XmlDoc.CreateElement("vcontent"))
				Set XMLcdata = XmlDoc.createNode("cdatasection", "","")
					XMLcdata.NodeValue = Request.Form("vcontent"&i)
				Set CThemeDescription = vcontent.AppendChild(XMLcdata)
				Set CThemeDescription = Nothing
			Set XMLcdata = Nothing
			Set vcontent=Nothing
			XmlDoc.Save(Server.mappath(FilePath))
			Set Root = Nothing
		Set XmlDoc = Nothing
 
 Next 





		Call fycms.ActErr("修改成功","Sys_fy/variables/Index.asp","")
	End Sub	

	 
 
 
	sub edit()
	Dim DiyPath,Rs,content,filedisabled,frmAction,tempurl,vidstr
	IF Action = "fuckdz" Then
 
		 


Set FolderObj = FsoObj.GetFolder(Server.MapPath(fycms.ThisTheme&"/variables/"))
Set SubFolderObj = FolderObj.SubFolders
Set FileObj = FolderObj.Files

for each FsoItem In FileObj
	FileExtName = LCase(Mid(FsoItem.name,InstrRev(FsoItem.name,".")+1))
  	if FileExtName="xml" Then
		variablesname=Split(FsoItem.name,".")(0) 
   			Set XML=fycms.NoAppGetXMLFromFile(server.MapPath(fycms.actsys&fycms.SysThemePath&"/"&fycms.NowTheme&"/variables/"&variablesname&".xml"))
		
			If IsObject(XML) And XML.readyState=4 Then
 				If XML.parseError.errorCode <> 0 Then 
				Else 
				vidstr = vidstr&XML.documentElement.selectSingleNode("vid").text&","
   				End If 
			Set XML=Nothing
		  End If 
 
end if
next
 vidstr=Left(vidstr, Len(vidstr) - 1)
 strs=vidstr
 			arrs=Split(vidstr,",")

	Else
 			arrs=Split(fycms.s("vid"),",")
 			strs=fycms.s("vid")
	End If
	

  %>     <form name="form1" method="post" action="edit.asp">

    <div class="divtable"> 
     
       <dl class="merger" >
            <dt>修改内容:</dt> <dd></dd>
          </dl>



         <input type="hidden" name="strs" id="strs" value="<%=strs%>">
<%

For i=0 To ubound(arrs)


    	 Set XML=fycms.NoAppGetXMLFromFile(server.MapPath(fycms.actsys&fycms.SysThemePath&"/"&fycms.NowTheme&"/variables/"&arrs(i)&".xml"))
 		
			If IsObject(XML) And XML.readyState=4 Then
 				If XML.parseError.errorCode <> 0 Then 
				Else 
				vid = XML.documentElement.selectSingleNode("vid").text
				vname = XML.documentElement.selectSingleNode("vname").text
				vtype = XML.documentElement.selectSingleNode("vtype").text
 				vcontent = XML.documentElement.selectSingleNode("vcontent").Text
 				vdescription = XML.documentElement.selectSingleNode("vdescription").Text
				
  				End If 
			Set XML=Nothing
		  End If 
		  if vtype="5" then editpost=editpost& checkeditpost("vcontent"&i,999)

  %> <input type="hidden" name="vvid<%= i %>" id="vvid" value="<%=vid%>">
<input type="hidden" name="vname<%= i %>" id="vname" value="<%=vname%>">
<input type="hidden" name="vtype<%= i %>" id="vtype" value="<%=vtype%>">
		 <input name="vdescription<%= i %>" type="hidden" id="vdescription<%= i %>" value="<%=vdescription%>">
        <dl>
            <dt><%= vname %></dt>
            <dd>
               <%


Select Case vtype
	Case "1"
		echo "<input type=""text"" id=""vcontent"&i&""" name=""vcontent"&i&""" size=""50""  class=""Ainput"" value="""&vcontent&""">&nbsp;"&vdescription&""
	Case "2"
 		echo "<input type=""text"" name=""vcontent"&i&"""  id=""vcontent"&i&""" size=""50""  class=""Ainput""  value="""&vcontent&"""><input id=""PicUrlsvcontent"&i&""" class=""btn btn_primary"" onClick=""javascript:tdialog(999,'"&fycms.actsys&fycms.adminurl&"/include/Upload_Admin.asp?A=add&instr=0&ModeID=999&instrname=vcontent"&i&"');"" name=""button"" type=""button""   value=""点击上传图片"">&nbsp;"&vdescription&""
	Case "3"
		echo "<input  "&getchecked(1,vcontent)&" type=""radio"" name=""vcontent"&i&""" value=""1"" />是<input   "&getchecked(0,vcontent)&" type=""radio"" name=""vcontent"&i&""" value=""0"" />否&nbsp;"&vdescription&""
	Case "4"
		echo "<textarea name=""vcontent"&i&""" id=""vcontent"" cols=""100%"" rows=""20"">"&Server.HTMLEncode(vcontent)&"</textarea>"&vdescription&""
	Case "5"
		echo writeeditor(999,"vcontent"&i&"","vcontent"&i&"","basic",vcontent)&"&nbsp;"&vdescription
	Case Else
		echo "文本"
End Select  


%>
             </dd>
         </dl>
        


<%Next 


%>
 
            <dl>
            <dt>提交：</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="saveedit">
				<input name="ID" type="hidden" id="ID" value="<%=id%>">
				<input name="files" type="hidden"  value="<%=fycms.s("file")%>">
            </dd>
         </dl>
        
    </div>
    </form>


</div>
<script language="javascript">

function CheckForm()
{ var form=document.form1;
	 
	   <%=editpost%>
	    form.submit();
        return true;
	}</script>  
	<%end sub
CloseConn 

Function getchecked(n,v)
	If n=1 Then 
		If v="1" Then 
			getchecked="checked=""checked"""
		End If 
	Else 
		If v="0" Then 
			getchecked="checked=""checked"""
		End If 
	End If 

End Function 
%></body>
</html>
