コード例 #1
0
 public function initMenu()
 {
     Console::output('初始化后台菜单 ....');
     /* ============= 添加后台菜单 ============= */
     //用户
     AdminHelper::addMenu('user', ['/user/admin/user/index'], '用户管理', ['icon' => 'fa-user', 'priority' => 10]);
     //rbac
     AdminHelper::addMenu('rbac', ['/user/admin/rbac/index'], '角色权限', ['subShow' => false, 'icon' => 'fa-group', 'priority' => 20]);
     AdminHelper::addSubMenu('rbac', 'roles', ['/user/admin/rbac/roles'], '角色列表');
     AdminHelper::addSubMenu('rbac', 'permissions', ['/user/admin/rbac/permissions'], '权限列表');
     //系统设置
     AdminHelper::addMenu('system', ['/admin/system/index'], '系统设置', ['icon' => 'fa-gears', 'priority' => 20]);
     Console::output('初始化后台菜单完成 ....');
 }
コード例 #2
0
ファイル: main.php プロジェクト: igaojie/yii-QA
echo Menu::widget(['encodeLabels' => false, 'activateParents' => true, 'options' => ['class' => 'sidebar-menu'], 'submenuTemplate' => "\n<ul class=\"treeview-menu\">\n{items}\n</ul>\n", 'items' => call_user_func(function ($menus) {
    $return = [];
    $activeItem = isset($this->params['activeMenu']) ? $this->params['activeMenu'] : null;
    foreach ($menus as $k => $menu) {
        $submenus = !empty($menu['submenu']) ? $menu['submenu'] : false;
        $notice = isset($menu['notice']) ? $menu['notice'] : ($submenus ? '<i class="fa fa-angle-left pull-right"></i>' : '');
        $return[$k] = ['url' => $submenus ? 'javascript:;' : $menu['link'], 'label' => '<i class="fa ' . $menu['icon'] . '"></i> ' . $menu['title'] . $notice, 'options' => ['class' => $submenus ? 'treeview' : ''], 'active' => $activeItem == $k ? true : null];
        if ($submenus) {
            $menu['subShow'] && ($return[$k]['items'][] = ['url' => $menu['link'], 'label' => '<i class="fa fa-angle-double-right"></i> ' . $menu['title'], 'active' => $return[$k]['active']]);
            foreach ($submenus as $key => $submenu) {
                $return[$k]['items'][] = ['url' => $submenu['link'], 'label' => '<i class="fa ' . $submenu['icon'] . '"></i> ' . $submenu['title'], 'active' => $activeItem == implode('/', [$k, $key]) ? true : null];
            }
        }
    }
    return $return;
}, AdminHelper::getMenu())]);
?>
        </section>
    </aside>
    <aside class="right-side">
        <section class="content-header">
            <h1>
                <?php 
echo Html::encode($this->title);
?>
                <?php 
if (!empty($this->params['smallTitle'])) {
    ?>
                    <small><?php 
    echo Html::encode($this->params['smallTitle']);
    ?>