<!--{template 'head'}-->
<table cellpadding="1" cellspacing="1" border="0" align=center class="tableborder" >
	<tr>
		<td class="tablerow"><b>管理选项：</b>
			<a href="plugin.php?plugin=mypage&action=add"> 添加网页 </a> | 
			<a href="plugin.php?plugin=mypage&action=manage">网页管理</a>
		</td>
	</tr>
</table>

<!--{if $action=='manage'}-->
<style>
#mytable td{padding:5px 0;}
</style>
<form method="post" name="myform">
<table cellpadding="0" cellspacing="0" class="tableborder bg" id="mytable">
	<tr align="center">
		<td width="40" class="tablerowhighlight"></td>
		<td width="30%" class="tablerowhighlight">标题</td>
		<td width="45%" class="tablerowhighlight">网页地址</td>
		<td class="tablerowhighlight">更新日期</td>
		<td class="tablerowhighlight">管理操作</td>
	</tr>
	<!--{if $pages}-->
	<!--{loop $pages $page}-->
	<tr align="center" class="item" id="item-{$id}">
		<td><input type="checkbox" name="id[]" id="ids_{$page[id]}" value="{$page[id]}"></td>
		<td align="left" style="padding-left:10px;">{$page[title]}</td>
		<td align="left" style="padding-left:10px;"><a href='{$page[url]}' target='_blank'>{$page[url]}</a></td>
		<td>{$page[updatetime]}</td>
		<td><a href='plugin.php?plugin=mypage&action=edit&id={$page[id]}'>修改</a> | <a href='plugin.php?plugin=mypage&action=delete&id={$page[id]}'>删除</a></td>
	</tr>
	<!--{/loop}-->
	<!--{else}-->
	<tr>
		<td colspan="5"><p style="padding:25px;text-align:center">还没有相关数据</p></td>
	</tr>
	<!--{/if}-->
	<tr>
		<td class="tablerowl"><input name='chkall' type='checkbox' id='chkall' onclick='checkall(this.form)' value='checkbox'></td>
		<td colspan=4 class="tablerowl" style="text-align:left;">
			<input type="submit" name="submit" value="删除选定的网页"  class="f-button" onClick="document.myform.action='plugin.php?plugin=mypage&action=delete'">&nbsp;&nbsp;
		</td>
	</tr>
</table>	</form>
<!--{/if}-->
<script language=JavaScript>
function doCheck()
{
	if (document.myform.title.value=="") 
	{
		alert("请输入标题");
		return false;
	}
	if (document.myform.meta_title.value=="") 
	{
		alert("请输入网页标题");
		return false;
	}
	$('submit').disabled = true;
}
</script>
<!--{if $action=='add' || $action == 'edit'}-->
<table cellpadding="2" cellspacing="1" class="tableborder">
	<tr>
		<th colspan=2>添加网页</th>
	</tr>
	<form name="myform" id="myform" method="post" action="plugin.php?plugin=mypage&action={$action}" onsubmit="return doCheck();">
	<tr>
		<td width="20%" class="tablerowl"><font color="red">单位页标题</font></td>
		<td class="tablerow"><input class="f-text"  name="title" type="text" size="60" value="{$title}"></td>
	</tr>
	<tr>
		<td class="tablerowl"><font color="red">网页标题</font></td>
		<td class="tablerow">
			<input name="meta_title"  class="f-text" type="text" size="60" value="{$meta_title}"> &nbsp;&nbsp;如果不设置则系统以标题代替此项
		</td>
	</tr>
	<tr>
		<td class="tablerowl">网页关键词</td>
		<td class="tablerow">
			<input name="meta_keywords" class="f-text"  type="text" size="60" value="{$meta_keywords}"> &nbsp;&nbsp;如果不设置则系统以网站关键词代替此项
		</td>
	</tr>
	<tr>
		<td class="tablerowl">网页描述</td>
		<td class="tablerow">
			<input name="meta_description"  class="f-text" type="text" size="60" value="{$meta_description}">&nbsp;&nbsp;如果不设置则系统以网站描述代替此项
		</td>
	</tr>
	<tr>
		<td class="tablerowl">网页模板</td>
		<td class="tablerow">
			<input name="tpl" id="tpl" type="text"  class="f-text" size="40" value='{$tpl}'>  <input type="button" onclick="SelectBrowse('images/browse.html?type=read&amp;channelid=-1&amp;callback=getDir','tpl',550,360);" value="选择模版"/> 为空则使用系统默认模板
		</td>
	</tr>
	<tr>
		<td class="tablerowl"><font color="red">网页内容</font></td>
		<td class="tablerow">
			<textarea name="content" id="content" style="display:none">{$content}</textarea>
			<iframe height="400" frameborder="0" width="100%" scrolling="no" src="../images/fck/editor/fckeditor.html?InstanceName=content&amp;Toolbar=Standard" id="FCKeditor1___Frame" name="FCKeditor1___Frame" style="border: 0pt none ; margin: 0pt; padding: 0pt; background-color: transparent; background-image: none; width: 100%; height: 400px;"></iframe>
		</td>
	</tr>
	<tr>
		<td class="tablerowl" colspan=2>
			<input type=hidden name=id value={$id}>
			<input type=hidden name=insert value=1>
			<input type="submit" name="Submit" id='submit' value=" 确定 " class="f-button" > &nbsp;
		</td>
	</tr>
	</form>
</table>
<!--{/if}-->


<!--{if $action == 'category'}-->

	<!--{if $action_do == 'manage'}-->
		<script language=javascript>
		function s_add()
		{
			var myInsertRow = 1;
			name         = $("add_name").value;
			description  = $("add_description").value;
			if( name=="")
			{
				alert("请填写完整数据");
				return false;
			}
			$("add_name").value = "";
			$("add_description").value = "";
			$("action").value = "数据处理中";
			$("action").disabled = true;
			link         = "plugin.php?plugin=mypage&action=category&action_do=add";
			AJAX.request( link,
			{
				method		: 'post',
				parameters  	: 'name='+name+'&description='+description ,
				onComplete	: function(json)
				{
					$("action").value = "添加数据";
					$("action").disabled = false;
					if( json.status == 200)
					{
						display(json.id, json.name);
					}
				}
			});
		}

		function display(id, name)
		{
			num = $('b_l').rowIndex;
			var x=$('table_ls').insertRow( num);
			x.height="25";
			x.bgColor="#F1F3F5";
			x.id="tr_"+id;
			x.align="center";
			var a=x.insertCell(0);
			var b=x.insertCell(1);
			var c=x.insertCell(2);
			a.innerHTML = id;
			b.innerHTML = "<input type=text value="+name+" size=15 id='name"+id+"'>";
			c.innerHTML = "<a style='cursor:pointer;' onclick=\"save("+id+");\">保存修改</a> | <a style='cursor:pointer;' onclick=\"del(this.parentNode.parentNode.rowIndex,"+id+");\">删除</a>";
		}	

		function del( _sId, id)
		{
			if(!confirm("你确定要删除该数据吗?\n此操作不可恢复"))
			{
				return false ;
			}
			link         = "plugin.php?plugin=mypage&action=category&action_do=del&id="+id;
			AJAX.request( link,
			{
				method		: 'get',
				onComplete	: function(json)
				{
					if( json.status!=200)
					{
						alert( json.message);
						return false;
					}
					else
					{
						var mytr=$('table_ls');
						$('table_ls').deleteRow( _sId);
					}
				}
			});
		}

		function save( id)
		{
			name         = $("name"+id).value;
			if( name=="")
			{
				alert("请填写完整数据");
				return false;
			}
			link         = "ajax.php?file=download_set&action=save&table="+table+"&id="+id;
			AJAX.request( link,
			{
				method		: 'post',
				parameters  : 'name='+name ,
				onComplete	: function(json)
				{
					if( json[0]==0)
					{
						alert("您的操作失败 原因可能如下:\n没有修改任何数据");
						return false;
					}
					else
					{
						alert(lang[json[1]]);
						return true;
					}
				}
			});
		}
		</script>
		<table id=table_ls width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='tableborder'>
			<tr>
				<td class="tablerowl" height=30> ID </td>
				<td class="tablerowl">名称</td>
				<td class="tablerowl">操作</td>
			</tr>
			<tr id='b_l'>
				<th align='center' class=submenu colspan=3><b>系统信息设置</b></th>
			</tr>
			<tr height=25>
				<td  class="tablerowl">分类名称</td>
				<td  class="tablerow" colspan=2><input class="f-text"  type=text id=add_name size=25></td>
			</tr>
			<tr height=25>
				<td  class="tablerowl">分类名称</td>
				<td  class="tablerow" colspan=2><textarea id=add_description cols='50' rows='4'></textarea></td>
			</tr>
			<tr height=25>
				<td class="tablerowl" colspan=3><input type=button class="f-button"  value="添加数据" id=action onclick="return s_add();"></td>
			</tr>
		</table>
		<script type="text/javascript">
			<!--{loop $lists $list}-->
			display( {$list[id]}, "{$list[name]}");
			<!--{/loop}-->
		</script>
	<!--{/if}-->

<!--{/if}-->
<!--{template 'foot'}-->
