Commit 489903a0 authored by Dries's avatar Dries

- Patch #113603 by chx: first crack at re-implementing tabs.

parent 585fdfc9
......@@ -544,6 +544,16 @@ function menu_rebuild() {
$vancode = '';
$link = '';
}
$tab = ($item['type'] & MENU_IS_LOCAL_TASK) ? 1 : 0;
$default_tab = $item['type'] == MENU_DEFAULT_LOCAL_TASK;
if (!isset($item['parent'])) {
if ($tab) {
$item['parent'] = implode('/', array_slice($item['_parts'], 0, $item['_number_parts'] - 1));
}
else {
$item['parent'] = $path;
}
}
$insert_item = $item + array(
'access arguments' => array(),
'access callback' => '',
......@@ -552,8 +562,18 @@ function menu_rebuild() {
'map arguments' => array(),
'map callback' => '',
);
db_query("INSERT INTO {menu} (mid, pid, path, access_callback, access_arguments, page_callback, page_arguments, map_callback, map_arguments, fit, number_parts, vancode, menu_link, visible, parents, depth, has_children) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, '%s', %d, %d)", $insert_item['_mid'], $insert_item['_pid'], $path, $insert_item['access callback'], serialize($insert_item['access arguments']), $insert_item['page callback'], serialize($insert_item['page arguments']), $insert_item['map callback'], serialize($insert_item['map arguments']), $insert_item['_fit'], $insert_item['_number_parts'], $vancode .'+', $link, $insert_item['_visible'], $insert_item['_parents'], $insert_item['_depth'], $insert_item['_has_children']);
// $item needs to be unset because of the reference above.
db_query("INSERT INTO {menu} (
mid, pid, path,
access_callback, access_arguments, page_callback, page_arguments, map_callback, map_arguments, fit,
number_parts, vancode, menu_link, visible, parents, depth, has_children, tab, default_tab, title, parent)
VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, '%s', %d, %d, %d, %d, '%s', '%s')",
$insert_item['_mid'], $insert_item['_pid'], $path, $insert_item['access callback'],
serialize($insert_item['access arguments']), $insert_item['page callback'],
serialize($insert_item['page arguments']), $insert_item['map callback'],
serialize($insert_item['map arguments']), $insert_item['_fit'],
$insert_item['_number_parts'], $vancode .'+', $link, $insert_item['_visible'],
$insert_item['_parents'], $insert_item['_depth'], $insert_item['_has_children'],
$tab, $default_tab, $insert_item['title'], $insert_item['parent']);
unset($item);
}
}
......@@ -571,6 +591,28 @@ function menu_secondary_links() {
}
function menu_primary_local_tasks() {
$router_item = menu_get_item();
$result = db_query("SELECT * FROM {menu} WHERE parent = '%s' AND tab = 1 ORDER BY vancode", $router_item->parent);
$tabs = array();
while ($item = db_fetch_object($result)) {
$map = explode('/', $item->path);
foreach ($map as $key => $value) {
if ($value == '%') {
$map[$key] = arg($key);
}
}
$path = implode('/', $map);
if (_menu_access($item, $map, TRUE)) {
$link = l($item->title, $path);
if ((!$router_item->tab && $item->default_tab) || ($path == $_GET['q'])) {
$tabs[] = array('class' => 'active', 'data' => $link);
}
else {
$tabs[] = $link;
}
}
}
return theme('item_list', $tabs, NULL, 'ul', array('class' => 'tabs primary'));
}
function menu_secondary_local_tasks() {
......
......@@ -41,6 +41,7 @@ function aggregator_menu() {
'page arguments' => array('aggregator_form_feed'),
'access arguments' => array('administer news feeds'),
'type' => MENU_LOCAL_TASK,
'parent' => 'admin/content/aggregator',
);
$items['admin/content/aggregator/add/category'] = array(
'title' => t('Add category'),
......@@ -48,6 +49,7 @@ function aggregator_menu() {
'page arguments' => array('aggregator_form_category'),
'access arguments' => array('administer news feeds'),
'type' => MENU_LOCAL_TASK,
'parent' => 'admin/content/aggregator',
);
$items['admin/content/aggregator/remove/%'] = array(
'title' => t('Remove items'),
......
......@@ -58,12 +58,14 @@ function forum_menu() {
'page callback' => 'forum_form_main',
'page arguments' => array('container'),
'type' => MENU_LOCAL_TASK,
'parent' => 'admin/content/forum',
);
$items['admin/content/forum/add/forum'] = array(
'title' => t('Add forum'),
'page callback' => 'forum_form_main',
'page arguments' => array('forum'),
'type' => MENU_LOCAL_TASK,
'parent' => 'admin/content/forum',
);
$items['admin/content/forum/settings'] = array(
'title' => t('Settings'),
......@@ -71,6 +73,7 @@ function forum_menu() {
'page arguments' => array('forum_admin_settings'),
'weight' => 5,
'type' => MENU_LOCAL_TASK,
'parent' => 'admin/content/forum',
);
$items['admin/content/forum/edit'] = array(
'page callback' => 'forum_form_main',
......
......@@ -61,6 +61,7 @@ function locale_menu() {
'page callback' => 'locale_string_search',
'weight' => 10,
'type' => MENU_LOCAL_TASK,
'parent' => 'admin/settings/locale',
);
// Manage languages subtabs
......
......@@ -168,30 +168,19 @@ function search_menu() {
foreach (module_implements('search') as $name) {
$items['search/'. $name] = array(
'title' => module_invoke($name, 'search', 'name', TRUE),
'page callback' => 'search_view',
'page arguments' => array($name),
'access callback' => FALSE,
'type' => MENU_LOCAL_TASK,
'access callback' => '_search_menu',
'access arguments' => array($name),
'type' => $name == 'node' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
);
}
return $items;
}
function search_init() {
// To remember the user's search keywords when switching across tabs,
// we dynamically add the keywords to the search tabs' paths.
if (arg(0) == 'search') {
$keys = search_get_keys();
$keys = strlen($keys) ? '/'. $keys : '';
foreach (module_implements('search') as $name) {
$title = module_invoke($name, 'search', 'name');
$item = menu_get_item('search/'. $name);
$item->title = $title;
$item->access = user_access('search content') && $title;
menu_set_item('search/'. $name, $item);
menu_set_item('search/'. $name . $keys, $item);
}
}
function _search_menu($name) {
return user_access('search content') && module_invoke($name, 'search', 'name');
}
/**
......
......@@ -344,6 +344,10 @@ function system_install() {
parents varchar(255) NOT NULL default '',
depth int NOT NULL default '0',
has_children int NOT NULL default '0',
tab int NOT NULL default 0,
title varchar(255) NOT NULL default '',
default_tab int NOT NULL default '0',
parent varchar(255) NOT NULL default '',
PRIMARY KEY (path),
KEY vancode (vancode),
KEY fit (fit),
......@@ -812,6 +816,10 @@ function system_install() {
parents varchar(255) NOT NULL default '',
depth int NOT NULL default '0',
has_children int NOT NULL default '0',
tab int NOT NULL default '0',
title varchar(255) NOT NULL default '',
default_tab int NOT NULL default '0',
parent varchar(255) NOT NULL default '',
PRIMARY KEY (path)
)");
......
......@@ -88,6 +88,7 @@ function taxonomy_menu() {
'page callback' => 'drupal_get_form',
'page arguments' => array('taxonomy_form_vocabulary'),
'type' => MENU_LOCAL_TASK,
'parent' => 'admin/content/taxonomy',
);
$items['admin/content/taxonomy/edit/vocabulary/%'] = array(
......@@ -136,6 +137,7 @@ function taxonomy_menu() {
'page callback' => 'drupal_get_form',
'page arguments' => array('taxonomy_form_term', 3),
'type' => MENU_LOCAL_TASK,
'parent' => 'admin/content/taxonomy/%',
);
return $items;
......
......@@ -427,10 +427,10 @@ function user_file_download($file) {
/**
* Implementation of hook_search().
*/
function user_search($op = 'search', $keys = NULL) {
function user_search($op = 'search', $keys = NULL, $skip_access_check = FALSE) {
switch ($op) {
case 'name':
if (user_access('access user profiles')) {
if ($skip_access_check || user_access('access user profiles')) {
return t('Users');
}
case 'search':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment