diff options
Diffstat (limited to 'modules/menu')
-rw-r--r-- | modules/menu/menu.admin.inc | 45 | ||||
-rw-r--r-- | modules/menu/menu.install | 16 | ||||
-rw-r--r-- | modules/menu/menu.module | 31 |
3 files changed, 53 insertions, 39 deletions
diff --git a/modules/menu/menu.admin.inc b/modules/menu/menu.admin.inc index b12f78315..8c86033b5 100644 --- a/modules/menu/menu.admin.inc +++ b/modules/menu/menu.admin.inc @@ -173,7 +173,7 @@ function theme_menu_overview_form($form) { drupal_add_tabledrag('menu-overview', 'order', 'sibling', 'menu-weight'); $header = array( - t('Menu item'), + t('Menu link'), array('data' => t('Enabled'), 'class' => 'checkbox'), array('data' => t('Expanded'), 'class' => 'checkbox'), t('Weight'), @@ -293,27 +293,27 @@ function menu_edit_item(&$form_state, $type, $item, $menu) { '#type' => 'checkbox', '#title' => t('Enabled'), '#default_value' => !$item['hidden'], - '#description' => t('Menu items that are not enabled will not be listed in any menu.'), + '#description' => t('Menu links that are not enabled will not be listed in any menu.'), ); $form['menu']['expanded'] = array( '#type' => 'checkbox', '#title' => t('Expanded'), '#default_value' => $item['expanded'], - '#description' => t('If selected and this menu item has children, the menu will always appear expanded.'), + '#description' => t('If selected and this menu link has children, the menu will always appear expanded.'), ); // Generate a list of possible parents (not including this item or descendants). $options = menu_parent_options(menu_get_menus(), $item); $default = $item['menu_name'] . ':' . $item['plid']; if (!isset($options[$default])) { - $default = 'navigation:0'; + $default = 'main-menu:0'; } $form['menu']['parent'] = array( '#type' => 'select', - '#title' => t('Parent item'), + '#title' => t('Parent link'), '#default_value' => $default, '#options' => $options, - '#description' => t('The maximum depth for an item and all its children is fixed at !maxdepth. Some menu items may not be available as parents if selecting them would exceed this limit.', array('!maxdepth' => MENU_MAX_DEPTH)), + '#description' => t('The maximum depth for a link and all its children is fixed at !maxdepth. Some menu links may not be available as parents if selecting them would exceed this limit.', array('!maxdepth' => MENU_MAX_DEPTH)), '#attributes' => array('class' => 'menu-title-select'), ); $form['menu']['weight'] = array( @@ -386,13 +386,14 @@ function menu_edit_item_submit($form, &$form_state) { * Menu callback; Build the form that handles the adding/editing of a custom menu. */ function menu_edit_menu(&$form_state, $type, $menu = array()) { + $system_menus = menu_list_system_menus(); if ($type == 'edit') { $form['menu_name'] = array('#type' => 'value', '#value' => $menu['menu_name']); $form['#insert'] = FALSE; $form['delete'] = array( '#type' => 'submit', '#value' => t('Delete'), - '#access' => !in_array($menu['menu_name'], menu_list_system_menus()), + '#access' => !isset($system_menus[$menu['menu_name']]), '#submit' => array('menu_custom_delete_submit'), '#weight' => 10, ); @@ -409,12 +410,20 @@ function menu_edit_menu(&$form_state, $type, $menu = array()) { $form['#insert'] = TRUE; } $form['#title'] = $menu['title']; - $form['title'] = array( - '#type' => 'textfield', - '#title' => t('Title'), - '#default_value' => $menu['title'], - '#required' => TRUE, - ); + if (isset($system_menus[$menu['menu_name']])) { + $form['title'] = array( + '#type' => 'value', + '#value' => $menu['title'], + ); + } + else { + $form['title'] = array( + '#type' => 'textfield', + '#title' => t('Title'), + '#default_value' => $menu['title'], + '#required' => TRUE, + ); + } $form['description'] = array( '#type' => 'textarea', '#title' => t('Description'), @@ -440,7 +449,8 @@ function menu_custom_delete_submit($form, &$form_state) { */ function menu_delete_menu_page($menu) { // System-defined menus may not be deleted. - if (in_array($menu['menu_name'], menu_list_system_menus())) { + $system_menus = menu_list_system_menus(); + if (isset($system_menus[$menu['menu_name']])) { drupal_access_denied(); return; } @@ -468,7 +478,8 @@ function menu_delete_menu_confirm_submit($form, &$form_state) { $menu = $form['#menu']; $form_state['redirect'] = 'admin/build/menu'; // System-defined menus may not be deleted - only menus defined by this module. - if (in_array($menu['menu_name'], menu_list_system_menus()) || !db_result(db_query("SELECT COUNT(*) FROM {menu_custom} WHERE menu_name = '%s'", $menu['menu_name']))) { + $system_menus = menu_list_system_menus(); + if (isset($system_menus[$menu['menu_name']]) || !(db_query("SELECT 1 FROM {menu_custom} WHERE menu_name = :name", array('name' => $menu['menu_name']))->fetchField())) { return; } // Reset all the menu links defined by the system via hook_menu. @@ -618,7 +629,7 @@ function menu_configure() { $form['menu_main_links_source'] = array( '#type' => 'select', '#title' => t('Source for the Main links'), - '#default_value' => $main, + '#default_value' => 'main-menu', '#options' => $main_options, '#tree' => FALSE, '#description' => t('Select what should be displayed as the Main links (typically at the top of the page).'), @@ -628,7 +639,7 @@ function menu_configure() { $form["menu_secondary_links_source"] = array( '#type' => 'select', '#title' => t('Source for the Secondary links'), - '#default_value' => 'secondary-menu', + '#default_value' => 'user-menu', '#options' => $secondary_options, '#tree' => FALSE, '#description' => t("Select the source for the Secondary links. An advanced option allows you to use the same source for both Main links (currently %main) and Secondary links: if your source menu has two levels of hierarchy, the top level menu links will appear in the Main links, and the children of the active link will appear in the Secondary links." , array('%main' => $main_options[$main])), diff --git a/modules/menu/menu.install b/modules/menu/menu.install index 16b4792ef..a41f4e9e2 100644 --- a/modules/menu/menu.install +++ b/modules/menu/menu.install @@ -7,11 +7,19 @@ function menu_install() { // Create tables. drupal_install_schema('menu'); - + $system_menus = menu_list_system_menus(); + $descriptions = array( + 'navigation' => 'The <em>Navigation</em> menu contains links such as Recent posts (if the Tracker module is enabled). Non-administrative links are added to this menu by default by modules.', + 'user-menu' => "The <em>User menu</em> contains links to the user's account, and 'Log out' and is the source for the User links that may be displayed by the theme.", + 'management' => 'The <em>Management</em> menu contains links for content creation, site building, user management, and similar site activites.', + 'main-menu' => 'The <em>Main menu</em> is the default source for the Main links which are often used by themes to show the major sections of a site.', + 'secondary-menu' => 'The <em>Secondary menu</em> is the default source for the Secondary links which are often used for legal notices, contact details, and other navigation items that play a lesser role than the Main links.', + ); $t = get_t(); - db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", 'navigation', $t('Navigation'), $t('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 ('%s', '%s', '%s')", 'main-menu', $t('Main menu'), $t('The Main menu is often used by themes to show the major sections of a site.')); - db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", 'secondary-menu', $t('Secondary menu'), $t('The Secondary menu is often used for pages like legal notices, contact details, and other navigation items that play a lesser role than the Main menu.')); + $query = db_insert('menu_custom')->fields(array('menu_name', 'title', 'description')); + foreach ($system_menus as $menu_name => $title) { + $query->values(array('menu_name' => $menu_name, 'title' => $t($title), 'description' => $t($descriptions[$menu_name])))->execute(); + } } /** diff --git a/modules/menu/menu.module b/modules/menu/menu.module index 200dc6f0e..b85aae91e 100644 --- a/modules/menu/menu.module +++ b/modules/menu/menu.module @@ -18,18 +18,18 @@ define('MENU_MAX_MENU_NAME_LENGTH_UI', 27); function menu_help($path, $arg) { switch ($path) { case 'admin/help#menu': - $output = '<p>' . t("The menu module provides an interface to control and customize Drupal's powerful menu system. Menus are a hierarchical collection of links, or menu items, used to navigate a website, and are positioned and displayed using Drupal's flexible block system. By default, three menus are created during installation: <em>Navigation</em>, <em>Main menu</em>, and <em>Secondary menu</em>. The <em>Navigation</em> menu contains most links necessary for working with and navigating your site, and is often displayed in either the left or right sidebar. Most Drupal themes also provide support for the <em>Main menu</em> and <em>Secondary menu</em>, by displaying them in either the header or footer of each page. By default, the <em>Main menu</em> and <em>Secondary menu</em> contain no menu items but may be configured to contain custom menu items specific to your site.") . '</p>'; - $output .= '<p>' . t('The <a href="@menu">menus page</a> displays all menus currently available on your site. Select a menu from this list to add or edit a menu item, or to rearrange items within the menu. Create new menus using the <a href="@add-menu">add menu page</a> (the block containing a new menu must also be enabled on the <a href="@blocks">blocks administration page</a>).', array('@menu' => url('admin/build/menu'), '@add-menu' => url('admin/build/menu/add'), '@blocks' => url('admin/build/block'))) . '</p>'; + $output = '<p>' . t("The menu module provides an interface to control and customize Drupal's powerful menu system. Menus are a hierarchical collection of links used to navigate a website. Each menu is rendered in a block that may be positioned and displayed using Drupal's flexible block system. Five menus are provided by Drupal and are always present: <em>Navigation</em>, <em>Management</em>, <em>User menu</em>, <em>Main menu</em>, and <em>Secondary menu</em>. The <em>Management</em> menu contains links for administration and content creation, while the <em>Navigation</em> menu is the default location for site navigation links created by newly enabled modules. Both of these are often displayed in either the left or right sidebar. Most Drupal themes also provide support for the <em>Main links</em> and <em>Secondary links</em>, by displaying them in either the header or footer of each page. The <em>Main menu</em> is the default source for the <em>Main links</em> and the <em>User menu</em> is the default source for the <em>Secondary links</em>. By default, the <em>User menu</em> has links to take the current user to their account or allow them to log out, while the <em>Main menu</em> and <em>Secondary menu</em> contain no menu links but may be configured to contain custom menu items specific to your site. You may create an unlimited number of additional menus, each of which will automatically have an associated block.") . '</p>'; + $output .= '<p>' . t('The <a href="@menu">menus page</a> displays all menus currently available on your site. Select a menu from this list to add or edit a menu link, or to rearrange links within the menu. Create new menus using the <a href="@add-menu">add menu page</a> (the block containing a new menu must also be enabled on the <a href="@blocks">blocks administration page</a>).', array('@menu' => url('admin/build/menu'), '@add-menu' => url('admin/build/menu/add'), '@blocks' => url('admin/build/block'))) . '</p>'; $output .= '<p>' . t('For more information, see the online handbook entry for <a href="@menu">Menu module</a>.', array('@menu' => 'http://drupal.org/handbook/modules/menu/')) . '</p>'; return $output; case 'admin/build/menu': - return '<p>' . t('Menus are a collection of links (menu items) used to navigate a website. The menus currently available on your site are displayed below. Select a menu from this list to manage its menu items.') . '</p>'; + return '<p>' . t('Menus are a collection of links used to navigate a website. If the Block module is enabled, each menu has a corresponding block that is managed on the <a href="@blocks">blocks administration page</a>. Select an existing menu from this list to manage its menu links.', array('@blocks' => url('admin/build/block'))) . '</p>'; case 'admin/build/menu/add': return '<p>' . t('Enter the name for your new menu. Remember to enable the newly created block in the <a href="@blocks">blocks administration page</a>.', array('@blocks' => url('admin/build/block'))) . '</p>'; case 'admin/build/menu-customize/%': - return '<p>' . t('To rearrange menu items, grab a drag-and-drop handle under the <em>Menu item</em> column and drag the items (or group of items) to a new location in the list. (Grab a handle by clicking and holding the mouse while hovering over a handle icon.) Remember that your changes will not be saved until you click the <em>Save configuration</em> button at the bottom of the page.') . '</p>'; + return '<p>' . t('To rearrange menu links, grab a drag-and-drop handle under the <em>Menu link</em> column and drag the link (or group of links) to a new location in the list. (Grab a handle by clicking and holding the mouse while hovering over a handle icon.) Remember that your changes will not be saved until you click the <em>Save configuration</em> button at the bottom of the page.') . '</p>'; case 'admin/build/menu/item/add': - return '<p>' . t('Enter the title and path for your new menu item.') . '</p>'; + return '<p>' . t('Enter the title and path for your new menu link.') . '</p>'; } } @@ -86,12 +86,12 @@ function menu_menu() { 'type' => MENU_CALLBACK, ); $items['admin/build/menu-customize/%menu/list'] = array( - 'title' => 'List items', + 'title' => 'List links', 'weight' => -10, 'type' => MENU_DEFAULT_LOCAL_TASK, ); $items['admin/build/menu-customize/%menu/add'] = array( - 'title' => 'Add item', + 'title' => 'Add link', 'page callback' => 'drupal_get_form', 'page arguments' => array('menu_edit_item', 'add', NULL, 3), 'access arguments' => array('administer menu'), @@ -112,21 +112,21 @@ function menu_menu() { 'type' => MENU_CALLBACK, ); $items['admin/build/menu/item/%menu_link/edit'] = array( - 'title' => 'Edit menu item', + 'title' => 'Edit menu link', 'page callback' => 'drupal_get_form', 'page arguments' => array('menu_edit_item', 'edit', 4, NULL), 'access arguments' => array('administer menu'), 'type' => MENU_CALLBACK, ); $items['admin/build/menu/item/%menu_link/reset'] = array( - 'title' => 'Reset menu item', + 'title' => 'Reset menu link', 'page callback' => 'drupal_get_form', 'page arguments' => array('menu_reset_item_confirm', 4), 'access arguments' => array('administer menu'), 'type' => MENU_CALLBACK, ); $items['admin/build/menu/item/%menu_link/delete'] = array( - 'title' => 'Delete menu item', + 'title' => 'Delete menu link', 'page callback' => 'menu_item_delete_page', 'page arguments' => array(4), 'access arguments' => array('administer menu'), @@ -260,9 +260,7 @@ function menu_reset_item($item) { * Implementation of hook_block_list(). */ function menu_block_list() { - $menus = menu_get_menus(); - // The Navigation menu is handled by the user module. - unset($menus['navigation']); + $menus = menu_get_menus(FALSE); $blocks = array(); foreach ($menus as $name => $title) { @@ -279,10 +277,7 @@ function menu_block_list() { * Implementation of hook_block_view(). */ function menu_block_view($delta = '') { - $menus = menu_get_menus(); - // The Navigation menu is handled by the user module. - unset($menus['navigation']); - + $menus = menu_get_menus(FALSE); $data['subject'] = check_plain($menus[$delta]); $data['content'] = menu_tree($delta); return $data; @@ -469,7 +464,7 @@ function menu_node_form_submit($form, &$form_state) { * titles as the values. */ function menu_get_menus($all = TRUE) { - $system_menus = menu_list_system_menus(); + $system_menus = array_keys(menu_list_system_menus()); $query = db_select('menu_custom'); $query->addField('menu_custom', 'menu_name', 'menu_name'); $query->addField('menu_custom', 'title', 'title'); |