如:http://www.cnblogs.com/fengzhiqiangcaisangzi/p/3368417.html
引用权限模型类:
class XAdminiAcl{ //权限配制数据 public static $aclList = array( '首页' => array( 'controller'=>'home', 'url'=>'default/home','acl'=>'home','action'=>array( array('name'=>'系统首页','url'=>'default/home','acl'=>'home_index','list_acl'=>array()), array('name'=>'栏目管理','url'=>'catalog/index','acl'=>'config_catalog','list_acl'=>array( '录入'=>'catalog_create', '编辑'=>'catalog_update','删除'=>'catalog_delete','排序'=>'catalog_sort_order' )), ) ), '设置' => array( 'controller'=>'config', 'url'=>'config/index', 'acl'=>'config','action'=>array( array('name'=>'站点设置','url'=>'config/index','acl'=>'config_index','list_acl'=>array()), array('name'=>'SEO设置','url'=>'config/seo','acl'=>'config_seo','list_acl'=>array()), array('name'=>'上传设置','url'=>'config/upload','acl'=>'config_upload','list_acl'=>array()), array('name'=>'自定义设置','url'=>'config/custom','acl'=>'config_custom','list_acl'=>array()), ) ), '内容' => array( 'controller'=>'post', 'url'=>'post/index', 'acl'=>'post','action'=>array( array('name'=>'内容管理','url'=>'post/index','acl'=>'post_index','list_acl'=>array( '录入'=>'post_create', '编辑'=>'post_update', '批量审核'=>'post_verify', '批量推荐'=>'post_commend', '删除'=>'post_delete' )), array('name'=>'评论管理','url'=>'post/comment','acl'=>'post_comment','list_acl'=>array( '回复'=>'post_comment_update', '删除'=>'post_comment_delete' )), array('name'=>'专题管理','url'=>'post/special','acl'=>'post_special','list_acl'=>array( '录入'=>'post_special_create', '编辑'=>'post_special_update', '删除'=>'post_special_delete' )), array('name'=>'单页管理','url'=>'page/index','acl'=>'page_index','list_acl'=>array( '录入'=>'page_create', '编辑'=>'page_update', '删除'=>'page_delete' )), ) ), '用户' => array( 'controller'=>'user', 'url'=>'admin/index', 'acl'=>'user','action'=>array( array('name'=>'管理员列表','url'=>'admin/index','acl'=>'admin_index','list_acl'=>array( '录入'=>'admin_create', '编辑'=>'admin_update', '删除'=>'admin_delete' )), array('name'=>'管理员权限','url'=>'admin/group','acl'=>'admin_group','list_acl'=>array( '录入'=>'admin_group_create', '编辑'=>'admin_group_update', '删除'=>'admin_group_delete' )), array('name'=>'管理员日志','url'=>'logger/admin','acl'=>'admin_logger','list_acl'=>array( '删除'=>'admin_logger_delete' )), array('name'=>'留言反馈','url'=>'question/index','acl'=>'question_index','list_acl'=>array( '回复'=>'question_update', '删除'=>'question_delete' )), ) ), }
views:
//获得第一级
<div class="nav"> <ul> <?php $i=0; foreach(XAdminiAcl::filterMenu() as $key=>$row):?> <li index="<?php echo $i ?>"> <div><a href="<?php echo $this->createUrl($row['url']) ?>" target="win" hidefocus><?php echo $key ?></a></div> </li> <?php $i++;endforeach;?> </ul> </div>
//获得第二级 <div id="leftmenu" class="menu"> <?php $i = 0; foreach(XAdminiAcl::filterMenu() as $key=>$row):?> <ul index="<?php echo $i ?>" class="left_menu"> <?php foreach((array)$row['action'] as $k=>$rc):?> <li index="<?php echo $k ?>"><a href="<?php echo $this->createUrl($rc['url'])?>" target="win"><?php echo $rc['name'] ?></a></li> <?php endforeach;?> </ul> <?php $i++; endforeach;?> </div>
第三级使用框架 <div class="mainB" id="mainB"> <iframe src="<?php echo $this->createUrl('default/home')?>" name="win" id="win" width="100%" height="100%" frameborder="0"></iframe> </div>
最后的js:(调整第二级的切换,第三级框架的视图,url的索引化)
<script type="text/javascript"> window.onload =window.onresize= function(){winresize();} function winresize() { function $(s){return document.getElementById(s);} var D=document.documentElement||document.body, h=D.clientHeight-90,w=D.clientWidth-160; $("main").style.height=h+"px"; $("mainB").style.width=w+"px"; } $(document).ready(function(){ var s=document.location.hash; if(s==undefined||s==""){s="#0_0";} s=s.slice(1); var navIndex=s.split("_"); $(".nav").find("li:eq("+navIndex[0]+")").addClass("active"); var targetLink=$(".menu").find("ul").hide().end() .find(".left_menu:eq("+navIndex[0]+")").show() .find("li:eq("+navIndex[1]+")").addClass("active") .find("a").attr("href"); $("#win").attr("src",targetLink); $(".nav").find("li").click(function(){ $(this).parent().find("li").removeClass("active").end().end() .addClass("active"); var index=$(this).attr("index"); $(".menu").find(".left_menu").hide(); $(".menu").find(".left_menu:eq("+index+")").show() .find("li").removeClass("active").first().addClass("active"); document.location.hash=index+"_0"; }); $(".left_menu").find("li").click(function(){ $(this).parent().find("li").removeClass("active").end().end() .addClass("active"); document.location.hash=$(this).parent().attr("index")+"_"+$(this).attr("index"); }); }); </script>