/** * Override or insert variables into the page template. */ function garland_preprocess_page(&$vars) { $vars['tabs2'] = menu_secondary_local_tasks(); if (isset($vars['main_menu'])) { $vars['primary_nav'] = theme('links__system_main_menu', array('links' => $vars['main_menu'], 'attributes' => array('class' => array('links', 'main-menu')), 'heading' => array('text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible')))); } else { $vars['primary_nav'] = FALSE; } if (isset($vars['secondary_menu'])) { $vars['secondary_nav'] = theme('links__system_secondary_menu', array('links' => $vars['secondary_menu'], 'attributes' => array('class' => array('links', 'secondary-menu')), 'heading' => array('text' => t('Secondary menu'), 'level' => 'h2', 'class' => array('element-invisible')))); } else { $vars['secondary_nav'] = FALSE; } // Prepare header. $site_fields = array(); if (!empty($vars['site_name'])) { $site_fields[] = check_plain($vars['site_name']); } if (!empty($vars['site_slogan'])) { $site_fields[] = check_plain($vars['site_slogan']); } $vars['site_title'] = implode(' ', $site_fields); if (!empty($site_fields)) { $site_fields[0] = '<span>' . $site_fields[0] . '</span>'; } $vars['site_html'] = implode(' ', $site_fields); // Set a variable for the site name title and logo alt attributes text. $slogan_text = filter_xss_admin(variable_get('site_slogan', '')); $site_name_text = filter_xss_admin(variable_get('site_name', 'Drupal')); $vars['site_name_and_slogan'] = $site_name_text . ' ' . $slogan_text; }
/** * Override or insert variables for the breadcrumb theme function. * * @param $variables * An array of variables to pass to the theme function. * @param $hook * The name of the theme hook being called ("breadcrumb" in this case). * * @see zen_breadcrumb() */ function zen_preprocess_breadcrumb(&$variables, $hook) { // Define variables for the breadcrumb-related theme settings. This is done // here so that sub-themes can dynamically change the settings under // particular conditions in a preprocess function of their own. $variables['display_breadcrumb'] = check_plain(theme_get_setting('zen_breadcrumb')); $variables['display_breadcrumb'] = $variables['display_breadcrumb'] == 'yes' || $variables['display_breadcrumb'] == 'admin' && arg(0) == 'admin' ? TRUE : FALSE; $variables['breadcrumb_separator'] = filter_xss_admin(theme_get_setting('zen_breadcrumb_separator')); $variables['display_trailing_separator'] = theme_get_setting('zen_breadcrumb_trailing') ? TRUE : FALSE; // Optionally get rid of the homepage link. if (!theme_get_setting('zen_breadcrumb_home')) { array_shift($variables['breadcrumb']); } // Add the title of the page to the end of the breadcrumb list. if (!empty($variables['breadcrumb']) && theme_get_setting('zen_breadcrumb_title')) { $item = menu_get_item(); if (!empty($item['tab_parent'])) { // If we are on a non-default tab, use the tab's title. $variables['breadcrumb'][] = check_plain($item['title']); } else { $variables['breadcrumb'][] = drupal_get_title(); } // Turn off the trailing separator. $variables['display_trailing_separator'] = FALSE; } // Provide a navigational heading to give context for breadcrumb links to // screen-reader users. if (empty($variables['title'])) { $variables['title'] = t('You are here'); } }
/** * Override or insert variables into the page template. */ function denholo_preprocess_page(&$vars) { $vars['slideshow_display'] = theme_get_setting('slideshow_display', 'denholo'); $vars['slide1_title'] = theme_get_setting('slide1_title', 'denholo'); $vars['slide2_title'] = theme_get_setting('slide2_title', 'denholo'); $vars['slide3_title'] = theme_get_setting('slide3_title', 'denholo'); $vars['slide1_desc'] = theme_get_setting('slide1_desc', 'denholo'); $vars['slide2_desc'] = theme_get_setting('slide2_desc', 'denholo'); $vars['slide3_desc'] = theme_get_setting('slide3_desc', 'denholo'); $vars['img1'] = base_path() . drupal_get_path('theme', 'denholo') . '/images/slideshow/cat12_slide2.jpg'; $vars['img2'] = base_path() . drupal_get_path('theme', 'denholo') . '/images/slideshow/rsz_2delta.jpg'; $vars['img3'] = base_path() . drupal_get_path('theme', 'denholo') . '/images/slideshow/scenic_hills.jpg'; $image1var = array('path' => $vars['img1'], 'alt' => $vars['slide1_title'], 'title' => $vars['slide1_title'], 'attributes' => array('class' => 'slide-img')); $vars['slideimage1'] = theme('image', $image1var); $image2var = array('path' => $vars['img2'], 'alt' => $vars['slide2_title'], 'title' => $vars['slide2_title'], 'attributes' => array('class' => 'slide-img')); $vars['slideimage2'] = theme('image', $image2var); $image3var = array('path' => $vars['img3'], 'alt' => $vars['slide3_title'], 'title' => $vars['slide3_title'], 'attributes' => array('class' => 'slide-img')); $vars['slideimage3'] = theme('image', $image3var); $vars['columns_display'] = filter_xss_admin(theme_get_setting('columns_display', 'denholo')); $vars['col1'] = filter_xss_admin(theme_get_setting('colone', 'denholo')); $vars['col1title'] = filter_xss_admin(theme_get_setting('colonetitle', 'denholo')); $vars['col1image'] = filter_xss_admin(theme_get_setting('coloneimage', 'denholo')); $vars['col2'] = filter_xss_admin(theme_get_setting('coltwo', 'denholo')); $vars['col2title'] = filter_xss_admin(theme_get_setting('coltwotitle', 'denholo')); $vars['col2image'] = filter_xss_admin(theme_get_setting('coltwoimage', 'denholo')); $vars['col3'] = filter_xss_admin(theme_get_setting('colthree', 'denholo')); $vars['col3title'] = filter_xss_admin(theme_get_setting('colthreetitle', 'denholo')); $vars['col3image'] = filter_xss_admin(theme_get_setting('colthreeimage', 'denholo')); }
function dms_form_element($element, $value) { // This is also used in the installer, pre-database setup. $t = get_t(); $output = '<div class="form-item"'; if (!empty($element['#id'])) { $output .= ' id="' . $element['#id'] . '-wrapper"'; } $output .= ">\n"; $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '">(Required)</span>' : ''; if (!empty($element['#title'])) { $title = $element['#title']; if (!empty($element['#id'])) { $label = trim(str_replace(":", "", $t('!title !required:', array('!title' => filter_xss_admin($title), '!required' => $required)))) . ":"; $output .= ' <label for="' . $element['#id'] . '">' . $label . "</label>\n"; } else { $output .= ' <label>' . $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n"; } } $output .= " {$value}\n"; if (!empty($element['#description'])) { $output .= ' <div class="description">' . $element['#description'] . "</div>\n"; } $output .= "</div>\n"; return $output; }
function razorDrupal_process_page(&$variables) { // Hook into color.module. if (module_exists('color')) { _color_page_alter($variables); } // Always print the site name and slogan, but if they are toggled off, we'll // just hide them visually. $variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE; $variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE; if ($variables['hide_site_name']) { // If toggle_name is FALSE, the site_name will be empty, so we rebuild it. $variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal')); } if ($variables['hide_site_slogan']) { // If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it. $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', '')); } // Since the title and the shortcut link are both block level elements, // positioning them next to each other is much simpler with a wrapper div. if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) { // Add a wrapper div using the title_prefix and title_suffix render elements. $variables['title_prefix']['shortcut_wrapper'] = array('#markup' => '<div class="shortcut-wrapper clearfix">', '#weight' => 100); $variables['title_suffix']['shortcut_wrapper'] = array('#markup' => '</div>', '#weight' => -99); // Make sure the shortcut link is the first item in title_suffix. $variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100; } }
/** * Overrides theme_form_element_label(). */ function bootstrap_psdpt_form_element_label(&$variables) { $element = $variables['element']; // This is also used in the installer, pre-database setup. $t = get_t(); // Determine if certain things should skip for checkbox or radio elements. $skip = isset($element['#type']) && ('checkbox' === $element['#type'] || 'radio' === $element['#type']); // If title and required marker are both empty, output no label. if ((!isset($element['#title']) || $element['#title'] === '' && !$skip) && empty($element['#required'])) { return ''; } // If the element is required, a required marker is appended to the label. $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : ''; $title = filter_xss_admin($element['#title']); $attributes = array(); // Style the label as class option to display inline with the element. if ($element['#title_display'] == 'after' && !$skip) { $attributes['class'][] = $element['#type']; } elseif ($element['#title_display'] == 'invisible') { $attributes['class'][] = 'element-invisible'; } if (!empty($element['#id'])) { $attributes['for'] = $element['#id']; } // Insert radio and checkboxes inside label elements. $output = ''; if (isset($variables['#children'])) { $output .= $variables['#children']; } // Append label. $output .= $t('!title !required', array('!title' => $title, '!required' => $required)); // The leading whitespace helps visually separate fields from inline labels. return ' <label' . drupal_attributes($attributes) . '>' . $output . "</label>\n"; }
function mothership_form_element($element, $value) { // This is also used in the installer, pre-database setup. $t = get_t(); //$output = '<div>'; // removed $output = '<div class="form-item"'; //so we dont know its a div hmm? form>div .... $output = '<div '; // removed the ID wrapper? if (!empty($element['#id'])) { $output .= ' id="' . $element['#id'] . '-wrapper"'; } $output .= ">\n"; $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '">*</span>' : ''; if (!empty($element['#title'])) { $title = $element['#title']; if (!empty($element['#id'])) { $output .= ' <label for="' . $element['#id'] . '">' . $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n"; } else { $output .= ' <label>' . $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n"; } } //TODO test to see if this is clean text - then we might need a <span> etc $output .= "{$value}\n"; if (!empty($element['#description'])) { $output .= '<div class="description">' . $element['#description'] . "</div>\n"; } $output .= "</div>\n"; return $output; }
public function tagcloudsListVocs($tagclouds_vocs = NULL) { $vocs = tagclouds_vocs_load($tagclouds_vocs); if (empty($vocs)) { throw new NotFoundHttpException(); } $output = ''; foreach ($vocs as $vid) { $vocabulary = entity_load('taxonomy_vocabulary', $vid); if ($vocabulary == FALSE) { throw new NotFoundHttpException(); } // Clean out vocabulary, so that we don't have to leave security to our // theme layer. $vocabulary->description = filter_xss_admin($vocabulary->description); $vocabulary->name = filter_xss_admin($vocabulary->name); $config = \Drupal::config('tagclouds.admin_page'); $tags = tagclouds_get_tags(array($vocabulary->vid), $config->get('tagclouds_levels'), $config->get('tagclouds_page_amount')); $tags = tagclouds_sort_tags($tags); $output .= _theme('tagclouds_list_box', array('vocabulary' => $vocabulary, 'tags' => $tags)); } if (!$output) { throw new NotFoundHttpException(); } $output = "<div class=\"wrapper tagclouds\">{$output}</div>"; return $output; }
/** * @file * form mothership overwrites */ function mothership_form_element($element, $value) { // This is also used in the installer, pre-database setup. $t = get_t(); //add a more specific form-item-$type $output = "<div class=\"form-item form-item-" . $element['#type'] . " \" "; // TODO cant this be dublicated on a page? //and then its not unique if (!empty($element['#id'])) { $output .= ' id="' . $element['#id'] . '-wrapper"'; } $output .= ">\n"; $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '">*</span>' : ''; if (!empty($element['#title'])) { $title = $element['#title']; if (!empty($element['#id'])) { $output .= ' <label for="' . $element['#id'] . '">' . $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n"; } else { $output .= ' <label>' . $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n"; } } //TODO test to see if this is clean text - then we might need a <span> //if we need to catch the content with $output .= "{$value}\n"; if (!empty($element['#description'])) { $output .= '<div class="form-description">' . $element['#description'] . "</div>\n"; } $output .= "</div>\n"; return $output; }
/** * Implements theme_form_element_label(). */ function tibco_styles_form_element_label($variables) { $element = $variables['element']; // This is also used in the installer, pre-database setup. $t = get_t(); // If title and required marker are both empty, output no label. if ((!isset($element['#title']) || $element['#title'] === '') && empty($element['#required'])) { return ''; } // If the element is required, a required marker is appended to the label. $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : ''; $title = filter_xss_admin($element['#title']); $attributes = array(); // Style the label as class option to display inline with the element. if ($element['#title_display'] == 'after') { $attributes['class'] = 'option'; } elseif ($element['#title_display'] == 'invisible') { $attributes['class'] = 'element-invisible'; } if (!empty($element['#id'])) { $attributes['for'] = $element['#id']; } $help = ''; if ($element['#type'] == 'checkbox' && $element['#entity_type'] == 'entityform') { $help = $element['#checkbox_suffix']; } // The leading whitespace helps visually separate fields from inline labels. return ' <label' . drupal_attributes($attributes) . '>' . $t('!title !required', array('!title' => $title, '!required' => $required)) . $help . "</label>\n"; }
/** * Overrides theme_links(). */ function badm_links__ucms_dashboard_filter($variables) { $links = $variables['links']; $heading = $variables['heading']; $output = ''; if (count($links) > 0) { if (!empty($heading)) { if (is_string($heading)) { $heading = ['text' => $heading, 'level' => 'strong', 'class' => []]; } $output .= '<' . $heading['level']; if (!empty($heading['class'])) { $output .= drupal_attributes(['class' => $heading['class']]); } $output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>'; } $output .= '<ul class="list-unstyled">'; foreach ($links as $link) { if (isset($link['href'])) { $link['attributes']['class'][] = 'list-group-item'; // Deal with title manually because we are going to force HTML code anyway if (empty($link['html'])) { $r_title = check_plain($link['title']); } else { $r_title = filter_xss_admin($link['title']); } $r_href = url($link['href'], $link); // And we must manually handle the active class too for the checkbox. if (!empty($link['attributes']['class']) && in_array('active', $link['attributes']['class'])) { $r_c_attributes = ' checked="checked"'; } else { $r_c_attributes = ''; } // Also link attributes, and it should it. if (empty($links['attributes'])) { $r_attributes = ''; } else { unset($links['attributes']['href']); // Just in case... $r_attributes = drupal_attributes($links['attributes']); } $output .= <<<EOT <li> <div class="checkbox"> <label> <a href="{$r_href}"{$r_attributes}> <input type="checkbox"{$r_c_attributes}> {$r_title} </a> </label> </div> </li> EOT; } } $output .= '</ul>'; } return $output; }
/** * Hook allowing other modules to alter any newly defined regions blocks. * * This happens before the each block object is rendered by theme_block(). * * @param array $blocks * A keyed array of block objects provided by core block and context modules. * @param string $region_name * machine name of the region. * * @see _regions_blocks() * @see theme_block() */ function hook_regions_blocks_alter(&$blocks = array(), $region_name = NULL) { // Example to support HTML titles, with a safe but unorthodox workaround. foreach ($blocks as $key => $block) { $block->subject = filter_xss_admin(html_entity_decode($block->subject)); $blocks[$key] = $block; } }
function neb_blockify_logo($variables) { $site_name = filter_xss_admin(variable_get('site_name', 'Drupal')); // Strip the base_path from the beginning of the logo path. $path = preg_replace('|^' . base_path() . '|', '', $variables['logo_path']); $image = array('#theme' => 'image', '#path' => $path, '#alt' => t('!site_name logo', array('!site_name' => $site_name))); return l(render($image), '<front>', array('html' => TRUE, 'attributes' => array('id' => 'logo', 'rel' => 'home', 'title' => t('Return to the !site_name home page', array('!site_name' => $site_name))))); }
/** * Return a themed mission trail. * * @return * a string containing the mission output, or execute PHP code snippet if * mission is enclosed with <?php ?>. */ function phptemplate_mission() { $mission = theme_get_setting('mission'); if (preg_match('/^<\\?php/', $mission)) { $mission = drupal_eval($mission); } else { $mission = filter_xss_admin($mission); } return isset($mission) ? $mission : ''; }
function bartik_less_process_maintenance_page(&$variables) { $variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TURE; $variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TURE; if ($variables['hide_site_name']) { $variables['site_name'] = filter_xss_admin(variale_get('site_name', 'Drupal')); } if ($variables['hide_side_slogan']) { $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', '')); } }
/** * Preprocess variables for page template. */ function spacelab_preprocess_page(&$vars) { // Get the entire main menu tree. $main_menu_tree = array(); $main_menu_tree = menu_tree_all_data('main-menu', NULL, 2); // Add the rendered output to the $main_menu_expanded variable. $vars['main_menu_expanded'] = menu_tree_output($main_menu_tree); // Always print the site name and slogan, but if they are toggled off, we'll // just hide them visually. $vars['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE; $vars['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE; if ($vars['hide_site_name']) { // If toggle_name is FALSE, the site_name will be empty, so we rebuild it. $vars['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal')); } if ($vars['hide_site_slogan']) { // If toggle_site_slogan is FALSE, the site_slogan will be empty, // so we rebuild it. $vars['site_slogan'] = filter_xss_admin(variable_get('site_slogan', '')); } // Since the title and the shortcut link are both block level elements, // positioning them next to each other is much simpler with a wrapper div. if (!empty($vars['title_suffix']['add_or_remove_shortcut']) && $vars['title']) { // Add a wrapper div using title_prefix and title_suffix render elements. $vars['title_prefix']['shortcut_wrapper'] = array('#markup' => '<div class="shortcut-wrapper clearfix">', '#weight' => 100); $vars['title_suffix']['shortcut_wrapper'] = array('#markup' => '</div>', '#weight' => -99); // Make sure the shortcut link is the first item in title_suffix. $vars['title_suffix']['add_or_remove_shortcut']['#weight'] = -100; } // If panels arent being used at all. $vars['no_panels'] = !(module_exists('page_manager') && page_manager_get_current_page()); // Check if we're to always print the page title, even on panelized pages. $vars['always_show_page_title'] = theme_get_setting('always_show_page_title') ? TRUE : FALSE; /** * insert variables into page template. */ if ($vars['page']['sidebar_first'] && $vars['page']['sidebar_second']) { $vars['sidebar_grid_class'] = 'col-md-3'; $vars['main_grid_class'] = 'col-md-6'; } elseif ($vars['page']['sidebar_first'] || $vars['page']['sidebar_second']) { $vars['sidebar_grid_class'] = 'col-md-3'; $vars['main_grid_class'] = 'col-md-9'; } else { $vars['main_grid_class'] = 'col-md-12'; } if ($vars['page']['header_top_left'] && $vars['page']['header_top_right']) { $vars['header_top_left_grid_class'] = 'col-md-8'; $vars['header_top_right_grid_class'] = 'col-md-4'; } elseif ($vars['page']['header_top_right'] || $vars['page']['header_top_left']) { $vars['header_top_left_grid_class'] = 'col-md-12'; $vars['header_top_right_grid_class'] = 'col-md-12'; } }
/** * Preprocessor for theme_page(). */ function ginkgo_preprocess_page(&$vars) { // Add icon markup to main menu ginkgo_icon_links($vars['primary_links']); // If tabs are active, the title is likely shown in them. Don't show twice. $vars['title'] = !empty($vars['tabs']) ? '' : $vars['title']; // Respect anything people are requesting through context. if (module_exists('context')) { $vars['custom_layout'] = context_get('theme', 'layout') == 'custom' ? TRUE : FALSE; $vars['attr']['class'] .= context_isset('theme', 'body_classes') ? " " . context_get('theme', 'body_classes') : ''; } // Add a smarter body class than "not logged in" for determining whether // we are on a login/password/user registration related page. global $user; $vars['mission'] = ''; if (!$user->uid && arg(0) == 'user') { $vars['attr']['class'] .= ' anonymous-login'; $vars['mission'] = filter_xss_admin(variable_get('site_mission', '')); } // Theme specific settings $settings = theme_get_settings('ginkgo'); // Show site title/emblem ? $vars['site_name'] = isset($settings['emblem']) && !$settings['emblem'] ? '' : $vars['site_name']; // 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() . path_to_theme() . '/ie.css'; $vars['ie'] = "<!--[if lte IE 8]><style type='text/css' media='screen'>@import '{$ie}';</style><![endif]-->"; // Add spaces design CSS back in if (!isset($_GET['print'])) { if (empty($vars['spaces_design_styles'])) { global $theme_info; $space = spaces_get_space(); // Retrieve default colors from info file if (isset($theme_info->info["spaces_design_{$space->type}"])) { $default = $theme_info->info["spaces_design_{$space->type}"]; } else { $default = '#3399aa'; } $color = !empty($settings["color_{$space->type}"]) ? $settings["color_{$space->type}"] : $default; $vars['styles'] .= theme('spaces_design', $color); $vars['attr']['class'] .= ' spaces-design'; } else { $vars['styles'] .= $vars['spaces_design_styles']; } } }
/** * Return a themed breadcrumb trail. * * @param $variables * - title: An optional string to be used as a navigational heading to give * context for breadcrumb links to screen-reader users. * - title_attributes_array: Array of HTML attributes for the title. It is * flattened into a string within the theme function. * - breadcrumb: An array containing the breadcrumb links. * @return * A string containing the breadcrumb output. */ function zen_breadcrumb($variables) { $breadcrumb = $variables['breadcrumb']; $output = ''; // Determine if we are to display the breadcrumb. $show_breadcrumb = theme_get_setting('zen_breadcrumb'); if ($show_breadcrumb == 'yes' || $show_breadcrumb == 'admin' && arg(0) == 'admin') { // Optionally get rid of the homepage link. $show_breadcrumb_home = theme_get_setting('zen_breadcrumb_home'); if (!$show_breadcrumb_home) { array_shift($breadcrumb); } // Return the breadcrumb with separators. if (!empty($breadcrumb)) { $breadcrumb_separator = filter_xss_admin(theme_get_setting('zen_breadcrumb_separator')); $trailing_separator = $title = ''; if (theme_get_setting('zen_breadcrumb_title')) { $item = menu_get_item(); if (!empty($item['tab_parent'])) { // If we are on a non-default tab, use the tab's title. $breadcrumb[] = check_plain($item['title']); } else { $breadcrumb[] = drupal_get_title(); } } elseif (theme_get_setting('zen_breadcrumb_trailing')) { $trailing_separator = $breadcrumb_separator; } // Provide a navigational heading to give context for breadcrumb links to // screen-reader users. if (empty($variables['title'])) { $variables['title'] = t('You are here'); } // Unless overridden by a preprocess function, make the heading invisible. if (!isset($variables['title_attributes_array']['class'])) { $variables['title_attributes_array']['class'][] = 'element-invisible'; } // Build the breadcrumb trail. $output = '<nav class="breadcrumb" role="navigation">'; $output .= '<h2' . drupal_attributes($variables['title_attributes_array']) . '>' . $variables['title'] . '</h2>'; $output .= '<ol><li>' . implode($breadcrumb_separator . '</li><li>', $breadcrumb) . $trailing_separator . '</li></ol>'; $output .= '</nav>'; } } return $output; }
/** * Define some variables for use in theme templates. */ function blocks_process_page(&$variables) { // Assign site name and slogan toggle theme settings to variables. $variables['disable_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE; $variables['disable_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE; // Assign site name/slogan defaults if there is no value. if ($variables['disable_site_name']) { $variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal')); } if ($variables['disable_site_slogan']) { $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', '')); } }
/** * Returns HTML for a form element label and required marker. * * Form element labels include the #title and a #required marker. The label is * associated with the element itself by the element #id. Labels may appear * before or after elements, depending on theme_form_element() and * #title_display. * * This function will not be called for elements with no labels, depending on * #title_display. For elements that have an empty #title and are not required, * this function will output no label (''). For required elements that have an * empty #title, this will output the required marker alone within the label. * The label will use the #id to associate the marker with the field that is * required. That is especially important for screenreader users to know * which field is required. * * @param array $variables * An associative array containing: * - element: An associative array containing the properties of the element. * Properties used: #required, #title, #id, #value, #description. * * @return string * The constructed HTML. * * @see theme_form_element_label() * * @ingroup theme_functions */ function bootstrap_form_element_label(&$variables) { $element = $variables['element']; // Extract variables. $output = ''; $title = !empty($element['#title']) ? filter_xss_admin($element['#title']) : ''; // Only show the required marker if there is an actual title to display. if ($title && ($required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : '')) { $title .= ' ' . $required; } $display = isset($element['#title_display']) ? $element['#title_display'] : 'before'; $type = !empty($element['#type']) ? $element['#type'] : FALSE; $checkbox = $type && $type === 'checkbox'; $radio = $type && $type === 'radio'; // Immediately return if the element is not a checkbox or radio and there is // no label to be rendered. if (!$checkbox && !$radio && ($display === 'none' || !$title)) { return ''; } // Retrieve the label attributes array. $attributes =& _bootstrap_get_attributes($element, 'label_attributes'); // Add Bootstrap label class. $attributes['class'][] = 'control-label'; // Add the necessary 'for' attribute if the element ID exists. if (!empty($element['#id'])) { $attributes['for'] = $element['#id']; } // Checkboxes and radios must construct the label differently. if ($checkbox || $radio) { if ($display === 'before') { $output .= $title; } elseif ($display === 'none' || $display === 'invisible') { $output .= '<span class="element-invisible">' . $title . '</span>'; } // Inject the rendered checkbox or radio element inside the label. if (!empty($element['#children'])) { $output .= $element['#children']; } if ($display === 'after') { $output .= $title; } } else { // Show label only to screen readers to avoid disruption in visual flows. if ($display === 'invisible') { $attributes['class'][] = 'element-invisible'; } $output .= $title; } // The leading whitespace helps visually separate fields from inline labels. return ' <label' . drupal_attributes($attributes) . '>' . $output . "</label>\n"; }
function mothership_preprocess_forum_list(&$variables) { global $user; $row = 0; $count = 0; $count2 = 0; // Sanitize each forum so that the template can safely print the data. foreach ($variables['forums'] as $id => $forum) { $variables['forums'][$id]->description = !empty($forum->description) ? filter_xss_admin($forum->description) : ''; $variables['forums'][$id]->link = url("forum/{$forum->tid}"); $variables['forums'][$id]->name = check_plain($forum->name); $variables['forums'][$id]->is_container = !empty($forum->container); $variables['forums'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even'; $row++; // $variables['forums'][$id]->depth == 1 // make a count of the non container forums if ($variables['forums'][$id]->depth) { if (!$variables['forums'][$id]->is_container) { $variables['forums'][$id]->count = $count; $count++; } } else { if (!$variables['forums'][$id]->is_container) { $variables['forums'][$id]->count = $count2; $count2++; } } $variables['forums'][$id]->new_text = ''; $variables['forums'][$id]->new_url = ''; $variables['forums'][$id]->new_topics = 0; $variables['forums'][$id]->old_topics = $forum->num_topics; $variables['forums'][$id]->icon_class = 'default'; $variables['forums'][$id]->icon_title = t('No new posts'); if ($user->uid) { $variables['forums'][$id]->new_topics = _forum_topics_unread($forum->tid, $user->uid); if ($variables['forums'][$id]->new_topics) { $variables['forums'][$id]->new_text = format_plural($variables['forums'][$id]->new_topics, '1 new', '@count new'); $variables['forums'][$id]->new_url = url("forum/{$forum->tid}", array('fragment' => 'new')); $variables['forums'][$id]->icon_class = 'new'; $variables['forums'][$id]->icon_title = t('New posts'); } $variables['forums'][$id]->old_topics = $forum->num_topics - $variables['forums'][$id]->new_topics; } $variables['forums'][$id]->last_reply = theme('forum_submitted', array('topic' => $forum->last_post)); } // $tid = term id. if (isset($variables['tid'])) { $variables['forum_id'] = $variables['tid']; unset($variables['tid']); } }
/** * Override or insert variables into the maintenance page template. */ function bartik_process_maintenance_page(&$variables) { // Always print the site name, but don't always show it visually. $variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE; $variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE; if ($variables['hide_site_name']) { // If toggle_name is FALSE, the site_name will be empty, so we rebuild it. $variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal')); } if ($variables['hide_site_slogan']) { // If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it. $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', '')); } }
function floyd_preprocess_html(&$variables) { // Construct page title. if (drupal_get_title()) { $head_title = array('title' => strip_tags(html_entity_decode(drupal_get_title())), 'name' => check_plain(strip_tags(html_entity_decode(variable_get('site_name', 'Drupal'))))); } else { $head_title = array('name' => check_plain(strip_tags(html_entity_decode(variable_get('site_name', 'Drupal'))))); if (variable_get('site_slogan', '')) { $head_title['slogan'] = filter_xss_admin(variable_get('site_slogan', '')); } } $variables['head_title_array'] = $head_title; $variables['head_title'] = implode(' | ', $head_title); }
/** * Preprocessor for theme_page(). */ function ginkgo_preprocess_page(&$vars) { // Add icon markup to main menu ginkgo_icon_links($vars['primary_links']); // Grab the header dropdown links $vars['header'] = theme('blocks_header', array()); $vars['dropdown_links'] = theme('blocks_header', array(), TRUE); // If tabs are active, the title is likely shown in them. Don't show twice. $vars['title'] = !empty($vars['tabs']) ? '' : $vars['title']; // Respect anything people are requesting through context. if (module_exists('context')) { if (context_get('theme', 'layout') == 'custom') { $vars['custom_layout'] = TRUE; } if ($classes = context_get('theme', 'body_classes')) { $vars['attr']['class'] .= " {$classes}"; } } // Add a smarter body class than "not logged in" for determining whether // we are on a login/password/user registration related page. global $user; $vars['mission'] = ''; if (!$user->uid && arg(0) == 'user') { $vars['attr']['class'] .= ' anonymous-login'; $vars['mission'] = filter_xss_admin(variable_get('site_mission', '')); } // Theme specific settings $settings = theme_get_settings('ginkgo'); // Show site title/emblem ? if (isset($settings['emblem']) && !$settings['emblem']) { $vars['site_name'] = ''; } // Add spaces design CSS back in if (empty($vars['spaces_design_styles'])) { global $theme_info; $space = spaces_get_space(); // Retrieve default colors from info file if (isset($theme_info->info["spaces_design_{$space->type}"])) { $default = $theme_info->info["spaces_design_{$space->type}"]; } else { $default = '#3399aa'; } $color = !empty($settings["color_{$space->type}"]) ? $settings["color_{$space->type}"] : $default; $vars['styles'] .= theme('spaces_design', $color); $vars['attr']['class'] .= ' spaces-design'; } else { $vars['styles'] .= $vars['spaces_design_styles']; } }
/** * Override or insert variables into the maintenance page template. */ function corky_process_maintenance_page(&$variables) { // Always print the site name and slogan, but if they are toggled off, we'll // just hide them visually. $variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE; $variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE; if ($variables['hide_site_name']) { // If toggle_name is FALSE, the site_name will be empty, so we rebuild it. $variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal')); } if ($variables['hide_site_slogan']) { // If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it. $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', '')); } }
/** * Display the list of available node types for node creation. */ function slate_node_add_list($content) { $output = ''; if ($content) { $output = '<ul class="node-type-list">'; foreach ($content as $item) { $output .= "<li class='clear-block'>"; $output .= '<label>' . l($item['title'], $item['href'], $item['localized_options']) . '</label>'; $output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>'; $output .= "</li>"; } $output .= '</ul>'; } return $output; }
/** * Display the list of available node types for node creation. */ function seven_node_add_list($content) { $output = ''; if ($content) { $output = '<ul class="node-type-list">'; foreach ($content as $item) { $output .= '<li class="clearfix">'; $output .= '<span class="label">' . l($item['title'], $item['href'], $item['localized_options']) . '</span>'; $output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>'; $output .= '</li>'; } $output .= '</ul>'; } return $output; }
/** * Overriding theme_form_element(). */ function form_fun_form_element($element, $value) { // This is also used in the installer, pre-database setup. $t = get_t(); $attributes = array(); // Add drupal defaults if (!empty($element['#id'])) { $attributes['id'] = $element['#id'] . '-wrapper'; } $attributes['class'][] = 'form-item'; // Add a class indicating if a label isn't inside this element. // (Not sure if I'm keeping this or not) if (empty($element['#title'])) { $attributes['class'][] = 'form-item-no-label'; } // Add a clearfix classes on most elements, might add some more here. $inline = array('radio', 'checkbox'); if (!in_array($element['#type'], $inline)) { $attributes['class'][] = 'clearfix'; } // Flatten the attributes for output. $attributes = theme('render_attributes', $attributes); // Form required marker $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '">*</span>' : ''; // Label if (!empty($element['#title'])) { $title = $element['#title']; if (!empty($element['#id'])) { $label = '<label for="' . $element['#id'] . '">' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . '</label>' . "\n"; } else { $label = '<label>' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . '</label>' . "\n"; } } // Description if (!empty($element['#description'])) { $description = '<div class="description">' . $element['#description'] . '</div>' . "\n"; } // Prepare the output $output = "\n" . '<div' . $attributes . '>' . "\n"; // If there is no label, we can have less markup. Wrapper level class can handle positioning. if (!$label) { $output .= '<div class="inner">' . "\n" . $value . "\n" . $description . '</div>'; } else { $output .= $label . '<div class="right">' . "\n" . '<div class="inner">' . "\n" . $value . "\n" . $description . '</div>' . "\n" . '</div>' . "\n"; } $output .= '</div>' . "\n"; return $output; }
/** * Overrides theme_admin_block_content(). * * Use unordered list markup in both compact and extended mode. */ function seven_admin_block_content($variables) { $content = $variables['content']; $output = ''; if (!empty($content)) { $output = system_admin_compact_mode() ? '<ul class="admin-list compact">' : '<ul class="admin-list">'; foreach ($content as $item) { $output .= '<li class="leaf">'; $output .= l($item['title'], $item['href'], $item['localized_options']); if (isset($item['description']) && !system_admin_compact_mode()) { $output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>'; } $output .= '</li>'; } $output .= '</ul>'; } return $output; }
/** * Define some variables for use in theme templates. */ function redcrackle_process_page(&$variables) { $tid = arg(2); // Assign site name and slogan toggle theme settings to variables. $variables['disable_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE; $variables['disable_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE; // Assign site name/slogan defaults if there is no value. if ($variables['disable_site_name']) { $variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal')); } if ($variables['disable_site_slogan']) { $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', '')); } if (!empty($tid) && arg(1) == 'term') { $term = taxonomy_term_load($tid); // Unset the default content //unset($variables['page']['content']); taxonomy_term_load($tid); $field_image = field_get_items('taxonomy_term', $term, 'field_image'); $uri = !empty($field_image[0]['uri']) ? $field_image[0]['uri'] : ''; $alt = !empty($field_image[0]['alt']) ? $field_image[0]['alt'] : ''; if (!empty($uri)) { $variables['image_url'] = theme('image_style', array('path' => $uri, 'style_name' => 'large', 'alt' => $alt)); } $variables['description'] = $term->description; $variables['theme_hook_suggestions'][] = 'page__taxonomy__services'; } }