Esempio n. 1
0
/**
 * Preprocessor for theme('page').
 */
function rubik_preprocess_page(&$vars)
{
    // Show a warning if base theme is not present.
    if (!function_exists('tao_theme') && user_access('administer site configuration')) {
        drupal_set_message(t('The Rubik theme requires the !tao base theme in order to work properly.', array('!tao' => l('Tao', 'http://code.developmentseed.org/tao'))), 'warning');
    }
    // Set a page icon class.
    $vars['page_icon_class'] = ($item = menu_get_item()) ? implode(' ', _rubik_icon_classes($item['href'])) : '';
    // Help pages. They really do need help.
    if (strpos($_GET['q'], 'admin/help/') === 0 && isset($vars['page']['content']['system_main']['main']['#markup'])) {
        $vars['page']['content']['system_main']['main']['#markup'] = theme('help_page', array('content' => $vars['page']['content']['system_main']['main']['#markup']));
    }
    // Clear out help text if empty.
    if (empty($vars['help']) || !strip_tags($vars['help'])) {
        $vars['help'] = '';
    }
    // Process local tasks. Only do this processing if the current theme is
    // indeed Rubik. Subthemes must reimplement this call.
    global $theme;
    if ($theme === 'rubik') {
        _rubik_local_tasks($vars);
    }
    // Overlay is enabled.
    $vars['overlay'] = module_exists('overlay') && overlay_get_mode() === 'child';
}
Esempio n. 2
0
/**
 * Preprocessor for theme('page').
 */
function cube_preprocess_page(&$vars)
{
    // Automatically adjust layout for page with right sidebar content if no
    // explicit layout has been set.
    $layout = module_exists('context_layouts') ? context_layouts_get_active_layout() : NULL;
    if (arg(0) != 'admin' && !empty($vars['page']['right']) && (!$layout || $layout['layout'] == 'default')) {
        $vars['theme_hook_suggestion'] = 'page__context_layouts_cube_columns';
        drupal_add_css(drupal_get_path('theme', 'cube') . '/layout-sidebar.css');
    }
    // Clear out help text if empty.
    if (empty($vars['help']) || !strip_tags($vars['help'])) {
        $vars['help'] = '';
    }
    // Help text toggler link.
    $vars['help_toggler'] = l(t('Help'), $_GET['q'], array('attributes' => array('id' => 'help-toggler', 'class' => array('toggler')), 'fragment' => 'help-text'));
    // Overlay is enabled.
    $vars['overlay'] = module_exists('overlay') && overlay_get_mode() === 'child';
    if ($vars['overlay']) {
    }
    // Display user links
    $vars['user_links'] = _cube_user_links();
    // Display tabs
    $vars['primary_tabs'] = menu_primary_local_tasks();
    $vars['secondary_tabs'] = menu_secondary_local_tasks();
}
Esempio n. 3
0
/**
 * Preprocessor for theme_page().
 */
function eldir_preprocess_page(&$variables, $hook)
{
    // Prepare the svg URL
    if (strpos($variables['logo'], 'eldir')) {
        $variables['svg_logo'] = str_replace('logo.png', 'images-source/aegir_logo_horizontal.svg', $variables['logo']);
    }
    // Overlay is enabled.
    $variables['overlay'] = module_exists('overlay') && overlay_get_mode() === 'child';
    $variables['tabs2'] = $variables['tabs'];
    unset($variables['tabs']['#secondary']);
    unset($variables['tabs2']['#primary']);
    // Move the local actions into place of the secondary tabs, for now.
    if (is_array($variables['action_links'])) {
        foreach ($variables['action_links'] as $link) {
            $variables['tabs2']['#secondary'][] = $link;
            $variables['tabs2']['#theme'] = 'menu_local_tasks';
        }
        $variables['action_links']['#access'] = FALSE;
    }
    if (!isset($variables['title'])) {
        $variables['title'] = isset($variables['node']) ? $variables['node']->title : drupal_get_title();
    }
    $node = menu_get_object();
    if (!empty($node) && !$variables['overlay']) {
        // Add a node type label on node pages to help users.
        $types = node_type_get_types();
        $type = $node->type;
        if (!empty($types[$type])) {
            $variables['title'] = "<span class='label'>{$types[$type]->name}</span>" . $variables['title'];
        }
    }
}
/**
 * Override or insert variables into all templates.
 */
function genesis_process(&$vars)
{
    // Provide a variable to check if the page is in the overlay.
    if (module_exists('overlay')) {
        $vars['in_overlay'] = overlay_get_mode() == 'child';
    } else {
        $vars['in_overlay'] = FALSE;
    }
}
Esempio n. 5
0
/**
 * Override or insert variables into the page template.
 */
function shiny_preprocess_page(&$vars)
{
    $vars['primary_local_tasks'] = $vars['tabs'];
    unset($vars['primary_local_tasks']['#secondary']);
    $vars['secondary_local_tasks'] = array('#theme' => 'menu_local_tasks', '#secondary' => $vars['tabs']['#secondary']);
    if (module_exists('overlay')) {
        if (overlay_get_mode() == 'child') {
            $vars['breadcrumb'] = '';
        }
    }
}
Esempio n. 6
0
/**
 * Adds classes to the page element
 */
function os_basetheme_preprocess_page(&$vars)
{
    $item = menu_get_item();
    // Remove the node view tab.
    if (!empty($vars['tabs']['#primary'])) {
        foreach ($vars['tabs']['#primary'] as $k => $l) {
            if ($l['#link']['path'] == 'node/%/view') {
                unset($vars['tabs']['#primary'][$k]);
            }
        }
    }
    //Adds OpenScholar header region awareness to body classes
    $header = array('header-left' => $vars['page']['header_first'], 'header-main' => $vars['page']['header_second'], 'header-right' => $vars['page']['header_third']);
    $content = array('content-top' => $vars['page']['content_top'], 'content-left' => $vars['page']['content_first'], 'content-right' => $vars['page']['content_second'], 'content-bottom' => $vars['page']['content_bottom']);
    $footer = array('footer-left' => $vars['page']['footer_first'], 'footer' => $vars['page']['footer'], 'footer-right' => $vars['page']['footer_third']);
    foreach (array('header', 'content', 'footer') as $var) {
        $visible = array_filter(${$var}, "__os_basetheme_is_empty");
        if (count($visible)) {
            $vars['classes_array'] = array_merge($vars['classes_array'], array_keys($visible));
        } else {
            $vars['classes_array'][] = $var . '-none';
        }
    }
    if (module_exists('overlay') && overlay_get_mode() == 'child') {
        // overlay does this, but adaptive theme renders them in a different way that overlay doesn't expect
        $vars['primary_local_tasks'] = $vars['title'] = false;
    }
    if (!isset($vars['use_content_regions'])) {
        $vars['use_content_regions'] = FALSE;
    }
    // Do not show the login button on the following pages, redundant.
    $login_pages = array('user', 'private_site', 'user/password');
    if (isset($item) && !in_array($item['path'], $login_pages)) {
        $vars['login_link'] = theme('openscholar_login');
    }
    //hide useless tabs - drupal uses $vars['tabs'], but adaptive loads primary and secondary menu local tasks.
    $vars['primary_local_tasks'] = !empty($vars['tabs']['#primary']) ? $vars['tabs']['#primary'] : '';
    $vars['secondary_local_tasks'] = $vars['tabs']['#secondary'];
    $theme_name = $GLOBALS['theme_key'];
    // Adds skip link var to page template
    $vars['skip_link'] = 'main-content';
    if (at_get_setting('skip_link_target', $theme_name)) {
        $skip_link_target = at_get_setting('skip_link_target', $theme_name);
        $vars['skip_link'] = trim(check_plain($skip_link_target), '#');
    }
}
Esempio n. 7
0
/**
 * Override or insert variables into the page template.
 */
function corolla_process_page(&$variables)
{
    // Since the title and the shortcut link are both block level elements,
    // positioning them next to each other is much simpler with a wrapper div.
    if (!empty($variables['title_suffix']['add_or_remove_shortcut'])) {
        // Add a wrapper div using the title_prefix and title_suffix render elements.
        $variables['title_prefix']['shortcut_wrapper'] = array('#markup' => '<div class="shortcut-wrapper clearfix">', '#weight' => 100);
        $variables['title_suffix']['shortcut_wrapper'] = array('#markup' => '</div>', '#weight' => -99);
        // Make sure the shortcut link is the first item in title_suffix.
        $variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
    }
    // Provide a variable to check if the page is in the overlay.
    if (module_exists('overlay')) {
        $variables['in_overlay'] = overlay_get_mode() == 'child';
    } else {
        $variables['in_overlay'] = FALSE;
    }
    // Add variables with weight value for each main column
    $variables['weight']['content'] = 0;
    $variables['weight']['sidebar-first'] = 'disabled';
    $variables['weight']['sidebar-second'] = 'disabled';
    if ($variables["page"]["sidebar_first"]) {
        $variables['weight']['sidebar-first'] = theme_get_setting('sidebar_first_weight');
    }
    if ($variables["page"]["sidebar_second"]) {
        $variables['weight']['sidebar-second'] = theme_get_setting('sidebar_second_weight');
    }
    // Add $main_columns_number variable (used in page-*.tpl.php files)
    $columns = 0;
    foreach (array('content', 'sidebar_first', 'sidebar_second') as $n) {
        if ($variables["page"]["{$n}"]) {
            $columns++;
        }
    }
    $variables['main_columns_number'] = $columns;
    // Add $navigation variable to page.tpl.php. Unlike built-in $main_menu variable, it supports nested menus
    if (isset($variables['main_menu'])) {
        $pid = variable_get('menu_main_links_source', 'main-menu');
        $tree = menu_tree($pid);
        $variables['navigation'] = drupal_render($tree);
    } else {
        $variables['navigation'] = FALSE;
    }
}
Esempio n. 8
0
/**
 * Preprocessor for theme('page').
 */
function rubik_preprocess_page(&$vars)
{
    // Show a warning if base theme is not present.
    if (!function_exists('tao_theme') && user_access('administer site configuration')) {
        drupal_set_message(t('The Rubik theme requires the !tao base theme in order to work properly.', array('!tao' => l('Tao', 'http://drupal.org/project/tao'))), 'warning');
    }
    // Set a page icon class.
    $vars['page_icon_class'] = ($item = menu_get_item()) ? implode(' ', _rubik_icon_classes($item['href'])) : '';
    // Help pages. They really do need help.
    if (strpos($_GET['q'], 'admin/help/') === 0 && isset($vars['page']['content']['system_main']['main']['#markup'])) {
        $vars['page']['content']['system_main']['main']['#markup'] = theme('help_page', array('content' => $vars['page']['content']['system_main']['main']['#markup']));
    }
    // Clear out help text if empty.
    if (empty($vars['help']) || !strip_tags($vars['help'])) {
        $vars['help'] = '';
    }
    // Process local tasks. This will get called for rubik and its subthemes.
    _rubik_local_tasks($vars);
    // Overlay is enabled.
    $vars['overlay'] = module_exists('overlay') && overlay_get_mode() === 'child';
    // Disable sticky in the sidebar. Set option in JS
    $disable_sticky = theme_get_setting('rubik_disable_sticky_sidebar');
    drupal_add_js(array('rubik' => array('disable_sticky' => $disable_sticky)), array('type' => 'setting'));
}
Esempio n. 9
0
/**
 * Alter batch information before a batch is processed.
 *
 * Called by batch_process() to allow modules to alter a batch before it is
 * processed.
 *
 * @param $batch
 *   The associative array of batch information. See batch_set() for details on
 *   what this could contain.
 *
 * @see batch_set()
 * @see batch_process()
 *
 * @ingroup batch
 */
function hook_batch_alter(&$batch)
{
    // If the current page request is inside the overlay, add ?render=overlay to
    // the success callback URL, so that it appears correctly within the overlay.
    if (overlay_get_mode() == 'child') {
        if (isset($batch['url_options']['query'])) {
            $batch['url_options']['query']['render'] = 'overlay';
        } else {
            $batch['url_options']['query'] = array('render' => 'overlay');
        }
    }
}
Esempio n. 10
0
/**
 * Sets variable that tells the page if it is being rendered in the overlay.
 *
 * Allows you to hide eg. sidebars in the overlay.
 *
 * Usage in page.tpl.php:
 *   <php? if ($region_name && !$in_overlay): ?>
 *     <?php print render($region_name); ?>
 *   <?php endif; ?>
 */
function THEMENAME_preprocess_page(&$vars)
{
    if (module_exists('overlay')) {
        if (overlay_get_mode() == 'child') {
            $vars['in_overlay'] = TRUE;
        } else {
            $vars['in_overlay'] = FALSE;
        }
    }
}
Esempio n. 11
0
function rootcandy_preprocess_page(&$vars)
{
    // Hook into color.module.
    if (module_exists('color')) {
        _color_page_alter($vars);
    }
    // get theme settings
    $vars['hide_header'] = theme_get_setting('rootcandy_header_display');
    $vars['hide_panel'] = theme_get_setting('rootcandy_hide_panel');
    $vars['tabs2'] = array('#theme' => 'menu_local_tasks', '#secondary' => $vars['tabs']['#secondary']);
    unset($vars['tabs']['#secondary']);
    //set the links level in settings
    // 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';
    }
    $menu_tree = array();
    if (!$rootcandy_navigation) {
        if (!$user->uid) {
            $rootcandy_navigation[] = array('href' => 'user/login', 'title' => t('User login'));
        }
    } else {
        if ($rootcandy_navigation == '_rootcandy_default_navigation') {
            if ($user->uid) {
                $rootcandy_navigation = menu_navigation_links($rootcandy_nav['menu'], 1);
            } else {
                $rootcandy_navigation = array(array('href' => 'user/login', 'title' => t('User login')));
            }
        } else {
            $rootcandy_navigation = menu_navigation_links($rootcandy_navigation);
        }
    }
    $vars['rootcandy_navigation'] = theme('links__rc_main_navigation', array('links' => $rootcandy_navigation));
    $rootcandy_navigation_class = array();
    // detect overlay
    $overlay_mode = FALSE;
    if (module_exists('overlay')) {
        if (overlay_get_mode() == 'child') {
            // we show the panel and header by default
            $vars['hide_panel'] = 0;
            $vars['hide_header'] = 0;
            if (theme_get_setting('rootcandy_header_display_overlay')) {
                $vars['hide_header'] = 1;
            }
            if (theme_get_setting('rootcandy_hide_panel_overlay')) {
                $vars['hide_panel'] = 1;
            }
        }
    }
    if (!$vars['hide_header']) {
        $rootcandy_navigation_class[] = 'i' . theme_get_setting('rootcandy_navigation_icons_size');
        $rootcandy_navigation_class[] = 'header-on';
    }
    $vars['rootcandy_navigation_class'] = '';
    if ($rootcandy_navigation_class) {
        $vars['rootcandy_navigation_class'] .= ' ' . implode(' ', $rootcandy_navigation_class);
    }
    if (!theme_get_setting('rootcandy_hide_author')) {
        $vars['legal'] = '<div id="legal-notice">Theme created by <a href="http://sotak.co.uk" rel="external">Marek Sotak</a></div>';
    }
    // fetch user and display welcome message
    if ($user->uid) {
        $user_first_name = $user->name;
        $vars['welcome_user'] = l($user_first_name, 'user', array('attributes' => array('class' => 'user-name'))) . ' | ' . l(t('Logout '), 'user/logout');
    } else {
        // TODO: get from settings
        $user_first_name = t('Anonymous');
        $vars['welcome_user'] = l($user_first_name, 'user', array('attributes' => array('class' => 'user-name'))) . ' | ' . l(t('Login '), 'user');
    }
}
Esempio n. 12
0
/**
 * Preprocessor for theme('page').
 */
function stanley_preprocess_page(&$vars)
{
    // Toolbar is enabled
    $vars['toolbar'] = module_exists('toolbar');
    // local tasks
    $vars['primary_local_tasks'] = $vars['secondary_local_tasks'] = FALSE;
    if (!empty($vars['tabs']['#primary'])) {
        $vars['primary_local_tasks'] = $vars['tabs'];
        unset($vars['primary_local_tasks']['#secondary']);
    }
    if (!empty($vars['tabs']['#secondary'])) {
        $vars['secondary_local_tasks'] = array('#theme' => 'menu_local_tasks', '#secondary' => $vars['tabs']['#secondary']);
    }
    // Set a page icon class.
    $vars['page_icon_class'] = ($item = menu_get_item()) ? implode(' ', _stanley_icon_classes($item['href'])) : '';
    // Overlay is enabled.
    $vars['overlay'] = module_exists('overlay') && overlay_get_mode() === 'child';
    if ($vars['overlay']) {
        $vars['theme_hook_suggestions'][] = 'page__overlay';
        $vars['primary_local_tasks'] = menu_primary_local_tasks();
    }
}