コード例 #1
0
ファイル: template.php プロジェクト: hoannm/d6e
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);
    }
}
コード例 #2
0
ファイル: template.php プロジェクト: noslokire/Project-206
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;
}
コード例 #3
0
ファイル: template.php プロジェクト: espixxl/topguay
function rootcandy_links__rc_main_navigation($variables)
{
    global $language_url;
    $links = $variables['links'];
    $attributes = $variables['attributes'];
    $heading = $variables['heading'];
    $output = '';
    if (count($links) > 0) {
        $output = '';
        // Treat the heading first if it is present to prepend it to the
        // list of links.
        if (!empty($heading)) {
            if (is_string($heading)) {
                // Prepare the array that will be used when the passed heading
                // is a string.
                $heading = array('text' => $heading, 'level' => 'h2');
            }
            $output .= '<' . $heading['level'];
            if (!empty($heading['class'])) {
                $output .= drupal_attributes(array('class' => $heading['class']));
            }
            $output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>';
        }
        $output .= '<ul' . drupal_attributes($attributes) . '>';
        $num_links = count($links);
        $i = 1;
        $size = theme_get_setting('rootcandy_navigation_icons_size');
        $icons_disabled = theme_get_setting('rootcandy_navigation_icons');
        $list_class = 'i' . $size;
        // custom icons
        $custom_icons = _rootcandy_custom_icons();
        if (!isset($custom_icons)) {
            $custom_icons = '';
        }
        $match = _rootcandy_besturlmatch($_GET['q'], $links);
        $items = array();
        foreach ($links as $key => $link) {
            $class = array($key);
            $id = '';
            $icon = '';
            $class = '';
            // icons
            if (!$icons_disabled) {
                $arg = explode("/", $link['href']);
                $icon = _rootcandy_icon($arg, $size, 'admin', $custom_icons);
                if ($icon) {
                    $icon = $icon . '<br />';
                }
                $link['html'] = TRUE;
            }
            if ($key == $match) {
                $id = 'current';
                if (!$icons_disabled && $size) {
                    $id = 'current-' . $size;
                }
            }
            // add a class to li
            if (isset($arg) and is_array($arg)) {
                $class[] = implode($arg, '-');
            }
            // Add first, last and active classes to the list of links to help out themers.
            if ($i == 1) {
                $class[] = 'first';
            }
            if ($i == $num_links) {
                $class[] = 'last';
            }
            if (isset($link['href']) && ($link['href'] == $_GET['q'] || $link['href'] == '<front>' && drupal_is_front_page()) && (empty($link['language']) || $link['language']->language == $language_url->language)) {
                $class[] = 'active';
            }
            $output .= '<li' . drupal_attributes(array('class' => $class, 'id' => $id)) . '>';
            if (isset($link['href'])) {
                // Pass in $link as $options, they share the same keys.
                $output .= l($icon . $link['title'], $link['href'], $link);
            } elseif (!empty($link['title'])) {
                // Some links are actually not links, but we wrap these in <span> for adding title and class attributes.
                if (empty($link['html'])) {
                    $link['title'] = check_plain($link['title']);
                }
                $span_attributes = '';
                if (isset($link['attributes'])) {
                    $span_attributes = drupal_attributes($link['attributes']);
                }
                $output .= '<span' . $span_attributes . '>' . $link['title'] . '</span>';
            }
            $i++;
            $output .= "</li>\n";
        }
        $output .= '</ul>';
    }
    return $output;
}