- Patch #145058 by pwolanin (and chx): re-parenting and caching for menu links.
parent
860947d3c8
commit
a8ceb7613b
|
@ -342,12 +342,7 @@ function drupal_not_found() {
|
|||
|
||||
$path = drupal_get_normal_path(variable_get('site_404', ''));
|
||||
if ($path && $path != $_GET['q']) {
|
||||
menu_set_active_item($path);
|
||||
$return = menu_execute_active_handler();
|
||||
}
|
||||
else {
|
||||
// Redirect to a non-existent menu item to make possible tabs disappear.
|
||||
menu_set_active_item('');
|
||||
$return = menu_execute_active_handler($path);
|
||||
}
|
||||
|
||||
if (empty($return)) {
|
||||
|
@ -372,12 +367,7 @@ function drupal_access_denied() {
|
|||
|
||||
$path = drupal_get_normal_path(variable_get('site_403', ''));
|
||||
if ($path && $path != $_GET['q']) {
|
||||
menu_set_active_item($path);
|
||||
$return = menu_execute_active_handler();
|
||||
}
|
||||
else {
|
||||
// Redirect to a non-existent menu item to make possible tabs disappear.
|
||||
menu_set_active_item('');
|
||||
$return = menu_execute_active_handler($path);
|
||||
}
|
||||
|
||||
if (empty($return)) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -7,6 +7,9 @@
|
|||
function menu_install() {
|
||||
// Create tables.
|
||||
drupal_install_schema('menu');
|
||||
db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('navigation', 'Navigation', 'The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.')");
|
||||
db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('primary_links', 'Primary links', 'Primary links are often used at the theme layer to show the major sections of a site. A typical representation for primary links would be tabs along the top.')");
|
||||
db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('secondary_links', 'Secondary links', 'Secondary links are often used for pages like legal notices, contact details, and other secondary navigation items that play a lesser role than primary links')");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,71 +2,15 @@
|
|||
// $Id$
|
||||
|
||||
function menu_schema() {
|
||||
$schema['menu_router'] = array(
|
||||
$schema['menu_custom'] = array(
|
||||
'fields' => array(
|
||||
'path' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'load_functions' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'to_arg_functions' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'access_callback' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'access_arguments' => array('type' => 'text', 'not null' => FALSE),
|
||||
'page_callback' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'page_arguments' => array('type' => 'text', 'not null' => FALSE),
|
||||
'fit' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'number_parts' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'tab_parent' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'tab_root' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'title_callback' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'title_arguments' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'type' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'block_callback' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'description' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'position' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'file' => array('type' => 'text', 'size' => 'medium')
|
||||
'menu_name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'description' => array('type' => 'text', 'not null' => FALSE),
|
||||
),
|
||||
'indexes' => array(
|
||||
'fit' => array('fit'),
|
||||
'tab_parent' => array('tab_parent')
|
||||
),
|
||||
'primary key' => array('path'),
|
||||
'primary key' => array('menu_name'),
|
||||
);
|
||||
|
||||
$schema['menu_links'] = array(
|
||||
'fields' => array(
|
||||
'menu_name' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''),
|
||||
'mlid' => array('type' => 'serial', 'not null' => TRUE),
|
||||
'plid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'href' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'router_path' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'hidden' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
|
||||
'external' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
|
||||
'has_children' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'expanded' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
|
||||
'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'depth' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'p1' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'p2' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'p3' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'p4' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'p5' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'p6' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'module' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'system'),
|
||||
'link_title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'options' => array('type' => 'text', 'not null' => FALSE)
|
||||
),
|
||||
'indexes' => array(
|
||||
'expanded_children' => array('expanded', 'has_children'),
|
||||
'menu_name_path' => array('menu_name', 'href'),
|
||||
'parents' => array('plid', 'p1', 'p2', 'p3', 'p4', 'p5')
|
||||
),
|
||||
'primary key' => array('mlid'),
|
||||
);
|
||||
|
||||
$schema['cache_menu'] = drupal_get_schema_unprocessed('system', 'cache');
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -15,18 +15,21 @@ function system_main_admin_page($arg = NULL) {
|
|||
if (system_status(TRUE)) {
|
||||
drupal_set_message(t('One or more problems were detected with your Drupal installation. Check the <a href="@status">status report</a> for more information.', array('@status' => url('admin/logs/status'))), 'error');
|
||||
}
|
||||
$result = db_query("SELECT * FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path
|
||||
WHERE ml.href like 'admin/%' AND ml.href != 'admin/help' AND ml.depth = 2 AND ml.menu_name = 'navigation'
|
||||
ORDER BY p1 ASC, p2 ASC, p3 ASC");
|
||||
while ($item = db_fetch_object($result)) {
|
||||
$result = db_query("
|
||||
SELECT *
|
||||
FROM {menu_links} ml
|
||||
INNER JOIN {menu_router} m ON ml.router_path = m.path
|
||||
WHERE ml.link_path like 'admin/%' AND ml.link_path != 'admin/help' AND ml.depth = 2 AND ml.menu_name = 'navigation' AND hidden = 0
|
||||
ORDER BY p1 ASC, p2 ASC, p3 ASC");
|
||||
while ($item = db_fetch_array($result)) {
|
||||
_menu_link_translate($item);
|
||||
if (!$item->access) {
|
||||
if (!$item['access']) {
|
||||
continue;
|
||||
}
|
||||
$block = (array)$item;
|
||||
$block = $item;
|
||||
$block['content'] = '';
|
||||
if ($item->block_callback && function_exists($item->block_callback)) {
|
||||
$function = $item->block_callback;
|
||||
if ($item['block_callback'] && function_exists($item['block_callback'])) {
|
||||
$function = $item['block_callback'];
|
||||
$block['content'] .= $function();
|
||||
}
|
||||
$block['content'] .= theme('admin_block_content', system_admin_menu_block($item));
|
||||
|
|
|
@ -227,7 +227,7 @@ function system_install() {
|
|||
}
|
||||
|
||||
// Create tables.
|
||||
$modules = array('system', 'filter', 'block', 'user', 'node', 'menu', 'comment', 'taxonomy');
|
||||
$modules = array('system', 'filter', 'block', 'user', 'node', 'comment', 'taxonomy');
|
||||
foreach ($modules as $module) {
|
||||
drupal_install_schema($module);
|
||||
}
|
||||
|
@ -2977,14 +2977,15 @@ function system_update_6012() {
|
|||
db_add_column($ret, 'cache', 'serialized', 'smallint', array('default' => "'0'", 'not null' => TRUE));
|
||||
db_add_column($ret, 'cache_filter', 'serialized', 'smallint', array('default' => "'0'", 'not null' => TRUE));
|
||||
db_add_column($ret, 'cache_page', 'serialized', 'smallint', array('default' => "'0'", 'not null' => TRUE));
|
||||
db_add_column($ret, 'cache_menu', 'serialized', 'smallint', array('default' => "'0'", 'not null' => TRUE));
|
||||
break;
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
$ret[] = update_sql("ALTER TABLE {cache} ADD serialized int(1) NOT NULL default '0'");
|
||||
$ret[] = update_sql("ALTER TABLE {cache_filter} ADD serialized int(1) NOT NULL default '0'");
|
||||
$ret[] = update_sql("ALTER TABLE {cache_page} ADD serialized int(1) NOT NULL default '0'");
|
||||
$ret[] = update_sql("ALTER TABLE {cache_menu} ADD serialized int(1) NOT NULL default '0'");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
@ -3284,6 +3285,26 @@ function system_update_6019() {
|
|||
return $ret;
|
||||
}
|
||||
|
||||
function system_update_6020() {
|
||||
$ret = array();
|
||||
|
||||
$schema['menu_router'] = drupal_get_schema_unprocessed('system', 'menu_router');
|
||||
$schema['menu_links'] = drupal_get_schema_unprocessed('system', 'menu_links');
|
||||
_drupal_initialize_schema('system', $schema);
|
||||
$ret = array();
|
||||
foreach ($schema as $table) {
|
||||
db_create_table($ret, $table);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function system_update_6021() {
|
||||
$ret = array();
|
||||
// TODO - menu module updates. These need to happen before we do the menu_rebuild
|
||||
|
||||
menu_rebuild();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "defgroup updates-5.x-to-6.x"
|
||||
|
|
|
@ -144,6 +144,7 @@ function system_menu() {
|
|||
$items['admin/by-task'] = array(
|
||||
'title' => 'By task',
|
||||
'page callback' => 'system_main_admin_page',
|
||||
'file' => 'system.admin.inc',
|
||||
'type' => MENU_DEFAULT_LOCAL_TASK,
|
||||
);
|
||||
$items['admin/by-module'] = array(
|
||||
|
@ -392,14 +393,18 @@ function system_user($type, $edit, &$user, $category = NULL) {
|
|||
*/
|
||||
function system_admin_menu_block($item) {
|
||||
$content = array();
|
||||
if (!isset($item->mlid)) {
|
||||
$item->mlid = db_result(db_query("SELECT mlid FROM {menu_links} ml WHERE ml.router_path = '%s' AND menu_name = 'navigation'", $item->path));
|
||||
if (!isset($item['mlid'])) {
|
||||
$item['mlid'] = db_result(db_query("SELECT mlid FROM {menu_links} ml WHERE ml.router_path = '%s' AND menu_name = 'navigation'", $item['path']));
|
||||
}
|
||||
$result = db_query("SELECT * FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path
|
||||
WHERE ml.plid = '%s' AND ml.menu_name = 'navigation' ORDER BY m.weight, m.title", $item->mlid);
|
||||
while ($item = db_fetch_object($result)) {
|
||||
$result = db_query("
|
||||
SELECT *
|
||||
FROM {menu_links} ml
|
||||
INNER JOIN {menu_router} m ON ml.router_path = m.path
|
||||
WHERE ml.plid = %d AND ml.menu_name = 'navigation' AND hidden = 0
|
||||
ORDER BY m.weight, m.title", $item['mlid']);
|
||||
while ($item = db_fetch_array($result)) {
|
||||
_menu_link_translate($item);
|
||||
if (!$item->access) {
|
||||
if (!$item['access']) {
|
||||
continue;
|
||||
}
|
||||
$content[] = (array)$item;
|
||||
|
@ -1670,9 +1675,6 @@ function system_modules_submit($form_values, $form, &$form_state) {
|
|||
}
|
||||
}
|
||||
|
||||
// Temporarily disable menu module while it's broken.
|
||||
unset($form_values['status']['menu']);
|
||||
|
||||
// If there where unmet dependencies and they haven't confirmed don't process
|
||||
// the submission yet. Store the form submission data needed later.
|
||||
if ($dependencies) {
|
||||
|
|
|
@ -28,6 +28,7 @@ function system_schema() {
|
|||
|
||||
$schema['cache_form'] = $schema['cache'];
|
||||
$schema['cache_page'] = $schema['cache'];
|
||||
$schema['cache_menu'] = $schema['cache'];
|
||||
|
||||
$schema['files'] = array(
|
||||
'fields' => array(
|
||||
|
@ -71,6 +72,68 @@ function system_schema() {
|
|||
),
|
||||
'primary key' => array('uid', 'nid'),
|
||||
);
|
||||
$schema['menu_router'] = array(
|
||||
'fields' => array(
|
||||
'path' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'load_functions' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'to_arg_functions' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'access_callback' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'access_arguments' => array('type' => 'text', 'not null' => FALSE),
|
||||
'page_callback' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'page_arguments' => array('type' => 'text', 'not null' => FALSE),
|
||||
'fit' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'number_parts' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
|
||||
'tab_parent' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'tab_root' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'title_callback' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'title_arguments' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'type' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'block_callback' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'description' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'position' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'file' => array('type' => 'text', 'size' => 'medium')
|
||||
),
|
||||
'indexes' => array(
|
||||
'fit' => array('fit'),
|
||||
'tab_parent' => array('tab_parent')
|
||||
),
|
||||
'primary key' => array('path'),
|
||||
);
|
||||
|
||||
$schema['menu_links'] = array(
|
||||
'fields' => array(
|
||||
'menu_name' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''),
|
||||
'mlid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
|
||||
'plid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
||||
'link_path' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'router_path' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'hidden' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
|
||||
'external' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
|
||||
'has_children' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
|
||||
'expanded' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
|
||||
'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'depth' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
|
||||
'p1' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
||||
'p2' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
||||
'p3' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
||||
'p4' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
||||
'p5' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
||||
'p6' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
||||
'module' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'system'),
|
||||
'link_title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
||||
'options' => array('type' => 'text', 'not null' => FALSE)
|
||||
),
|
||||
'indexes' => array(
|
||||
'expanded_children' => array('expanded', 'has_children'),
|
||||
'menu_name_path' => array('menu_name', 'link_path'),
|
||||
'plid'=> array('plid'),
|
||||
'parents' => array('p1', 'p2', 'p3', 'p4', 'p5'),
|
||||
'router_path' => array('router_path'),
|
||||
),
|
||||
'primary key' => array('mlid'),
|
||||
);
|
||||
|
||||
$schema['sequences'] = array(
|
||||
'fields' => array(
|
||||
|
|
Loading…
Reference in New Issue