summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-10-11 06:05:53 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-10-11 06:05:53 +0000
commit1d72b6ec9f5b577d976b51498a7212d112c5cc33 (patch)
treea74184429fcc920587d8c568d9f3d6a16347e62b /includes
parentb3265dbe174ce0efefa181b8af6c1eaea3ff22c2 (diff)
downloadbrdo-1d72b6ec9f5b577d976b51498a7212d112c5cc33.tar.gz
brdo-1d72b6ec9f5b577d976b51498a7212d112c5cc33.tar.bz2
#599706 by sun: Allow altering local tasks/actions.
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc4
-rw-r--r--includes/menu.inc66
2 files changed, 47 insertions, 23 deletions
diff --git a/includes/common.inc b/includes/common.inc
index c264147e9..8532e46c7 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -4939,10 +4939,10 @@ function drupal_common_theme() {
'arguments' => array('tree' => NULL),
),
'menu_local_task' => array(
- 'arguments' => array('link' => NULL, 'active' => FALSE),
+ 'arguments' => array('element' => NULL),
),
'menu_local_action' => array(
- 'arguments' => array('link' => NULL),
+ 'arguments' => array('element' => NULL),
),
'menu_local_tasks' => array(
'arguments' => array(),
diff --git a/includes/menu.inc b/includes/menu.inc
index eba2a9036..076bcc6f6 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -1349,29 +1349,29 @@ function theme_menu_link(array $variables) {
*
* @param $variables
* An associative array containing:
- * - link: A menu link array with 'title', 'href', and 'localized_options'
+ * - #link: A menu link array with 'title', 'href', and 'localized_options'
* keys.
- * - active: A boolean indicating whether the local task is active.
+ * - #active: A boolean indicating whether the local task is active.
*
* @ingroup themeable
*/
function theme_menu_local_task($variables) {
- $link = $variables['link'];
- return '<li ' . ($variables['active'] ? 'class="active" ' : '') . '>' . l($link['title'], $link['href'], $link['localized_options']) . "</li>\n";
+ $link = $variables['element']['#link'];
+ return '<li' . (!empty($variables['element']['#active']) ? ' class="active"' : '') . '>' . l($link['title'], $link['href'], $link['localized_options']) . "</li>\n";
}
/**
* Generate the HTML output for a single local action link.
*
- * @param $variables
+ * @param $element
* An associative array containing:
- * - link: A menu link array with 'title', 'href', and 'localized_options'
+ * - #link: A menu link array with 'title', 'href', and 'localized_options'
* keys.
*
* @ingroup themeable
*/
function theme_menu_local_action($variables) {
- $link = $variables['link'];
+ $link = $variables['element']['#link'];
return '<li>' . l($link['title'], $link['href'], $link['localized_options']) . "</li>\n";
}
@@ -1564,8 +1564,8 @@ function menu_local_tasks($level = 0) {
$data = &drupal_static(__FUNCTION__);
$root_path = &drupal_static(__FUNCTION__ . ':root_path', '');
$empty = array(
- 'tabs' => array('count' => 0, 'output' => ''),
- 'actions' => array('count' => 0, 'output' => ''),
+ 'tabs' => array('count' => 0, 'output' => array()),
+ 'actions' => array('count' => 0, 'output' => array()),
'root_path' => &$root_path,
);
@@ -1606,8 +1606,8 @@ function menu_local_tasks($level = 0) {
// equal the depth. Thus we use the $depth counter (offset by 1000 for ksort).
$depth = 1001;
while (isset($children[$path])) {
- $tabs_current = '';
- $actions_current = '';
+ $tabs_current = array();
+ $actions_current = array();
$next_path = '';
$tab_count = 0;
$action_count = 0;
@@ -1620,17 +1620,27 @@ function menu_local_tasks($level = 0) {
for ($p = $item['tab_parent']; $tasks[$p]['type'] == MENU_DEFAULT_LOCAL_TASK; $p = $tasks[$p]['tab_parent']);
// Use the path of the parent instead.
$link['href'] = $tasks[$p]['href'];
- $tabs_current .= theme('menu_local_task', array('link' => $link, 'active' => TRUE));
+ $tabs_current[] = array(
+ '#theme' => 'menu_local_task',
+ '#link' => $link,
+ '#active' => TRUE,
+ );
$next_path = $item['path'];
$tab_count++;
}
else {
if ($item['type'] == MENU_LOCAL_TASK) {
- $tabs_current .= theme('menu_local_task', array('link' => $link));
+ $tabs_current[] = array(
+ '#theme' => 'menu_local_task',
+ '#link' => $link,
+ );
$tab_count++;
}
else {
- $actions_current .= theme('menu_local_action', array('link' => $link));
+ $actions_current[] = array(
+ '#theme' => 'menu_local_action',
+ '#link' => $link,
+ );
$action_count++;
}
}
@@ -1650,7 +1660,7 @@ function menu_local_tasks($level = 0) {
$current = $router_item;
$depth = 1000;
while (isset($children[$parent])) {
- $tabs_current = '';
+ $tabs_current = array();
$next_path = '';
$next_parent = '';
$count = 0;
@@ -1672,14 +1682,21 @@ function menu_local_tasks($level = 0) {
}
// We check for the active tab.
if ($item['path'] == $path) {
- $tabs_current .= theme('menu_local_task', array('link' => $link, 'active' => TRUE));
+ $tabs_current[] = array(
+ '#theme' => 'menu_local_task',
+ '#link' => $link,
+ '#active' => TRUE,
+ );
$next_path = $item['tab_parent'];
if (isset($tasks[$next_path])) {
$next_parent = $tasks[$next_path]['tab_parent'];
}
}
else {
- $tabs_current .= theme('menu_local_task', array('link' => $link));
+ $tabs_current[] = array(
+ '#theme' => 'menu_local_task',
+ '#link' => $link,
+ );
}
}
}
@@ -1694,6 +1711,9 @@ function menu_local_tasks($level = 0) {
// Remove the depth, we are interested only in their relative placement.
$tabs = array_values($tabs);
$data['tabs'] = $tabs;
+
+ // Allow modules to alter local tasks or dynamically append further tasks.
+ drupal_alter('menu_local_tasks', $data, $router_item, $root_path);
}
if (isset($data['tabs'][$level])) {
@@ -1741,18 +1761,22 @@ function menu_tab_root_path() {
}
/**
- * Returns the rendered local tasks. The default implementation renders them as tabs.
+ * Returns renderable local tasks.
*
* @ingroup themeable
*/
function theme_menu_local_tasks() {
- $output = '';
+ $output = array();
if ($primary = menu_primary_local_tasks()) {
- $output .= "<ul class=\"tabs primary\">\n" . $primary . "</ul>\n";
+ $primary['#prefix'] = '<ul class="tabs primary">';
+ $primary['#suffix'] = '</ul>';
+ $output[] = $primary;
}
if ($secondary = menu_secondary_local_tasks()) {
- $output .= "<ul class=\"tabs secondary\">\n" . $secondary . "</ul>\n";
+ $secondary['#prefix'] = '<ul class="tabs secondary">';
+ $secondary['#suffix'] = '</ul>';
+ $output[] = $secondary;
}
return $output;