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_weights = theme_get_setting('role-weight'); if ($role_weights) { $filter_out = array_keys($user->roles); $roles = array_intersect(array_flip($role_weights), $filter_out); ksort($roles); $keys = array_keys($roles); $role = $roles[$keys[0]]; $rootcandy_navigation = theme_get_setting('rootcandy_navigation_source_' . $role); } } else { $rootcandy_navigation = '_rootcandy_default_navigation'; } 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')); $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'); $class = ' class = i' . $size; $output = '<ul' . $class . '>'; $custom_icons = rootcandy_custom_icons(); if (!isset($custom_icons)) { $custom_icons = ''; } $match = _rootcandy_besturlmatch($_GET['q'], $menu_tree); foreach ($menu_tree as $key => $item) { $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 = ' id="current"'; if (!$icons_disabled && $size) { $id = ' id="current-' . $size . '"'; } } $output .= '<li' . $id . $class . '><a href="' . url($item['href']) . '">' . $icon . $item['title'] . '</a>'; $output .= '</li>'; } $output .= '</ul>'; } return $output; }
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); } }