<%@ page contentType="text/html; charset=GBK" session="false"%>

<%@ taglib uri="/cmsTag" prefix="cms"%>
<%@ page contentType="text/html; charset=GBK"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<%
			response.setHeader("Pragma", "No-cache");
			response.setHeader("Cache-Control", "no-cache");
			response.setDateHeader("Expires", 0);
		%>
		<title>文件列表</title>

		<link rel="stylesheet" type="text/css" href="../../style/default/main.css" />
		<script type="text/javascript" src="../javascript/commonUtil.js"></script>



	</head>



	<body>
		<button type="button" id="save" onclick="javascript:enterFolder('${param.prevEntry}');">
			<img src="../../core/style/default/images/up-action.png" alt="" />
			上级目录
		</button>
		&nbsp;
		<button type="reset" onclick='javascript:showAddDialog();'">
			<img src="../../core/style/default/images/script-add.png" alt="" />
			创建
		</button>
		&nbsp;
		<button type="reset" onClick="javascript:showImportDialog('${param.entry}');">
			<img src="../../core/style/default/images/script-import.png" alt="" />
			导入
		</button>
		&nbsp;
		<%--<button name="RESET" type="reset" name="save" onClick='javascript:showEditDialog();'>
			<img src="../../core/style/default/images/script-edit.png" alt="" />
			编辑
		</button>
		&nbsp;
		--%>
		<button type="reset" onClick="submitDeleteAction();">
			<img src="../../core/style/default/images/script-rename.png" alt="" />
			重命名
		</button>
		&nbsp;
		<button type="reset" onClick="javascript:deleteFile();">
			<img src="../../core/style/default/images/script-delete.png" alt="" />
			删除
		</button>
		&nbsp;
		<form method="post" name='templetForm' id='templetForm'>

			<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="b5d6e6">
				<tr>
					<td width="3%" height="22" background="../../core/style/default/images/bg.gif" bgcolor="#FFFFFF">
						<div align="center">
							<input type="checkbox" id="selectAll" name="selectFile" value="selectAll" onclick="javascript:regCheckBox(this);" />
						</div>
					</td>

					<td width="45%" height="22" background="../../core/style/default/images/bg.gif" bgcolor="#FFFFFF">
						<div align="center">
							<span class="STYLE1">模板全名</span>
						</div>
					</td>
					<td width="10%" height="22" background="../../core/style/default/images/bg.gif" bgcolor="#FFFFFF">
						<div align="center">
							<span class="STYLE1">文件大小</span>
						</div>
					</td>
					<td width="12%" height="22" background="../../core/style/default/images/bg.gif" bgcolor="#FFFFFF">
						<div align="center">
							<span class="STYLE1">最后修改时间</span>
						</div>
					</td>
					<td width="10%" height="22" background="../../core/style/default/images/bg.gif" bgcolor="#FFFFFF">
						<div align="center">
							<span class="STYLE1">添加者</span>
						</div>
					</td>
					<td width="10%" height="22" background="../../core/style/default/images/bg.gif" bgcolor="#FFFFFF">
						<div align="center">
							<span class="STYLE1">操作</span>
						</div>
					</td>




				</tr>
				<br>
				<cms:SiteFileInfoList>

					<cms:if test="${SiteFile.dir==true}">
						<tr>
							<td height="20" bgcolor="#FFFFFF" style="margin-top: 10px;">
								<div align="center">
									<input type="checkbox" name="selectFile" value="${SiteFile.entry}" onclick="javascript:regCheckBox(this);" />
								</div>
							</td>
							<td height="20" bgcolor="#FFFFFF" style="margin-top: 10px;">
								<div class="STYLE1" ondblclick="javascript:enterFolder('${SiteFile.entry}')">
									&nbsp;
									<img src='../../core/style/default/images/folder.png' />
									${SiteFile.fileName}
								</div>
							</td>
							<td height="20" bgcolor="#FFFFFF" style="margin-top: 50px;">
								<div align="left">
									目录
								</div>
							</td>
							<td height="40" bgcolor="#FFFFFF" style="margin-top: 10px;">
								<div align="center">
									<span class="STYLE1"> ${SiteFile.lastModifyTime}</span>
								</div>
							</td>
							<td height="20" bgcolor="#FFFFFF" style="margin-top: 10px;">
								<div align="center">
									<span class="STYLE1">${SiteFile.creator}</span>
								</div>
							</td>
							<td height="20" bgcolor="#FFFFFF" style="margin-top: 10px;">

							</td>
						</tr>

					</cms:if>
					<cms:else>
						<tr>
							<td height="20" bgcolor="#FFFFFF" style="margin-top: 10px;">
								<div align="center">
									<input type="checkbox" name="selectFile" value="${SiteFile.entry}" onclick="javascript:regCheckBox(this);" />
								</div>
							</td>
							<td height="20" bgcolor="#FFFFFF" style="margin-top: 10px;">
								<div class="STYLE1" ondblclick="javascript:editTempletFile('${SiteFile.entry}','${SiteFile.fileName}')">
									&nbsp;
									<cms:if test="${SiteFile.type=='jsp' || TempletFile.type=='html' || TempletFile.type=='htm'}">
										<img src='../../core/style/default/images/page_code.png' />
									</cms:if>
									<cms:elseif test="${SiteFile.type=='js'}">
										<img src='../../core/style/default/images/js.png' />

									</cms:elseif>
									<cms:elseif test="${SiteFile.type=='swf'}">
										<img src='../../core/style/default/images/flash.png' />

									</cms:elseif>
									<cms:elseif test="${SiteFile.type=='css'}">
										<img src='../../core/style/default/images/css.png' />
									</cms:elseif>
									<cms:elseif test="${SiteFile.type=='jpg' || TempletFile.type=='png' || TempletFile.type=='gif' || TempletFile.type=='jpeg'}">
										<img src='../../core/style/default/images/image.png' />
									</cms:elseif>
									<cms:else>
										<img src='../../core/style/default/images/unknown.png' />
									</cms:else>
									${SiteFile.fileName}

								</div>
							</td>
							<td height="20" bgcolor="#FFFFFF" style="margin-top: 50px;">
								<div align="center">
									<span class="STYLE1">${SiteFile.size}kb</span>
								</div>
							</td>
							<td height="40" bgcolor="#FFFFFF" style="margin-top: 10px;">
								<div align="center">
									<span class="STYLE1">${SiteFile.lastModifyTime}</span>
								</div>
							</td>
							<td height="20" bgcolor="#FFFFFF" style="margin-top: 10px;">
								<div align="center">
									<span class="STYLE1">${SiteFile.creator}</span>
								</div>
							</td>
							<td height="20" bgcolor="#FFFFFF" style="margin-top: 10px;">
								<div align="center">
									<span class="STYLE1"><button type="reset" onClick="javascript:editTempletFile('${SiteFile.entry}','${SiteFile.fileName}')">
											<img src="../../core/style/default/images/script-edit.png" alt="" />
											编辑
										</button> </span>
								</div>
							</td>

						</tr>
					</cms:else>


				</cms:SiteFileInfoList>


			</table>

			<input type="hidden" id="checkedFile" name="checkedFile">
			<input type="hidden" id="templetEntry" name="templetEntry" value="${param.entry}">
		</form>
	</body>

</html>

<script type="text/javascript">
var api = frameElement.api, W = api.opener;
  
function close()
{

	api.close();
}
   
var checkedIdMap = new HashMapJs();


function showAddDialog()
{
      var classInfo = new Object();
     // classInfo.className="${Class.className}";
     // classInfo.classId="${Class.classId}";
    //  classInfo.window=window.parent.location;
      
      var parent = window.showModalDialog("CreateTempletFile.jsp?random="+Math.random(),classInfo,"dialogWidth=550px;dialogHeight=150px;status=no;scrollbars=0");
      
       //alert( parent);
       
      //  window.parent.document.all[id='treeFrame'].src='ListClass.jsp'
      
     // if(typeof(parent) == "undefined")
    //  {
     //    return;
    //  }
     
      
     
 
      //document.getElementById('prevParent').value=parent;
      //document.moveContentClassForm.action='../../channel/moveContentClass.cmd';
    //  document.moveContentClassForm.submit();
}

function showImportDialog(currentEntry)
{

      var classInfo = new Object();
     // classInfo.className="${Class.className}";
     // classInfo.classId="${Class.classId}";
    //  classInfo.window=window.parent.location;
      
   	 window.showModalDialog("uploadTempletFile.jsp?random="+Math.random()+"&currentEntry="+currentEntry,classInfo,"dialogWidth=320px;dialogHeight=70px;status=no");
     window.location.reload();
     // alert( parent);
       
      //  window.parent.document.all[id='treeFrame'].src='ListClass.jsp'
      
     // if(typeof(parent) == "undefined")
    //  {
     //    return;
    //  }
     
      
     
 
      //document.getElementById('prevParent').value=parent;
      //document.moveContentClassForm.action='../../channel/moveContentClass.cmd';
    //  document.moveContentClassForm.submit();
}

function enterFolder(entry)
{
	entryAction("ListSiteFileInfo.jsp",entry);
}


function editTempletFile(entry,param)
{
    entryAction("EditTempletFile.jsp",entry, '&name='+param);
}




function showEditDialog()
{
	document.location.href='EditTempletFile.jsp';

}

function deleteFile()
{
	if(checkedIdMap.size()==0)
	{
		alert("需要选择目标文件");
		return;
	}

	
	if(confirm('当前模板目录以及子目录所有文件将被物理删除,您确定要删除吗?'))
    {
    	document.forms.templetForm.action="../../templet/deleteTemplateFile.cmd";
		document.getElementById("checkedFile").value=checkedIdMap.allValueToString("*");
		document.forms.templetForm.submit();
    }
    else
    {
      return;
    }


	
}


function regCheckBox(cBox)
{

  if(cBox.id==="selectAll" && cBox.checked==true)
  {
      selectAll();
      return false;
  }
  
  if(cBox.id==="selectAll" && cBox.checked==false)
  {
      unSelectAll();
      return false;
  }
  
   
  if(cBox.checked)
  {
      //document.getElementById("classId").value=cBox.value;
      checkedIdMap.put(cBox.value,cBox.value);
  }
  else
  {
      checkedIdMap.remove(cBox.value,cBox.value);
      document.getElementById("selectAll").checked=false;
  }
  
   return false;
  
}

function selectAll()
{
   var checks = document.getElementsByName('selectFile');

   for(var i = 0; i < checks.length; i++)
   {
      checks[i].checked=true;
      checkedIdMap.put(checks[i].value,checks[i].value);
   }
   checkedIdMap.remove('selectAll');
}

function unSelectAll()
{
   var checks = document.getElementsByName('selectFile');

   for(var i = 0; i < checks.length; i++)
   {
      checks[i].checked=false;
   }
   checkedIdMap.removeAll();
}



</script>
