Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.557
diff -u -p -r1.557 theme.inc
--- includes/theme.inc	2 Dec 2009 14:56:32 -0000	1.557
+++ includes/theme.inc	9 Dec 2009 04:29:55 -0000
@@ -2246,6 +2246,10 @@ function template_preprocess(&$variables
   $variables['title_attributes_array'] = array();
   $variables['content_attributes_array'] = array();
 
+  // Initialize 'title_prefix' and 'title_suffix' renderable arrays.
+  $variables['title_prefix'] = array();
+  $variables['title_suffix'] = array();
+
   // Set default variables that depend on the database.
   $variables['is_admin']            = FALSE;
   $variables['is_front']            = FALSE;
Index: modules/block/block.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.tpl.php,v
retrieving revision 1.7
diff -u -p -r1.7 block.tpl.php
--- modules/block/block.tpl.php	6 Dec 2009 01:00:27 -0000	1.7
+++ modules/block/block.tpl.php	9 Dec 2009 04:29:55 -0000
@@ -11,7 +11,6 @@
  * - $block->module: Module that generated the block.
  * - $block->delta: An ID for the block, unique within each module.
  * - $block->region: The block region embedding the current block.
- * - $contextual_links (array): An array of contextual links for the block.
  * - $classes: String of classes that can be used to style contextually through
  *   CSS. It can be manipulated through the variable $classes_array from
  *   preprocess functions. The default values can be one or more of the following:
@@ -19,6 +18,12 @@
  *   - block-[module]: The module generating the block. For example, the user module
  *     is responsible for handling the default user navigation block. In that case
  *     the class would be "block-user".
+ * - $title_prefix (array): An array containing additional output populated by
+ *   modules, intended to be displayed in front of the main title tag that
+ *   appears in the template.
+ * - $title_suffix (array): An array containing additional output populated by
+ *   modules, intended to be displayed after the main title tag that appears in
+ *   the template.
  *
  * Helper variables:
  * - $classes_array: Array of html class attribute values. It is flattened
@@ -38,13 +43,11 @@
 ?>
 <div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
  
-<?php if (!empty($contextual_links)): ?>
-  <?php print render($contextual_links); ?>
-<?php endif; ?>
- 
+  <?php print render($title_prefix); ?>
 <?php if ($block->subject): ?>
   <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
 <?php endif;?>
+  <?php print render($title_suffix); ?>
 
   <div class="content"<?php print $content_attributes; ?>>
     <?php print $content ?>
Index: modules/comment/comment.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.tpl.php,v
retrieving revision 1.16
diff -u -p -r1.16 comment.tpl.php
--- modules/comment/comment.tpl.php	19 Oct 2009 20:33:21 -0000	1.16
+++ modules/comment/comment.tpl.php	9 Dec 2009 04:29:55 -0000
@@ -23,7 +23,6 @@
  * - $status: Comment status. Possible values are:
  *   comment-unpublished, comment-published or comment-preview.
  * - $title: Linked title.
- * - $contextual_links (array): An array of contextual links for the comment.
  * - $classes: String of classes that can be used to style contextually through
  *   CSS. It can be manipulated through the variable $classes_array from
  *   preprocess functions. The default values can be one or more of the following:
@@ -35,6 +34,12 @@
  *   - comment-unpublished: An unpublished comment visible only to administrators.
  *   - comment-by-viewer: Comment by the user currently viewing the page.
  *   - comment-new: New comment since last the visit.
+ * - $title_prefix (array): An array containing additional output populated by
+ *   modules, intended to be displayed in front of the main title tag that
+ *   appears in the template.
+ * - $title_suffix (array): An array containing additional output populated by
+ *   modules, intended to be displayed after the main title tag that appears in
+ *   the template.
  *
  * These two variables are provided for context:
  * - $comment: Full comment object.
@@ -51,17 +56,15 @@
  */
 ?>
 <div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
-  <?php if ($contextual_links): ?>
-    <?php print render($contextual_links); ?>
-  <?php endif; ?>
-
   <?php print $picture ?>
 
   <?php if ($new): ?>
     <span class="new"><?php print $new ?></span>
   <?php endif; ?>
 
+  <?php print render($title_prefix); ?>
   <h3<?php print $title_attributes; ?>><?php print $title ?></h3>
+  <?php print render($title_suffix); ?>
 
   <div class="submitted">
     <?php
Index: modules/contextual/contextual.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/contextual/contextual.module,v
retrieving revision 1.1
diff -u -p -r1.1 contextual.module
--- modules/contextual/contextual.module	6 Dec 2009 01:00:27 -0000	1.1
+++ modules/contextual/contextual.module	9 Dec 2009 04:29:55 -0000
@@ -45,9 +45,6 @@ function contextual_library() {
 function contextual_preprocess(&$variables, $hook) {
   static $hooks;
 
-  // Initialize the $contextual_links template variable.
-  $variables['contextual_links'] = array();
-
   // Nothing to do here if the user is not permitted to access contextual links.
   if (!user_access('access contextual links')) {
     return;
@@ -70,8 +67,8 @@ function contextual_preprocess(&$variabl
   }
 
   if (isset($element) && is_array($element) && !empty($element['#contextual_links'])) {
-    $variables['contextual_links'] = contextual_links_build($element);
-    if (!empty($variables['contextual_links'])) {
+    $variables['title_suffix']['contextual_links'] = contextual_links_build($element);
+    if (!empty($variables['title_suffix']['contextual_links'])) {
       $variables['classes_array'][] = 'contextual-links-region';
     }
   }
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1180
diff -u -p -r1.1180 node.module
--- modules/node/node.module	7 Dec 2009 03:42:27 -0000	1.1180
+++ modules/node/node.module	9 Dec 2009 04:29:55 -0000
@@ -1183,9 +1183,12 @@ function node_build($node, $build_mode =
     '#node' => $node,
     '#build_mode' => $build_mode,
   );
-  // Add contextual links for this node.
+  // Add contextual links for this node, when it's not being displayed on its
+  // own page.
   // @todo Make this configurable per build mode.
-  $build['#contextual_links']['node'] = array('node', array($node->nid));
+  if (!menu_get_object('node')) {
+    $build['#contextual_links']['node'] = array('node', array($node->nid));
+  }
 
   // Allow modules to modify the structured node.
   drupal_alter('node_build', $build);
Index: modules/node/node.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.tpl.php,v
retrieving revision 1.29
diff -u -p -r1.29 node.tpl.php
--- modules/node/node.tpl.php	6 Dec 2009 01:00:27 -0000	1.29
+++ modules/node/node.tpl.php	9 Dec 2009 04:29:55 -0000
@@ -18,7 +18,6 @@
  * - $node_url: Direct url of the current node.
  * - $terms: the themed list of taxonomy term links output from theme_links().
  * - $display_submitted: whether submission information should be displayed.
- * - $contextual_links (array): An array of contextual links for the node.
  * - $classes: String of classes that can be used to style contextually through
  *   CSS. It can be manipulated through the variable $classes_array from
  *   preprocess functions. The default values can be one or more of the following:
@@ -32,6 +31,12 @@
  *   - node-promoted: Nodes promoted to the front page.
  *   - node-sticky: Nodes ordered above other non-sticky nodes in teaser listings.
  *   - node-unpublished: Unpublished nodes visible only to administrators.
+ * - $title_prefix (array): An array containing additional output populated by
+ *   modules, intended to be displayed in front of the main title tag that
+ *   appears in the template.
+ * - $title_suffix (array): An array containing additional output populated by
+ *   modules, intended to be displayed after the main title tag that appears in
+ *   the template.
  *
  * Other variables:
  * - $node: Full node object. Contains data that may not be safe.
@@ -75,13 +80,11 @@
 
   <?php print $user_picture; ?>
 
-  <?php if (!$page && !empty($contextual_links)): ?>
-    <?php print render($contextual_links); ?>
-  <?php endif; ?>
-
+  <?php print render($title_prefix); ?>
   <?php if (!$page): ?>
     <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $node_title; ?></a></h2>
   <?php endif; ?>
+  <?php print render($title_suffix); ?>
 
   <?php if ($display_submitted || !empty($content['links']['terms'])): ?>
     <div class="meta">
Index: modules/shortcut/shortcut.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/shortcut/shortcut.module,v
retrieving revision 1.11
diff -u -p -r1.11 shortcut.module
--- modules/shortcut/shortcut.module	4 Dec 2009 16:49:47 -0000	1.11
+++ modules/shortcut/shortcut.module	9 Dec 2009 04:29:55 -0000
@@ -522,9 +522,9 @@ function shortcut_renderable_links($shor
 }
 
 /**
- * Implements hook_page_build().
+ * Implements hook_preprocess_page().
  */
-function shortcut_page_build(&$page) {
+function shortcut_preprocess_page(&$variables) {
   if (shortcut_set_edit_access()) {
     $link = $_GET['q'];
     $query_parameters = drupal_get_query_parameters();
@@ -559,13 +559,13 @@ function shortcut_page_build(&$page) {
       $link_path = 'admin/config/system/shortcut/link/' . $mlid . '/delete';
     }
 
-    $page['add_or_remove_shortcut'] = array(
-     '#prefix' => '<div class="add-or-remove-shortcuts ' . $link_mode . '-shortcut">',
-     '#type' => 'link',
-     '#title' => '<span class="icon"></span><span class="text">' . $link_text . '</span>',
-     '#href' => $link_path,
-     '#options' => array('query' => $query, 'html' => TRUE),
-     '#suffix' => '</div>',
+    $variables['title_suffix']['add_or_remove_shortcut'] = array(
+      '#prefix' => '<div class="add-or-remove-shortcuts ' . $link_mode . '-shortcut">',
+      '#type' => 'link',
+      '#title' => '<span class="icon"></span><span class="text">' . $link_text . '</span>',
+      '#href' => $link_path,
+      '#options' => array('query' => $query, 'html' => TRUE),
+      '#suffix' => '</div>',
     );
   }
 }
@@ -609,24 +609,3 @@ function shortcut_toolbar_pre_render($to
   return $toolbar;
 }
 
-/**
- * Implements hook_preprocess_page().
- */
-function shortcut_preprocess_page(&$variables) {
-  if (isset($variables['page']['add_or_remove_shortcut'])) {
-    $variables['add_or_remove_shortcut'] = drupal_render($variables['page']['add_or_remove_shortcut']);
-  }
-}
-
-/**
- * Implements hook_system_info_alter().
- *
- * If the overlay module is enabled, indicate that the link for adding or
- * removing shortcuts is one of the page "regions" that should display in the
- * overlay.
- */
-function shortcut_system_info_alter(&$info, $file, $type) {
-  if (module_exists('overlay') && $type == 'theme') {
-    $info['overlay_regions'][] = 'add_or_remove_shortcut';
-  }
-}
Index: modules/system/page.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/page.tpl.php,v
retrieving revision 1.39
diff -u -p -r1.39 page.tpl.php
--- modules/system/page.tpl.php	20 Nov 2009 04:20:38 -0000	1.39
+++ modules/system/page.tpl.php	9 Dec 2009 04:29:55 -0000
@@ -34,7 +34,13 @@
  * - $breadcrumb: The breadcrumb trail for the current page.
  *
  * Page content (in order of occurrence in the default page.tpl.php):
+ * - $title_prefix (array): An array containing additional output populated by
+ *   modules, intended to be displayed in front of the main title tag that
+ *   appears in the template.
  * - $title: The page title, for use in the actual HTML content.
+ * - $title_suffix (array): An array containing additional output populated by
+ *   modules, intended to be displayed after the main title tag that appears in
+ *   the template.
  * - $messages: HTML for status and error messages. Should be displayed
  *   prominently.
  * - $tabs (array): Tabs linking to any sub-pages beneath the current page
@@ -113,7 +119,11 @@
       <div id="content" class="column"><div class="section">
         <?php if ($page['highlight']): ?><div id="highlight"><?php print render($page['highlight']); ?></div><?php endif; ?>
         <a name="main-content" id="main-content"></a>
-        <?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
+        <?php print render($title_prefix); ?>
+        <?php if ($title): ?>
+          <h1 class="title" id="page-title"><?php print $title; ?></h1>
+        <?php endif; ?>
+        <?php print render($title_suffix); ?>
         <?php if ($tabs): ?><div class="tabs"><?php print render($tabs); ?></div><?php endif; ?>
         <?php print render($page['help']); ?>
         <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?>
Index: themes/garland/block.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/block.tpl.php,v
retrieving revision 1.12
diff -u -p -r1.12 block.tpl.php
--- themes/garland/block.tpl.php	6 Dec 2009 01:00:27 -0000	1.12
+++ themes/garland/block.tpl.php	9 Dec 2009 04:29:55 -0000
@@ -3,13 +3,11 @@
 ?>
 <div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
 
-<?php if (!empty($contextual_links)): ?>
-  <?php print render($contextual_links); ?>
-<?php endif; ?>
-
+  <?php print render($title_prefix); ?>
 <?php if (!empty($block->subject)): ?>
   <h2 class="title"<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
 <?php endif;?>
+  <?php print render($title_suffix); ?>
 
   <div class="content"<?php print $content_attributes; ?>><?php print $content ?></div>
 </div>
Index: themes/garland/comment.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/comment.tpl.php,v
retrieving revision 1.19
diff -u -p -r1.19 comment.tpl.php
--- themes/garland/comment.tpl.php	19 Oct 2009 01:30:07 -0000	1.19
+++ themes/garland/comment.tpl.php	9 Dec 2009 04:29:55 -0000
@@ -5,10 +5,6 @@
 
   <div class="clearfix">
 
-  <?php if ($contextual_links): ?>
-    <?php print render($contextual_links); ?>
-  <?php endif; ?>
-
     <span class="submitted"><?php print $created; ?> — <?php print $author; ?></span>
 
   <?php if ($new) : ?>
@@ -17,7 +13,9 @@
 
   <?php print $picture ?>
 
+    <?php print render($title_prefix); ?>
     <h3<?php print $title_attributes; ?>><?php print $title ?></h3>
+    <?php print render($title_suffix); ?>
 
     <div class="content"<?php print $content_attributes; ?>>
       <?php hide($content['links']); print render($content); ?>
Index: themes/garland/node.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/node.tpl.php,v
retrieving revision 1.20
diff -u -p -r1.20 node.tpl.php
--- themes/garland/node.tpl.php	6 Dec 2009 01:00:27 -0000	1.20
+++ themes/garland/node.tpl.php	9 Dec 2009 04:29:55 -0000
@@ -3,15 +3,13 @@
 ?>
 <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
 
-  <?php if (!$page && !empty($contextual_links)): ?>
-    <?php print render($contextual_links); ?>
-  <?php endif; ?>
-
   <?php print $user_picture; ?>
 
+  <?php print render($title_prefix); ?>
   <?php if (!$page): ?>
     <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $node_title; ?></a></h2>
   <?php endif; ?>
+  <?php print render($title_suffix); ?>
 
   <?php if ($display_submitted): ?>
     <span class="submitted"><?php print $date; ?> — <?php print $name; ?></span>
Index: themes/garland/page.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/page.tpl.php,v
retrieving revision 1.39
diff -u -p -r1.39 page.tpl.php
--- themes/garland/page.tpl.php	22 Nov 2009 23:44:09 -0000	1.39
+++ themes/garland/page.tpl.php	9 Dec 2009 04:29:55 -0000
@@ -42,7 +42,11 @@
           <?php if ($page['highlight']): ?><div id="highlight"><?php render($page['highlight']); ?></div><?php endif; ?>
           <a name="main-content" id="main-content"></a>
           <?php if ($tabs): ?><div id="tabs-wrapper" class="clearfix"><?php endif; ?>
-          <?php if ($title): ?><h1<?php print $tabs ? ' class="with-tabs"' : '' ?>><?php print $title ?></h1><?php endif; ?>
+          <?php print render($title_prefix); ?>
+          <?php if ($title): ?>
+            <h1<?php print $tabs ? ' class="with-tabs"' : '' ?>><?php print $title ?></h1>
+          <?php endif; ?>
+          <?php print render($title_suffix); ?>
           <?php if ($tabs): ?><ul class="tabs primary"><?php print render($tabs) ?></ul></div><?php endif; ?>
           <?php if ($tabs2): ?><ul class="tabs secondary"><?php print render($tabs2) ?></ul><?php endif; ?>
           <?php print $messages; ?>
Index: themes/seven/page.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/seven/page.tpl.php,v
retrieving revision 1.9
diff -u -p -r1.9 page.tpl.php
--- themes/seven/page.tpl.php	22 Nov 2009 23:44:09 -0000	1.9
+++ themes/seven/page.tpl.php	9 Dec 2009 04:29:55 -0000
@@ -4,8 +4,11 @@
   <a name="main-content" id="main-content"></a>
   <div id="branding" class="clearfix">
     <?php print $breadcrumb; ?>
-    <?php if ($title): ?><h1 class="page-title"><?php print $title; ?></h1><?php endif; ?>
-    <?php if (isset($add_or_remove_shortcut)): ?><?php print $add_or_remove_shortcut; ?><?php endif; ?>
+    <?php print render($title_prefix); ?>
+    <?php if ($title): ?>
+      <h1 class="page-title"><?php print $title; ?></h1>
+    <?php endif; ?>
+    <?php print render($title_suffix); ?>
     <?php if ($primary_local_tasks): ?><ul class="tabs primary"><?php print render($primary_local_tasks); ?></ul><?php endif; ?>
   </div>
 
