Skip to content
Snippets Groups Projects
Commit c4d170c9 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #147656 by pwolanin and chx: menu module update for Drupal 6.

parent 20b0af0b
No related branches found
No related tags found
No related merge requests found
...@@ -80,12 +80,11 @@ ...@@ -80,12 +80,11 @@
define('MENU_IS_ROOT', 0x0001); define('MENU_IS_ROOT', 0x0001);
define('MENU_VISIBLE_IN_TREE', 0x0002); define('MENU_VISIBLE_IN_TREE', 0x0002);
define('MENU_VISIBLE_IN_BREADCRUMB', 0x0004); define('MENU_VISIBLE_IN_BREADCRUMB', 0x0004);
define('MENU_MODIFIED_BY_ADMIN', 0x0008); define('MENU_LINKS_TO_PARENT', 0x0008);
define('MENU_MODIFIABLE_BY_ADMIN', 0x0010); define('MENU_MODIFIABLE_BY_ADMIN', 0x0010);
define('MENU_CREATED_BY_ADMIN', 0x0020); define('MENU_MODIFIED_BY_ADMIN', 0x0020);
define('MENU_IS_LOCAL_TASK', 0x0040); define('MENU_CREATED_BY_ADMIN', 0x0040);
define('MENU_EXPANDED', 0x0080); define('MENU_IS_LOCAL_TASK', 0x0080);
define('MENU_LINKS_TO_PARENT', 0x00100);
/** /**
* @} End of "Menu flags". * @} End of "Menu flags".
...@@ -303,7 +302,8 @@ function menu_get_item($path = NULL) { ...@@ -303,7 +302,8 @@ function menu_get_item($path = NULL) {
function menu_execute_active_handler($path = NULL) { function menu_execute_active_handler($path = NULL) {
if (_menu_site_is_offline()) { if (_menu_site_is_offline()) {
return MENU_SITE_OFFLINE; return MENU_SITE_OFFLINE;
} if ($router_item = menu_get_item($path)) { }
if ($router_item = menu_get_item($path)) {
if ($router_item['access']) { if ($router_item['access']) {
if ($router_item['file']) { if ($router_item['file']) {
require_once($router_item['file']); require_once($router_item['file']);
...@@ -886,7 +886,7 @@ function menu_get_names($reset = FALSE) { ...@@ -886,7 +886,7 @@ function menu_get_names($reset = FALSE) {
} }
function menu_primary_links() { function menu_primary_links() {
$tree = menu_tree_page_data('primary_links'); $tree = menu_tree_page_data('primary-links');
$links = array(); $links = array();
foreach ($tree as $item) { foreach ($tree as $item) {
$l = $item['link']['options']; $l = $item['link']['options'];
...@@ -898,7 +898,7 @@ function menu_primary_links() { ...@@ -898,7 +898,7 @@ function menu_primary_links() {
} }
function menu_secondary_links() { function menu_secondary_links() {
$tree = menu_tree_page_data('secondary_links'); $tree = menu_tree_page_data('secondary-links');
$links = array(); $links = array();
foreach ($tree as $item) { foreach ($tree as $item) {
$l = $item['link']['options']; $l = $item['link']['options'];
...@@ -1134,7 +1134,6 @@ function menu_link_load($mlid) { ...@@ -1134,7 +1134,6 @@ function menu_link_load($mlid) {
} }
function menu_cache_clear($menu_name = 'navigation') { function menu_cache_clear($menu_name = 'navigation') {
cache_clear_all('links:'. $menu_name .':', 'cache_menu', TRUE); cache_clear_all('links:'. $menu_name .':', 'cache_menu', TRUE);
} }
...@@ -1189,26 +1188,34 @@ function menu_router_build($reset = FALSE) { ...@@ -1189,26 +1188,34 @@ function menu_router_build($reset = FALSE) {
return $menu; return $menu;
} }
/**
* Builds a link from a router item.
*/
function _menu_link_build($item) {
if ($item['type'] == MENU_CALLBACK) {
$item['hidden'] = -1;
}
elseif ($item['type'] == MENU_SUGGESTED_ITEM) {
$item['hidden'] = 1;
}
// Note, we set this as 'system', so that we can be sure to distinguish all
// the menu links generated automatically from entries in {menu_router}.
$item['module'] = 'system';
$item += array(
'menu_name' => 'navigation',
'link_title' => $item['title'],
'link_path' => $item['path'],
'hidden' => 0,
'options' => empty($item['description']) ? array() : array('attributes' => array('title' => $item['description'])),
);
return $item;
}
function _menu_navigation_links_rebuild($menu) { function _menu_navigation_links_rebuild($menu) {
// Add normal and suggested items as links. // Add normal and suggested items as links.
$menu_links = array(); $menu_links = array();
foreach ($menu as $path => $item) { foreach ($menu as $path => $item) {
if ($item['type'] == MENU_CALLBACK) { $item = _menu_link_build($item);
$item['hidden'] = -1;
}
elseif ($item['type'] == MENU_SUGGESTED_ITEM) {
$item['hidden'] = 1;
}
// Note, we set this as 'system', so that we can be sure to distinguish all
// the menu links generated automatically from entries in {menu_router}.
$item['module'] = 'system';
$item += array(
'menu_name' => 'navigation',
'link_title' => $item['title'],
'link_path' => $path,
'hidden' => 0,
'options' => empty($item['description']) ? array() : array('attributes' => array('title' => $item['description'])),
);
// We add nonexisting items. // We add nonexisting items.
if ($item['_visible'] && !db_result(db_query("SELECT COUNT(*) FROM {menu_links} WHERE menu_name = '%s' AND link_path = '%s'", $item['menu_name'], $item['link_path']))) { if ($item['_visible'] && !db_result(db_query("SELECT COUNT(*) FROM {menu_links} WHERE menu_name = '%s' AND link_path = '%s'", $item['menu_name'], $item['link_path']))) {
$menu_links[$path] = $item; $menu_links[$path] = $item;
...@@ -1249,7 +1256,6 @@ function menu_link_delete($mlid, $path = NULL) { ...@@ -1249,7 +1256,6 @@ function menu_link_delete($mlid, $path = NULL) {
} }
function _menu_delete_item($item) { function _menu_delete_item($item) {
// System-created items get automatically deleted, but only on menu rebuild. // System-created items get automatically deleted, but only on menu rebuild.
if ($item && $item['module'] != 'system') { if ($item && $item['module'] != 'system') {
...@@ -1264,6 +1270,7 @@ function _menu_delete_item($item) { ...@@ -1264,6 +1270,7 @@ function _menu_delete_item($item) {
} }
db_query('DELETE FROM {menu_links} WHERE mlid = %d', $item['mlid']); db_query('DELETE FROM {menu_links} WHERE mlid = %d', $item['mlid']);
// Update the has_children status of the parent // Update the has_children status of the parent
$children = (bool)db_result(db_query("SELECT COUNT(*) FROM {menu_links} WHERE plid = %d AND hidden = 0", $item['plid'])); $children = (bool)db_result(db_query("SELECT COUNT(*) FROM {menu_links} WHERE plid = %d AND hidden = 0", $item['plid']));
db_query("UPDATE {menu_links} SET has_children = %d WHERE mlid = %d", $children, $item['plid']); db_query("UPDATE {menu_links} SET has_children = %d WHERE mlid = %d", $children, $item['plid']);
...@@ -1429,7 +1436,7 @@ function menu_link_save(&$item) { ...@@ -1429,7 +1436,7 @@ function menu_link_save(&$item) {
$names[] = $n['menu_name']; $names[] = $n['menu_name'];
} }
variable_set('menu_expanded', $names); variable_set('menu_expanded', $names);
return TRUE; return $item['mlid'];
} }
/** /**
......
...@@ -8,8 +8,8 @@ function menu_install() { ...@@ -8,8 +8,8 @@ function menu_install() {
// Create tables. // Create tables.
drupal_install_schema('menu'); 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 ('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 ('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')"); 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')");
} }
/** /**
......
This diff is collapsed.
...@@ -462,7 +462,7 @@ function system_admin_theme_submit($form, &$form_state) { ...@@ -462,7 +462,7 @@ function system_admin_theme_submit($form, &$form_state) {
} }
} }
/* /**
* Returns a fieldset containing the theme select form. * Returns a fieldset containing the theme select form.
* *
* @param $description * @param $description
......
...@@ -15,5 +15,5 @@ body { ...@@ -15,5 +15,5 @@ body {
#header img { #header img {
float: right; float: right;
padding: 0em 0em .5em 2em; padding: 0em 0em .5em 2em;
} }
...@@ -4,7 +4,7 @@ body { ...@@ -4,7 +4,7 @@ body {
padding: 5em 3em 0 0; padding: 5em 3em 0 0;
} }
/** /**
* Yes - right is on the left and left is on the right! * Yes - right is on the left and left is on the right!
* Welcome to design by tables.. * Welcome to design by tables..
*/ */
#sidebar-left { #sidebar-left {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment