<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<title>默认模板管理</title>
		<link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css">
		<link rel="stylesheet" href="../static/web/css/bootstrap.min.css">
		<link rel="stylesheet" href="../static/web/css/admin.css">
	</head>
	<body>
		<table width="98%" cellspacing="1" cellpadding="0" align="center" class="table maintable my-3">
			<tr>
				<td colspan="4" bgcolor="#f5f5f5">
					<?php
					if ($acdir=='plus') echo '插件模板';
					else if ($acdir=='system') echo '系统模板';
					else echo '模板管理 &gt; '.$acdir;
					?>
				</td>
			</tr>
			<tr bgColor="#e9ecef" align="center">
				<td width="26%">模板名</td>
				<td width="26%">模板描述</td>
				<td width="26%">修改时间</td>
				<td>操作</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:s",$filetime);
				$fileinfo = (isset($fileinfos[$filename]) ? $fileinfos[$filename]:'未知模板');
			?>
			<tr align="center">
				<td align="left"><a href="<?php echo $templeturld.'/'.$filename;?>" target="_blank"><img src="../static/web/img/icon_htm.png"><?php echo $filename;?></a></td>
				<td><?php echo $fileinfo;?></td>
				<td><?php echo $filetime;?></td>
				<td align="left">
					<a href="tpl.php?action=edit&acdir=<?php echo $acdir;?>&filename=<?php echo $filename;?>" class="btn btn-light btn-sm"><i class="fa fa-pencil-square"></i> 修改</a>
					<?php if (!isset($fileinfos[$filename])) {?>
					<a href="javascript:;" onclick="javascript:DelTpl('<?php echo $filename;?>');" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i> 删除</a>
					<?php }?>
				</td>
			</tr>
			<?php }?>
			<tr>
				<td bgcolor="#f5f5f5" colspan="4" align="center">
					<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>
					<a class="btn btn-success btn-sm" href="tpl.php?action=newfile&acdir=<?php echo $acdir;?>">新建模板</a>
					<a class="btn btn-success btn-sm" href="tpl.php?action=upload&acdir=<?php echo $acdir;?>">上传模板</a>
				</td>
			</tr>
		</table>
		<script>
			function DelTpl(filename) {
				if (window.confirm('您确实要删除这个模板吗')) location = 'tpl.php?action=del&acdir=<?php echo $acdir; ?>&filename=' + filename;
				else return false;
			}
		</script>
	</body>
</html>