コード例 #1
0
ファイル: template.php プロジェクト: stacksight/openscholar
/**
 * Override or insert PHPTemplate variables into the templates.
 */
function cp_theme_preprocess_page(&$vars, $hook)
{
    $tabs2 = menu_secondary_local_tasks();
    if ($tabs2) {
        $vars['tabs2'] = '<ul class="tabs secondary clear-block">' . menu_secondary_local_tasks() . '</ul>';
    }
    //adds cp page classes
    $body_classes = array($vars['body_classes']);
    list($section, ) = explode('/', $_GET['q'], 1);
    $body_classes[] = scholar_base_id_safe('page-' . $section);
    $vars['body_classes'] = implode(' ', $body_classes);
}
コード例 #2
0
ファイル: template.php プロジェクト: stacksight/openscholar
/**
 * // Adds classes to the body tag.
 */
function scholar_base_preprocess_page(&$vars, $hook)
{
    $vars['styles'] .= $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'], '');
    //dpm($vars['conditional_styles']);
    $body_classes = array($vars['body_classes']);
    //Replace left and right with first and second
    $original = array('left', 'right');
    $new = array('first', 'second');
    $body_classes = str_replace($original, $new, $body_classes);
    if (!$vars['is_front']) {
        // Add unique classes for each page/site section
        // (This snippet comes from Zen but is modified.)
        //$path = drupal_get_path_alias($_GET['q']);
        list($section, ) = explode('/', $_GET['q'], 2);
        $body_classes[] = scholar_base_id_safe('section-' . $section);
        if (arg(0) == 'node') {
            if (arg(1) == 'add') {
                if ($section == 'node') {
                    array_pop($body_classes);
                    // Remove 'section-node'
                }
                $body_classes[] = 'section-node-add';
                // Add 'section-node-add'
            } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
                if ($section == 'node') {
                    array_pop($body_classes);
                    // Remove 'section-node'
                }
                $body_classes[] = 'section-node-' . arg(2);
                // Add 'section-node-edit' or 'section-node-delete'
            }
        }
    }
    if (module_exists('taxonomy') && $vars['node']->nid) {
        foreach (taxonomy_node_get_terms($vars['node']) as $term) {
            $body_classes[] = 'category-' . str_replace(' ', '-', scholar_base_id_safe($term->name));
        }
    }
    //Adds OpenScholar header region awareness to body classes
    $regions = array('left' => $vars['header_left'], 'main' => $vars['header_main'], 'right' => $vars['header_right']);
    $non_empty_regions = array_filter($regions, "__scholar_base_is_empty");
    $header_classes = 'header-';
    if (count($non_empty_regions)) {
        $header_classes .= implode('-', array_keys($non_empty_regions));
    } else {
        $header_classes .= 'none';
    }
    $body_classes[] = $header_classes;
    $vars['body_classes'] = implode(' ', $body_classes);
}