function _rootcandy_admin_navigation() { $path = base_path() . path_to_theme(); $base = path_to_theme(); // get users role global $user; if ($user->uid != 1) { // get sorted roles $role_menu = _rootcandy_init_role_menu(); if ($role_menu) { $rootcandy_navigation = theme_get_setting('rootcandy_navigation_source_' . $role_menu); } } else { $rootcandy_navigation = theme_get_setting('rootcandy_navigation_source_admin'); if (!isset($rootcandy_navigation)) { $rootcandy_navigation = '_rootcandy_default_navigation'; } } $menu_tree = array(); if (!$rootcandy_navigation) { if (!$user->uid) { $menu_tree[] = array('href' => 'user/login', 'title' => t('User login')); } } elseif ($rootcandy_navigation == '_rootcandy_default_navigation') { // build default menu $menu_tree[] = array('href' => 'admin', 'title' => t('Dashboard')); $menu_tree[] = array('href' => 'admin/content', 'title' => t('Content')); if (variable_get('node_admin_theme', '0')) { $menu_tree[] = array('href' => 'node/add', 'title' => t('Create content')); } $menu_tree[] = array('href' => 'admin/build', 'title' => t('Building')); $menu_tree[] = array('href' => 'admin/settings', 'title' => t('Configuration')); $menu_tree[] = array('href' => 'admin/user', 'title' => t('Users')); $menu_tree[] = array('href' => 'admin/reports', 'title' => t('Reports')); if (module_exists('help')) { $menu_tree[] = array('href' => 'admin/help', 'title' => t('Help')); } } else { $menu_tree = menu_navigation_links($rootcandy_navigation); } if ($menu_tree) { $size = theme_get_setting('rootcandy_navigation_icons_size'); $icons_disabled = theme_get_setting('rootcandy_navigation_icons'); $list_class = 'i' . $size; $custom_icons = rootcandy_custom_icons(); if (!isset($custom_icons)) { $custom_icons = ''; } $match = _rootcandy_besturlmatch($_GET['q'], $menu_tree); $items = array(); foreach ($menu_tree as $key => $item) { $router_item = menu_get_item($item['href']); if (!$router_item['access']) { continue; } $id = ''; $icon = ''; $class = ''; // icons if (!$icons_disabled) { $size = theme_get_setting('rootcandy_navigation_icons_size'); if (!isset($size)) { $size = 24; } $arg = explode("/", $item['href']); $icon = _rootcandy_icon($arg, $size, 'admin', $custom_icons); if ($icon) { $icon = $icon . '<br />'; } } if ($key == $match) { $id = 'current'; if (!$icons_disabled && $size) { $id = 'current-' . $size; } } // add a class to li $class = ""; if (is_array($arg)) { $class = implode($arg, '-'); } $item['data'] = l($icon . $item['title'], $item['href'], array('html' => TRUE)); if (!empty($id)) { $item['id'] = $id; } if (!empty($class)) { $item['class'] = $class; } if (!empty($item['attributes'])) { unset($item['attributes']); } $items[] = $item; } $level = 1; if ($rootcandy_navigation == '_rootcandy_default_navigation') { $rootcandy_navigation = 'navigation'; $level = 2; } return array('navigation' => theme('admin_navigation', $items, $list_class), 'menu' => $rootcandy_navigation, 'level' => $level); } }
function rootcandy_page_alter(&$page) { // TODO: ideally we should merge these from preprocess_page // to page_alter and have just one instance of code // this is a hack at the moment, but works as expected // get users role global $user; if ($user->uid != 1) { // get sorted roles $role_menu = _rootcandy_init_role_menu(); if ($role_menu) { $rootcandy_navigation = theme_get_setting('rootcandy_navigation_source_' . $role_menu); } } else { $rootcandy_navigation = theme_get_setting('rootcandy_navigation_source_admin'); if (!isset($rootcandy_navigation)) { $rootcandy_navigation = '_rootcandy_default_navigation'; } } $rootcandy_nav['menu'] = $rootcandy_navigation; if ($rootcandy_navigation == '_rootcandy_default_navigation') { $rootcandy_nav['menu'] = 'management'; } // get admin links into the region $rootcandy_nav['level'] = 2; $menu = menu_navigation_links($rootcandy_nav['menu'], $rootcandy_nav['level']); $menu_links = theme('links', array('links' => $menu, 'attributes' => array('id' => 'content-menu'))); global $language; if (!empty($menu_links)) { if ($language->direction) { $page['sidebar_second']['nav']['#markup'] = $menu_links; } else { $page['sidebar_first']['nav']['#markup'] = $menu_links; $page['sidebar_first']['nav']['#weight'] = -100; $page['sidebar_first']['#sorted'] = FALSE; } } }