<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="forum_smiliemanage.aspx.cs" Inherits="Discuz.ForumPage.Admin.smiliemanage" %>
<%@ Register TagPrefix="cc1" Namespace="Discuz.Control" Assembly="Discuz.Control" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 

<html>
  <head>
    <title>论坛表情管理</title>		
	<LINK href="../styles/datagrid.css" type="text/css" rel="stylesheet">
			
	<script language="javascript" src="../js/common.js"></script>
	<link href="../styles/dntmanager.css" type="text/css" rel="stylesheet"> 
	<script type="text/javascript">
		function validate()
		{
			var str = ",<%=ViewState["dir"]%>";
			var count = 2;
			while(true)
			{
				if(	document.getElementById("id" + count) != null)
				{
					for(var i = count - 1; i >= 1; i--)
					{
						if(!document.getElementById("id" + i).checked) continue;
						if(!document.getElementById("id" + count).checked) continue;
						if(document.getElementById("group" + i).value == document.getElementById("group" + count).value)
						{
							Message("第" + i + "行的表情组名与第" + count + "行相同");
							return false;
						}
					}
					count++;
				}
				else
					break;
			}
			for(var i = 1;;i++)
			{
				if(document.getElementById("id" + i) == null)
				{
					Message("没有要提交的数据!");
					return false;
				}
				if(document.getElementById("id" + i).checked) break;
			}
			for(var i = 1;; i++)
			{
				if(document.getElementById("id" + i) == null)
					return true;
				else
				{
					if(document.getElementById("group" + i).value == "")
					{
						Message("第" + i + "行的表情组名为空！");
						document.getElementById("group" + i).focus();
						return;
					}
					if(str.indexOf("," + document.getElementById("group" + i).value + ",") >= 0)
					{
						Message("第" + i + "行的表情组名与原有的表情组名相同");
						return false;
					}
					if(isNaNEx(document.getElementById("order" + i).value))
					{
						Message("第" + i + "行为非零数字");
						return false;
					}
				}
			}
		}
		
		function Message(m)
		{
			document.getElementById("success").style.display = 'none';
			document.getElementById("SubmitButton").disabled = false;
			alert(m);
		}
		
		function isNaNEx(str)
		{
			return !(/^\d+$/.test(str));
		}
		
		function checkFileList(form)
		{
			var i = 1;
			while(true)
			{
				if(form.elements["id" + i] == null)
					break;
				form.elements["id" + i].checked = form.cfile.checked;
				i++;
			}
		}
	</script>
  </head>
  <body>
	
    <form id="Form1" method="post" runat="server">
    <cc1:datagrid id="smilesgrid" runat="server" OnCancelCommand="DataGrid_Cancel" OnEditCommand="DataGrid_Edit" OnUpdateCommand="DataGrid_Update" OnDeleteCommand="DataGrid_Delete">
				<Columns>
					<asp:BoundColumn DataField="ID" SortExpression="id" HeaderText="Id" Visible="false"></asp:BoundColumn>
					<asp:BoundColumn DataField="code" SortExpression="code" HeaderText="表情组名称"></asp:BoundColumn>
					<asp:BoundColumn DataField="displayorder" SortExpression="displayorder" HeaderText="显示顺序" ></asp:BoundColumn>
					<asp:BoundColumn DataField="url" SortExpression="url" HeaderText="图片路径" Readonly="true"></asp:BoundColumn>
					<asp:TemplateColumn HeaderText="操作">
						<ItemTemplate>
							<a href="forum_smilegrid.aspx?typeid=<%# DataBinder.Eval(Container, "DataItem.id").ToString() %>">管理此分类表情</a>
						</ItemTemplate>
					</asp:TemplateColumn>		
				</Columns>
	</cc1:datagrid>
	<div class="ManagerForm">
    <fieldset>
		<legend style="background:url(../images/icons/icon49.jpg) no-repeat 6px 50%;">增加现有表情组</legend>
			<table class="table1" cellspacing="0" cellpadding="3" rules="rows" border="0"  width="100%">
				<tr class="datagridHeader">
				  <td width="5%" align="left"><input type="checkbox" name="cfile" onclick="checkFileList(this.form)"></td>
				  <td width="25%">表情组名称</td>
				  <td width="25%">显示顺序</td>
				  <td width="45%">图片路径</td>
				</tr>
				<asp:Literal ID="dirinfoList" Runat="server" />
				<tr><td colspan="4" align="center" style="padding:10px 0;"><cc1:Button id="SubmitButton" runat="server" Text=" 提 交 " ValidateForm="true"></cc1:Button></td></tr>
			  </table>
    </fieldset>
    </div>
    </form>
	<%=footer%>
  </body>
</html>
