public function run() { preg_match("/(^.*?)\\?|(^.*)/", $_SERVER['REQUEST_URI'], $matchs); $currentRoute = empty($matchs[1]) ? $matchs[2] : $matchs[1]; //$closeUser = Yii::app()->params['close_user']; if ($this->allMenu) { $actions = Action::model()->getAllMenu(); } else { $actions = Privilege::getMenu($this->userid); } //var_dump($this->userid,$actions);exit; $first = $second = array(); foreach ($actions as $v) { if ($v['is_menu'] == 1) { $first[$v['aid']] = $v; } else { if ($v['is_menu'] == 2) { if (!isset($second[$v['first_menu']])) { $second[$v['first_menu']] = array(); } $second[$v['first_menu']][] = $v; } } } if (empty($this->horiz)) { $this->render('main.views.widget.left_menu_metro', array('first' => $first, 'second' => $second)); } else { $this->render('main.views.widget.horiz_menu_metro', array('first' => $first, 'second' => $second)); } }
public function run() { preg_match("/(^.*?)\\?|(^.*)/", $_SERVER['REQUEST_URI'], $matchs); $currentRoute = empty($matchs[1]) ? $matchs[2] : $matchs[1]; $actions = Privilege::getMenu($this->userid); $content = " <ul class='left_nav_ul'> "; foreach ($actions as $k => $v) { if (preg_match("|^{$v['route']}|", $currentRoute)) { // 点击后 $logopath = $v['logo_click']; $class = "click"; } else { $logopath = $v['logo']; $class = ""; } if ($this->type == 'logo' && !empty($v['logo'])) { $content .= "\n <li class='{$class}'><a href='{$v['route']}'><img src='{$logopath}' /></a></li>\n "; } else { $content .= "\n <li class='{$class}'><a href='{$v['route']}'>{$v['aname']}</a></li>\n "; } } $content .= " </ul> "; $this->render('main.views.widget.left_menu', array('show' => $content)); }