' . implode($breadcrumb_separator, $breadcrumb) . "$trailing_separator$title"; } } // 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) { // Add conditional stylesheets. if (!module_exists('conditional_styles')) { $vars['styles'] .= $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'], ''); } // Classes for body element. Allows advanced theming based on context // (home page, node of certain type, etc.) $classes = explode(' ', $vars['body_classes']); // Remove the mostly useless page-ARG0 class. if ($index = array_search(preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-'. drupal_strtolower(arg(0))), $classes)) { unset($classes[$index]); //print_r( $vars); //print_r( $classes); } if (!$vars['is_front']) { // Add unique class for each page. $path = drupal_get_path_alias($_GET['q']); $classes[] = zen_id_safe('page-' . $path); // Add unique class for each website section. list($section, ) = explode('/', $path, 2); if (arg(0) == 'node') { if (arg(1) == 'add') { $section = 'node-add'; } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) { $section = 'node-' . arg(2); } } $classes[] = zen_id_safe('section-' . $section); } if (theme_get_setting('zen_wireframes')) { $classes[] = 'with-wireframes'; // Optionally add the wireframes style. } //if ($vars['is_front']){ // $classes[] = 'right-sidebar' ; // } $vars['body_classes_array'] = $classes; $vars['body_classes'] = implode(' ', $classes); // Concatenate with spaces. } /** * Override or insert variables into the maintenance page template. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("maintenance_page" in this case.) */ function zen_preprocess_maintenance_page(&$vars, $hook) { // Add conditional stylesheets. if (!module_exists('conditional_styles')) { $vars['styles'] .= $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'], ''); } // Classes for body element. Allows advanced theming based on context // (home page, node of certain type, etc.) $vars['body_classes_array'] = explode(' ', $vars['body_classes']); } /** * 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) { // Special classes for nodes $classes = array('node'); if ($vars['sticky']) { $classes[] = 'sticky'; } if (!$vars['status']) { $classes[] = 'node-unpublished'; $vars['unpublished'] = TRUE; } else { $vars['unpublished'] = FALSE; } if ($vars['uid'] && $vars['uid'] == $GLOBALS['user']->uid) { $classes[] = 'node-mine'; // Node is authored by current user. } if ($vars['teaser']) { $classes[] = 'node-teaser'; // Node is displayed as teaser. } // Class for node type: "node-type-page", "node-type-story", "node-type-my-custom-type", etc. $classes[] = zen_id_safe('node-type-' . $vars['type']); $vars['classes'] = implode(' ', $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 './' . _zen_path() . '/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['edit_links_array'] = array(); $vars['edit_links'] = ''; if (theme_get_setting('zen_block_editing') && user_access('administer blocks')) { include_once './' . _zen_path() . '/template.block-editing.inc'; zen_preprocess_block_editing($vars, $hook); $classes[] = 'with-block-editing'; } // Render block classes. $vars['classes'] = implode(' ', $classes); } /** * 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 alphanumeric characters 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. return strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', $string)); } /** * Returns the path to the Zen theme. * * drupal_get_filename() is broken; see #341140. When that is fixed in Drupal 6, * replace _zen_path() with drupal_get_path('theme', 'zen'). */ function _zen_path() { static $path = FALSE; if (!$path) { $matches = drupal_system_listing('zen\.info$', 'themes', 'name', 0); if (!empty($matches['zen']->filename)) { $path = dirname($matches['zen']->filename); } } return $path; } /** * This snippet loads a custom page-login.tpl.php layout file when * users click through to the login, request password or register pages */ ############################################################################################ /** * This snippet catches the default login form and looks for an * user_register.tpl.php file in the theme folder */ function phptemplate_user_register($form) { return _phptemplate_callback('user_register', array('form' => $form)); } ############################################################################################ function _phptemplate_variables($hook, $variables = array()) { switch ($hook) { case 'page': global $user; if (arg(0) == 'user'){ if (!$user->uid) { //check to see if the user is logged in. If not display the special login page layout $variables['template_file'] = 'page-login'; } elseif (arg(1) == 'login' || arg(1) == 'register' || arg(1) == 'password' ) { $variables['template_file'] = 'page-login'; } } break; } return $variables; } /*! * Dynamic display block preprocess functions * Copyright (c) 2008 - 2009 P. Blaauw All rights reserved. * Version 1.6 (01-OCT-2009) * Licenced under GPL license * http://www.gnu.org/licenses/gpl.html */ /** * Override or insert variables into the ddblock_cycle_block_content templates. * Used to convert variables from view_fields to slider_items template variables * * @param $vars * An array of variables to pass to the theme template. * */ function zen_preprocess_ddblock_cycle_block_content(&$vars) { if ($vars['output_type'] == 'view_fields') { $content = array(); // Add slider_items for the template // If you use the devel module uncomment the following line to see the theme variables // dsm($vars['settings']['view_name']); // dsm($vars['content'][0]); // If you don't use the devel module uncomment the following line to see the theme variables // drupal_set_message('
' . var_export($vars['settings']['view_name'], true) . '
'); // drupal_set_message('
' . var_export($vars['content'][0], true) . '
'); if ($vars['settings']['view_name'] == 'news_items') { if (!empty($vars['content'])) { foreach ($vars['content'] as $key1 => $result) { // add slide_image variable if (isset($result->node_data_field_pager_item_text_field_image_fid)) { // get image id $fid = $result->node_data_field_pager_item_text_field_image_fid; // get path to image $filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid)); // use imagecache (imagecache, preset_name, file_path, alt, title, array of attributes) if (module_exists('imagecache') && is_array(imagecache_presets()) && $vars['imgcache_slide'] <> ''){ $slider_items[$key1]['slide_image'] = theme('imagecache', $vars['imgcache_slide'], $filepath, check_plain($result->node_title)); } else { $slider_items[$key1]['slide_image'] = '' . check_plain($result->node_title) . 
                ''; } } // add slide_text variable if (isset($result->node_data_field_pager_item_text_field_slide_text_value)) { $slider_items[$key1]['slide_text'] = check_markup($result->node_data_field_pager_item_text_field_slide_text_value); } // add slide_title variable if (isset($result->node_title)) { $slider_items[$key1]['slide_title'] = check_plain($result->node_title); } // add slide_read_more variable and slide_node variable if (isset($result->nid)) { $slider_items[$key1]['slide_read_more'] = l('Read more...', 'node/' . $result->nid); $slider_items[$key1]['slide_node'] = base_path() . 'node/' . $result->nid; } } } } $vars['slider_items'] = $slider_items; } } /** * Override or insert variables into the ddblock_cycle_pager_content templates. * Used to convert variables from view_fields to pager_items template variables * Only used for custom pager items * * @param $vars * An array of variables to pass to the theme template. * */ function zen_preprocess_ddblock_cycle_pager_content(&$vars) { if (($vars['output_type'] == 'view_fields') && ($vars['pager_settings']['pager'] == 'custom-pager')){ $content = array(); // Add pager_items for the template // If you use the devel module uncomment the following lines to see the theme variables // dsm($vars['pager_settings']['view_name']); // dsm($vars['content'][0]); // If you don't use the devel module uncomment the following lines to see the theme variables // drupal_set_message('
' . var_export($vars['pager_settings'], true) . '
'); // drupal_set_message('
' . var_export($vars['content'][0], true) . '
'); if ($vars['pager_settings']['view_name'] == 'news_items') { if (!empty($vars['content'])) { foreach ($vars['content'] as $key1 => $result) { // add pager_item_image variable if (isset($result->node_data_field_pager_item_text_field_image_fid)) { $fid = $result->node_data_field_pager_item_text_field_image_fid; $filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid)); // use imagecache (imagecache, preset_name, file_path, alt, title, array of attributes) if (module_exists('imagecache') && is_array(imagecache_presets()) && $vars['imgcache_pager_item'] <> ''){ $pager_items[$key1]['image'] = theme('imagecache', $vars['pager_settings']['imgcache_pager_item'], $filepath, check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value)); } else { $pager_items[$key1]['image'] = '' . check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value) . 
                ''; } } // add pager_item _text variable if (isset($result->node_data_field_pager_item_text_field_pager_item_text_value)) { $pager_items[$key1]['text'] = check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value); } } } } $vars['pager_items'] = $pager_items; } }