Beispiel #1
0
/**
 * Preprocessor for theme_page().
 */
function ginkgo_preprocess_page(&$vars) {
  // Switch layout for 404/403 pages.
  $headers = drupal_get_headers();
  if ((strpos($headers, 'HTTP/1.1 403 Forbidden') !== FALSE) || strpos($headers, 'HTTP/1.1 404 Not Found') !== FALSE) {
    $vars['template_files'][] = 'layout-wide';
  }

  // Add body class for layout.
  $vars['attr']['class'] .= !empty($vars['template_files']) ? ' '. end($vars['template_files']) : '';

  // Don't show the navigation in the admin section.
  // Otherwise add icon markup to main menu.
  if (arg(0) === 'admin') {
    $vars['primary_links'] = '';
  }
  else {
    ginkgo_icon_links($vars['primary_links']);
  }

  // If tabs are active, the title is likely shown in them. Don't show twice.
  $vars['title_attr'] = array('class' => 'page-title');
  $vars['title_attr']['class'] .= (!empty($vars['tabs']) || menu_get_object()) ? ' page-title-hidden' : '';

  // Show mission text on login page for anonymous users.
  global $user;
  $vars['mission'] = (!$user->uid && arg(0) == 'user') ? filter_xss_admin(variable_get('site_mission', '')) : '';

  // Fallback logo.
  $vars['logo'] = !empty($vars['logo']) ? $vars['logo'] : l(check_plain(variable_get('site_name', 'Drupal')), '<front>', array('attributes' => array('class' => 'logo')));

  // Footer links
  $vars['footer_links'] = isset($vars['footer_links']) ? $vars['footer_links'] : array();
  $item = menu_get_item('admin');
  if ($item && $item['access']) {
    $vars['footer_links']['admin'] = $item;
  }

  // IE7 CSS
  // @TODO: Implement IE styles key in tao.
  $ie = base_path() . drupal_get_path('theme', 'ginkgo') .'/ie.css';
  $vars['ie'] = "<!--[if lte IE 8]><style type='text/css' media='screen'>@import '{$ie}';</style><![endif]-->";

  // Help text toggler link.
  $vars['help_toggler'] = !empty($vars['help']) ? l(t('Help'), $_GET['q'], array('fragment' => 'block-atrium-help', 'attributes' => array('id' => 'help-toggler', 'class' => 'palette-toggle'))) : '';
}
Beispiel #2
0
/**
 * Intercept page template variables
 *
 * @param $vars
 *   A sequential array of variables passed to the theme function.
 */
function SimplyCivi_preprocess_page(&$vars)
{
    global $user;
    $vars['path'] = base_path() . path_to_theme() . '/';
    $vars['path_parent'] = base_path() . drupal_get_path('theme', 'SimplyCivi') . '/';
    $vars['user'] = $user;
    // Prep the logo for being displayed
    $site_slogan = !$vars['site_slogan'] ? '' : ' - ' . $vars['site_slogan'];
    $logo_img = '';
    $title = $text = variable_get('site_name', '');
    if ($vars['logo']) {
        $logo_img = "<img src='" . $vars['logo'] . "' alt='" . $title . "' border='0' />";
        $text = $vars['site_name'] ? $logo_img . $text : $logo_img;
    }
    $vars['logo_block'] = !$vars['site_name'] && !$vars['logo'] ? '' : l($text, '', array('attributes' => array('title' => $title . $site_slogan), 'html' => !empty($logo_img)));
    //Play nicely with the page_title module if it is there.
    if (!module_exists('page_title')) {
        // Fixup the $head_title and $title vars to display better.
        $title = drupal_get_title();
        $headers = drupal_get_headers();
        // if this is a 403 and they aren't logged in, tell them they need to log in
        if (strpos($headers, 'HTTP/1.1 403 Forbidden') && !$user->uid) {
            $title = t('Please login to continue');
        }
        $vars['title'] = $title;
        if (!drupal_is_front_page()) {
            $vars['head_title'] = $title . ' | ' . $vars['site_name'];
            if ($vars['site_slogan'] != '') {
                $vars['head_title'] .= ' &ndash; ' . $vars['site_slogan'];
            }
        }
        $vars['head_title'] = strip_tags($vars['head_title']);
    }
    //Perform RTL - LTR swap and load RTL Styles.
    if ($vars['language']->dir == 'rtl') {
        // Remove SimplyCivi Grid and use RTL grid
        $css = $vars['css'];
        $css['screen,projection']['theme'][path_to_theme() . '/SimplyCivi/SimplyCivi/plugins/rtl/screen.css'] = TRUE;
        $vars['styles'] = drupal_get_css($css);
        //setup rtl css for IE
        $vars['styles_ie']['ie'] = '<link href="' . $path . 'css/ie-rtl.css" rel="stylesheet"  type="text/css"  media="screen, projection" />';
        $vars['styles_ie']['ie6'] = '<link href="' . $path . 'css/ie6-rtl.css" rel="stylesheet"  type="text/css"  media="screen, projection" />';
    }
    $vars['meta'] = '';
    // SEO optimization, add in the node's teaser, or if on the homepage, the mission statement
    // as a description of the page that appears in search engines
    if ($vars['is_front'] && $vars['mission'] != '') {
        $vars['meta'] .= '<meta name="description" content="' . SimplyCivi_trim_text($vars['mission']) . '" />' . "\n";
    } elseif (isset($vars['node']->teaser) && $vars['node']->teaser != '') {
        $vars['meta'] .= '<meta name="description" content="' . SimplyCivi_trim_text($vars['node']->teaser) . '" />' . "\n";
    } elseif (isset($vars['node']->body) && $vars['node']->body != '') {
        $vars['meta'] .= '<meta name="description" content="' . SimplyCivi_trim_text($vars['node']->body) . '" />' . "\n";
    }
    // SEO optimization, if the node has tags, use these as keywords for the page
    if (isset($vars['node']->taxonomy)) {
        $keywords = array();
        foreach ($vars['node']->taxonomy as $term) {
            $keywords[] = $term->name;
        }
        $vars['meta'] .= '<meta name="keywords" content="' . implode(',', $keywords) . '" />' . "\n";
    }
    // SEO optimization, avoid duplicate titles in search indexes for pager pages
    if (isset($_GET['page']) || isset($_GET['sort'])) {
        $vars['meta'] .= '<meta name="robots" content="noindex,follow" />' . "\n";
    }
    if (theme_get_setting('SimplyCivi_showgrid')) {
        $vars['body_classes'] .= ' showgrid ';
    }
    // Make sure framework styles are placed above all others.
    $vars['css_alt'] = SimplyCivi_css_reorder($vars['css']);
    $vars['styles'] = drupal_get_css($vars['css_alt']);
    /* I like to embed the Google search in various places, uncomment to make use of this
      // setup search for custom placement
      $search = module_invoke('google_cse', 'block', 'view', '0');
      $vars['search'] = $search['content'];
      */
    /* to remove specific CSS files from modules use this trick
      // Remove stylesheets
      $css = $vars['css'];
      unset($css['all']['module']['sites/all/modules/contrib/plus1/plus1.css']);
      $vars['styles'] = drupal_get_css($css);
      */
}