<%@ Page Inherits="Dvbbs.bbs.UI.Admin.admin_template" %>
<%@ Import Namespace="Dvbbs.Utils" %>
<%@ Import Namespace="System.IO" %>
<%@ Register tagPrefix="Dvbbs" namespace="Dvbbs.Controls" assembly="Dvbbs.Web"%>
<%@ Register tagPrefix="bbs" tagName="AdminHeader" src="controls/admin_header.ascx"%>
<%@ Register tagPrefix="bbs" tagName="AdminFooter" src="controls/admin_footer.ascx"%>
<bbs:AdminHeader title="修改论坛设置(bbs.config)" runat="server" ID="Adminheader1" />
<table width="100%" class="maintable" cellpadding="0" cellspacing="1" border="0" ID="Table1">
	<tr>
		<td class="title">风格模板管理</td>
	</tr>
	<tr>
		<td>
			<span>
					1. 您可以修改模板，可以编辑新建和编辑模板风格；操作时请按照相关页面提示，完整填写表单信息。<br />
					2. 论坛当前正在使用的默认模板不能删除；必须至少保留一套模板，无法删除所有模板。<br />
					3. CSS风格配置可较为方便的更改论坛字体、背景颜色、表格边框和颜色等配置。
			</span>
		</td>
	</tr>
	<tr>
		<td class="bottom">
			<a href="admin_template.aspx">模板管理首页</a><%=("list_tpl" == Fetch.Get("do_action") ? "" : "")%>
			<%if ("list_tpl" == Fetch.Get("do_action") || "edit_tpl" == Fetch.Get("do_action")){%>
			<a href="?do_action=list_skin&amp;tpl_name=<%=Fetch.Get("tpl_name")%>">&nbsp;&nbsp;|&nbsp;&nbsp;当前模板的皮肤管理首页</a><%}%>
		</td>
	</tr>
</table>
<br />
<%
if (string.Empty == Fetch.Get("tpl_name")) {	//	可用的模板列表
%>
<form method="post" action="?do_action=delete_selected_tpl">
	<table width="100%" class="maintable" cellpadding="0" cellspacing="1" border="0" ID="Table2">
		<tr>
			<td colspan="9" class="title">风格模板列表</td>
		</tr>
		<tr>
			<td colspan="9"><span>点击模板名称进行模板管理，如果要删除模板，请选择它们，然后点击“删 除”按钮。</span>
			</td>
		</tr>
		<tr class="Option">
			<td width="3%" nowrap>删除？</td>
			<td width="15%" nowrap>模板名称</td>
			<td width="3%" nowrap>创建日期</td>
			<td width="3%" nowrap>模板版本</td>
			<td width="3%" nowrap>适用的论坛版本</td>
			<td width="15%" nowrap>作者</td>
			<td width="3%" nowrap>作者的电子邮件</td>
			<td width="25%" nowrap>版权信息</td>
			<td style="text-align: left;">模板说明</td>
		</tr>
		<base target="_blank" />
		<%
	foreach (TemplateInfo ti in TemplateInfo.GetAllTemplateInfo())
	{
	%>
		<tr>
			<td><input type="checkbox" name="tpl_list" value="<%=ti.Name%>" class="checkbox" /></td>
			<td nowrap><a href="?do_action=list_tpl&amp;tpl_name=<%=ti.Name%>" target="_self"><%=ti.FriendlyName%></a></td>
			<td nowrap><%=ti.CreationDate.ToString("yyyy-MM-dd")%></td>
			<td><%=ti.Version%></td>
			<td><%=ti.InPointForumVersion%></td>
			<td><%=ti.Author%></td>
			<td><a href="mailto:<%=ti.AuthorEmail%>"><%=ti.AuthorEmail%></a></td>
			<td><%=ti.Copyright%></td>
			<td><%=ti.Description%></td>
		</tr>
		<%
	}
	%>
		<base target="_self" />
		<tr>
			<td class="bottom" colspan="9"><input class="button" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
					onMouseOut="IEvent('mouseout',this)" type="submit" value="删 除" /></td>
		</tr>
	</table>
</form>
<br />
<%
}
else if ("list_tpl" == Fetch.Get("do_action"))	//	模板文件列表
{
	TemplateInfo ti = TemplateInfo.CreateInstance(Fetch.Get("tpl_name"));
%>
<form action="?do_action=rebuild_all_tpl&tpl_name=<%=Fetch.Get("tpl_name")%>" method="post">
	<table width="100%" class="maintable" cellpadding="0" cellspacing="1" border="0" ID="Table3">
		<tr>
			<td colspan="3" class="title">[<%=ti.FriendlyName%>]&nbsp;&nbsp;编辑列表</td>
		</tr>
		<tr>
			<td colspan="3"><span>点击模板文件名称进行编辑。</span>
			</td>
		</tr>
		<tr class="Option">
			<td width="30%" nowrap="false">模板文件</td>
			<td>功能说明</td>
		</tr>
		<tr>
			<td colspan="3" style="padding: 0px;">
				<div style="overflow: auto; height: 350px; width: 100%; border: 0px solid red; margin: 0px;">
					<table width="100%" height="100%" cellpadding="2" cellspacing="2">
						<%
	string[,] files = ti.GetFiles();
	int rank1_length = files.GetLength(0);
	for (int i = 0; i < rank1_length; i++)
	{
	%>
						<tr>
							<td width="30%" nowrap="false"><div style="width: 98%; overflow: hidden;"><a href="?<%=("do_action=edit_tpl&amp;tpl_name=" + Fetch.Get("tpl_name") + "&amp;tpl_file_name=" + Server.UrlEncode(files[i, 0]))%>" title="<%=Server.HtmlEncode(Path.GetFileNameWithoutExtension(files[i, 0]))%>"><%=Path.GetFileNameWithoutExtension(files[i, 0])%></a></div>
							</td>
							<td><%=files[i, 1]%></td>
						</tr>
						<%
	}
	%>
					</table>
				</div>
			</td>
		</tr>
		<tr>
			<td colspan="3" class="bottom" align="center"><input type="submit" class="button" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)"
					onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" value="重新生成模板缓存" /></td>
		</tr>
	</table>
</form>
<br />
<%
}
else if ("edit_tpl" == Fetch.Get("do_action"))	//	编辑模板文件
{
	TemplateInfo ti = TemplateInfo.CreateInstance(Fetch.Get("tpl_name"));
%>
<form method="post" action="?<%=Request.QueryString.ToString()%>">
	<table width="100%" class="maintable" cellpadding="0" cellspacing="1" border="0">
		<tr>
			<th>
				编辑 [<%=ti.Name%>
				→
				<%=Path.GetFileNameWithoutExtension(Fetch.Get("tpl_file_name"))%>
				]</th>
		</tr>
		<tr>
			<td>
				<textarea name="tpl_content" style="width: 98%;height: 400px;margin-top:5px;margin-bottom:5px;margin-left:10px;"
					rows="20" cols="20" id="content"><%=Server.HtmlEncode(ti.GetTemplateFileContent(Fetch.Get("tpl_file_name"), Request.ContentEncoding))%></textarea>
			</td>
		</tr>
		<tr>
			<td align="center" class="bottom">
				<input class="button" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
					onMouseOut="IEvent('mouseout',this)" type="submit" value="保 存" />&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" value="返 回" onclick="history.back();" onFocus="IEvent('focus',this)"
					onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" /></td>
		</tr>
	</table>
</form>
<br />
<%
}
else if ("list_skin" == Fetch.Get("do_action"))	//	皮肤列表
{
	TemplateInfo ti = TemplateInfo.CreateInstance(Fetch.Get("tpl_name"));
%>
<style type="text/css">
.Option td { font-size: 11px; font-weight: normal; text-align: left; }
.ChkBox { border-width: 0px; }
</style>
<form method="post" action="?do_action=delete_selected_skin&tpl_name=<%=Fetch.Get("tpl_name")%>">
	<table width="100%" class="maintable" cellpadding="0" cellspacing="1" border="0" ID="Table4">
		<tr>
			<td colspan="9" class="title">[<%=ti.FriendlyName%>]&nbsp;&nbsp;的皮肤列表</td>
		</tr>
		<tr>
			<td colspan="9">点击皮肤的名称编辑皮肤样式，如果要删除皮肤，请选择它们，然后点击“提交”按钮。</td>
		</tr>
		<tr class="Option">
			<td width="3%" nowrap>删除？</td>
			<td width="15%" nowrap>名称</td>
			<td width="3%" nowrap>创建日期</td>
			<td width="3%" nowrap>版本</td>
			<td width="3%" nowrap>适用的论坛版本</td>
			<td width="15%" nowrap>作者</td>
			<td width="3%" nowrap>作者的电子邮件</td>
			<td width="25%" nowrap>版权信息</td>
			<td style="text-align: left;">说明</td>
		</tr>
		<base target="_blank" />
		<%
	foreach (TemplateSkinInfo tsi in ti.GetSkinInfoArray())
	{
	%>
		<tr>
			<td><input type="checkbox" name="skin_list" value="<%=tsi.Name%>" class="checkbox" /></td>
			<td nowrap><a href="?do_action=edit_skin&amp;tpl_name=<%=ti.Name%>&amp;skin_name=<%=tsi.Name%>" target="_self"><%=tsi.FriendlyName%></a></td>
			<td nowrap><%=tsi.CreationDate.ToString("yyyy-MM-dd")%></td>
			<td><%=tsi.Version%></td>
			<td><%=tsi.InPointForumVersion%></td>
			<td><%=tsi.Author%></td>
			<td><a href="mailto:<%=tsi.AuthorEmail%>"><%=tsi.AuthorEmail%></a></td>
			<td><%=tsi.Copyright%></td>
			<td><%=tsi.Description%></td>
		</tr>
		<%
	}
	%>
		<base target="_self" />
		<tr>
			<td align="center" class="bottom" colspan="9">
				<input class="button" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
					onMouseOut="IEvent('mouseout',this)" type="submit" value="保 存" /> &nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" class="button" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)"
					onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" value="返 回"
					onclick="history.back();" /></td>
		</tr>
	</table>
</form>
<br />
<%
}
else if ("edit_skin" == Fetch.Get("do_action"))	//	编辑皮肤样式
{
	TemplateInfo ti = TemplateInfo.CreateInstance(Fetch.Get("tpl_name"));
	TemplateSkinInfo tsi = ti.GetTemplateSkinInfo(Fetch.Get("skin_name"));
%>
<form method="post" action="?<%=Request.QueryString.ToString()%>">
	<table width="100%" class="maintable" cellpadding="0" cellspacing="1" border="0" ID="Table5">
		<tr>
			<td class="title">编辑 [<%=ti.Name%>
				→
				<%=tsi.Name%>
				]</td>
		</tr>
		<tr>
			<td>
				<textarea onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
					onMouseOut="IEvent('mouseout',this)" name="tpl_content" rows="20" cols="20" style="width:700px;height:400px"
					id="content"><%=Server.HtmlEncode(tsi.GetSkinFileContent(Request.ContentEncoding))%></textarea>
			</td>
		</tr>
		<tr>
			<td align="center" class="bottom">
				<input class="button" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
					onMouseOut="IEvent('mouseout',this)" type="submit" value="保 存" />&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" class="button" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)"
					onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" value="返 回"
					onclick="history.back();" /></td>
		</tr>
	</table>
</form>
<br />
<%
}
%>
<bbs:AdminFooter runat="server" ID="Adminfooter1" />