Commit 5eaf3e03 authored by webchick's avatar webchick

#655742 by sun, jide: Add template variable for outputting HTML HEAD title safely.

parent bb9e871f
......@@ -2194,14 +2194,18 @@ function template_preprocess_html(&$variables) {
// Construct page title.
if (drupal_get_title()) {
$head_title = array(strip_tags(drupal_get_title()), check_plain(variable_get('site_name', 'Drupal')));
$head_title = array(
'title' => strip_tags(drupal_get_title()),
'name' => check_plain(variable_get('site_name', 'Drupal')),
);
}
else {
$head_title = array(check_plain(variable_get('site_name', 'Drupal')));
$head_title = array('name' => check_plain(variable_get('site_name', 'Drupal')));
if (variable_get('site_slogan', '')) {
$head_title[] = filter_xss_admin(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);
// Populate the page template suggestions.
......@@ -2419,18 +2423,22 @@ function template_preprocess_maintenance_page(&$variables) {
// Construct page title
if (drupal_get_title()) {
$head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal'));
$head_title = array(
'title' => strip_tags(drupal_get_title()),
'name' => variable_get('site_name', 'Drupal'),
);
}
else {
$head_title = array(variable_get('site_name', 'Drupal'));
$head_title = array('name' => variable_get('site_name', 'Drupal'));
if (variable_get('site_slogan', '')) {
$head_title[] = variable_get('site_slogan', '');
$head_title['slogan'] = variable_get('site_slogan', '');
}
}
// set the default language if necessary
$language = isset($GLOBALS['language']) ? $GLOBALS['language'] : language_default();
$variables['head_title_array'] = $head_title;
$variables['head_title'] = implode(' | ', $head_title);
$variables['base_path'] = base_path();
$variables['front_page'] = url();
......
......@@ -13,7 +13,15 @@
* $language->dir contains the language direction. It will either be 'ltr' or 'rtl'.
* - $rdf_namespaces: All the RDF namespace prefixes used in the HTML document.
* - $grddl_profile: A GRDDL profile allowing agents to extract the RDF data.
* - $head_title: A modified version of the page title, for use in the TITLE tag.
* - $head_title: A modified version of the page title, for use in the TITLE
* tag.
* - $head_title_array: (array) An associative array containing the string parts
* that were used to generate the $head_title variable, already prepared to be
* output as TITLE tag. The key/value pairs may contain one or more of the
* following, depending on conditions:
* - title: The title of the current page, if any.
* - name: The name of the site.
* - slogan: The slogan of the site, if any, and if there is no title.
* - $head: Markup for the HEAD section (including meta tags, keyword tags, and
* so on).
* - $styles: Style tags necessary to import all CSS files for the page.
......
......@@ -5,8 +5,8 @@
* @file
* Default theme implementation to display a single Drupal page while offline.
*
* All the available variables are mirrored in page.tpl.php. Some may be left
* blank but they are provided for consistency.
* All the available variables are mirrored in html.tpl.php and page.tpl.php.
* Some may be blank but they are provided for consistency.
*
* @see template_preprocess()
* @see template_preprocess_maintenance_page()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment