diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-05-27 20:31:13 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-05-27 20:31:13 +0000 |
commit | a8ceb7613b808c1b6643e910f96dc7319012bf67 (patch) | |
tree | 3965e8935437879f60b6cdddc995cf27282d5567 /modules/system | |
parent | 860947d3c87e8ebd53031ac8077d1dce24716e32 (diff) | |
download | brdo-a8ceb7613b808c1b6643e910f96dc7319012bf67.tar.gz brdo-a8ceb7613b808c1b6643e910f96dc7319012bf67.tar.bz2 |
- Patch #145058 by pwolanin (and chx): re-parenting and caching for menu links.
Diffstat (limited to 'modules/system')
-rw-r--r-- | modules/system/system.admin.inc | 19 | ||||
-rw-r--r-- | modules/system/system.install | 25 | ||||
-rw-r--r-- | modules/system/system.module | 22 | ||||
-rw-r--r-- | modules/system/system.schema | 63 |
4 files changed, 109 insertions, 20 deletions
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index 41ed65edb..e5c0370b4 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -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)); diff --git a/modules/system/system.install b/modules/system/system.install index ad34067f1..d3bfd6ed7 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -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" diff --git a/modules/system/system.module b/modules/system/system.module index 3820d27ef..b94bc9742 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -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)); - } - $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)) { + 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 = %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) { diff --git a/modules/system/system.schema b/modules/system/system.schema index e8c6c829c..608d752d8 100644 --- a/modules/system/system.schema +++ b/modules/system/system.schema @@ -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( |