2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
$items[]=array('path'=>'admin/menu/item/add','title'=>t('add menu item'),
'callback'=>'menu_edit_item',
'access'=>user_access('administer menu'),
'type'=>MENU_LOCAL_TASK);
$items[]=array('path'=>'admin/settings/menu',
'title'=>t('menus'),
'callback'=>'menu_configure');
}
return$items;
}
/**
/**
* Implementation of hook_help().
* Implementation of hook_help().
*/
*/
functionmenu_help($section){
functionmenu_help($section){
switch($section){
switch($section){
case'admin/help#menu':
case'admin/help#menu':
$output=t('<p>The menu module allows for customization of the menus. Menus are useful for providing navigation in your site. The main menu for navigation is the navigation menu. Menus appear in blocks on your site.</p>
$output=t('<p>The menu module allows for customization of the menus. Menus are useful for providing navigation in your site. The main menu for navigation is the navigation menu. Menus appear in blocks on your site.</p>
<ul>
<ul>
<li>On the administer menu page administrators can \"edit\" to change the title, description, parent or weight of the menu item. Under the \"operations\" column, click on \"enable/disable\" to toggle the menu item on or off. Menu items which are disabled are not deleted; they are merely not available for navigating the site in the sidebar menu block. Note that the default menu items generated by the menu module cannot be deleted, only disabled.</li>
<li>On the administer menu page administrators can "edit" to change the title, description, parent or weight of the menu item. Under the "operations" column, click on "enable/disable" to toggle the menu item on or off. Menu items which are disabled are not deleted; they are merely not available for navigating the site in the sidebar menu block. Note that the default menu items generated by the menu module cannot be deleted, only disabled.</li>
<li>Using the \"add menu\" tab submit a title for a new custom menu. Once submitted, the new menu will appear in a list toward the bottom of the administer menu page underneath the main navigation menu.</li>
<li>Using the "add menu" tab submit a title for a new custom menu. Once submitted, the new menu will appear in a list toward the bottom of the administer menu page underneath the main navigation menu.</li>
<li>Use the \"add menu item\" tab to create new links in either the navigation or a custom menu. Select the parent item to place the new link within an existing menu structure. For top level menu items, choose the name of the menu in which the link is to be added.</li>
<li>Use the "add menu item" tab to create new links in either the navigation or a custom menu. Select the parent item to place the new link within an existing menu structure. For top level menu items, choose the name of the menu in which the link is to be added.</li>
<li>To turn off the navigation menu block, administer the block page.</li>
<li>To turn off the navigation menu block, administer the block page.</li>
</ul>
</ul>
');
');
...
@@ -89,67 +43,59 @@ function menu_help($section) {
...
@@ -89,67 +43,59 @@ function menu_help($section) {
}
}
}
}
/**
/**
* Menu callback; presents menu configuration options.
* Implementation of hook_menu().
*/
*/
functionmenu_configure(){
functionmenu_menu($may_cache){
$menu=menu_get_menu();
$items=array();
$root_menus=menu_get_root_menus();
$primary_options=$root_menus;
$primary_options[0]=t('No primary links');
$form['settings_links']=array(
'#type'=>'fieldset',
'#title'=>t('Primary links settings'),
);
$form['settings_links']['intro']=array(
'#type'=>'item',
'#value'=>t('Primary links is a navigation system which usually (depending on your theme) appears at the top-right of the browser window. There are usually two rows of links, primary and secondary. You may control which links appear in this area by choosing a menu from which the links will be generated and then placing your links into the menu using the <a href="%menu">menu administration</a> or the menu settings pane on each post authoring form.',array('%menu'=>url('admin/menu'))),
'#description'=>t('If you select the same menu as primary links then secondary links will display the appropriate second level of your navigation hierarchy.'),
);
$form['settings_authoring']=array(
'#type'=>'fieldset',
'#title'=>t('Post authoring form settings'),
);
$form['settings_authoring']['intro']=array(
if($may_cache){
'#type'=>'item',
$items[]=array('path'=>'admin/menu',
'#value'=>t('On each post authoring form there is a menu settings pane. This setting allows you to limit what is displayed in the parent item drop-down menu of that pane. This can be used to force new menu items to be created in the primary links menu or to hide admin menu items.'),
'#value'=>t('You may also <a href="%edit">edit the advanced settings</a> for this menu item.',array('%edit'=>url("admin/menu/item/edit/{$item['mid']}"))),
);
}
}
}
/**
* Menu callback; presents menu configuration options.
'#value'=>t('Primary and secondary links provide a navigational menu system which usually (depending on your theme) appears at the top-right of the browser window. The links displayed can be generated either from a custom list created via the <a href="%menu">menu administration</a> page or from a built-in list of menu items such as the navigation menu links.',array('%menu'=>url('admin/menu'))),
'#description'=>t('If you select the same menu as primary links then secondary links will display the appropriate second level of your navigation hierarchy.'),
'#value'=>t('The menu module allows on-the-fly creation of menu links in the post authoring forms. The following option limits the menus in which a new link may be added. For e.g. this can be used to force new menu items to be created in the primary links menu or to hide admin menu items.'),
t('Are you sure you want to reset the item %item to its default values?',array('%item'=>theme('placeholder',$title))),
'admin/menu',t('Any customizations will be lost. This action cannot be undone.'),
t('Reset'));
}
}
/**
* Menu callback; delete a single custom item.
*/
functionmenu_edit_item_delete($mid){
$op=isset($_POST['op'])?$_POST['op']:'';
$result=db_query('SELECT type, title FROM {menu} WHERE mid = %d',$mid);
$menu=db_fetch_object($result);
if(!$menu){
drupal_goto('admin/menu');
}
switch($op){
caset('Delete'):
menu_delete_item($mid);
if($menu->type&MENU_IS_ROOT){
drupal_set_message(t('The menu has been removed.'));
}
else{
drupal_set_message(t('The menu item has been removed.'));
}
drupal_goto('admin/menu');
break;
default:
if($menu->type&MENU_IS_ROOT){
$message=t('Are you sure you want to delete the menu %item?',array('%item'=>theme('placeholder',$menu->title)));
}
else{
$message=t('Are you sure you want to delete the custom menu item %item?',array('%item'=>theme('placeholder',$menu->title)));
}
returnconfirm_form('menu_confirm_delete',$form,$message,'admin/menu',t('This action cannot be undone.'),t('Delete'));
}
}
/**
* Menu callback; hide a menu item.
*/
functionmenu_disable_item($mid){
$item=menu_get_item($mid);
$type=$item['type'];
$type&=~MENU_VISIBLE_IN_TREE;
$type&=~MENU_VISIBLE_IN_BREADCRUMB;
$type|=MENU_MODIFIED_BY_ADMIN;
db_query('UPDATE {menu} SET type = %d WHERE mid = %d',$type,$mid);
drupal_set_message(t('The menu item has been disabled.'));
drupal_goto('admin/menu');
}
/**
/**
* Menu callback; dispatch to the appropriate menu item edit function.
* Menu callback; dispatch to the appropriate menu item edit function.
*/
*/
...
@@ -342,7 +346,7 @@ function menu_edit_item($mid = 0) {
...
@@ -342,7 +346,7 @@ function menu_edit_item($mid = 0) {
}
}
else{
else{
$edit['mid']=0;// In case a negative ID was passed in.
$edit['mid']=0;// In case a negative ID was passed in.
$edit['pid']=1;// default to "Navigation" menu.
$edit['pid']=1;// Default to "Navigation" menu.
$edit['type']=MENU_CUSTOM_ITEM;
$edit['type']=MENU_CUSTOM_ITEM;
}
}
$output.=menu_edit_item_form($edit);
$output.=menu_edit_item_form($edit);
...
@@ -357,32 +361,66 @@ function menu_edit_item($mid = 0) {
...
@@ -357,32 +361,66 @@ function menu_edit_item($mid = 0) {
functionmenu_edit_item_form($edit){
functionmenu_edit_item_form($edit){
if($edit['pid']==0){
if($edit['pid']==0){
// Display a limited set of fields for menus (not items).
// Display a limited set of fields for menus (not items).
$form['title']=array('#type'=>'textfield','#title'=>t('Title'),'#default_value'=>$edit['title'],'#description'=>t('The name of the menu.'),'#required'=>TRUE);
$form['title']=array('#type'=>'textfield','#title'=>t('Title'),'#default_value'=>$edit['title'],'#description'=>t('The name of the menu item.'),'#required'=>TRUE);
$form['title']=array('#type'=>'textfield',
$form['description']=array('#type'=>'textfield','#title'=>t('Description'),'#default_value'=>$edit['description'],'#description'=>t('The description displayed when hovering over a menu item.'));
'#title'=>t('Title'),
'#default_value'=>$edit['title'],
'#description'=>t('The name of the menu item.'),
'#required'=>TRUE,
);
$form['description']=array('#type'=>'textfield',
'#title'=>t('Description'),
'#default_value'=>$edit['description'],
'#description'=>t('The description displayed when hovering over a menu item.'),
);
$path_description=t('The Drupal path this menu item links to. Enter %front to link to the front page.',array('%front'=>theme('placeholder','<front>')));
$path_description=t('The Drupal path this menu item links to. Enter %front to link to the front page.',array('%front'=>theme('placeholder','<front>')));
$form['expanded']=array('#type'=>'checkbox','#title'=>t('Expanded'),'#default_value'=>$expanded,'#description'=>t('If selected and this menu item has children, the menu will always appear expanded.'));
$form['expanded']=array('#type'=>'checkbox',
'#title'=>t('Expanded'),
'#default_value'=>$expanded,
'#description'=>t('If selected and this menu item has children, the menu will always appear expanded.'),
);
// Generate a list of possible parents (not including this item or descendants).
// Generate a list of possible parents (not including this item or descendants).
$form['weight']=array('#type'=>'weight','#title'=>t('Weight'),'#default_value'=>$edit['weight'],'#description'=>t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'));
$form['weight']=array('#type'=>'weight',
'#title'=>t('Weight'),
'#default_value'=>$edit['weight'],
'#description'=>t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
'#value'=>t('You may also <a href="%edit">edit the advanced settings</a> for this menu item.',array('%edit'=>url("admin/menu/item/edit/{$item['mid']}"))),