diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-01-04 03:57:19 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-01-04 03:57:19 +0000 |
commit | 37b78e02594e95ac059a69fe47ee62bf24ce5db5 (patch) | |
tree | 25c2d9222d30847680ddf664a1a8565868163408 /modules | |
parent | 89586bac91ecdd20255f615abd7993dc79092a50 (diff) | |
download | brdo-37b78e02594e95ac059a69fe47ee62bf24ce5db5.tar.gz brdo-37b78e02594e95ac059a69fe47ee62bf24ce5db5.tar.bz2 |
#646874 by sun and David_Rothstein: Remove assumptions about Contextual links and Shortcut modules from template files.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/block/block.tpl.php | 13 | ||||
-rw-r--r-- | modules/comment/comment.tpl.php | 13 | ||||
-rw-r--r-- | modules/contextual/contextual.module | 7 | ||||
-rw-r--r-- | modules/node/node.module | 6 | ||||
-rw-r--r-- | modules/node/node.tpl.php | 13 | ||||
-rw-r--r-- | modules/shortcut/shortcut.module | 39 | ||||
-rw-r--r-- | modules/system/page.tpl.php | 8 |
7 files changed, 47 insertions, 52 deletions
diff --git a/modules/block/block.tpl.php b/modules/block/block.tpl.php index beb54687b..ad09a1ea0 100644 --- a/modules/block/block.tpl.php +++ b/modules/block/block.tpl.php @@ -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 ?> diff --git a/modules/comment/comment.tpl.php b/modules/comment/comment.tpl.php index bb6026041..ac5f431f7 100644 --- a/modules/comment/comment.tpl.php +++ b/modules/comment/comment.tpl.php @@ -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 diff --git a/modules/contextual/contextual.module b/modules/contextual/contextual.module index 080cf0d3a..480f9e663 100644 --- a/modules/contextual/contextual.module +++ b/modules/contextual/contextual.module @@ -64,9 +64,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; @@ -89,8 +86,8 @@ function contextual_preprocess(&$variables, $hook) { } if (isset($element) && is_array($element) && !empty($element['#contextual_links'])) { - $variables['contextual_links'] = contextual_links_view($element); - if (!empty($variables['contextual_links'])) { + $variables['title_suffix']['contextual_links'] = contextual_links_view($element); + if (!empty($variables['title_suffix']['contextual_links'])) { $variables['classes_array'][] = 'contextual-links-region'; } } diff --git a/modules/node/node.module b/modules/node/node.module index ba298bec2..469565a72 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1186,9 +1186,11 @@ function node_view($node, $view_mode = 'full') { '#node' => $node, '#view_mode' => $view_mode, ); - // Add contextual links for this node. + // Add contextual links for this node except for 'full' view mode. // @todo Make this configurable per view mode. - $build['#contextual_links']['node'] = array('node', array($node->nid)); + if ($view_mode != 'full') { + $build['#contextual_links']['node'] = array('node', array($node->nid)); + } // Allow modules to modify the structured node. drupal_alter('node_view', $build); diff --git a/modules/node/node.tpl.php b/modules/node/node.tpl.php index 1cbd06a7a..4c46a73c5 100644 --- a/modules/node/node.tpl.php +++ b/modules/node/node.tpl.php @@ -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"> diff --git a/modules/shortcut/shortcut.module b/modules/shortcut/shortcut.module index a442bc00a..4314c9ddd 100644 --- a/modules/shortcut/shortcut.module +++ b/modules/shortcut/shortcut.module @@ -522,9 +522,9 @@ function shortcut_renderable_links($shortcut_set = NULL) { } /** - * 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($toolbar) { 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'; - } -} diff --git a/modules/system/page.tpl.php b/modules/system/page.tpl.php index da5219774..7324c7430 100644 --- a/modules/system/page.tpl.php +++ b/modules/system/page.tpl.php @@ -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,9 @@ <div id="content" class="column"><div class="section"> <?php if ($page['highlight']): ?><div id="highlight"><?php print render($page['highlight']); ?></div><?php endif; ?> <a id="main-content"></a> + <?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; ?> |