<%@ Page language="c#" AutoEventWireup="False" Inherits="Dvbbs.bbs.UI.Admin.admin_template_custom_main_page" %>
<%@ 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 cellpadding="0" cellspacing="1" width="100%" class="maintable" border="0">
	<tr>
		<th>
			自定义个性首页</th>
	</tr>
	<tr>
		<td class="nf2">
			<div class="underline">功能说明：</div>
			<span>
			1. 您可以修改模板，可以编辑新建和编辑模板风格；操作时请按照相关页面提示，完整填写表单信息。<br />
			2. 论坛当前正在使用的默认模板不能删除；必须至少保留一套模板，无法删除所有模板。<br />
			3. CSS风格配置可较为方便的更改论坛字体、背景颜色、表格边框和颜色等配置。
			</span>
		</td>
	</tr>
	<tr>
		<td>
			<b>快捷操作选项</b>&nbsp;&nbsp;<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")){%>
			&nbsp;&nbsp;<a href="?do_action=list_skin&amp;tpl_name=<%=Fetch.Get("tpl_name")%>">当前模板的皮肤管理首页</a><%}%>
		</td>
	</tr>
</table>
<br />
<%
string do_action = Get("do_action");
%>
<%
if (0 == do_action.Length) {
%>
<script type="text/javascript">
function GotoStartCustomMainPage(form)
{
	var ele = null;
	for (var i = 0; i < form.elements.length; i++)
	{
		ele = form.elements[i];
		if (ele.checked)
		{
			form.selecte_tpl.value = ele.tpl_name;
			form.selecte_tpl_friendly_name.value = ele.tpl_friendly_name;
		}
	}
	return true;
}
</script>
<form method="get" action="?" onsubmit="return GotoStartCustomMainPage(this);">
	<input type="hidden" name="do_action" value="start_custom_main_page" /> <input type="hidden" name="selecte_tpl" value="" />
	<input type="hidden" name="selecte_tpl_friendly_name" value="" />
	<table cellpadding="0" cellspacing="1" width="100%" class="maintable" border="0">
		<tr>
			<th>
				请选择风格模板</th>
		</tr>
		<tr>
			<td><span>选择一套风格模板，然后点击下一步，将可以自定义所选模板的首页。</span></td>
		</tr>
		<tr height="150px">
			<td>
				<%
			foreach (TemplateInfo ti in TemplateInfo.GetAllTemplateInfo()) {
				TemplateSkinInfo[] arr_tsi = ti.GetSkinInfoArray();
				if (null == arr_tsi || 0 == arr_tsi.Length)
				{
					continue;
				}
				TemplateSkinInfo tsi = arr_tsi[0];
			%>
				<div style="width:25%;float:left;text-align:center"><img src="<%=(tsi.SourceDirectory + tsi.ThumbnailPath)%>" style="margin:6px 4px" width="160" height="120" border="0" />
					<br />
					<input type="radio" id="<%=Text.JoinString(tsi.TemplateInfoName, "_", tsi.Name)%>" name="selected_skin" value="<%=tsi.Name%>" class="smallbox" <%=((tsi.TemplateInfoName == Fetch.CurrentTemplateName) && (tsi.Name == Fetch.CurrentSkinName) ? "checked=\"checked\"" : "")%> onclick="this.form.selecte_tpl.value=this.tpl_name" tpl_name="<%=tsi.TemplateInfoName%>" tpl_friendly_name="<%=tsi.FriendlyName%>" />
					<label for="<%=Text.JoinString(tsi.TemplateInfoName, "_", tsi.Name)%>">
						<%=tsi.FriendlyName%>
					</label>
				</div>
				<%
			}
			%>
			</td>
		</tr>
		<tr>
			<td align="center"><input type="submit" value="下一步" class="button" onFocus="IEvent('focus',this)" onBlur="IEvent('blur',this)"
					onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" /></td>
		</tr>
	</table>
</form>
<%
}
else if ("start_custom_main_page" == do_action)
{
%>
<script type="text/javascript" src="../templates/scripts/json.js"></script>
<script type="text/javascript">
function SubmitTplContent(form)
{
	var sys_options = __Layout__.getSystemOptions();
	var comma = '';
	form.sys_label_list.value = '';
	for (var i = 0; i < sys_options.length; i++)
	{
		form.sys_label_list.value += comma + sys_options[i];
		comma = ',';
	}
	
	var common_options = __Layout__.getCommonOptions();
	comma = form.common_label_list.value = '';
	for (var i = 0; i < common_options.length; i++)
	{
		form.common_label_list.value += comma + common_options[i];
		comma = ',';
	}
	
	form.json_string.value = __Layout__.toJSONString();
	
	form.tpl_content.value = __Layout__.getSubmitString('default_1_1');
	
	form.submit();
}
</script>
<form method="post" action="?do_action=submit_tpl_content">
	<input type="hidden" name="selecte_tpl" value="<%=Fetch.Get("selecte_tpl")%>" />
	<input type="hidden" name="sys_label_list" value="" /> <input type="hidden" name="common_label_list" value="" />
	<input type="hidden" name="tpl_content" value="" /> <input type="hidden" name="json_string" value="" />
	<table cellpadding="0" cellspacing="1" width="100%" class="maintable" border="0">
		<tr>
			<th>
				当前模板 --&gt; <font color="red"><b>
						<%=Get("selecte_tpl_friendly_name")%>
					</b></font>
			</th>
		</tr>
		<!-- 选择版式 -->
		<tr>
			<td><div style="border:0px solid red; line-height: 24px; font-size: 12pt;"><b>选择版式</b></div>
			</td>
		</tr>
		<tr>
			<td align="left">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr>
						<td style="text-align:center;vertical-align:top">
							<input type="radio" name="tpl_layout" class="radio" id="LO1" value="OneCol" onclick="__Layout__.setLayout('OneCol')" <%=("OneCol" == TemplateFormat ? "checked=\"checked\"" : "")%> disabled="disabled" />
							<label for="LO1">一列<br />
							<img src="images/custom_layout00.gif" id="LOI1" alt="一列" style="height:50px;width:50px" />
						</label>
						</td>
						<td style="text-align:center;vertical-align:top">
							<input type="radio" name="tpl_layout" class="radio" id="LO2" value="SymmetricTwoCol" onclick="__Layout__.setLayout('SymmetricTwoCol')" <%=("SymmetricTwoCol" == TemplateFormat ? "checked=\"checked\"" : "")%> disabled="disabled" />
							<label for="LO2">两列对称<br />
							<img src="images/custom_layout04.gif" id="LOI2" alt="两列对称" style="height:50px;width:50px" />
						</label>
						</td>
						<td style="text-align:center;vertical-align:top">
							<input type="radio" name="tpl_layout" class="radio" id="LO5" value="BackwardsTwoCol" onclick="__Layout__.setLayout('BackwardsTwoCol')" <%=("BackwardsTwoCol" == TemplateFormat ? "checked=\"checked\"" : "")%> />
							<label for="LO5">两列，右列窄<br />
							<img src="images/custom_layout02.gif" id="LOI5" alt="两列，右列窄" style="height:50px;width:50px" />
						</label>
						</td>
						<td style="text-align:center;vertical-align:top">
							<input type="radio" name="tpl_layout" class="radio" id="LO4" value="ClassicTwoCol" onclick="__Layout__.setLayout('ClassicTwoCol')" <%=("ClassicTwoCol" == TemplateFormat ? "checked=\"checked\"" : "")%> />
							<label for="LO4">两列，左列窄<br />
							<img src="images/custom_layout01.gif" id="LOI4" alt="两列，左列窄" style="height:50px;width:50px" />
						</label>
						</td>
						<td style="text-align:center;vertical-align:top">
							<input type="radio" name="tpl_layout" class="radio" id="LO3" value="ClassicThreeCol"onclick="__Layout__.setLayout('ClassicThreeCol')" <%=("ClassicThreeCol" == TemplateFormat ? "checked=\"checked\"" : "")%> disabled="disabled" />
							<label for="LO3">三列，中间宽<br />
							<img src="images/custom_layout03.gif" id="LOI3" alt="三列，中间宽" style="height:50px;width:50px" />
						</label>
						</td>
					</tr>
					<tr>
						<td style="text-align:center;vertical-align:top">
							<input type="radio" name="tpl_layout" class="radio" id="LO6" value="RightHeavyThreeCol" onclick="__Layout__.setLayout('RightHeavyThreeCol')" <%=("RightHeavyThreeCol" == TemplateFormat ? "checked=\"checked\"" : "")%> disabled="disabled" /><label for="LO6">三列，左列窄<br />
							<img src="images/custom_layout05.gif" id="LOI6" alt="三列，左列窄" style="height:50px;width:50px" />
						</label>
						</td>
						<td style="text-align:center;vertical-align:top">
							<input type="radio" name="tpl_layout" class="radio" id="LO7" value="SymmetricFourCol" onclick="__Layout__.setLayout('SymmetricFourCol')" <%=("SymmetricFourCol" == TemplateFormat ? "checked=\"checked\"" : "")%> disabled="disabled" />
							<label for="LO7">四个对称列<br />
							<img src="images/custom_layout06.gif" id="LOI7" alt="四个对称列" style="height:50px;width:50px" />
						</label>
						</td>
						<td colspan="3">&nbsp;</td>
					</tr>
				</table>
			</td>
		</tr>
		<!-- 选择要添加的模块 -->
		<tr>
			<td><div style="border:0px solid red; line-height: 24px; font-size: 12pt;"><b>选择要添加的标签/标签排列</b></div>
			</td>
		</tr>
		<tr>
			<td>
				<table cellpadding="3" cellspacing="1" border="1" bordercolor="#999999" width="100%">
					<tr>
						<td width="150px" height="150px" valign="top">
							<select name="LabelList" size="34" style="width: 100%;" ondblclick="if(this.form.LabelList.selectedIndex>=0){__Layout__.addLabel(this.form.LabelList.options[this.form.LabelList.selectedIndex]);}">
								<%
							string[] applied_label_list = GetAppliedLabelList();
							foreach (System.Data.DataRow dr in TemplateLabeList)
							{
								if (-1 != Array.IndexOf(applied_label_list, dr["label_name"].ToString()))
								{
									continue;
								}
							%>
								<option value="<%=dr["label_name"].ToString()%>" _label_type="<%=dr["label_type"].ToString()%>"><%=dr["description"].ToString()%></option>
								<%
							}
							%>
							</select>
						</td>
						<td valign="middle" align="center" width="30px">
							<input type="button" value="&gt;&gt;" class="button" onclick="if(this.form.LabelList.selectedIndex>=0){__Layout__.addLabel(this.form.LabelList.options[this.form.LabelList.selectedIndex]);}" />
							<br />
							<br />
							<input type="button" value="&lt;&lt;" class="button" onclick="__Layout__.cutTo(this.form.LabelList)" />
						</td>
						<td width="*">
							<!-- <div id="TemplateRank" style="width: 100%;"></div> -->
							<script type="text/javascript" src="scripts/admin_template_custom_main_page.js"></script>
							<script type="text/javascript">
								<% if (JsonString.Length > 0) { %>
								__Layout__.parseJSON('<%=JsonString%>');
								document.write(__Layout__.toHtmlString());
								<% } else { %>
								__Layout__.setLayout('<%=TemplateFormat%>');
								<% } %>
							</script>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td align="center" class="bottom"><input type="button" value=" 保  存 " class="button" onclick="SubmitTplContent(this.form)" onFocus="IEvent('focus',this)"
					onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" /></td>
		</tr>
	</table>
</form>
<%
}
%>
<br />
<bbs:AdminFooter runat="server" ID="Adminfooter1" />
