diff --git a/includes/common.inc b/includes/common.inc index 9b0a73748bb93b38284650ee00d381c2eb17af63..a05a09a7b16435f5db5ae6020d6c8fc971e1a527 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -248,26 +248,10 @@ function drupal_get_breadcrumb() { return $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 21543426b0ccf56a6b55b22401054d6354973d0d..e50df0638588a9021b9e9d54b1e0337cd02feaf8 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 ad5514570a5a6399a977111a06aa55fd478e01a6..87e2d3a931317201c3187f6877e94e07568cb7dc 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 ebecd4237f62064928f59a9cd2c273101074b585..1a296469aa46db50b1ad40f6b3c5beda95182f1f 100644 --- a/modules/rdf/rdf.module +++ b/modules/rdf/rdf.module @@ -460,6 +460,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(). */ diff --git a/modules/rdf/rdf.test b/modules/rdf/rdf.test index 7586235cf4d5f826613c32defbd0321af0d8d609..50177ca78d4e0148d95aafed9d33ce045e598d37 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 bd8d52c558f80fa7c525f9d8fb91d85b2a9f2f0f..5154e0ccda3a0f44d021153a6c6ada60d22a1fc0 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -2387,38 +2387,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(). */ diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test index 0cecec0d28598d5255687e1946aaa62fc54943ea..fd881243f66a27f4daa84c32afd65dc7b1908851 100644 --- a/modules/simpletest/tests/theme.test +++ b/modules/simpletest/tests/theme.test @@ -460,3 +460,31 @@ class ThemeHtmlTag extends DrupalUnitTestCase { $this->assertEqual('title test'."\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 e95f62214aed4c0dfccfa699ec5b8c3071feb812..597c090da0c031d6124df5dfa4f75b84d6242297 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 0e012774dcef95dc5ed502bdea28e8a9f91a21b3..de56db1da1574927414275da82a56e00e52c53b0 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() */ -?> -> - - - - <?php print $head_title; ?> - - - -> - - - - - +?> +> + + + <?php print $head_title; ?> + + + + > + + + + +