Construit le menu supplémentaire de la gestion des utilisateurs

@param SidebarItem $sidebar Sidebar d'origine à completer
437634
public function build(SidebarItem $sidebar)
    {
        if (!$this->context->isGranted('ROLE_SUPER_ADMIN')) return;
        
        $security = $sidebar->addChild('olix_security', array(
            'label' => 'Droits & accès',
            'icon'  => 'fa fa-lock fa-fw',
            'route' => 'olix_security_manager',
        ));
        $security->addChild('olix_security_users', array(
            'label' => 'Gestion des utilisateurs',
            'icon'  => 'fa fa-user fa-fw',
            'route' => 'olix_security_manager_user_list',
        ));
        $security->addChild('olix_security_groups', array(
            'label' => 'Gestion des groupes',
            'icon'  => 'fa fa-group fa-fw',
            'route' => 'olix_security_manager_group_list',
        ));
    }
889873
public function output($sidebar)
    {
        if (!isset($this->modules[$sidebar]) || !$this->isModularitySidebarActive($sidebar)) {
            return;
        }

        // Get modules
        $modules = $this->modules[$sidebar];

        // Get sidebar arguments
        $sidebarArgs = $this->getSidebarArgs($sidebar);

        // Loop and output modules
        foreach ($modules['modules'] as $module) {
            if (!is_preview() && $module->hidden == 'true') {
                continue;
            }

            $this->outputModule($module, $sidebarArgs, \Modularity\ModuleManager::$moduleSettings[get_post_type($module)]);
        }
    }
1218645
public function isActiveSidebar($isActiveSidebar, $sidebar)
    {
        $widgets = wp_get_sidebars_widgets();
        $widgets = array_map('array_filter', $widgets);
        $visibleModules = false;

        if (isset($this->modules[$sidebar]) && count($this->modules[$sidebar]) > 0) {
            foreach ($this->modules[$sidebar]['modules'] as $module) {
                if (!is_preview() && $module->hidden == 'true') {
                    continue;
                }

                $visibleModules = true;
            }
        }

        $hasWidgets = !empty($widgets[$sidebar]);
        $hasModules = ($visibleModules && isset($this->modules[$sidebar]) && count($this->modules[$sidebar]) > 0);

        if ($hasWidgets || $hasModules) {
            return true;
        }

        return false;
    }
487993
protected function setupSidebars($sidebars)
    {
        // load current widget condig
        $active_widgets = get_option('sidebars_widgets');

        // collect widgets to be added to sidebars
        foreach ($sidebars as $sidebar => $widgets) {
            $new_widgets = [];
            foreach ($widgets as $type => $data) {
                // load all widgets for this type
                $widget = get_option('widget_' . $type);

                // add a new widget and retrieve id
                $widget[] = $data;
                end($widget);
                $id = key($widget);

                // save the widgets back to db
                update_option('widget_' . $type, $widget);

                // add the new widget id to active widgets
                $new_widgets[] = $type . '-' . $id;
            }
            // set active widgets for sidebar
            $active_widgets[$sidebar] = $new_widgets;
        }
        // save sidebars with widgets
        update_option('sidebars_widgets', $active_widgets);
    }
292009
public function updateSidebars(ServerRequestInterface $request): ResponseInterface
    {
        $modules = $this->module_service->findByInterface(ModuleSidebarInterface::class, true);

        $this->updateStatus($modules, $request);
        $this->updateOrder($modules, 'sidebar_order', $request);
        $this->updateAccessLevel($modules, ModuleSidebarInterface::class, $request);

        return redirect(route('sidebars'));
    }
183722
public function createSideMenu()
    {
        $this->pool->prepare();

        $menu = $this->factory->createItem('root', [
            'childrenAttributes' => [
                'id' => 'sidebar-menu'
            ]
        ]);

        $menu
            ->addChild('dashboard', [
                'route' => 'ekyna_admin_dashboard',
                'labelAttributes' => ['icon' => 'dashboard'],
            ])
            ->setLabel('ekyna_admin.dashboard')
        ;

        $this->appendChildren($menu);

        return $menu;
    }
801580
public function renderSidebarMenuItems($config): string
    {
        $config = $this->prepareMenuConfig($config);
        $this->setPageTitle($config);
        $out = '';
        foreach ($config as $mainData) {
            $childrenContainer = '';
            $liclass = $mainData['active'] ? 'active' : '';

            if (!empty($mainData['children'])) {
                $children = '';
                foreach ($mainData['children'] as $child) {
                    $children .= Text::insert($this->_defaultConfig['templates']['item'], [
                        'title' => $child['title'],
                        'icon' => isset($child['icon']) ? Text::insert($this->_defaultConfig['templates']['icon'], ['icon' => $child['icon']]) : '',
                        'href' => isset($child['url']) ? Router::url($child['url']) : '',
                        'childrenArrow' => '',
                        'childrenContainer' => '',
                        'liclass' => $child['active'] ? 'active' : '',
                    ]);
                }
                $childrenContainer = Text::insert($this->_defaultConfig['templates']['childrenContainer'], [
                    'children' => $children,
                ]);
                $liclass .= ' treeview';
            }
            $out .= Text::insert($this->_defaultConfig['templates']['item'], [
                'class' => $mainData['active'] ? 'active' : '',
                'liclass' => $liclass,
                'title' => '<span>' . $mainData['title'] . '</span>',
                'icon' => isset($mainData['icon']) ? Text::insert($this->_defaultConfig['templates']['icon'], ['icon' => $mainData['icon']]) : '',
                'href' => isset($mainData['url']) ? Router::url($mainData['url']) : '',
                'childrenArrow' => !empty($mainData['children']) ? $this->_defaultConfig['templates']['childrenArrow'] : '',
                'childrenContainer' => $childrenContainer,
            ]);
        }

        return $out;
    }
507288
public static function get_sidebar( $sidebar = 'sidebar.php', $data = array() ) {
		if ( strstr(strtolower($sidebar), '.php') ) {
			return self::get_sidebar_from_php($sidebar, $data);
		}
		return self::compile($sidebar, $data);
	}
1246299
public function registerSidebarsCollection()
    {
        $this->app->singleton('sidebars.collection', function ($app) {
            return new SidebarsCollection;
        });

        $this->app->alias('sidebars.collection', SidebarsCollection::class);
    }
142390
private function menusTranslations()
    {
        $menuItem = $this->_menuItem('Dashboard');
        if ($menuItem->exists) {
            $_arr = $this->_arr('menu_items', 'title', $menuItem->id);
            $this->_trans('en', $_arr, 'Dashboard');
            $this->_trans('pt', $_arr, 'Painel de Controle');
        }

        $menuItem = $this->_menuItem('Media');
        if ($menuItem->exists) {
            $_arr = $this->_arr('menu_items', 'title', $menuItem->id);
            $this->_trans('en', $_arr, 'Media');
            $this->_trans('pt', $_arr, 'Media');
        }

        $menuItem = $this->_menuItem('Posts');
        if ($menuItem->exists) {
            $_arr = $this->_arr('menu_items', 'title', $menuItem->id);
            $this->_trans('en', $_arr, 'Posts');
            $this->_trans('pt', $_arr, 'Publicações');
        }

        $menuItem = $this->_menuItem('Users');
        if ($menuItem->exists) {
            $_arr = $this->_arr('menu_items', 'title', $menuItem->id);
            $this->_trans('en', $_arr, 'Users');
            $this->_trans('pt', $_arr, 'Utilizadores');
        }

        $menuItem = $this->_menuItem('Categories');
        if ($menuItem->exists) {
            $_arr = $this->_arr('menu_items', 'title', $menuItem->id);
            $this->_trans('en', $_arr, 'Categories');
            $this->_trans('pt', $_arr, 'Categorias');
        }

        $menuItem = $this->_menuItem('Pages');
        if ($menuItem->exists) {
            $_arr = $this->_arr('menu_items', 'title', $menuItem->id);
            $this->_trans('en', $_arr, 'Pages');
            $this->_trans('pt', $_arr, 'Páginas');
        }

        $menuItem = $this->_menuItem('Roles');
        if ($menuItem->exists) {
            $_arr = $this->_arr('menu_items', 'title', $menuItem->id);
            $this->_trans('en', $_arr, 'Roles');
            $this->_trans('pt', $_arr, 'Funções');
        }

        $menuItem = $this->_menuItem('Tools');
        if ($menuItem->exists) {
            $_arr = $this->_arr('menu_items', 'title', $menuItem->id);
            $this->_trans('en', $_arr, 'Tools');
            $this->_trans('pt', $_arr, 'Ferramentas');
        }

        $menuItem = $this->_menuItem('Menu Builder');
        if ($menuItem->exists) {
            $_arr = $this->_arr('menu_items', 'title', $menuItem->id);
            $this->_trans('en', $_arr, 'Menu Builder');
            $this->_trans('pt', $_arr, 'Menus');
        }

        $menuItem = $this->_menuItem('Database');
        if ($menuItem->exists) {
            $_arr = $this->_arr('menu_items', 'title', $menuItem->id);
            $this->_trans('en', $_arr, 'Database');
            $this->_trans('pt', $_arr, 'Base de dados');
        }

        $menuItem = $this->_menuItem('Settings');
        if ($menuItem->exists) {
            $_arr = $this->_arr('menu_items', 'title', $menuItem->id);
            $this->_trans('en', $_arr, 'Settings');
            $this->_trans('pt', $_arr, 'Configurações');
        }
    }
1282108
public function build()
    {
        foreach ($this->modules->enabled() as $module) {
            $name = studly_case($module->getName());
            $class = 'Modules\\'.$name.'\\MenuExtenders\\SidebarExtender';

            if (class_exists($class)) {
                $extender = $this->container->make($class);

                $this->menu->add(
                    $extender->extendWith($this->menu)
                );
            }
        }
    }
1166593
public function init() {

		parent::init();

		// Config
		$this->apixBase	= 'core/permission';

		// Sidebar
		$this->sidebar = [ 'parent' => 'sidebar-identity', 'child' => 'perm' ];

		// Return Url
		$this->returnUrl = Url::previous( 'permissions' );
		$this->returnUrl = isset( $this->returnUrl ) ? $this->returnUrl : Url::toRoute( [ '/core/permission/all' ], true );

		// Breadcrumbs
		$this->breadcrumbs = [
			'base' => [
				[ 'label' => 'Home', 'url' => Url::toRoute( '/dashboard' ) ]
			],
			'all' => [ [ 'label' => 'Permissions' ] ],
			'groups' => [ [ 'label' => 'Permissions', 'url' => $this->returnUrl ], [ 'label' => 'Groups' ] ],
			'create' => [ [ 'label' => 'Permissions', 'url' => $this->returnUrl ], [ 'label' => 'Add' ] ],
			'update' => [ [ 'label' => 'Permissions', 'url' => $this->returnUrl ], [ 'label' => 'Update' ] ],
			'delete' => [ [ 'label' => 'Permissions', 'url' => $this->returnUrl ], [ 'label' => 'Delete' ] ]
		];
	}
856469
public function isActiveSidebar($sidebarName)
    {
        if (!$sidebarOption = $this->findOneByOptionName('sidebars_widgets')) {
            return false;
        }

        if (false === ($sidebarOption = unserialize($sidebarOption->getValue()))) {
            return false;
        }

        return isset($sidebarOption[$sidebarName]);
    }
371387
public function index()
    {
        $this->loadModel('Menu.Menus');
        $menus = $this->Menus->find()->all();

        $this->title(__d('menu', 'Menus List'));
        $this->set('menus', $menus);
        $this->Breadcrumb->push('/admin/menu/manage');
    }
403228
private function get_sidebar_content( $slug ) {
		if ( empty( $slug ) ) {
			return '';
		}

		return $this->get_view( 'admin/sidebar/' . $slug, $this->get_sidebar_content_params(), false, false );
	}
1321436
public function onMenuChange(Menu $menu) : void
    {
        $this->aliasManager->invalidate(['site_id' => $menu->getSiteId()]);
        $this->aliasCacheLookup->refresh();
    }
1162157
protected function initializeMenus()
    {
        foreach ($this->config('menu') as $name => $config) {
            Menu::create($name, $config);
        }

        // Add default menu items to sidebar
        if ($appshellMenu = Menu::get('appshell')) {
            // CRM Group
            $crm = $appshellMenu->addItem('crm_group', __('CRM'));

            $crm
                ->addSubItem('customers', __('Customers'), ['route' => 'appshell.customer.index'])
                ->data('icon', 'accounts-list')
                ->allowIfUserCan('list customers');

            // Settings Group
            $settings = $appshellMenu->addItem('settings_group', __('Settings'));

            $settings
                ->addSubItem('users', __('Users'), ['route' => 'appshell.user.index'])
                ->data('icon', 'accounts')
                ->allowIfUserCan('list users');
            $settings
                ->addSubItem('roles', __('Permissions'), ['route' => 'appshell.role.index'])
                ->data('icon', 'shield-security')
                ->allowIfUserCan('list roles');
            $settings
                ->addSubItem('settings', __('Settings'), ['route' => 'appshell.settings.index'])
                ->data('icon', 'settings')
                ->allowIfUserCan('list settings');
        }
    }