index.php类初始化以后,默认执行indexOp()操作:
public function indexOp(){ //输出管理员信息 Tpl::output(‘admin_info‘,$this->getAdminInfo()); //getAdminInfo()继承于父类SystemControl //输出菜单 $this->getNav(‘‘,$top_nav,$left_nav,$map_nav); //获取菜单,在公共方法中 Tpl::output(‘top_nav‘,$top_nav); Tpl::output(‘left_nav‘,$left_nav); Tpl::output(‘map_nav‘,$map_nav); Tpl::showpage(‘index‘,‘index_layout‘);}
protected final function getNav($permission = ‘‘,&$top_nav,&$left_nav,&$map_nav){ $act = $_GET[‘act‘]?$_GET[‘act‘]:$_POST[‘act‘]; $op = $_GET[‘op‘]?$_GET[‘op‘]:$_POST[‘op‘]; if ($this->admin_info[‘sp‘] != 1 && empty($this->permission)){ $gadmin = Model(‘gadmin‘)->getby_gid($this->admin_info[‘gid‘]); $permission = decrypt($gadmin[‘limits‘],MD5_KEY.md5($gadmin[‘gname‘])); $this->permission = $permission = explode(‘|‘,$permission); } Language::read(‘common‘); $lang = Language::getLangContent(); $array = require(BASE_PATH.‘/include/menu.php‘); $array = $this->parseMenu($array); //管理地图 $map_nav = $array[‘left‘]; unset($map_nav[0]);//unset()销毁变量 $model_nav = "<li><a class=\"link actived\" id=\"nav__nav_\" href=\"javascript:;\" onclick=\"openItem(‘_args_‘);\"><span>_text_</span></a></li>\n"; $top_nav = ‘‘; //顶部菜单 foreach ($array[‘top‘] as $k=>$v) { $v[‘nav‘] = $v[‘args‘]; $top_nav .= str_ireplace(array(‘_args_‘,‘_text_‘,‘_nav_‘),$v,$model_nav); } $top_nav = str_ireplace("\n<li><a class=\"link actived\"","\n<li><a class=\"link\"",$top_nav); //左侧菜单 $model_nav = " <ul id=\"sort__nav_\"> <li> <dl> <dd> <ol> list_body </ol> </dd> </dl> </li> </ul>\n"; $left_nav = ‘‘; foreach ($array[‘left‘] as $k=>$v) { $left_nav .= str_ireplace(array(‘_nav_‘),array($v[‘nav‘]),$model_nav); $model_list = "<li nc_type=‘_pkey_‘><a href=\"JavaScript:void(0);\" name=\"item__opact_\" id=\"item__opact_\" onclick=\"openItem(‘_args_‘);\">_text_</a></li>"; $tmp_list = ‘‘; $current_parent = ‘‘;//当前父级key foreach ($v[‘list‘] as $key=>$value) { $model_list_parent = ‘‘; $args = explode(‘,‘,$value[‘args‘]); if ($admin_array[‘admin_is_super‘] != 1){ if ([email protected]_array($args[1],$permission)){ } } if (!empty($value[‘parent‘])){ if (empty($current_parent) || $current_parent != $value[‘parent‘]){ $model_list_parent = "<li nc_type=‘parentli‘ dataparam=‘{$value[‘parent‘]}‘><dt>{$value[‘parenttext‘]}</dt><dd style=‘display:block;‘></dd></li>"; } $current_parent = $value[‘parent‘]; } $value[‘op‘] = $args[0]; $value[‘act‘] = $args[1]; //str_ireplace()使用一个字符串替换字符串中的另一些字符,对大小写敏感的搜索 str_replace(find,replace,string,count) $tmp_list .= str_ireplace(array(‘_args_‘,‘_text_‘,‘_opact_‘,‘_pkey_‘),array($value[‘args‘],$value[‘text‘],$value[‘op‘].$value[‘act‘],$value[‘parent‘]),$model_list_parent.$model_list); } $left_nav = str_replace(‘list_body‘,$tmp_list,$left_nav); }}
时间: 2024-11-05 02:43:50