summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcatch2011-10-28 02:34:00 +0900
committercatch2011-10-28 02:34:00 +0900
commit67c299d28ed2f07b13b43076e5a12c2f08850bb0 (patch)
treeead8cd87c2798c94eb88e9b42445997298c3e52f
parent5b38f202c4aef420e4f5778ccee8bba99acf5f80 (diff)
Issue #1077566 by scor, karschsp, jessebeach: Convert html.tpl.php to HTML5.
-rw-r--r--includes/common.inc18
-rw-r--r--includes/theme.inc19
-rw-r--r--modules/field/modules/number/number.module4
-rw-r--r--modules/rdf/rdf.module12
-rw-r--r--modules/rdf/rdf.test45
-rw-r--r--modules/simpletest/tests/common.test32
-rw-r--r--modules/simpletest/tests/theme.test28
-rw-r--r--modules/simpletest/tests/theme_test.module8
-rw-r--r--modules/system/html.tpl.php37
9 files changed, 126 insertions, 77 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 9b0a737..a05a09a 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -249,25 +249,9 @@ function drupal_get_breadcrumb() {
}
/**
- * Returns a string containing RDF namespace declarations for use in XML and
- * XHTML output.
- */
-function drupal_get_rdf_namespaces() {
- $xml_rdf_namespaces = array();
-
- // Serializes the RDF namespaces in XML namespace syntax.
- if (function_exists('rdf_get_namespaces')) {
- foreach (rdf_get_namespaces() as $prefix => $uri) {
- $xml_rdf_namespaces[] = 'xmlns:' . $prefix . '="' . $uri . '"';
- }
- }
- return count($xml_rdf_namespaces) ? "\n " . implode("\n ", $xml_rdf_namespaces) : '';
-}
-
-/**
* Add output to the head tag of the HTML page.
*
- * This function can be called as long the headers aren't sent. Pass no
+ * This function can be called as long as the headers aren't sent. Pass no
* arguments (or NULL for both) to retrieve the currently stored elements.
*
* @param $data
diff --git a/includes/theme.inc b/includes/theme.inc
index 2154342..e50df06 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -2359,13 +2359,14 @@ function template_preprocess_html(&$variables) {
$variables['classes_array'][] = drupal_html_class('node-type-' . $node->type);
}
- // RDFa allows annotation of XHTML pages with RDF data, while GRDDL provides
- // mechanisms for extraction of this RDF content via XSLT transformation
- // using an associated GRDDL profile.
- $variables['rdf_namespaces'] = drupal_get_rdf_namespaces();
- $variables['grddl_profile'] = 'http://www.w3.org/1999/xhtml/vocab';
- $variables['language'] = $GLOBALS['language'];
- $variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
+ // Initializes attributes which are specific to the html and body elements.
+ $variables['html_attributes_array'] = array();
+ $variables['body_attributes_array'] = array();
+
+ // HTML element attributes.
+ $variables['html_attributes_array']['xmlns'] = "http://www.w3.org/1999/xhtml";
+ $variables['html_attributes_array']['xml:lang'] = $GLOBALS['language']->language;
+ $variables['html_attributes_array']['dir'] = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
// Add favicon.
if (theme_get_setting('toggle_favicon')) {
@@ -2494,6 +2495,10 @@ function template_process_page(&$variables) {
* @see html.tpl.php
*/
function template_process_html(&$variables) {
+ // Flatten out html_attributes and body_attributes.
+ $variables['html_attributes'] = drupal_attributes($variables['html_attributes_array']);
+ $variables['body_attributes'] = drupal_attributes($variables['body_attributes_array']);
+
// Render page_top and page_bottom into top level variables.
$variables['page_top'] = drupal_render($variables['page']['page_top']);
$variables['page_bottom'] = drupal_render($variables['page']['page_bottom']);
diff --git a/modules/field/modules/number/number.module b/modules/field/modules/number/number.module
index ad55145..87e2d3a 100644
--- a/modules/field/modules/number/number.module
+++ b/modules/field/modules/number/number.module
@@ -188,7 +188,7 @@ function number_field_formatter_info() {
'label' => t('Default'),
'field types' => array('number_integer'),
'settings' => array(
- 'thousand_separator' => ' ',
+ 'thousand_separator' => '',
// The 'decimal_separator' and 'scale' settings are not configurable
// through the UI, and will therefore keep their default values. They
// are only present so that the 'number_integer' and 'number_decimal'
@@ -202,7 +202,7 @@ function number_field_formatter_info() {
'label' => t('Default'),
'field types' => array('number_decimal', 'number_float'),
'settings' => array(
- 'thousand_separator' => ' ',
+ 'thousand_separator' => '',
'decimal_separator' => '.',
'scale' => 2,
'prefix_suffix' => TRUE,
diff --git a/modules/rdf/rdf.module b/modules/rdf/rdf.module
index ebecd42..1a29646 100644
--- a/modules/rdf/rdf.module
+++ b/modules/rdf/rdf.module
@@ -461,6 +461,18 @@ function rdf_process(&$variables, $hook) {
}
/**
+ * Implements MODULE_preprocess_HOOK()
+ */
+function rdf_preprocess_html(&$variables) {
+ // Adds RDF namespace prefix bindings in the form of an RDFa 1.1 prefix
+ // attribute inside the html element.
+ $prefixes = array();
+ foreach(rdf_get_namespaces() as $prefix => $uri) {
+ $variables['html_attributes_array']['prefix'][] = $prefix . ': ' . $uri . "\n";
+ }
+}
+
+/**
* Implements MODULE_preprocess_HOOK().
*/
function rdf_preprocess_node(&$variables) {
diff --git a/modules/rdf/rdf.test b/modules/rdf/rdf.test
index 7586235..50177ca 100644
--- a/modules/rdf/rdf.test
+++ b/modules/rdf/rdf.test
@@ -713,3 +713,48 @@ class RdfGetRdfNamespacesTestCase extends DrupalWebTestCase {
$this->assertTrue(!isset($ns['dc']), t('A prefix with conflicting namespaces is discarded.'));
}
}
+
+/**
+ * Tests for RDF namespaces XML serialization.
+ */
+class DrupalGetRdfNamespacesTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'RDF namespaces serialization test',
+ 'description' => 'Confirm that the serialization of RDF namespaces in present in the HTML markup.',
+ 'group' => 'RDF',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('rdf', 'rdf_test');
+ }
+
+ /**
+ * Test RDF namespaces.
+ */
+ function testGetRdfNamespaces() {
+ // Fetches the front page and extracts RDFa 1.1 prefixes.
+ $this->drupalGet('');
+
+ $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', array(
+ ':prefix_binding' => 'rdfs: http://www.w3.org/2000/01/rdf-schema#',
+ ));
+ $this->assertTrue(!empty($element), t('A prefix declared once is displayed.'));
+
+ $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', array(
+ ':prefix_binding' => 'foaf: http://xmlns.com/foaf/0.1/',
+ ));
+ $this->assertTrue(!empty($element), t('The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.'));
+
+ $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', array(
+ ':prefix_binding' => 'foaf1: http://xmlns.com/foaf/0.1/',
+ ));
+ $this->assertTrue(!empty($element), t('Two prefixes can be assigned the same namespace.'));
+
+ $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', array(
+ ':prefix_binding' => 'dc: ',
+ ));
+ $this->assertTrue(empty($element), t('A prefix with conflicting namespaces is discarded.'));
+ }
+}
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index bd8d52c..5154e0c 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -2388,38 +2388,6 @@ class DrupalJSONTest extends DrupalUnitTestCase {
}
/**
- * Tests for RDF namespaces XML serialization.
- */
-class DrupalGetRdfNamespacesTestCase extends DrupalWebTestCase {
- public static function getInfo() {
- return array(
- 'name' => 'RDF namespaces XML serialization tests',
- 'description' => 'Confirm that the serialization of RDF namespaces via drupal_get_rdf_namespaces() is output and parsed correctly in the XHTML document.',
- 'group' => 'System',
- );
- }
-
- function setUp() {
- parent::setUp('rdf', 'rdf_test');
- }
-
- /**
- * Test RDF namespaces.
- */
- function testGetRdfNamespaces() {
- // Fetches the front page and extracts XML namespaces.
- $this->drupalGet('');
- $xml = new SimpleXMLElement($this->content);
- $ns = $xml->getDocNamespaces();
-
- $this->assertEqual($ns['rdfs'], 'http://www.w3.org/2000/01/rdf-schema#', t('A prefix declared once is displayed.'));
- $this->assertEqual($ns['foaf'], 'http://xmlns.com/foaf/0.1/', t('The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.'));
- $this->assertEqual($ns['foaf1'], 'http://xmlns.com/foaf/0.1/', t('Two prefixes can be assigned the same namespace.'));
- $this->assertTrue(!isset($ns['dc']), t('A prefix with conflicting namespaces is discarded.'));
- }
-}
-
-/**
* Basic tests for drupal_add_feed().
*/
class DrupalAddFeedTestCase extends DrupalWebTestCase {
diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test
index 0cecec0..fd88124 100644
--- a/modules/simpletest/tests/theme.test
+++ b/modules/simpletest/tests/theme.test
@@ -460,3 +460,31 @@ class ThemeHtmlTag extends DrupalUnitTestCase {
$this->assertEqual('<title>title test</title>'."\n", theme_html_tag($tag), t('Test title tag generation.'));
}
}
+
+/**
+ * Functional test for attributes of html.tpl.php.
+ */
+class ThemeHtmlTplPhpAttributesTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'html.tpl.php html and body attributes',
+ 'description' => 'Tests attributes inserted in the html and body elements of html.tpl.php.',
+ 'group' => 'Theme',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('theme_test');
+ }
+
+ /**
+ * Tests that modules and themes can alter variables in html.tpl.php.
+ */
+ function testThemeHtmlTplPhpAttributes() {
+ $this->drupalGet('');
+ $attributes = $this->xpath('/html[@theme_test_html_attribute="theme test html attribute value"]');
+ $this->assertTrue(count($attributes) == 1, t('Attribute set in the html element via hook_preprocess_html() found.'));
+ $attributes = $this->xpath('/html/body[@theme_test_body_attribute="theme test body attribute value"]');
+ $this->assertTrue(count($attributes) == 1, t('Attribute set in the body element via hook_preprocess_html() found.'));
+ }
+}
diff --git a/modules/simpletest/tests/theme_test.module b/modules/simpletest/tests/theme_test.module
index e95f622..597c090 100644
--- a/modules/simpletest/tests/theme_test.module
+++ b/modules/simpletest/tests/theme_test.module
@@ -127,3 +127,11 @@ function _theme_test_suggestion() {
function theme_test_preprocess_breadcrumb(&$variables) {
$variables['theme_test_preprocess_breadcrumb'] = 1;
}
+
+/**
+ * Implements hook_preprocess_html().
+ */
+function theme_test_preprocess_html(&$variables) {
+ $variables['html_attributes_array']['theme_test_html_attribute'] = 'theme test html attribute value';
+ $variables['body_attributes_array']['theme_test_body_attribute'] = 'theme test body attribute value';
+}
diff --git a/modules/system/html.tpl.php b/modules/system/html.tpl.php
index 0e01277..de56db1 100644
--- a/modules/system/html.tpl.php
+++ b/modules/system/html.tpl.php
@@ -9,7 +9,8 @@
* - $css: An array of CSS files for the current page.
* - $language: (object) The language the site is being displayed in.
* $language->language contains its textual representation.
- * $language->dir contains the language direction. It will either be 'ltr' or 'rtl'.
+ * $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
@@ -40,22 +41,20 @@
* @see template_preprocess_html()
* @see template_process()
*/
-?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
- "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>"<?php print $rdf_namespaces; ?>>
-
-<head profile="<?php print $grddl_profile; ?>">
- <?php print $head; ?>
- <title><?php print $head_title; ?></title>
- <?php print $styles; ?>
- <?php print $scripts; ?>
-</head>
-<body class="<?php print $classes; ?>" <?php print $attributes;?>>
- <div id="skip-link">
- <a href="#main-content" class="element-invisible element-focusable"><?php print t('Skip to main content'); ?></a>
- </div>
- <?php print $page_top; ?>
- <?php print $page; ?>
- <?php print $page_bottom; ?>
-</body>
+?><!DOCTYPE html>
+<html<?php print $html_attributes; ?>>
+ <head>
+ <?php print $head; ?>
+ <title><?php print $head_title; ?></title>
+ <?php print $styles; ?>
+ <?php print $scripts; ?>
+ </head>
+ <body class="<?php print $classes; ?>" <?php print $body_attributes;?>>
+ <div id="skip-link">
+ <a href="#main-content" class="element-invisible element-focusable"><?php print t('Skip to main content'); ?></a>
+ </div>
+ <?php print $page_top; ?>
+ <?php print $page; ?>
+ <?php print $page_bottom; ?>
+ </body>
</html>