<!DOCTYPE html>
<html>
<head>
<meta charset="<?php echo $cfg_soft_lang; ?>">
<title>模板管理器</title>
<link rel="stylesheet" href="../static/web/css/bootstrap.min.css">
<link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css">
<link rel="stylesheet" href="../static/web/css/admin.css">
<style>
a.btn{color:white!important}
.linerow{border-bottom:1px solid #CBD8AC}
</style>
<script>
function DelTpl(filename) {
	if (window.confirm('您确定要删除这篇文档吗')) location = 'tpl.php?action=del&acdir=<?php echo $acdir; ?>&filename=' + filename;
	else return false;
}
</script>
</head>
<body background="../static/web/img/allbg.gif" leftmargin="8" topmargin="8">
	<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table maintable table-bordered mt-3">
		<tr>
			<td height="30" background="../static/web/img/tbg.gif" colspan="7">
				模板管理
			</td>
		</tr>
	</table>
	<table width="98%" border="0" cellspacing="1" cellpadding="0" align="center" class="table maintable table-bordered">
		<tr height="30" align="center">
			<td width="25%" background="../static/web/img/wbg.gif">文件名</td>
			<td width="30%" background="../static/web/img/wbg.gif">文件描述</td>
			<td width="25%" background="../static/web/img/wbg.gif">修改时间</td>
			<td width="20%" background="../static/web/img/wbg.gif">操作</td>
		</tr>
		<tr>
			<td colspan="4" height="30" bgcolor="#f8f8f8">
				<span style="float:left;line-height:26px">
				当前位置：
				<?php
      			if($acdir=='plus') echo '插件模板';
      			else if($acdir=='system') echo '底层模板';
      			else echo '核心模板 &gt; '.$acdir;
      			?>
				</span>
				<span style="float:right;padding-right:10px">
					<a class="btn btn-success btn-sm" href="templets_main.php">默认模板目录</a>
					<a class="btn btn-success btn-sm" href="templets_main.php?acdir=plus">插件模板目录</a>
				</span>
			</td>
		</tr>
		<?php
		$files = scandir($templetdird);
		foreach ($files as $filename){
			if(!preg_match("#\.htm#", $filename))
			continue;
			$filetime = filemtime($templetdird.'/'.$filename);
			$filetime = MyDate("Y-m-d H:i",$filetime);
			$fileinfo = (isset($fileinfos[$filename]) ? $fileinfos[$filename]:'未知模板');
		?>
		<tr height="26" bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';">
			<td><a href="<?php echo $templeturld.'/'.$filename; ?>" target="_blank"><img src="../static/web/img/htm.gif"><?php echo $filename; ?></a></td>
			<td><?php echo $fileinfo; ?></td>
			<td align="center"><?php echo $filetime; ?></td>
			<td align="center">
				<a href="tpl.php?action=edit&acdir=<?php echo $acdir; ?>&filename=<?php echo $filename; ?>" title="编辑" class="btn btn-success btn-sm"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></a>
				<?php
				if(!isset($fileinfos[$filename])){
				?>
				<a href="javascript:;" class="btn btn-success btn-sm" onClick="javascript:DelTpl('<?php echo $filename; ?>');" title="删除"><i class="fa fa-trash" aria-hidden="true"></i></a>
				<?php
		   		}
				?>
			</td>
		</tr>
		<?php
		}
		?>
		<tr>
			<td colspan="4" height="36" bgcolor="#f8f8f8">
				<a class="btn btn-success" href="tpl.php?action=newfile&acdir=<?php echo $acdir; ?>">新建模板</a>
				<a class="btn btn-success" href="tpl.php?action=upload&acdir=<?php echo $acdir; ?>">上传模板</a>
			</td>
		</tr>
	</table>
</body>
</html>