<% Option Explicit %>
<!--#include file="../../Inc/Cls_DB.asp" -->
<!--#include file="../../Inc/Const.asp" -->
<!--#include file="../../Inc/Function.asp" -->
<%
Dim DBC,Conn
Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),"P0301") then Call ReturnError1()
Dim NewsTempletPath,FS,FolderObj,SubFolderObj,FileObj,FileItem,FolderItem,FileIconDic,ParentPath,NewsTempleConfigObj
Set NewsTempleConfigObj = Conn.Execute("Select DoMain from Config")
NewsTempletPath = Request("Path")
if NewsTempletPath = "" then
	NewsTempletPath = "/"
	ParentPath = ""
else
	ParentPath = Mid(NewsTempletPath,1,InstrRev(NewsTempletPath,"/")-1)
	if ParentPath = "" then
		ParentPath = "/" & SysRootDir
	end if
end if
Set FS = Server.CreateObject("Scripting.FileSystemObject")
Set FolderObj = FS.GetFolder(Server.MapPath(NewsTempletPath))
Set SubFolderObj = FolderObj.SubFolders
Set FileObj = FolderObj.Files
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>模板列表</title> 
</head>
<link href="../../CSS/css.css" rel="stylesheet">
<script language="JavaScript" src="../JS/PublicJS.js"></script>
<body topmargin="0" leftmargin="0" onClick="SelectFile();" onselectstart="return false;" oncontextmenu="SelectFile();showMenu(MouseRightMenu);return false;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td height="20" class="ButtonList"> <div align="center">名称</div></td>
    <td height="20" class="ButtonList"> <div align="center">类型</div></td>
    <td height="20" class="ButtonList"> <div align="center">大小</div></td>
    <td height="20" class="ButtonList"> <div align="center">创建时间</div></td>
    <td height="20" class="ButtonList"> <div align="center">最后修改时间</div></td>
  </tr>
  <% if ParentPath <> "/" & SysRootDir and ParentPath <> "/" then %>
  <tr> 
    <td height="20"><table border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td><img src="../Images/arrow.gif" width="18" height="18"></td>
          <td><span class="TempletItem" title="上级目录<% = ParentPath %>" onDblClick="OpenParentFolder(this);" Path="<% = ParentPath %>">上级目录</span></td>
        </tr>
      </table></td>
    <td height="20">&nbsp;</td>
    <td height="20">&nbsp;</td>
    <td height="20">&nbsp;</td>
    <td height="20">&nbsp;</td>
  </tr>
  <%
end if
for Each FileItem In SubFolderObj
%>
  <tr> 
    <td height="20"> <table border="0" cellspacing="0" cellpadding="0">
        <tr title="双击鼠标进入此目录"> 
          <td>&nbsp;<img src="../Images/Folder.gif" width="18" height="18"></td>
          <td><span class="TempletItem" Path="<% = FileItem.name %>" onDblClick="OpenFolder(this);"> 
            <% = FileItem.name %>
            </span> </td>
        </tr>
      </table></td>
    <td height="20"> <div align="center">文件夹</div></td>
    <td height="20"> <div align="center"> 
        <% = FileItem.Size %>
      </div></td>
    <td height="20"> <div align="center"> 
        <% = FileItem.DateCreated %>
      </div></td>
    <td height="20"> <div align="center"> 
        <% = FileItem.DateLastModified %>
      </div></td>
  </tr>
  <%
Next
for Each FileItem In FileObj
%>
  <tr style="background:white;cursor:default;"> 
    <td height="20">&nbsp;<span File="<% = FileItem.Name %>"> 
      <% = FileItem.Name %>
      </span></td>
    <td height="20"> <div align="center"> 
        <% = FileItem.Type %>
      </div></td>
    <td height="20"> <div align="center"> 
        <% = FileItem.Size %>
        字节</div></td>
    <td height="20"> <div align="center"> 
        <% = FileItem.DateCreated %>
      </div></td>
    <td height="20"> <div align="center"> 
        <% = FileItem.DateLastModified %>
      </div></td>
  </tr>
  <%
next
%>
</table>
</body>
</html>
<!-- 鼠标右键菜单 -->
<div id=MouseRightMenu onclick="ClickMenu(this);" onmouseover="MouseOverRightMenu();" onmouseout="MouseOverRightMenu();" class="menu"> 
  <div class="MouseRightItem" id="AddTemplet" ExeFunction="OpenWindow('Frame.asp?FileName=NewTemplet.asp&Path='+CurrSelectPath,200,100,window);">新建</div> 
  <div class="MouseRightItem" id="EditTempletCode" ExeFunction="OpenEditerWindow('../Editer/TextEditer.asp?Path='+CurrPath+'&FileName='+SelectFileName,'TextEditer',800,560);">代码编辑</div>
  <div class="MouseRightItem" id="EditTemplet" ExeFunction="OpenEditerWindow('Templet_Edit.asp?Path='+CurrPath+'&FileName='+SelectFileName,'TextEditer',800,560);">可视编辑</div>
  <hr id="nouse2">
  <div class="MouseRightItem" id="DelTemplet" ExeFunction="if (confirm('确定要删除吗？')==true) DelNewsTemplet();">删除</div>
  <div class="MouseRightItem" id="ReNameTemplet" ExeFunction="OpenWindow('Frame.asp?FileName=FileReName.asp&Path='+CurrPath+'&OldFileName='+SelectFileName,200,100,window);">重命名</div>
  <hr id="nouse1">
  <div class="MouseRightItem" id="ImportTemplet" ExeFunction="OpenWindow('../Inc/UpFileFrame.asp?Path='+CurrSelectPath,350,150,window);">导入模板</div>
  <div class="MouseRightItem" id="BrowseTemplet" ExeFunction="window.open(CurrPath+'/'+SelectFileName);">预览</div>
  <hr id="nouse">
  <div class="MouseRightItem" id="reFresh" ExeFunction="location.reload();">刷新</div> 
   <hr id="HR6">
  <div class="MouseRightItem" id="Pros" ExeFunction="javascript:window.prompt('本页面路径属性' , '<%=Request.ServerVariables("SCRIPT_NAME")%>');">路径属性</div>
</div>
<%
Set Conn = Nothing
Set FS = Nothing
Set FolderObj = Nothing
Set FileObj = Nothing
Set SubFolderObj = Nothing
'Set FileIconDic = Nothing
%>
<script>
var CurrPath='<% = NewsTempletPath %>';
var CurrSelectPath='';
var SelectFileName='';
var SelectedFolder='';
EditTempletCode.className='MenuItemDisable';
EditTemplet.className='MenuItemDisable';
DelTemplet.className='MenuItemDisable';
ReNameTemplet.className='MenuItemDisable';
BrowseTemplet.className='MenuItemDisable';
function SelectFile()
{
	var el=event.srcElement;
	for (var i=0;i<document.all.length;i++) if (document.all(i).className=='TempletSelectItem') document.all(i).className='TempletItem';
	if (el.File!=null||el.Path!=null)
	{
		//if (el.id='UpParentPath') el.className='TempletSelectItem';
		el.className='TempletSelectItem';
		if (el.File!=null)	SelectFileName=el.File;
		else SelectFileName='';
		if (el.Path!=null)
		{
			SelectedFolder=el.Path;
			CurrSelectPath=CurrPath+'/'+SelectedFolder;
		}
		else
		{
			SelectedFolder='';
			CurrSelectPath=CurrPath;
		}
	}
	else
	{
		SelectFileName='';
		SelectedFolder='';
		CurrSelectPath=CurrPath;
	}
	if (SelectFileName!='')
	{
		EditTempletCode.className='MouseRightItem';
		EditTemplet.className='MouseRightItem';
		DelTemplet.className='MouseRightItem';
		ReNameTemplet.className='MouseRightItem';
		BrowseTemplet.className='MouseRightItem';
	}
	else
	{
		EditTempletCode.className='MenuItemDisable';
		EditTemplet.className='MenuItemDisable';
		DelTemplet.className='MenuItemDisable';
		ReNameTemplet.className='MenuItemDisable';
		BrowseTemplet.className='MenuItemDisable';
	}
}
function DelNewsTemplet()
{
	var ReturnValue='';
	//alert('NewsTemplet_Delete.asp?Path='+CurrPath+'&NewsTempletName='+SelectFileName);
	//return;
	ReturnValue=SendDataToServer('NewsTemplet_Delete.asp?Path='+CurrPath+'&NewsTempletName='+SelectFileName);
	if (ReturnValue!='') alert(ReturnValue);
	window.location.reload();
}
function SelectFolder(Obj)
{
	for (var i=0;i<document.all.length;i++)
	{
		if (document.all(i).className=='TempletSelectItem') document.all(i).className='TempletItem';
	}
	Obj.className='TempletSelectItem';
	//alert(Obj.tagName);
	SelectedFolder=Obj.Path;
}
function OpenFolder(Obj)
{
	var SubmitPath='';
	if (CurrPath=='/') SubmitPath=CurrPath+Obj.Path;
	else SubmitPath=CurrPath+'/'+Obj.Path;
	location.href='NewsTemplet_List.asp?Path='+SubmitPath;
}
function SelectUpFolder(Obj)
{
	for (var i=0;i<document.all.length;i++)
	{
		if (document.all(i).className=='TempletSelectItem') document.all(i).className='TempletItem';
	}
	Obj.className='TempletSelectItem';
}
function OpenParentFolder(Obj)
{
	location.href='NewsTemplet_List.asp?Path='+Obj.Path;
}
</script>