diff --git a/includes/common.inc b/includes/common.inc index d64be82..87ee45e 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 bea87c0..e77f612 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -2291,7 +2291,8 @@ function template_process(&$variables, $hook) { // Flatten out classes. $variables['classes'] = implode(' ', $variables['classes_array']); - // Flatten out attributes, title_attributes, and content_attributes. + // Flatten out attributes, head_attributes, title_attributes, and + // content_attributes. // Because this function can be called very often, and often with empty // attributes, optimize performance by only calling drupal_attributes() if // necessary. @@ -2345,13 +2346,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'; + // HTML element attributes. + $variables['attributes_array'] = array( + 'xmlns' => "http://www.w3.org/1999/xhtml", + 'xml:lang' => $GLOBALS['language']->language, + 'dir' => $GLOBALS['language']->direction ? 'rtl' : 'ltr', + ); + // HTML Doctype. + $variables['doctype'] = "\n"; // Add favicon. if (theme_get_setting('toggle_favicon')) { @@ -2360,6 +2362,9 @@ function template_preprocess_html(&$variables) { drupal_add_html_head_link(array('rel' => 'shortcut icon', 'href' => drupal_strip_dangerous_protocols($favicon), 'type' => $type)); } + $head_attributes_array = array(); + $variables['head_attributes'] = $head_attributes_array ? drupal_attributes($head_attributes_array) : ''; + // Construct page title. if (drupal_get_title()) { $head_title = array( diff --git a/modules/rdf/rdf.module b/modules/rdf/rdf.module index ebecd42..be2a066 100644 --- a/modules/rdf/rdf.module +++ b/modules/rdf/rdf.module @@ -267,8 +267,8 @@ function rdf_mapping_delete($type, $bundle) { * Builds an array of RDFa attributes for a given mapping. This array will * typically be passed through drupal_attributes() to create the attributes * variables that are available to template files. These include $attributes, - * $title_attributes, $content_attributes and the field-specific - * $item_attributes variables. For more information, see + * $head_attributes, $title_attributes, $content_attributes and the + * field-specific $item_attributes variables. For more information, see * theme_rdf_template_variable_wrapper(). * * @param $mapping @@ -428,10 +428,10 @@ function rdf_theme() { * Template process function for adding extra tags to hold RDFa attributes. * * Since template files already have built-in support for $attributes, - * $title_attributes, and $content_attributes, and field templates have support - * for $item_attributes, we try to leverage those as much as possible. However, - * in some cases additional attributes are needed not covered by these. We deal - * with those here. + * $head_attributes, $title_attributes, and $content_attributes, and field + * templates have support for $item_attributes, we try to leverage those as much + * as possible. However, in some cases additional attributes are needed not + * covered by these. We deal with those here. */ function rdf_process(&$variables, $hook) { // Handles attributes needed for content not covered by title, content, @@ -461,6 +461,26 @@ function rdf_process(&$variables, $hook) { } /** + * Implements MODULE_preprocess_HOOK() + */ +function rdf_preprocess_html(&$variables) { + // RDFa allows annotation of XHTML pages with RDF data. + // These attributes are applied to the element. + foreach(rdf_get_namespaces() as $prefix => $uri) { + $variables['head_attributes_array']['xmlns:' . $prefix] = $uri; + } + // Set the HTML version to XHTML+RDFa 1.0. + $variables['head_attributes_array']['version'] = "XHTML+RDFa 1.0"; + // GRDDL provides mechanisms for extraction of this RDF content via XSLT + // transformation using an associated GRDDL profile. + $variables['title_attributes_array'] = array( + 'profile' => 'http://www.w3.org/1999/xhtml/vocab', + ); + // Change the doctype to include RDFa. + $variables['doctype'] = "\n"; +} + +/** * Implements MODULE_preprocess_HOOK(). */ function rdf_preprocess_node(&$variables) { diff --git a/modules/system/html.tpl.php b/modules/system/html.tpl.php index 0e01277..a4f9c35 100644 --- a/modules/system/html.tpl.php +++ b/modules/system/html.tpl.php @@ -6,10 +6,12 @@ * Drupal page. * * Variables: + * - $doctype: The DOCTYPE is the simple HTML5 'html' by default. * - $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 +42,21 @@ * @see template_preprocess_html() * @see template_process() */ -?> -> - - - - <?php print $head_title; ?> - - - -> - - - - - +?> + +> + > + + <?php print $head_title; ?> + + + + > + + + + +