' . implode($breadcrumb_separator, $breadcrumb) . "$trailing_separator"; } } // Otherwise, return an empty string return ''; } /** * Implements theme_menu_item_link() */ function zen_menu_item_link($link) { if (empty($link['localized_options'])) { $link['localized_options'] = array(); } // If an item is a LOCAL TASK, render it as a tab if ($link['type'] & MENU_IS_LOCAL_TASK) { $link['title'] = '' . check_plain($link['title']) . ''; $link['localized_options']['html'] = TRUE; } return l($link['title'], $link['href'], $link['localized_options']); } /** * Duplicate of theme_menu_local_tasks() but adds clear-block to tabs. */ function zen_menu_local_tasks() { $output = ''; if ($primary = menu_primary_local_tasks()) { $output .= ''; } if ($secondary = menu_secondary_local_tasks()) { $output .= ''; } return $output; } /** * Override or insert variables into the page templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("page" in this case.) */ function zen_preprocess_page(&$vars, $hook) { global $theme; // These next lines add additional CSS files and redefine // the $css and $styles variables available to your page template if ($theme == 'zen') { // If we're in the main theme // Load the stylesheet for a liquid layout if (theme_get_setting('zen_layout') == 'border-politics-liquid') { drupal_add_css($vars['directory'] . '/layout-liquid.css', 'theme', 'all'); } // Or load the stylesheet for a fixed width layout else { drupal_add_css($vars['directory'] . '/layout-fixed.css', 'theme', 'all'); } } // Optionally add the block editing styles. if (theme_get_setting('zen_block_editing')) { drupal_add_css(path_to_zentheme() . '/block-editing.css', 'theme', 'all'); } // Optionally add the wireframes style. if (theme_get_setting('zen_wireframes')) { drupal_add_css(path_to_zentheme() . '/wireframes.css', 'theme', 'all'); } $vars['css'] = drupal_add_css(); $vars['styles'] = drupal_get_css(); // Allow sub-themes to have an ie.css file $vars['zentheme_directory'] = path_to_zentheme(); // Add an optional title to the end of the breadcrumb. if (theme_get_setting('zen_breadcrumb_title') && $vars['breadcrumb']) { $vars['breadcrumb'] = substr($vars['breadcrumb'], 0, -6) . $vars['title'] . ''; } // Don't display empty help from node_help(). if ($vars['help'] == "

\n
") { $vars['help'] = ''; } // Classes for body element. Allows advanced theming based on context // (home page, node of certain type, etc.) $body_classes = array($vars['body_classes']); if (!$vars['is_front']) { // Add unique classes for each page and website section $path = drupal_get_path_alias($_GET['q']); list($section, ) = explode('/', $path, 2); $body_classes[] = zen_id_safe('page-' . $path); $body_classes[] = zen_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' } } } $vars['body_classes'] = implode(' ', $body_classes); // Concatenate with spaces } /** * Override or insert variables into the node templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("node" in this case.) */ function zen_preprocess_node(&$vars, $hook) { global $user; // Special classes for nodes $node_classes = array(); if ($vars['sticky']) { $node_classes[] = 'sticky'; } if (!$vars['node']->status) { $node_classes[] = 'node-unpublished'; $vars['unpublished'] = TRUE; } else { $vars['unpublished'] = FALSE; } if ($vars['node']->uid && $vars['node']->uid == $user->uid) { // Node is authored by current user $node_classes[] = 'node-mine'; } if ($vars['teaser']) { // Node is displayed as teaser $node_classes[] = 'node-teaser'; } // Class for node type: "node-type-page", "node-type-story", "node-type-my-custom-type", etc. $node_classes[] = 'node-type-' . $vars['node']->type; $vars['node_classes'] = implode(' ', $node_classes); // Concatenate with spaces } /** * Override or insert variables into the comment templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("comment" in this case.) */ function zen_preprocess_comment(&$vars, $hook) { include_once './' . drupal_get_path('theme', 'zen') . '/template.comment.inc'; _zen_preprocess_comment($vars, $hook); } /** * Override or insert variables into the block templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("block" in this case.) */ function zen_preprocess_block(&$vars, $hook) { $block = $vars['block']; // Special classes for blocks. $classes = array('block'); $classes[] = 'block-' . $block->module; $classes[] = 'region-' . $vars['block_zebra']; $classes[] = $vars['zebra']; $classes[] = 'region-count-' . $vars['block_id']; $classes[] = 'count-' . $vars['id']; $vars['classes'] = implode(' ', $classes); $vars['edit_links_array'] = array(); $vars['edit_links'] = ''; if (theme_get_setting('zen_block_editing') && user_access('administer blocks')) { include_once './' . drupal_get_path('theme', 'zen') . '/template.block-editing.inc'; zen_preprocess_block_editing($vars, $hook); } } /** * Converts a string to a suitable html ID attribute. * * http://www.w3.org/TR/html4/struct/global.html#h-7.5.2 specifies what makes a * valid ID attribute in HTML. This function: * * - Ensure an ID starts with an alpha character by optionally adding an 'id'. * - Replaces any character except A-Z, numbers, and underscores with dashes. * - Converts entire string to lowercase. * * @param $string * The string * @return * The converted string */ function zen_id_safe($string) { // Replace with dashes anything that isn't A-Z, numbers, dashes, or underscores. $string = strtolower(preg_replace('/[^a-zA-Z0-9_-]+/', '-', $string)); // If the first character is not a-z, add 'n' in front. if (!ctype_lower($string{0})) { // Don't use ctype_alpha since its locale aware. $string = 'id' . $string; } return $string; } /** * Return the path to the main zen theme directory. */ function path_to_zentheme() { static $theme_path; if (!isset($theme_path)) { $theme_path = drupal_get_path('theme', 'zen'); } return $theme_path; }