Example #1
0
function acquia_marina_preprocess_page(&$vars)
{
    global $language;
    // Remove sidebars if disabled e.g., for Panels
    if (!$vars['show_blocks']) {
        $vars['sidebar_first'] = '';
        $vars['sidebar_last'] = '';
    }
    // Build array of helpful body classes
    $body_classes = array();
    $body_classes[] = $vars['logged_in'] ? 'logged-in' : 'not-logged-in';
    // Page user is logged in
    $body_classes[] = $vars['is_front'] ? 'front' : 'not-front';
    // Page is front page
    if (isset($vars['node'])) {
        $body_classes[] = $vars['node'] ? 'full-node' : '';
        // Page is one full node
        $body_classes[] = $vars['node']->type == 'forum' || arg(0) == 'forum' ? 'forum' : '';
        // Page is Forum page
        $body_classes[] = $vars['node']->type ? 'node-type-' . $vars['node']->type : '';
        // Page has node-type-x, e.g., node-type-page
    } else {
        $body_classes[] = arg(0) == 'forum' ? 'forum' : '';
        // Page is Forum page
    }
    $body_classes[] = module_exists('panels_page') && panels_page_get_current() ? 'panels' : '';
    // Page is Panels page
    $body_classes[] = 'layout-' . ($vars['sidebar_first'] ? 'first-main' : 'main') . ($vars['sidebar_last'] ? '-last' : '');
    // Page sidebars are active
    if ($vars['preface_first'] || $vars['preface_middle'] || $vars['preface_last']) {
        // Preface regions are active
        $preface_regions = 'preface';
        $preface_regions .= $vars['preface_first'] ? '-first' : '';
        $preface_regions .= $vars['preface_middle'] ? '-middle' : '';
        $preface_regions .= $vars['preface_last'] ? '-last' : '';
        $body_classes[] = $preface_regions;
    }
    if ($vars['postscript_first'] || $vars['postscript_middle'] || $vars['postscript_last']) {
        // Postscript regions are active
        $postscript_regions = 'postscript';
        $postscript_regions .= $vars['postscript_first'] ? '-first' : '';
        $postscript_regions .= $vars['postscript_middle'] ? '-middle' : '';
        $postscript_regions .= $vars['postscript_last'] ? '-last' : '';
        $body_classes[] = $postscript_regions;
    }
    $body_classes = array_filter($body_classes);
    // Remove empty elements
    $vars['body_classes'] = implode(' ', $body_classes);
    // Create class list separated by spaces
    // Add preface & postscript classes with number of active sub-regions
    $region_list = array('prefaces' => array('preface_first', 'preface_middle', 'preface_last'), 'postscripts' => array('postscript_first', 'postscript_middle', 'postscript_last'));
    foreach ($region_list as $sub_region_key => $sub_region_list) {
        $active_regions = array();
        foreach ($sub_region_list as $region_item) {
            if (!empty($vars[$region_item])) {
                $active_regions[] = $region_item;
            }
        }
        $vars[$sub_region_key] = $sub_region_key . '-' . strval(count($active_regions));
    }
    // Generate menu tree from source of primary links
    if (module_exists('i18nmenu')) {
        $vars['primary_links_tree'] = i18nmenu_translated_tree(variable_get('menu_primary_links_source', 'primary-links'));
    } else {
        $vars['primary_links_tree'] = menu_tree(variable_get('menu_primary_links_source', 'primary-links'));
    }
    // TNT THEME SETTINGS SECTION
    // Display mission statement on all pages
    if (theme_get_setting('mission_statement_pages') == 'all') {
        $vars['mission'] = theme_get_setting('mission', false);
    }
    // Hide breadcrumb on all pages
    if (theme_get_setting('breadcrumb_display') == 0) {
        $vars['breadcrumb'] = '';
    }
    // Set site title, slogan, mission, page title & separator
    if (!module_exists('page_title')) {
        $title = t(variable_get('site_name', ''));
        $slogan = t(variable_get('site_slogan', ''));
        $mission = t(variable_get('site_mission', ''));
        $page_title = t(drupal_get_title());
        $title_separator = theme_get_setting('configurable_separator');
        if (drupal_is_front_page()) {
            // Front page title settings
            switch (theme_get_setting('front_page_title_display')) {
                case 'title_slogan':
                    $vars['head_title'] = drupal_set_title($title . $title_separator . $slogan);
                    break;
                case 'slogan_title':
                    $vars['head_title'] = drupal_set_title($slogan . $title_separator . $title);
                    break;
                case 'title_mission':
                    $vars['head_title'] = drupal_set_title($title . $title_separator . $mission);
                    break;
                case 'custom':
                    if (theme_get_setting('page_title_display_custom') !== '') {
                        $vars['head_title'] = drupal_set_title(t(theme_get_setting('page_title_display_custom')));
                    }
            }
        } else {
            // Non-front page title settings
            switch (theme_get_setting('other_page_title_display')) {
                case 'ptitle_slogan':
                    $vars['head_title'] = drupal_set_title($page_title . $title_separator . $slogan);
                    break;
                case 'ptitle_stitle':
                    $vars['head_title'] = drupal_set_title($page_title . $title_separator . $title);
                    break;
                case 'ptitle_smission':
                    $vars['head_title'] = drupal_set_title($page_title . $title_separator . $mission);
                    break;
                case 'ptitle_custom':
                    if (theme_get_setting('other_page_title_display_custom') !== '') {
                        $vars['head_title'] = drupal_set_title($page_title . $title_separator . t(theme_get_setting('other_page_title_display_custom')));
                    }
                    break;
                case 'custom':
                    if (theme_get_setting('other_page_title_display_custom') !== '') {
                        $vars['head_title'] = drupal_set_title(t(theme_get_setting('other_page_title_display_custom')));
                    }
            }
        }
        $vars['head_title'] = strip_tags($vars['head_title']);
        // Remove any potential html tags
    }
    // Set meta keywords and description (unless using Meta tags module)
    if (!module_exists('nodewords')) {
        if (theme_get_setting('meta_keywords') !== '') {
            $keywords = '<meta name="keywords" content="' . theme_get_setting('meta_keywords') . '" />';
            $vars['head'] .= $keywords . "\n";
        }
        if (theme_get_setting('meta_description') !== '') {
            $keywords = '<meta name="description" content="' . theme_get_setting('meta_description') . '" />';
            $vars['head'] .= $keywords . "\n";
        }
    }
    // Add custom theme settings
    $theme_settings_path = path_to_theme() . '/theme_settings/';
    drupal_add_css($theme_settings_path . theme_get_setting('theme_width') . '.css', 'theme');
    drupal_add_css($theme_settings_path . theme_get_setting('theme_fonts') . '.css', 'theme');
    $banner_file = theme_get_setting('theme_banner');
    $vars['banner_image'] = $banner_file == 'none' ? '' : 'style="background: url(' . base_path() . $theme_settings_path . 'banners/' . $banner_file . ') no-repeat;"';
    // Set IE6 & IE7 stylesheets, plus right-to-left versions
    $theme_path = base_path() . path_to_theme();
    $vars['ie6_styles'] = '<link type="text/css" rel="stylesheet" media="all" href="' . $theme_path . '/ie6-fixes.css" />' . "\n";
    $vars['ie7_styles'] = '<link type="text/css" rel="stylesheet" media="all" href="' . $theme_path . '/ie7-fixes.css" />' . "\n";
    if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
        $vars['ie6_styles'] .= '    <link type="text/css" rel="stylesheet" media="all" href="' . $theme_path . '/ie6-fixes-rtl.css" />' . "\n";
        $vars['ie7_styles'] .= '    <link type="text/css" rel="stylesheet" media="all" href="' . $theme_path . '/ie7-fixes-rtl.css" />' . "\n";
    }
    if (file_exists(path_to_theme() . '/local.css')) {
        // Add local css file if present
        $theme_path = base_path() . path_to_theme() . '/local.css';
        $vars['local_styles'] = '<link type="text/css" rel="stylesheet" media="all" href="' . $theme_path . '" />' . "\n";
    }
    // Use grouped import technique for more than 30 un-aggregated stylesheets (css limit fix for IE)
    $css = drupal_add_css();
    if (theme_get_setting('fix_css_limit') && !variable_get('preprocess_css', FALSE) && acquia_marina_css_count($css) > 26) {
        $styles = '';
        $suffix = "\n" . '</style>' . "\n";
        foreach ($css as $media => $types) {
            $prefix = '<style type="text/css" media="' . $media . '">' . "\n";
            $imports = array();
            foreach ($types as $files) {
                foreach ($files as $file => $preprocess) {
                    $imports[] = '@import "' . base_path() . $file . '";';
                    if (count($imports) == 30) {
                        $styles .= $prefix . implode("\n", $imports) . $suffix;
                        $imports = array();
                    }
                }
            }
            $styles .= count($imports) > 0 ? $prefix . implode("\n", $imports) . $suffix : '';
        }
        $vars['styles'] = $styles;
    } else {
        $vars['styles'] = drupal_get_css();
        // Use normal link technique
    }
    if (drupal_is_front_page()) {
        $vars['closure'] .= '<div id="legal-notice">Theme provided by <a href="http://www.acquia.com">Acquia, Inc.</a> under GPL license from TopNotchThemes <a href="http://www.topnotchthemes.com">Drupal themes</a></div>';
    }
}
Example #2
0
function phptemplate_preprocess_page(&$vars)
{
    // Remove sidebars if disabled
    if (!$vars['show_blocks']) {
        $vars['sidebar_first'] = '';
        $vars['sidebar_last'] = '';
    }
    // Build array of helpful body classes
    $body_classes = array();
    $body_classes[] = $vars['logged_in'] ? 'logged-in' : 'not-logged-in';
    // Page user is logged in
    $body_classes[] = $vars['is_front'] ? 'front' : 'not-front';
    // Page is front page
    if (isset($vars['node'])) {
        $body_classes[] = $vars['node'] ? 'full-node' : '';
        // Page is one full node
        $body_classes[] = $vars['node']->type == 'forum' || arg(0) == 'forum' ? 'forum' : '';
        // Page is Forum page
        $body_classes[] = $vars['node']->type ? 'node-type-' . $vars['node']->type : '';
        // Page has node-type-x, e.g., node-type-page
    } else {
        $body_classes[] = arg(0) == 'forum' ? 'forum' : '';
        // Page is Forum page
    }
    $body_classes[] = module_exists('panels_page') && panels_page_get_current() ? 'panels' : '';
    // Page is Panels page
    $body_classes[] = 'layout-' . ($vars['sidebar_first'] ? 'first-main' : 'main') . ($vars['sidebar_last'] ? '-last' : '');
    // Page sidebars are active
    if ($vars['preface_first'] || $vars['preface_middle'] || $vars['preface_last']) {
        // Preface regions are active
        $preface_regions = 'preface';
        $preface_regions .= $vars['preface_first'] ? '-first' : '';
        $preface_regions .= $vars['preface_middle'] ? '-middle' : '';
        $preface_regions .= $vars['preface_last'] ? '-last' : '';
        $body_classes[] = $preface_regions;
    }
    if ($vars['postscript_first'] || $vars['postscript_middle'] || $vars['postscript_last']) {
        // Postscript regions are active
        $postscript_regions = 'postscript';
        $postscript_regions .= $vars['postscript_first'] ? '-first' : '';
        $postscript_regions .= $vars['postscript_middle'] ? '-middle' : '';
        $postscript_regions .= $vars['postscript_last'] ? '-last' : '';
        $body_classes[] = $postscript_regions;
    }
    $body_classes = array_filter($body_classes);
    // Remove empty elements
    $vars['body_classes'] = implode(' ', $body_classes);
    // Create class list separated by spaces
    // Add preface & postscript classes with number of active sub-regions
    $region_list = array('prefaces' => array('preface_first', 'preface_middle', 'preface_last'), 'postscripts' => array('postscript_first', 'postscript_middle', 'postscript_last'));
    foreach ($region_list as $sub_region_key => $sub_region_list) {
        $active_regions = array();
        foreach ($sub_region_list as $region_item) {
            if ($vars[$region_item]) {
                $active_regions[] = $region_item;
            }
        }
        $vars[$sub_region_key] = $sub_region_key . '-' . strval(count($active_regions));
    }
    // Generate menu tree from source of primary links
    $vars['primary_links_tree'] = menu_tree(variable_get('menu_primary_links_source', 'primary-links'));
    // TNT THEME SETTINGS SECTION
    // Hide breadcrumb on all pages
    if (theme_get_setting('breadcrumb_display') == 0) {
        $vars['breadcrumb'] = '';
    }
    // Set site title, slogan, mission, page title & separator (unless using Page Title module)
    if (!module_exists('page_title')) {
        $title = t(variable_get('site_name', ''));
        $slogan = t(variable_get('site_slogan', ''));
        $mission = t(variable_get('site_mission', ''));
        $page_title = t(drupal_get_title());
        $title_separator = theme_get_setting('configurable_separator');
        if (drupal_is_front_page()) {
            // Front page title settings
            switch (theme_get_setting('front_page_title_display')) {
                case 'title_slogan':
                    $vars['head_title'] = drupal_set_title($title . $title_separator . $slogan);
                    break;
                case 'slogan_title':
                    $vars['head_title'] = drupal_set_title($slogan . $title_separator . $title);
                    break;
                case 'title_mission':
                    $vars['head_title'] = drupal_set_title($title . $title_separator . $mission);
                    break;
                case 'custom':
                    if (theme_get_setting('page_title_display_custom') !== '') {
                        $vars['head_title'] = drupal_set_title(t(theme_get_setting('page_title_display_custom')));
                    }
            }
        } else {
            // Non-front page title settings
            switch (theme_get_setting('other_page_title_display')) {
                case 'ptitle_slogan':
                    $vars['head_title'] = drupal_set_title($page_title . $title_separator . $slogan);
                    break;
                case 'ptitle_stitle':
                    $vars['head_title'] = drupal_set_title($page_title . $title_separator . $title);
                    break;
                case 'ptitle_smission':
                    $vars['head_title'] = drupal_set_title($page_title . $title_separator . $mission);
                    break;
                case 'ptitle_custom':
                    if (theme_get_setting('other_page_title_display_custom') !== '') {
                        $vars['head_title'] = drupal_set_title($page_title . $title_separator . t(theme_get_setting('other_page_title_display_custom')));
                    }
                    break;
                case 'custom':
                    if (theme_get_setting('other_page_title_display_custom') !== '') {
                        $vars['head_title'] = drupal_set_title(t(theme_get_setting('other_page_title_display_custom')));
                    }
            }
        }
        $vars['head_title'] = strip_tags($vars['head_title']);
        // Remove any potential html tags
    }
    // Set meta keywords and description (unless using Meta tags module)
    if (!module_exists('nodewords')) {
        if (theme_get_setting('meta_keywords') !== '') {
            $keywords = '<meta name="keywords" content="' . theme_get_setting('meta_keywords') . '" />';
            $vars['head'] .= $keywords . "\n";
        }
        if (theme_get_setting('meta_description') !== '') {
            $keywords = '<meta name="description" content="' . theme_get_setting('meta_description') . '" />';
            $vars['head'] .= $keywords . "\n";
        }
    }
    if (drupal_is_front_page()) {
        $vars['closure'] .= '<div id="legal-notice">Theme provided by <a href="http://www.acquia.com">Acquia, Inc.</a> under GPL license from TopNotchThemes <a href="http://www.topnotchthemes.com">Drupal themes</a></div>';
    }
}
Example #3
0
function zeropoint_preprocess_page(&$vars)
{
    global $language;
    // Remove the duplicate meta content-type tag, a bug in Drupal 6
    $vars['head'] = preg_replace('/<meta http-equiv=\\"Content-Type\\"[^>]*>/', '', $vars['head']);
    // Remove sidebars if disabled
    if (!$vars['show_blocks']) {
        $vars['left'] = '';
        $vars['right'] = '';
    }
    //CHGK: force search box
    $vars['search_box'] = drupal_get_form('search_theme_form');
    // Build array of helpful body classes
    $body_classes = array();
    //$body_classes[] = ($vars['site_name']) ? $vars['site_name'] : '';         // Site name
    $body_classes[] = 'layout-' . ($vars['left'] ? 'left-main' : 'main') . ($vars['right'] ? '-right' : '');
    // Page sidebars are active (Jello Mold)
    $body_classes[] = $vars['is_admin'] ? 'admin' : 'not-admin';
    // Page user is admin
    $body_classes[] = $vars['logged_in'] ? 'logged-in' : 'not-logged-in';
    // Page user is logged in
    $body_classes[] = $vars['is_front'] ? 'front' : 'not-front';
    // Page is front page
    if (isset($vars['node'])) {
        $body_classes[] = $vars['node'] ? 'full-node' : '';
        // Page is one full node
        $body_classes[] = $vars['node']->type == 'forum' || arg(0) == 'forum' ? 'forum' : '';
        // Page is Forum page
        $body_classes[] = $vars['node']->type ? 'node-type-' . $vars['node']->type : '';
        // Page has node-type-x, e.g., node-type-page
        $body_classes[] = $vars['node']->nid ? 'nid-' . $vars['node']->nid : '';
        // Page has id-x, e.g., id-32
    } else {
        $body_classes[] = arg(0) == 'forum' ? 'forum' : '';
        // Page is Forum page
    }
    // Add any taxonomy terms for node pages
    if (isset($vars['node']->taxonomy)) {
        foreach ($vars['node']->taxonomy as $taxonomy_id => $term_info) {
            $body_classes[] = 'tag-' . $taxonomy_id;
            // Page has terms (tag-x)
            //      $taxonomy_name = id_safe($term_info->name);
            //      if ($taxonomy_name) {
            //        $body_classes[] = 'tag-'. $taxonomy_name;                                                 // Page has terms (tag-name)
            //      }
        }
    }
    // Add unique classes for each page and website section
    if (!$vars['is_front']) {
        $path = drupal_get_path_alias(check_plain($_GET['q']));
        list($section, ) = explode('/', $path, 2);
        $body_classes[] = id_safe('section-' . $section);
        $body_classes[] = id_safe('page-' . $path);
        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'
            }
        }
    }
    // Build array of additional body classes and retrieve custom theme settings
    $layoutwidth = theme_get_setting('layout-width');
    if ($layoutwidth == '0') {
        $body_classes[] = 'layout-jello';
    }
    if ($layoutwidth == '1') {
        $body_classes[] = 'layout-fluid';
    }
    if ($layoutwidth == '2') {
        $body_classes[] = 'layout-fixed';
    }
    $sidebarslayout = theme_get_setting('sidebarslayout');
    if ($sidebarslayout == '0') {
        $body_classes[] = ($vars['left'] ? 'l-m' : 'm') . ($vars['right'] ? '-r' : '') . '-var';
    }
    if ($sidebarslayout == '1') {
        $body_classes[] = ($vars['left'] ? 'l-m' : 'm') . ($vars['right'] ? '-r' : '') . '-fix';
    }
    if ($sidebarslayout == '2') {
        $body_classes[] = ($vars['left'] ? 'l-m' : 'm') . ($vars['right'] ? '-r' : '') . '-var1';
    }
    if ($sidebarslayout == '3') {
        $body_classes[] = ($vars['left'] ? 'l-m' : 'm') . ($vars['right'] ? '-r' : '') . '-fix1';
    }
    if ($sidebarslayout == '4') {
        $body_classes[] = ($vars['left'] ? 'l-m' : 'm') . ($vars['right'] ? '-r' : '') . '-eq';
    }
    $blockicons = theme_get_setting('blockicons');
    if ($blockicons == '1') {
        $body_classes[] = 'bicons32';
    }
    if ($blockicons == '2') {
        $body_classes[] = 'bicons48';
    }
    $pageicons = theme_get_setting('pageicons');
    if ($pageicons == '1') {
        $body_classes[] = 'picons';
    }
    $headerimg = theme_get_setting('headerimg');
    if ($headerimg == '1') {
        $body_classes[] = 'himg';
    }
    // Add Panels classes and lang
    $body_classes[] = module_exists('panels_page') && panels_page_get_current() ? 'panels' : '';
    // Page is Panels page
    $body_classes[] = $vars['language']->language ? 'lg-' . $vars['language']->language : '';
    // Page has lang-x
    $siteid = check_plain(theme_get_setting('siteid'));
    $body_classes[] = $siteid;
    $body_classes = array_filter($body_classes);
    // Remove empty elements
    $vars['body_classes'] = implode(' ', $body_classes);
    // Create class list separated by spaces
    // Generate menu tree from source of primary links
    if (module_exists('i18nmenu')) {
        $vars['primary_links_tree'] = i18nmenu_translated_tree(variable_get('menu_primary_links_source', 'primary-links'));
    } else {
        $vars['primary_links_tree'] = menu_tree(variable_get('menu_primary_links_source', 'primary-links'));
    }
    // TNT THEME SETTINGS SECTION
    // Display mission statement on all pages
    if (theme_get_setting('mission_statement_pages') == 'all') {
        $vars['mission'] = theme_get_setting('mission', false);
    }
    // Hide breadcrumb on all pages
    if (theme_get_setting('breadcrumb_display') == 0) {
        $vars['breadcrumb'] = '';
    }
    // Set site title, slogan, mission, page title & separator (unless using Page Title module)
    if (!module_exists('page_title')) {
        $title = t(variable_get('site_name', ''));
        $slogan = t(variable_get('site_slogan', ''));
        $mission = t(variable_get('site_mission', ''));
        $page_title = t(drupal_get_title());
        $title_separator = theme_get_setting('configurable_separator');
        if (drupal_is_front_page()) {
            // Front page title settings
            switch (theme_get_setting('front_page_title_display')) {
                case 'title_slogan':
                    $vars['head_title'] = drupal_set_title(check_plain($title . $title_separator . $slogan));
                    break;
                case 'slogan_title':
                    $vars['head_title'] = drupal_set_title(check_plain($slogan . $title_separator . $title));
                    break;
                case 'title_mission':
                    $vars['head_title'] = drupal_set_title(check_plain($title . $title_separator . $mission));
                    break;
                case 'custom':
                    if (theme_get_setting('page_title_display_custom') !== '') {
                        $vars['head_title'] = drupal_set_title(check_plain(t(theme_get_setting('page_title_display_custom'))));
                    }
            }
        } else {
            // Non-front page title settings
            switch (theme_get_setting('other_page_title_display')) {
                case 'ptitle_slogan':
                    $vars['head_title'] = drupal_set_title(check_plain($page_title . $title_separator . $slogan));
                    break;
                case 'ptitle_stitle':
                    $vars['head_title'] = drupal_set_title(check_plain($page_title . $title_separator . $title));
                    break;
                case 'ptitle_smission':
                    $vars['head_title'] = drupal_set_title(check_plain($page_title . $title_separator . $mission));
                    break;
                case 'ptitle_custom':
                    if (theme_get_setting('other_page_title_display_custom') !== '') {
                        $vars['head_title'] = drupal_set_title(check_plain($page_title . $title_separator . t(theme_get_setting('other_page_title_display_custom'))));
                    }
                    break;
                case 'custom':
                    if (theme_get_setting('other_page_title_display_custom') !== '') {
                        $vars['head_title'] = drupal_set_title(check_plain(t(theme_get_setting('other_page_title_display_custom'))));
                    }
            }
        }
        $vars['head_title'] = strip_tags($vars['head_title']);
        // Remove any potential html tags
    }
    // Set meta keywords and description (unless using Meta tags module)
    if (!module_exists('nodewords')) {
        if (theme_get_setting('meta_keywords') !== '') {
            $keywords = '<meta name="keywords" content="' . check_plain(theme_get_setting('meta_keywords')) . '" />';
            $vars['head'] .= $keywords . "\n";
        }
        if (theme_get_setting('meta_description') !== '') {
            $keywords = '<meta name="description" content="' . check_plain(theme_get_setting('meta_description')) . '" />';
            $vars['head'] .= $keywords . "\n";
        }
    }
    // Set IE6 & IE7 stylesheets
    $theme_path = base_path() . drupal_get_path('theme', 'zeropoint');
    $vars['ie6_style'] = '<link type="text/css" rel="stylesheet" media="all" href="' . $theme_path . '/css/ie6.css" />' . "\n";
    $vars['ie7_style'] = '<link type="text/css" rel="stylesheet" media="all" href="' . $theme_path . '/css/ie7.css" />' . "\n";
    // Use grouped import technique for more than 30 un-aggregated stylesheets (css limit fix for IE)
    $css = drupal_add_css();
    if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
        if (theme_get_setting('fix_css_limit') && !variable_get('preprocess_css', FALSE) && zeropoint_css_count($css) > 26) {
            $styles = '';
            $suffix = "\n" . '</style>' . "\n";
            foreach ($css as $media => $types) {
                $prefix = '<style type="text/css" media="' . $media . '">' . "\n";
                $imports = array();
                foreach ($types as $files) {
                    foreach ($files as $file => $preprocess) {
                        $imports[] = '@import "' . base_path() . $file . '";';
                        if (count($imports) == 30) {
                            $styles .= $prefix . implode("\n", $imports) . $suffix;
                            $imports = array();
                        }
                    }
                }
                $styles .= count($imports) > 0 ? $prefix . implode("\n", $imports) . $suffix : '';
            }
            $vars['styles'] = $styles;
        } else {
            $vars['styles'] = drupal_get_css();
            // Use normal link technique
        }
    }
    $momo = array();
    $momo[] = $vars['node']->type ? ' | ' . $vars['node']->type : '';
    $momo = array_filter($momo);
    $vars['momo'] = implode(' ', $momo);
    //CHGK: commented out
    //  $vars['closure'] .= '<div class="by"><a href="http://www.radut.net">Dr. Radut'.$vars['momo'].'</a></div>';
}
Example #4
0
function phptemplate_preprocess_page(&$vars)
{
    // Remove sidebars if disabled
    if (!$vars['show_blocks']) {
        $vars['sidebar_first'] = '';
        $vars['sidebar_last'] = '';
    }
    // Build array of helpful body classes
    $body_classes = array();
    $body_classes[] = $vars['logged_in'] ? 'logged-in' : 'not-logged-in';
    // Page user is logged in
    $body_classes[] = $vars['is_front'] ? 'front' : 'not-front';
    // Page is front page
    if (isset($vars['node'])) {
        $body_classes[] = $vars['node'] ? 'full-node' : '';
        // Page is one full node
        $body_classes[] = $vars['node']->type == 'forum' || arg(0) == 'forum' ? 'forum' : '';
        // Page is Forum page
        $body_classes[] = $vars['node']->type ? 'node-type-' . $vars['node']->type : '';
        // Page has node-type-x, e.g., node-type-page
    } else {
        $body_classes[] = arg(0) == 'forum' ? 'forum' : '';
        // Page is Forum page
    }
    $body_classes[] = module_exists('panels_page') && panels_page_get_current() ? 'panels' : '';
    // Page is Panels page
    $body_classes[] = 'layout-' . ($vars['sidebar_first'] || $vars['sidebar_second'] ? 'first-main' : 'main') . ($vars['sidebar_last'] ? '-last' : '');
    // Page sidebars are active
    if ($vars['preface_first'] || $vars['preface_middle'] || $vars['preface_last']) {
        // Preface regions are active
        $preface_regions = 'preface';
        $preface_regions .= $vars['preface_first'] ? '-first' : '';
        $preface_regions .= $vars['preface_middle'] ? '-middle' : '';
        $preface_regions .= $vars['preface_last'] ? '-last' : '';
        $body_classes[] = $preface_regions;
    }
    if ($vars['postscript_first'] || $vars['postscript_middle'] || $vars['postscript_last']) {
        // Postscript regions are active
        $postscript_regions = 'postscript';
        $postscript_regions .= $vars['postscript_first'] ? '-first' : '';
        $postscript_regions .= $vars['postscript_middle'] ? '-middle' : '';
        $postscript_regions .= $vars['postscript_last'] ? '-last' : '';
        $body_classes[] = $postscript_regions;
    }
    $body_classes = array_filter($body_classes);
    // Remove empty elements
    $vars['body_classes'] = implode(' ', $body_classes);
    // Create class list separated by spaces
    // Add preface & postscript classes with number of active sub-regions
    $region_list = array('prefaces' => array('preface_first', 'preface_middle', 'preface_last'), 'postscripts' => array('postscript_first', 'postscript_middle', 'postscript_last'));
    foreach ($region_list as $sub_region_key => $sub_region_list) {
        $active_regions = array();
        foreach ($sub_region_list as $region_item) {
            if ($vars[$region_item]) {
                $active_regions[] = $region_item;
            }
        }
        $vars[$sub_region_key] = $sub_region_key . '-' . strval(count($active_regions));
    }
    // Generate menu tree from source of primary links
    $vars['primary_links_tree'] = menu_tree(variable_get('menu_primary_links_source', 'primary-links'));
    // TNT THEME SETTINGS SECTION
    // Display mission statement on all pages
    if (theme_get_setting('mission_statement_pages') == 'all') {
        $vars['mission'] = theme_get_setting('mission', false);
    }
    // Hide breadcrumb on all pages
    if (theme_get_setting('breadcrumb_display') == 0) {
        $vars['breadcrumb'] = '';
    }
    // Add iepngfix on all pages
    if (theme_get_setting('iepngfix_display') == 1) {
        drupal_add_js(drupal_get_path('theme', 'm4music') . '/js/jquery.pngFix.js', 'theme');
    }
    // Add suckerfish on all pages
    if (theme_get_setting('suckerfish_display') == 1) {
        // js is added in page.tpl.php
        drupal_add_css(drupal_get_path('theme', 'm4music') . '/suckerfish.css', 'theme');
    }
    // show colorswitch on all pages
    if (theme_get_setting('colorswitch_display') == 1) {
        //session_start();
        //print_r($_SESSION);
        if (!isset($_SESSION['colorswitch_displaymodus'])) {
            $_SESSION['colorswitch_displaymodus'] = 1;
        }
        // 1: foreground
        // 0: switch
        // -1: background
        if ($_GET['switch'] == 'color') {
            $_SESSION['colorswitch_displaymodus'] = $_SESSION['colorswitch_displaymodus'] * -1;
        } else {
            if ($_GET['switch'] == 'bg') {
                $_SESSION['colorswitch_displaymodus'] = -1;
            } else {
                if ($_GET['switch'] == 'fg') {
                    $_SESSION['colorswitch_displaymodus'] = 1;
                }
            }
        }
        if ($_SESSION['colorswitch_displaymodus'] == 1) {
            $vars['colorswitch_modus'] = t('Background');
            $vars['colorswitch_bg'] = theme_get_setting('foreground_bg');
            $vars['colorswitch_border'] = theme_get_setting('foreground_border');
            $vars['colorswitch_font'] = theme_get_setting('foreground_font');
        } else {
            $vars['colorswitch_modus'] = t('Foreground');
            $vars['colorswitch_bg'] = theme_get_setting('background_bg');
            $vars['colorswitch_border'] = theme_get_setting('background_border');
            $vars['colorswitch_font'] = theme_get_setting('background_font');
        }
        $vars['colorswitch_text'] = '<a href="&switch=color" title="' . $vars['colorswitch_modus'] . '">' . $vars['colorswitch_modus'] . '</a>';
        $vars['colorswitch'] = $_SESSION['colorswitch_displaymodus'];
    }
    // Set site title, slogan, mission, page title & separator
    $title = t(variable_get('site_name', ''));
    $slogan = t(variable_get('site_slogan', ''));
    $mission = t(variable_get('site_mission', ''));
    $page_title = t(drupal_get_title());
    $title_separator = theme_get_setting('configurable_separator');
    if (drupal_is_front_page()) {
        // Front page title settings
        switch (theme_get_setting('front_page_title_display')) {
            case 'title_slogan':
                $vars['head_title'] = drupal_set_title($title . $title_separator . $slogan);
                break;
            case 'slogan_title':
                $vars['head_title'] = drupal_set_title($slogan . $title_separator . $title);
                break;
            case 'title_mission':
                $vars['head_title'] = drupal_set_title($title . $title_separator . $mission);
                break;
            case 'custom':
                if (theme_get_setting('page_title_display_custom') !== '') {
                    $vars['head_title'] = drupal_set_title(t(theme_get_setting('page_title_display_custom')));
                }
        }
    } else {
        // Non-front page title settings
        switch (theme_get_setting('other_page_title_display')) {
            case 'ptitle_slogan':
                $vars['head_title'] = drupal_set_title($page_title . $title_separator . $slogan);
                break;
            case 'ptitle_stitle':
                $vars['head_title'] = drupal_set_title($page_title . $title_separator . $title);
                break;
            case 'ptitle_smission':
                $vars['head_title'] = drupal_set_title($page_title . $title_separator . $mission);
                break;
            case 'ptitle_custom':
                if (theme_get_setting('other_page_title_display_custom') !== '') {
                    $vars['head_title'] = drupal_set_title($page_title . $title_separator . t(theme_get_setting('other_page_title_display_custom')));
                }
                break;
            case 'custom':
                if (theme_get_setting('other_page_title_display_custom') !== '') {
                    $vars['head_title'] = drupal_set_title(t(theme_get_setting('other_page_title_display_custom')));
                }
        }
    }
    $vars['head_title'] = strip_tags($vars['head_title']);
    // Remove any potential html tags
    if (!module_exists('nodewords')) {
        if (theme_get_setting('meta_keywords') !== '') {
            $keywords = '<meta name="keywords" content="' . theme_get_setting('meta_keywords') . '" />';
            $vars['head'] .= $keywords . "\n";
        }
        if (theme_get_setting('meta_description') !== '') {
            $keywords = '<meta name="description" content="' . theme_get_setting('meta_description') . '" />';
            $vars['head'] .= $keywords . "\n";
        }
    }
    $vars['closure'] .= '<div id="legal-notice">created by <a href="http://fabforge.ch">fabforge.ch</a></div>';
}