diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-11-03 06:47:23 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-11-03 06:47:23 +0000 |
commit | 0d8515deb750fe2a02ee6f9f12860caceed7248f (patch) | |
tree | 9898c0801cec5188f8e54229a2760a4ff15f44f5 /modules/system | |
parent | 3b2d24af0b8ca83415310e2b328cc60fa830837b (diff) | |
download | brdo-0d8515deb750fe2a02ee6f9f12860caceed7248f.tar.gz brdo-0d8515deb750fe2a02ee6f9f12860caceed7248f.tar.bz2 |
#552478 by pwolanin, samj, dropcube, and sun: Improve link/header API and support on node/comment pages rel=canonical and rel=shortlink standards.
Diffstat (limited to 'modules/system')
-rw-r--r-- | modules/system/system.api.php | 21 | ||||
-rw-r--r-- | modules/system/system.module | 46 |
2 files changed, 27 insertions, 40 deletions
diff --git a/modules/system/system.api.php b/modules/system/system.api.php index 36a06df8d..339f82d04 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -2282,6 +2282,27 @@ function hook_drupal_goto_alter(&$path, &$options, &$http_response_code) { } /** + * Alter XHTML HEAD tags before they are rendered by drupal_get_html_head(). + * + * Elements available to be altered are only those added using + * drupal_add_html_head_link() or drupal_add_html_head(). CSS and JS files + * are handled using drupal_add_css() and drupal_add_js(), so the head links + * for those files will not appear in the $head_elements array. + * + * @param $head_elements + * An array of renderable elements. Generally the values of the #attributes + * array will be the most likely target for changes. + */ +function hook_html_head_alter(&$head_elements) { + foreach($head_elements as $key => $element) { + if (isset($element['#attributes']['rel']) && $element['#attributes']['rel'] == 'canonical') { + // I want a custom canonical url. + $head_elements[$key]['#attributes']['href'] = mymodule_canonical_url(); + } + } +} + +/** * Alter the full list of installation tasks. * * @param $tasks diff --git a/modules/system/system.module b/modules/system/system.module index 0b587db77..da1089b92 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -179,12 +179,6 @@ function system_theme() { 'system_powered_by' => array( 'variables' => array(), ), - 'meta_generator_html' => array( - 'variables' => array('version' => NULL), - ), - 'meta_generator_header' => array( - 'variables' => array('version' => NULL), - ), 'system_compact_link' => array( 'variables' => array(), ), @@ -318,6 +312,12 @@ function system_element_info() { '#ajax_commands' => array(), ); + $types['html_tag'] = array( + '#theme' => 'html_tag', + '#attributes' => array(), + '#value' => NULL, + ); + // Input elements. $types['submit'] = array( '#input' => TRUE, @@ -1718,22 +1718,6 @@ function system_init() { } /** - * Implement MODULE_preprocess_HOOK(). - */ -function system_preprocess_page(&$variables) { - // Get the major version - list($version, ) = explode('.', VERSION); - - // Emit the META tag in the HTML HEAD section - theme('meta_generator_html', array('version' => $version)); - - // Emit the HTTP Header too - theme('meta_generator_header', array('version' => $version)); - - $variables['head'] = drupal_get_html_head(); -} - -/** * Implement hook_form_FORM_ID_alter(). */ function system_form_user_profile_form_alter(&$form, &$form_state) { @@ -2974,24 +2958,6 @@ function theme_system_compact_link() { } /** - * Send Drupal and the major version number in the META GENERATOR HTML. - * - * @ingroup themeable - */ -function theme_meta_generator_html($variables) { - drupal_add_html_head('<meta name="Generator" content="Drupal ' . $variables['version'] . ' (http://drupal.org)" />'); -} - -/** - * Send Drupal and the major version number in the HTTP headers. - * - * @ingroup themeable - */ -function theme_meta_generator_header($variables) { - drupal_add_http_header('X-Generator', 'Drupal ' . $variables['version'] . ' (http://drupal.org)'); -} - -/** * Implement hook_image_toolkits(). */ function system_image_toolkits() { |