summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-24 03:30:59 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-24 03:30:59 +0000
commit5eaf3e033fda5864b93b864ba2e97038ae2cec51 (patch)
treedd00739f0e52323c502e561343da8175d0580928
parentbb9e871f7c4e941cebed10844a01bbc221e44364 (diff)
downloadbrdo-5eaf3e033fda5864b93b864ba2e97038ae2cec51.tar.gz
brdo-5eaf3e033fda5864b93b864ba2e97038ae2cec51.tar.bz2
#655742 by sun, jide: Add template variable for outputting HTML HEAD title safely.
-rw-r--r--includes/theme.inc20
-rw-r--r--modules/system/html.tpl.php10
-rw-r--r--modules/system/maintenance-page.tpl.php4
3 files changed, 25 insertions, 9 deletions
diff --git a/includes/theme.inc b/includes/theme.inc
index 887ed23ce..4d8e054d7 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -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();
diff --git a/modules/system/html.tpl.php b/modules/system/html.tpl.php
index 5a02d8d14..8d560b1a4 100644
--- a/modules/system/html.tpl.php
+++ b/modules/system/html.tpl.php
@@ -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.
diff --git a/modules/system/maintenance-page.tpl.php b/modules/system/maintenance-page.tpl.php
index efc44c057..f0aec34c9 100644
--- a/modules/system/maintenance-page.tpl.php
+++ b/modules/system/maintenance-page.tpl.php
@@ -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()