<?php include $this->admin_tpl('meta');?>
<title>添加URL规则 - YzmCMS内容管理系统</title>
</head>
<style>
.exp{margin:5px 0px 5px 120px;color:#888}
</style>
<body>
<article class="page-container">
<div class="formdoby_normal"> 
	<form method="post" onsubmit="return dosub(this)">
		<ul>
			<li><label><span class="c-red">*</span>名称：</label>
				<input type="text" class="input" style="width:400px" name="name" value="">
				<p class="exp">给它起一个描述名称</p>
			</li>
			<li><label><span class="c-red">*</span>URL规则：</label>
				<input type="text" class="input" style="width:400px" name="urlrule" value="">
				<p class="exp">如：mylist/(\d+)，“(\d+)”表示匹配数字，支持的特殊符号有：<span class="c-red">~!@</span></p>
			</li>
			<li><label><span class="c-red">*</span>指向的路由：</label>
				<input type="text" class="input" style="width:400px" name="route" value="">
				<p class="exp">如：对应上面的例子：模块/控制器/方法/参数1/$1</p>
				<p class="exp">URL规则：模块/控制器/方法/参数1/$1/参数2/$2...<span class="c-red">（$1,$2为规则中匹配到的动态值）</span></p>
			</li>
			<li><label><span class="c-red">*</span>优先级排序：</label>
				<input type="text" class="input" style="width:400px" name="listorder" value="50">
				<p class="exp">取值范围1-255，数值越小优先级越高</p>
			</li>
		</ul>
		<div class="footer_btn">
			<input type="hidden" name="dosubmit" value="1">
			<input class="btn btn-primary radius" type="submit" value="提 交">
			<input class="btn btn-default radius" type="button" value="取 消" onclick="yzmcms_close()">	
		</div>
	</form>
</div>
</article>
<?php include $this->admin_tpl('footer');?>

<script type="text/javascript">
	function dosub(obj){
		if(obj.name.value==''){
			layer.msg('名称不能为空！', {icon:2});
			return false;
		}
		if(obj.urlrule.value==''){
			layer.msg('URL规则不能为空！', {icon:2});
			return false;
		}
		if(obj.route.value==''){
			layer.msg('指向的路由不能为空！', {icon:2});
			return false;
		}
		if(isNaN(obj.listorder.value) || obj.listorder.value<1){
			 layer.msg('优先级排序只能为数字类型且大于1！', {icon:2});
			 return false;
		}
        $.ajax({
            type: 'POST',
            url: '<?php echo U('add');?>', 
            data: $(obj).serialize(),
		    dataType: "json", 
            success: function (msg) {
				if(msg.status == 1){
					layer.msg(msg.message, {icon:1, time:800}, function(){
						parent.location.reload();
					});
			    }else{
					layer.msg(msg.message, {icon:2});
				}
            }
        })		 
		return false;			 
	}
</script> 

</body>
</html>