Esempio n. 1
0
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) {
            $key_parts = explode(' ', $key);
            $key = $key_parts[0];
            $active_trail = '';
            if (isset($key_parts[1])) {
                $active_trail = $key_parts[1];
            }
            $router_item = menu_get_item($item['href']);
            if (!$router_item['access'] && !menu_path_is_external($item['href']) && $item['href'] != '<front>') {
                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 || $active_trail == 'active-trail') {
                $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') {
            if (module_exists('admin_menu')) {
                $rootcandy_navigation = 'admin_menu';
            } else {
                $rootcandy_navigation = 'navigation';
            }
            $level = 2;
        }
        return array('navigation' => theme('admin_navigation', $items, $list_class), 'menu' => $rootcandy_navigation, 'level' => $level);
    }
}
Esempio n. 2
0
/**
 * Delete/Revert confirm form.
 *
 * @todo -- call back into the object instead.
 */
function ctools_export_ui_delete_confirm_form(&$form_state)
{
    $plugin = $form_state['plugin'];
    $item = $form_state['item'];
    $form = array();
    $export_key = $plugin['export']['key'];
    $question = str_replace('%title', check_plain($item->{$export_key}), $plugin['strings']['confirmation'][$form_state['op']]['question']);
    $path = !empty($_REQUEST['cancel_path']) && !menu_path_is_external($_REQUEST['cancel_path']) ? $_REQUEST['cancel_path'] : ctools_export_ui_plugin_base_path($plugin);
    $form = confirm_form($form, $question, $path, $plugin['strings']['confirmation'][$form_state['op']]['information'], $plugin['allowed operations'][$form_state['op']]['title'], t('Cancel'));
    return $form;
}