<%@ Register tagPrefix="bbs" tagName="AdminFooter" src="controls/admin_footer.ascx"%>
<%@ Register tagPrefix="bbs" tagName="AdminHeader" src="controls/admin_header.ascx"%>
<%@ Register tagPrefix="Dvbbs" namespace="Dvbbs.Controls" assembly="Dvbbs.Web"%>
<%@ Page Inherits="Dvbbs.bbs.UI.Admin.admin_help" %>
<bbs:adminheader id="AdminHeader1" title="论坛帮助管理" runat="server"></bbs:adminheader>
<script language="JavaScript">
<!--
 function checkclass()
 {
    var f=document.getElementById("classtitle");
    if(f.value=='')
    {
      alert('请填写内容！');
      f.focus();
      return false;
     }
}
function checkcontent()
{
   var f=document.getElementById("title");
   if(f.value=='')
   {
     alert('请填写标题');
     f.focus();
     return false;
   }
 }

 //-->
</script>
<table cellpadding="0" cellspacing="1" width="100%" class="maintable" border="0">
	<tr>
		<th colspan="3">
			<a href="?action=default">帮助管理首页</a> | <a href="?action=addclass">添加一级分类</a>|<a href="../help.aspx?style=new_style" target="_blank">预览帮助</a></th>
	</tr>
	<tr>
		<td colspan="2">
			<li>
				如果没有帮助分类，请先添加一级分类栏目；</li>
			<li>
				添加帮助时，帮助标题不可为空；</li>
			<li>
				无论是分类栏目还是帮助内容，均可以设置为前台或后台显示。如果分类栏目设置为后台显示，其下所有子栏目或帮助内容都不在前台显示；</li>
			<li>
				添加帮助时，可以先将图片上传到本地再在帮助内容中加入本地图片地址；</li>
			<li>
				上传图片时可设置图片存放路径，否则将默认存放于论坛/files/uploadfiles/目录下；</li>
			<li>
				在删除一级分类栏目时请慎重，因为删除一级栏目将同时删除其下所有子栏目或帮助；</li>
		</td>
	</tr>
</table>
<br />
<FORM METHOD="POST" name="searchform" ACTION="?action=search">
	<table cellpadding="0" cellspacing="1" width="100%" class="maintable" border="0">
		<tr>
			<th colspan="2">
				搜索帮助</th>
		</tr>
		<tr>
			<td class="left" width="30%">输入帮助关键字<br />
				<span>留空为显示所有帮助</span>
			</td>
			<td class="right" width="70%">
				<input type="text" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
					onMouseOut="IEvent('mouseout',this)" name="keyword" size="50" /> <input type="submit" class="button" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)"
					onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" name="submit" value="搜 索" />
			</td>
		</tr>
	</table>
</FORM>
<BR />
<%
 if(action=="addclass")
 { 
 %>
<FORM METHOD="POST" name="classform" ACTION="?action=addclass1">
	<table cellpadding="0" cellspacing="1" width="100%" class="maintable" border="0">
		<tr>
			<th colspan="3">
				添加一级分类</th>
		</tr>
		<tr>
			<td class="left" width="30%">
				输入一级分类名
			</td>
			<td class="right" width="70%">
				<input type="text" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
					onMouseOut="IEvent('mouseout',this)" name="classtitle" id="classtitle" size="50" />
			</td>
		<tr>
			<td class="left">
				显示类型<br />
				<span>前、后台</span>
			</td>
			<td class="right">
				<select name="htype">
					<option value="0" selected="selected">选择显示类型</option>
					<option value="0">前台</option>
					<option value="1">后台</option>
				</select>
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<input type="submit" name="submit" class="button" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)"
					onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" onclick="return checkclass();"
					value="添加" />
			</td>
		</tr>
	</table>
</FORM>
<BR />
<%
}
if(action=="default" || action=="search")
{

  if(this.GetClassCount()>0)
  {

%>
<!--以下是显示帮助列表-->
<table cellpadding="0" cellspacing="1" width="100%" class="maintable" border="0">
	<tr>
		<th colspan="2">
			论坛帮助列表</th>
	</tr>
	<tr>
		<td colspan="2">
			<span>请慎重使用删除或更新标题的功能，其中的删除功能将不可恢复而且删除一个一级分类将同时删除其下所有帮助内容！</span>
		</td>
	</tr>
	<tr>
		<td align="center" width="70%">帮助标题</td>
		<td align="center" width="30%">管理操作</td>
	</tr>
	<%
 System.Data.DataTable db=conn.GetDataTable(Sql);
  int c=db.Rows.Count,_i01=0;
  if(c>0)
  { int tipi=1;
    for(;_i01<db.Rows.Count;_i01++)
    {
     
      if(Int32.Parse(db.Rows[_i01]["H_ParentID"].ToString())==0)
      {
%>
	<tr>
		<td nowrap="nowrap">
			<B>
				<%=db.Rows[_i01]["H_Title"]%>
				&nbsp;&nbsp;[一级分类] </B>
		</td>
		<td align="right" nowrap="nowrap">[<%=db.Rows[_i01]["H_Type"].ToString()=="0"?"前、后台显示":"仅后台显示"%>]→ 
			[<a href="admin_help.aspx?action=edit&id=<%=db.Rows[_i01]["H_ID"]%>">编辑</a>][<a href="admin_help.aspx?action=del&id=<%=db.Rows[_i01]["H_ID"]%>&parentid=<%=Int32.Parse(db.Rows[_i01]["H_ParentID"].ToString())%>">删除</a>]
		</td>
	</tr>
	<%   
  }
 else
 {
 %>
	<tr>
		<td nowrap="nowrap">
			<B>
				<%=db.Rows[_i01]["H_Title"]%>
			</B>
		</td>
		<td align="right" nowrap="nowrap">[<%=db.Rows[_i01]["H_Type"].ToString()=="0"?"前、后台显示":"仅后台显示"%>]→ 
			[<a href="admin_help.aspx?action=view&id=<%=db.Rows[_i01]["H_ID"]%>">查看内容</a>] 
			[<a href="admin_help.aspx?action=edit&id=<%=db.Rows[_i01]["H_ID"]%>">编辑</a>] [<a href="admin_help.aspx?action=del&id=<%=db.Rows[_i01]["H_ID"]%>">删除</a>]
		</td>
	</tr>
	<% 
} tipi=tipi+1;
}
%>
	<tr>
		<td class="title" colspan="11"><Dvbbs:Pager id="pager" per="30" runat="server" /></td>
	</tr>
	<%
}
else
{
%>
	<tr>
		<td class="title" colspan="2">没有找到符合条件的帮助列表！</td>
	</tr>
	<%
  }
  %>
</table>
<br />
<!--以下是添加帮助内容部分-->
<table cellpadding="0" cellspacing="1" width="100%" class="maintable" border="0">
	<form id="Dvform" name="Dvform" action="?action=addcontent" onsubmit="try{this.elements['body'].value = OSWEBXHTML.GetXHTML(IframeID.document.body);return true;}catch(e){alert(e.description);return false;}"
		method="post">
		<tr>
			<th colspan="2">
				添加帮助内容</th>
		</tr>
		<tr>
			<td colspan="2"><span>如果您的帮助内容中包含图片，那么您可以先将图片上传，然后在内容中插入图片路径。</span></td>
		</tr>
		<tr>
			<td width="10%" class="left">标题</td>
			<td class="right"><input type="text" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
					onMouseOut="IEvent('mouseout',this)" name="title" id="title" size="50"><font color="red">*</font><span>不可为空</span></td>
		</tr>
		<tr>
			<td class="left">分类</td>
			<td class="right">
				<select name="parentid">
					<%
						System.Data.DataTable dt=this.GetFirstClass();
						for(int i=0;i<dt.Rows.Count;i++)
						{
							if(i==1)
							{
								Response.Write("<option value="+dt.Rows[i]["H_ID"]+" selected>"+dt.Rows[i]["H_Title"]+"</option>");
							}
							else
							{
								Response.Write("<option value="+dt.Rows[i]["H_ID"]+">"+dt.Rows[i]["H_Title"]+"</option>");
							}
						}
					%>
				</select>
				<font color="red">*</font><span>选择您的帮助属于哪个一级类别。</span>
			</td>
		</tr>
		<tr>
			<td class="left">类型</td>
			<td class="right">
				<select name="htype">
					<option value="0" selected>前台</option>
					<option value="1">后台</option>
				</select>
				<font color="red">*</font><span>确定您的帮助于前台显示还是后台显示,如果其所属一级类别为后台，那么它也将在后台显示。</span>
			</td>
		</tr>
		<tr>
			<td class="left">上传图片
			</td>
			<td class="right">
				<iframe style="border:none;" frameborder="0" name="uploadform" id="uploadform" src="admin_upimg.aspx"
					width="75%" height="28px"></iframe>
			</td>
		</tr>
		<tr>
			<td class="left">内容</td>
			<td>
				<% string hcontent="";%>
			<!--#include file="_editor.html"-->
		</tr>
		<tr>
			<td align="center" colspan="2"><input type="submit" class="button" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)"
					onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" name="submit" onclick="return checkcontent();"
					value="保 存"></td>
		</tr>
	</form>
</table>
<%
}
else
 Response.Write("<span class='toptable grid'>目前还没有任何分类，请先<a href='?action=addclass'>添加一级分类</a>!</span>");
}
%>
<!--以下是编辑帮助部分-->
<%
if(action=="edit")  
  { 
   int id=Int32.Parse(Get("id"));
   System.Data.DataTable editdt=this.GetHelp(id);

 %>
<table cellpadding="0" cellspacing="1" width="100%" class="maintable" border="0">
	<% if(editdt.Rows[0]["H_ParentID"].ToString()!="0")
   {
   %>
	<form id="Dvform" name="Dvform" action="?action=edit1" onsubmit="try{this.elements['body'].value = OSWEBXHTML.GetXHTML(IframeID.document.body);return true;}catch(e){alert(e.description);return false;}"
		method="post">
		<%
 }else{%>
		<form id="Dvform" name="Dvform" action="?action=edit1" method="post">
			<%}%>
			<tr>
				<th colspan="2">
					编辑帮助内容</th>
			</tr>
			<tr>
				<td width="40">标题：</td>
				<td width="*">
					<input type="text" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" name="title" id="title" value="<%=editdt.Rows[0]["H_Title"]%>" size=50>
					<input type="hidden"  name="id" value="<%=id%>"/>
				</td>
			</tr>
			<tr>
				<% if(editdt.Rows[0]["H_ParentID"].ToString()=="0")
    {
     Response.Write("<td><input type=hidden name=parentid value='0'/></td><td></td>");}
    else
    {
%>
				<td width="40">分类：</td>
				<td width="*">
					<select name="parentid">
						<%         
      System.Data.DataTable dt=this.GetFirstClass();
      for(int i=0;i<dt.Rows.Count;i++)
      {
          if(dt.Rows[i]["H_ID"].ToString()==editdt.Rows[0]["H_ParentID"].ToString())
          {
             Response.Write("<option value="+dt.Rows[i]["H_ID"]+" selected>"+dt.Rows[i]["H_Title"]+"</option>");
          }
          else
          {
             Response.Write("<option value="+dt.Rows[i]["H_ID"]+">"+dt.Rows[i]["H_Title"]+"</option>");
          }
      }
   %>
					</select>
					*选择您的帮助属于哪个一级类别。
				</td>
			</tr>
			<%}%>
			<tr>
				<td width="40">类型：</td>
				<td width="*">
					<select name="htype">
						<%
 
    if(editdt.Rows[0]["H_Type"].ToString()=="0")
    {
      Response.Write("<option value=0 selected>前台</option>");
      Response.Write("<option value=1>后台</option>");
     }
    if(editdt.Rows[0]["H_Type"].ToString()=="1")
    {
       Response.Write("<option value=0>前台</option>");
       Response.Write("<option value=1 selected>后台</option>");
     }   
 %>
					</select>
					*确定您的帮助于前台显示还是后台显示。
				</td>
			</tr>
			<% if(editdt.Rows[0]["H_ParentID"].ToString()=="0")
{
  Response.Write("<tr><td><input type=hidden name=content id=content value=''/></td></tr>");
}
else
{
%>
			<tr>
				<td>上传图片:
				</td>
				<td>
					<iframe style="border:none" frameborder="0" name="uploadform" id="uploadform" src="admin_upimg.aspx"
						text-align="center" width="70%" height="28px"></iframe>
				</td>
			</tr>
			<tr>
				<td width="40">内容：</td>
				<td>
					<%string hcontent=Dvbbs.Utils.Text.TextEncode(editdt.Rows[0]["H_Content"].ToString());%>
					<!--#include file="_editor.html"-->
				</td>
				<%}%>
			</tr>
			<tr>
				<td colspan="2" align="center"><input class="button" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
						onMouseOut="IEvent('mouseout',this)" type="submit" name="submit" value="保 存"></td>
			</tr>
		</form>
</table>
<%}%>
<%
if(action=="view")
{
 int viewid=Int32.Parse(Get("id"));
   System.Data.DataTable viewdt=this.GetHelp(viewid);
%>
<table cellpadding="0" cellspacing="1" width="100%" class="maintable" border="0">
	<tr>
		<th>
			查看论坛帮助</th>
	</tr>
	<tr>
		<td height="23">
			<BR>
			<center><b><%=viewdt.Rows[0]["H_Title"]%>
				</b>
			</center>
			<BR>
			<BR>
			<BR>
			<blockquote>
				<%=viewdt.Rows[0]["H_Content"].ToString()%>
			</blockquote>
			<div align="right">[<a href=admin_help.aspx?action=edit&id=<%=viewid%>>编辑</a>] [<a href=admin_help.aspx?action=del&id=<%=viewid%>>删除</a>]</div>
		</td>
	</tr>
</table>
<%}%>
<bbs:AdminFooter runat="server" id="AdminFooter1" />