diff options
Diffstat (limited to 'modules/menu')
-rw-r--r-- | modules/menu/menu.admin.inc | 1 | ||||
-rw-r--r-- | modules/menu/menu.admin.js | 1 | ||||
-rw-r--r-- | modules/menu/menu.api.php | 1 | ||||
-rw-r--r-- | modules/menu/menu.css | 1 | ||||
-rw-r--r-- | modules/menu/menu.info | 1 | ||||
-rw-r--r-- | modules/menu/menu.install | 1 | ||||
-rw-r--r-- | modules/menu/menu.js | 1 | ||||
-rw-r--r-- | modules/menu/menu.module | 34 | ||||
-rw-r--r-- | modules/menu/menu.test | 21 |
9 files changed, 40 insertions, 22 deletions
diff --git a/modules/menu/menu.admin.inc b/modules/menu/menu.admin.inc index 959c34982..1f3c4f728 100644 --- a/modules/menu/menu.admin.inc +++ b/modules/menu/menu.admin.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/menu/menu.admin.js b/modules/menu/menu.admin.js index 681c4814d..15bc2e7c7 100644 --- a/modules/menu/menu.admin.js +++ b/modules/menu/menu.admin.js @@ -1,4 +1,3 @@ -// $Id$ (function ($) { diff --git a/modules/menu/menu.api.php b/modules/menu/menu.api.php index 0abb1c546..3f3818e17 100644 --- a/modules/menu/menu.api.php +++ b/modules/menu/menu.api.php @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/menu/menu.css b/modules/menu/menu.css index 9b914d05c..96f861adb 100644 --- a/modules/menu/menu.css +++ b/modules/menu/menu.css @@ -1,4 +1,3 @@ -/* $Id$ */ .menu-operations { width: 100px; diff --git a/modules/menu/menu.info b/modules/menu/menu.info index 2d700e663..2219f6911 100644 --- a/modules/menu/menu.info +++ b/modules/menu/menu.info @@ -1,4 +1,3 @@ -; $Id$ name = Menu description = Allows administrators to customize the site navigation menu. package = Core diff --git a/modules/menu/menu.install b/modules/menu/menu.install index 1938a754f..05aed283f 100644 --- a/modules/menu/menu.install +++ b/modules/menu/menu.install @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/menu/menu.js b/modules/menu/menu.js index 8da220143..40c1bfe95 100644 --- a/modules/menu/menu.js +++ b/modules/menu/menu.js @@ -1,4 +1,3 @@ -// $Id$ (function ($) { diff --git a/modules/menu/menu.module b/modules/menu/menu.module index ded4bd21c..fc8f68a6c 100644 --- a/modules/menu/menu.module +++ b/modules/menu/menu.module @@ -1,9 +1,14 @@ <?php -// $Id$ /** * @file - * Allows administrators to customize the site navigation menu. + * Allows administrators to customize the site's navigation menus. + * + * A menu (in this context) is a hierarchical collection of links, generally + * used for navigation. This is not to be confused with the + * @link menu Menu system @endlink of menu.inc and hook_menu(), which defines + * page routing requests for Drupal, and also allows the defined page routing + * URLs to be added to the main site navigation menu. */ /** @@ -20,7 +25,7 @@ function menu_help($path, $arg) { case 'admin/help#menu': $output = ''; $output .= '<h3>' . t('About') . '</h3>'; - $output .= '<p>' . t('The Menu module provides an interface for managing menus. A menu is a hierarchical collection of links, which can be within or external to the site, generally used for navigation. Each menu is rendered in a block that can be enabled and positioned through the <a href="@blocks"">Blocks administration page</a>. You can view and manage menus on the <a href="@menus">Menus administration page</a>. For more information, see the online handbook entry for the <a href="@menu">Menu module</a>.', array('@blocks' => url('admin/structure/block'), '@menus' => url('admin/structure/menu'), '@menu' => 'http://drupal.org/handbook/modules/menu/')) . '</p>'; + $output .= '<p>' . t('The Menu module provides an interface for managing menus. A menu is a hierarchical collection of links, which can be within or external to the site, generally used for navigation. Each menu is rendered in a block that can be enabled and positioned through the <a href="@blocks">Blocks administration page</a>. You can view and manage menus on the <a href="@menus">Menus administration page</a>. For more information, see the online handbook entry for the <a href="@menu">Menu module</a>.', array('@blocks' => url('admin/structure/block'), '@menus' => url('admin/structure/menu'), '@menu' => 'http://drupal.org/handbook/modules/menu/')) . '</p>'; $output .= '<h3>' . t('Uses') . '</h3>'; $output .= '<dl>'; $output .= '<dt>' . t('Managing menus') . '</dt>'; @@ -352,7 +357,7 @@ function menu_parent_options($menus, $item) { /** * Page callback. - * Get all available menus and menu items as Javascript array. + * Get all the available menus and menu items as a JavaScript array. */ function menu_parent_options_js() { $available_menus = array(); @@ -535,18 +540,23 @@ function menu_node_delete($node) { function menu_node_prepare($node) { if (empty($node->menu)) { // Prepare the node for the edit form so that $node->menu always exists. - $menu_name = variable_get('menu_parent_' . $node->type, 'main-menu:0'); + $menu_name = strtok(variable_get('menu_parent_' . $node->type, 'main-menu:0'), ':'); $item = array(); if (isset($node->nid)) { + $mlid = FALSE; // Give priority to the default menu - $mlid = db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND menu_name = :menu_name AND module = 'menu' ORDER BY mlid ASC", 0, 1, array( - ':path' => 'node/' . $node->nid, - ':menu_name' => $menu_name, - ))->fetchField(); - // Check all menus if a link does not exist in the default menu. - if (!$mlid) { - $mlid = db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND module = 'menu' ORDER BY mlid ASC", 0, 1, array( + $type_menus = variable_get('menu_options_' . $node->type, array('main-menu' => 'main-menu')); + if (in_array($menu_name, $type_menus)) { + $mlid = db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND menu_name = :menu_name AND module = 'menu' ORDER BY mlid ASC", 0, 1, array( + ':path' => 'node/' . $node->nid, + ':menu_name' => $menu_name, + ))->fetchField(); + } + // Check all allowed menus if a link does not exist in the default menu. + if (!$mlid && !empty($type_menus)) { + $mlid = db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND module = 'menu' AND menu_name IN (:type_menus) ORDER BY mlid ASC", 0, 1, array( ':path' => 'node/' . $node->nid, + ':type_menus' => array_values($type_menus), ))->fetchField(); } if ($mlid) { diff --git a/modules/menu/menu.test b/modules/menu/menu.test index a90fbfb28..b457177cd 100644 --- a/modules/menu/menu.test +++ b/modules/menu/menu.test @@ -1,9 +1,8 @@ <?php -// $Id$ /** * @file - * Tests file for the menu module. + * Tests for menu.module. */ class MenuTestCase extends DrupalWebTestCase { @@ -380,7 +379,7 @@ class MenuTestCase extends DrupalWebTestCase { /** * Modify a menu link using the menu module UI. * - * @param array &$item Menu link passed by reference. + * @param array $item Menu link passed by reference. */ function modifyMenuLink(&$item) { $item['link_title'] = $this->randomName(16); @@ -665,5 +664,21 @@ class MenuNodeTestCase extends DrupalWebTestCase { // Assert that there is no link for the node. $this->drupalGet(''); $this->assertNoLink($node_title); + + // Add a menu link to the Management menu. + $item = array( + 'link_path' => 'node/' . $node->nid, + 'link_title' => $this->randomName(16), + 'menu_name' => 'management', + ); + menu_link_save($item); + + // Assert that disabled Management menu is not shown on the node/$nid/edit page. + $this->drupalGet('node/' . $node->nid . '/edit'); + $this->assertText('Provide a menu link', t('Link in not allowed menu not shown in node edit form')); + // Assert that the link is still in the management menu after save. + $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); + $link = menu_link_load($item['mlid']); + $this->assertTrue($link, t('Link in not allowed menu still exists after saving node')); } } |