Menu system


Menu flags

Flags for use in the "type" attribute of menu items.

enum  MENU_IS_ROOT
enum  MENU_VISIBLE_IN_TREE
enum  MENU_VISIBLE_IN_BREADCRUMB
enum  MENU_LINKS_TO_PARENT
enum  MENU_MODIFIED_BY_ADMIN
enum  MENU_CREATED_BY_ADMIN
enum  MENU_IS_LOCAL_TASK

Menu item types

End of "Menu flags".

Menu item definitions provide one of these constants, which are shortcuts for combinations of the above flags.

enum  MENU_NORMAL_ITEM
enum  MENU_CALLBACK
enum  MENU_SUGGESTED_ITEM
enum  MENU_LOCAL_TASK
enum  MENU_DEFAULT_LOCAL_TASK

Menu status codes

End of "Menu item types".

Status codes for menu callbacks.

enum  MENU_FOUND
enum  MENU_NOT_FOUND
enum  MENU_ACCESS_DENIED
enum  MENU_SITE_OFFLINE
enum  MENU_MAX_PARTS
enum  MENU_MAX_DEPTH

Functions

 menu_get_ancestors ($parts)
 menu_unserialize ($data, $map)
 menu_set_item ($path, $router_item)
 menu_get_item ($path=NULL, $router_item=NULL)
 menu_execute_active_handler ($path=NULL)
 _menu_load_objects (&$item, &$map)
 _menu_check_access (&$item, $map)
 _menu_item_localize (&$item, $map, $link_translate=FALSE)
 _menu_translate (&$router_item, $map, $to_arg=FALSE)
 _menu_link_map_translate (&$map, $to_arg_functions)
 menu_tail_to_arg ($arg, $map, $index)
 _menu_link_translate (&$item)
 menu_get_object ($type= 'node', $position=1, $path=NULL)
 menu_tree ($menu_name= 'navigation')
 menu_tree_output ($tree)
 menu_tree_all_data ($menu_name= 'navigation', $item=NULL)
 menu_tree_page_data ($menu_name= 'navigation')
 _menu_tree_cid ($menu_name, $data)
 menu_tree_collect_node_links (&$tree, &$node_links)
 menu_tree_check_access (&$tree, $node_links=array())
 _menu_tree_check_access (&$tree)
 menu_tree_data ($result=NULL, $parents=array(), $depth=1)
 _menu_tree_data ($result, $parents, $depth, $previous_element= '')
 drupal_help_arg ($arg=array())
 menu_get_active_help ()
 menu_get_names ($reset=FALSE)
 menu_list_system_menus ()
 menu_primary_links ()
 menu_secondary_links ()
 menu_navigation_links ($menu_name, $level=0)
 menu_local_tasks ($level=0, $return_root=FALSE)
 menu_primary_local_tasks ()
 menu_secondary_local_tasks ()
 menu_tab_root_path ()
 menu_set_active_menu_name ($menu_name=NULL)
 menu_get_active_menu_name ()
 menu_set_active_item ($path)
 menu_set_active_trail ($new_trail=NULL)
 menu_get_active_trail ()
 menu_get_active_breadcrumb ()
 menu_get_active_title ()
 menu_link_load ($mlid)
 menu_cache_clear ($menu_name= 'navigation')
 menu_cache_clear_all ()
 menu_rebuild ()
 menu_router_build ($reset=FALSE)
 _menu_link_build ($item)
 _menu_navigation_links_rebuild ($menu)
 menu_link_delete ($mlid, $path=NULL)
 _menu_delete_item ($item, $force=FALSE)
 menu_link_save (&$item)
 _menu_clear_page_cache ()
 _menu_set_expanded_menus ()
 _menu_find_router_path ($menu, $link_path)
 menu_link_maintain ($module, $op, $link_path, $link_title)
 menu_link_children_relative_depth ($item)
 _menu_link_move_children ($item, $existing_item)
 _menu_update_parental_status ($item, $exclude=FALSE)
 _menu_link_parents_set (&$item, $parent)
 _menu_router_build ($callbacks)
 menu_path_is_external ($path)
 _menu_site_is_offline ()
 menu_valid_path ($form_item)

Detailed Description

Define the navigation menus, and route page requests to code based on URLs.

The Drupal menu system drives both the navigation system from a user perspective and the callback system that Drupal uses to respond to URLs passed from the browser. For this reason, a good understanding of the menu system is fundamental to the creation of complex modules.

Drupal's menu system follows a simple hierarchy defined by paths. Implementations of hook_menu() define menu items and assign them to paths (which should be unique). The menu system aggregates these items and determines the menu hierarchy from the paths. For example, if the paths defined were a, a/b, e, a/b/c/d, f/g, and a/b/h, the menu system would form the structure:

When responding to a page request, the menu system looks to see if the path requested by the browser is registered as a menu item with a callback. If not, the system searches up the menu tree for the most complete match with a callback it can find. If the path a/b/i is requested in the tree above, the callback for a/b would be used.

The found callback function is called with any arguments specified in the "page arguments" attribute of its menu item. The attribute must be an array. After these arguments, any remaining components of the path are appended as further arguments. In this way, the callback for a/b above could respond to a request for a/b/i differently than a request for a/b/j.

For an illustration of this process, see page_example.module.

Access to the callback functions is also protected by the menu system. The "access callback" with an optional "access arguments" of each menu item is called before the page callback proceeds. If this returns TRUE, then access is granted; if FALSE, then access is denied. Menu items may omit this attribute to use the value provided by an ancestor item.

In the default Drupal interface, you will notice many links rendered as tabs. These are known in the menu system as "local tasks", and they are rendered as tabs by default, though other presentations are possible. Local tasks function just as other menu items in most respects. It is convention that the names of these tasks should be short verbs if possible. In addition, a "default" local task should be provided for each set. When visiting a local task's parent menu item, the default local task will be rendered as if it is selected; this provides for a normal tab user experience. This default task is special in that it links not to its provided path, but to its parent item's path instead. The default task's path is only used to place it appropriately in the menu hierarchy.

Everything described so far is stored in the menu_router table. The menu_links table holds the visible menu links. By default these are derived from the same hook_menu definitions, however you are free to add more with menu_link_save().


Enumeration Type Documentation

Internal menu status code -- Menu item access is denied.

Definition at line 193 of file menu.inc.

Menu type -- A hidden, internal callback, typically used for API calls.

Callbacks simply register a path so that the correct function is fired when the URL is accessed. They are not shown in the menu.

Definition at line 141 of file menu.inc.

Internal menu flag -- menu item was created by administrator.

Definition at line 108 of file menu.inc.

Menu type -- The "default" local task, which is initially active.

Every set of local tasks should provide one "default" task, that links to the same path as its parent when clicked.

Definition at line 168 of file menu.inc.

enum MENU_FOUND

Internal menu status code -- Menu item was found.

Definition at line 183 of file menu.inc.

Internal menu flag -- menu item is a local task.

Definition at line 113 of file menu.inc.

Internal menu flag -- menu item is the root of the menu tree.

Definition at line 83 of file menu.inc.

Internal menu flag -- menu item links back to its parnet.

Definition at line 98 of file menu.inc.

Menu type -- A task specific to the parent item, usually rendered as a tab.

Local tasks are menu items that describe actions to be performed on their parent item. An example is the path "node/52/edit", which performs the "edit" task on "node/52".

Definition at line 160 of file menu.inc.

The maximum depth of a menu links tree - matches the number of p columns.

Definition at line 219 of file menu.inc.

End of "Menu status codes". Menu tree parameters

Menu tree The maximum number of path elements for a menu callback

Definition at line 213 of file menu.inc.

Internal menu flag -- menu item can be modified by administrator.

Definition at line 103 of file menu.inc.

Menu type -- A "normal" menu item that's shown in menu and breadcrumbs.

Normal menu items show up in the menu tree and can be moved/hidden by the administrator. Use this for most menu items. It is the default value if no menu item type is specified.

Definition at line 133 of file menu.inc.

Internal menu status code -- Menu item was not found.

Definition at line 188 of file menu.inc.

Internal menu status code -- Menu item inaccessible because site is offline.

Definition at line 198 of file menu.inc.

Menu type -- A normal menu item, hidden until enabled by an administrator.

Modules may "suggest" menu items that the administrator may enable. They act just as callbacks do until enabled, at which time they act like normal items. Note for the value: 0x0010 was a flag which is no longer used, but this way the values of MENU_CALLBACK and MENU_SUGGESTED_ITEM are separate.

Definition at line 151 of file menu.inc.

Internal menu flag -- menu item is visible in the breadcrumb.

Definition at line 93 of file menu.inc.

Internal menu flag -- menu item is visible in the menu tree.

Definition at line 88 of file menu.inc.


Function Documentation

_menu_check_access ( &$  item,
map 
)

Check access to a menu item using the access callback

Parameters:
$item A menu router or menu link item
$map An array of path arguments (ex: array('node', '5'))
Returns:
$item['access'] becomes TRUE if the item is accessible, FALSE otherwise.

Definition at line 486 of file menu.inc.

References menu_unserialize().

Referenced by _menu_link_translate(), and _menu_translate().

Here is the call graph for this function:

_menu_clear_page_cache (  ) 

Helper function to clear the page and block caches at most twice per page load.

Definition at line 2023 of file menu.inc.

References _menu_set_expanded_menus(), and cache_clear_all().

Referenced by _menu_delete_item(), menu_link_save(), and menu_rebuild().

Here is the call graph for this function:

_menu_delete_item ( item,
force = FALSE 
)

Helper function for menu_link_delete; deletes a single menu link.

Parameters:
$item Item to be deleted.
$force Forces deletion. Internal use only, setting to TRUE is discouraged.

Definition at line 1842 of file menu.inc.

References $result, _menu_clear_page_cache(), _menu_update_parental_status(), db_fetch_array(), db_query(), menu_cache_clear(), menu_link_load(), and menu_link_save().

Referenced by _menu_navigation_links_rebuild(), drupal_uninstall_module(), and menu_link_delete().

Here is the call graph for this function:

_menu_find_router_path ( menu,
link_path 
)

Find the router path which will serve this path.

Parameters:
$menu The full built menu.
$link_path The path for we are looking up its router path.
Returns:
A path from $menu keys or empty if $link_path points to a nonexisting place.

Definition at line 2065 of file menu.inc.

References menu_get_ancestors().

Referenced by _menu_navigation_links_rebuild(), and menu_link_save().

Here is the call graph for this function:

_menu_item_localize ( &$  item,
map,
link_translate = FALSE 
)

Localize the router item title using t() or another callback.

Translate the title and description to allow storage of English title strings in the database, yet display of them in the language required by the current user.

Parameters:
$item A menu router item or a menu link item.
$map The path as an array with objects already replaced. E.g., for path node/123 $map would be array('node', $node) where $node is the node object for node 123.
$link_translate TRUE if we are translating a menu link item; FALSE if we are translating a menu router item.
Returns:
No return value. $item['title'] is localized according to $item['title_callback']. If an item's callback is check_plain(), $item['options']['html'] becomes TRUE. $item['description'] is translated using t(). When doing link translation and the $item['options']['attributes']['title'] (link title attribute) matches the description, it is translated as well.

Definition at line 532 of file menu.inc.

References menu_unserialize(), and t().

Referenced by _menu_link_translate(), and _menu_translate().

Here is the call graph for this function:

_menu_link_build ( item  ) 

Builds a link from a router item.

Definition at line 1741 of file menu.inc.

Referenced by _menu_navigation_links_rebuild().

_menu_link_map_translate ( &$  map,
to_arg_functions 
)

This function translates the path elements in the map using any to_arg helper function. These functions take an argument and return an object. See for more information.

Parameters:
map An array of path arguments (ex: array('node', '5'))
$to_arg_functions An array of helper function (ex: array(2 => 'menu_tail_to_arg'))

Definition at line 641 of file menu.inc.

Referenced by _menu_link_translate(), and _menu_translate().

_menu_link_move_children ( item,
existing_item 
)

Update the children of a menu link that's being moved.

The menu name, parents (p1 - p6), and depth are updated for all children of the link, and the has_children status of the previous parent is updated.

Definition at line 2149 of file menu.inc.

References _menu_update_parental_status(), and db_query().

Referenced by menu_link_save().

Here is the call graph for this function:

_menu_link_parents_set ( &$  item,
parent 
)

Helper function that sets the p1..p9 values for a menu link being saved.

Definition at line 2214 of file menu.inc.

Referenced by menu_link_save().

_menu_link_translate ( &$  item  ) 

This function is similar to _menu_translate() but does link-specific preparation such as always calling to_arg functions

Parameters:
$item A menu link
Returns:
Returns the map of path arguments with objects loaded as defined in the $item['load_functions']. $item['access'] becomes TRUE if the item is accessible, FALSE otherwise. $item['href'] is generated from link_path, possibly by to_arg functions. $item['title'] is generated from link_title, and may be localized. $item['options'] is unserialized; it is also changed within the call here to $item['localized_options'] by _menu_item_localize().

Definition at line 676 of file menu.inc.

References _menu_check_access(), _menu_item_localize(), _menu_link_map_translate(), _menu_load_objects(), and drupal_alter().

Referenced by _menu_tree_check_access(), menu_link_load(), menu_valid_path(), and system_main_admin_page().

Here is the call graph for this function:

_menu_load_objects ( &$  item,
&$  map 
)

Loads objects into the map as defined in the $item['load_functions'].

Parameters:
$item A menu router or menu link item
$map An array of path arguments (ex: array('node', '5'))
Returns:
Returns TRUE for success, FALSE if an object cannot be loaded. Names of object loading functions are placed in $item['load_functions']. Loaded objects are placed in $map[]; keys are the same as keys in the $item['load_functions'] array. $item['access'] is set to FALSE if an object cannot be loaded.

Definition at line 421 of file menu.inc.

References $return, and $value.

Referenced by _menu_link_translate(), and _menu_translate().

_menu_navigation_links_rebuild ( menu  ) 

Helper function to build menu links for the items in the menu router.

Definition at line 1764 of file menu.inc.

References $result, _menu_delete_item(), _menu_find_router_path(), _menu_link_build(), db_fetch_array(), db_placeholders(), db_query(), and menu_link_save().

Referenced by menu_rebuild().

Here is the call graph for this function:

_menu_router_build ( callbacks  ) 

Helper function to build the router table based on the data from hook_menu.

Definition at line 2232 of file menu.inc.

References db_query(), drupal_function_exists(), and variable_set().

Referenced by menu_router_build().

Here is the call graph for this function:

_menu_set_expanded_menus (  ) 

Helper function to update a list of menus with expanded items

Definition at line 2045 of file menu.inc.

References $result, db_fetch_array(), db_query(), and variable_set().

Referenced by _menu_clear_page_cache().

Here is the call graph for this function:

_menu_site_is_offline (  ) 

Checks whether the site is off-line for maintenance.

This function will log the current user out and redirect to front page if the current user has no 'administer site configuration' permission.

Returns:
FALSE if the site is not off-line or its the login page or the user has 'administer site configuration' permission. TRUE for anonymous users not on the login page if the site is off-line.

Definition at line 2421 of file menu.inc.

References drupal_get_normal_path(), drupal_get_path(), drupal_set_message(), t(), user_logout(), and variable_get().

Referenced by menu_execute_active_handler().

Here is the call graph for this function:

_menu_translate ( &$  router_item,
map,
to_arg = FALSE 
)

Handles dynamic path translation and menu access control.

When a user arrives on a page such as node/5, this function determines what "5" corresponds to, by inspecting the page's menu path definition, node/node. This will call node_load(5) to load the corresponding node object.

It also works in reverse, to allow the display of tabs and menu items which contain these dynamic arguments, translating node/node to node/5.

Translation of menu item titles and descriptions are done here to allow for storage of English strings in the database, and translation to the language required to generate the current page

Parameters:
$router_item A menu router item
$map An array of path arguments (ex: array('node', '5'))
$to_arg Execute $item['to_arg_functions'] or not. Use only if you want to render a path from the menu table, for example tabs.
Returns:
Returns the map with objects loaded as defined in the $item['load_functions. $item['access'] becomes TRUE if the item is accessible, FALSE otherwise. $item['href'] is set according to the map. If an error occurs during calling the load_functions (like trying to load a non existing node) then this function return FALSE.

Definition at line 604 of file menu.inc.

References _menu_check_access(), _menu_item_localize(), _menu_link_map_translate(), and _menu_load_objects().

Referenced by menu_get_item(), and menu_local_tasks().

Here is the call graph for this function:

_menu_tree_check_access ( &$  tree  ) 

Recursive helper function for menu_tree_check_access()

Definition at line 1048 of file menu.inc.

References _menu_link_translate().

Referenced by menu_tree_check_access().

Here is the call graph for this function:

_menu_tree_cid ( menu_name,
data 
)

Helper function - compute the real cache ID for menu tree data.

Definition at line 1002 of file menu.inc.

Referenced by menu_tree_all_data(), and menu_tree_page_data().

_menu_tree_data ( result,
parents,
depth,
previous_element = '' 
)

Recursive helper function to build the data representing a menu tree.

The function is a bit complex because the rendering of an item depends on the next menu item. So we are always rendering the element previously processed not the current one.

Definition at line 1093 of file menu.inc.

References $depth, $result, and db_fetch_array().

Referenced by menu_tree_data().

Here is the call graph for this function:

_menu_update_parental_status ( item,
exclude = FALSE 
)

Check and update the has_children status for the parent of a link.

Definition at line 2200 of file menu.inc.

References db_query(), db_query_range(), and db_result().

Referenced by _menu_delete_item(), _menu_link_move_children(), and menu_link_save().

Here is the call graph for this function:

drupal_help_arg ( arg = array()  ) 

Generates elements for the $arg array in the help hook.

Definition at line 1198 of file menu.inc.

Referenced by help_links_as_list(), help_page(), menu_get_active_help(), search_view(), system_admin_by_module(), and system_modules().

menu_cache_clear ( menu_name = 'navigation'  ) 

Clears the cached cached data for a single named menu.

Definition at line 1662 of file menu.inc.

References cache_clear_all().

Referenced by _menu_delete_item(), menu_link_maintain(), and menu_link_save().

Here is the call graph for this function:

menu_cache_clear_all (  ) 

Clears all cached menu data. This should be called any time broad changes might have been made to the router items or menu links.

Definition at line 1679 of file menu.inc.

References cache_clear_all().

Referenced by menu_delete_menu_confirm_submit(), and menu_rebuild().

Here is the call graph for this function:

menu_execute_active_handler ( path = NULL  ) 

Execute the page callback associated with the current path

Definition at line 386 of file menu.inc.

References _menu_site_is_offline(), drupal_function_exists(), menu_get_item(), menu_rebuild(), registry_load_path_files(), and variable_get().

Referenced by drupal_access_denied(), drupal_not_found(), and user_page().

Here is the call graph for this function:

menu_get_active_breadcrumb (  ) 

Get the breadcrumb for the current page, as determined by the active trail.

Definition at line 1600 of file menu.inc.

References drupal_is_front_page(), l(), menu_get_active_trail(), and menu_get_item().

Referenced by drupal_get_breadcrumb().

Here is the call graph for this function:

menu_get_active_help (  ) 

Returns the help associated with the active menu item.

Definition at line 1206 of file menu.inc.

References $name, $output, arg(), drupal_help_arg(), menu_tab_root_path(), module_exists(), module_hook(), module_invoke(), module_list(), theme(), and url().

Referenced by theme_help().

Here is the call graph for this function:

menu_get_active_menu_name (  ) 

Get the active menu for the current page - determines the active trail.

Definition at line 1509 of file menu.inc.

References menu_set_active_menu_name().

Referenced by menu_set_active_trail().

Here is the call graph for this function:

menu_get_active_title (  ) 

Get the title of the current page, as determined by the active trail.

Definition at line 1628 of file menu.inc.

References menu_get_active_trail().

Referenced by drupal_get_title().

Here is the call graph for this function:

menu_get_active_trail (  ) 

Get the active trail for the current page - the path to root in the menu tree.

Definition at line 1593 of file menu.inc.

References menu_set_active_trail().

Referenced by menu_get_active_breadcrumb(), and menu_get_active_title().

Here is the call graph for this function:

menu_get_ancestors ( parts  ) 

End of "Menu tree parameters". Returns the ancestors (and relevant placeholders) for any given path.

For example, the ancestors of node/12345/edit are:

  • node/12345/edit
  • node/12345/%
  • node//edit
  • node//%
  • node/12345
  • node/%
  • node

To generate these, we will use binary numbers. Each bit represents a part of the path. If the bit is 1, then it represents the original value while 0 means wildcard. If the path is node/12/edit/foo then the 1011 bitstring represents node//edit/foo where % means that any argument matches that part. We limit ourselves to using binary numbers that correspond the patterns of wildcards of router items that actually exists. This list of 'masks' is built in menu_rebuild().

Parameters:
$parts An array of path parts, for the above example array('node', '12345', 'edit').
Returns:
An array which contains the ancestors and placeholders. Placeholders simply contain as many 's' as the ancestors.

Definition at line 253 of file menu.inc.

References variable_get().

Referenced by _menu_find_router_path(), and menu_get_item().

Here is the call graph for this function:

menu_get_item ( path = NULL,
router_item = NULL 
)

Get a router item.

Parameters:
$path The path, for example node/5. The function will find the corresponding node/% item and return that.
$router_item Internal use only.
Returns:
The router item, an associate array corresponding to one row in the menu_router table. The value of key map holds the loaded objects. The value of key access is TRUE if the current user can access this page. The values for key title, page_arguments, access_arguments will be filled in based on the database values and the objects loaded.

Definition at line 354 of file menu.inc.

References _menu_translate(), arg(), db_fetch_array(), db_query_range(), menu_get_ancestors(), and menu_unserialize().

Referenced by menu_execute_active_handler(), menu_get_active_breadcrumb(), menu_get_object(), menu_local_tasks(), menu_set_active_trail(), menu_set_item(), menu_tree_page_data(), menu_valid_path(), node_add_page(), path_admin_form_validate(), registry_cache_path_files(), registry_load_path_files(), system_admin_menu_block_page(), system_logging_overview(), and system_settings_overview().

Here is the call graph for this function:

menu_get_names ( reset = FALSE  ) 

Build a list of named menus.

Definition at line 1232 of file menu.inc.

References $name, $result, db_fetch_array(), and db_query().

Here is the call graph for this function:

menu_get_object ( type = 'node',
position = 1,
path = NULL 
)

Get a loaded object from a router item.

menu_get_object() will provide you the current node on paths like node/5, node/5/revisions/48 etc. menu_get_object('user') will give you the user account on user/5 etc. Note - this function should never be called within a _to_arg function (like user_current_to_arg()) since this may result in an infinite recursion.

Parameters:
$type Type of the object. These appear in hook_menu definitons as type. Core provides aggregator_feed, aggregator_category, contact, filter_format, forum_term, menu, menu_link, node, taxonomy_vocabulary, user. See the relevant {$type}_load function for more on each. Defaults to node.
$position The expected position for $type object. For node/node this is 1, for comment/reply/node this is 2. Defaults to 1.
$path See menu_get_item() for more on this. Defaults to the current path.

Definition at line 738 of file menu.inc.

References $type, and menu_get_item().

Referenced by template_preprocess_page().

Here is the call graph for this function:

menu_link_children_relative_depth ( item  ) 

Find the depth of an item's children relative to its depth.

For example, if the item has a depth of 2, and the maximum of any child in the menu link tree is 5, the relative depth is 3.

Parameters:
$item An array representing a menu link item.
Returns:
The relative depth, or zero.

Definition at line 2127 of file menu.inc.

References db_query_range(), and db_result().

Referenced by menu_link_save().

Here is the call graph for this function:

menu_link_delete ( mlid,
path = NULL 
)

Delete one or several menu links.

Parameters:
$mlid A valid menu link mlid or NULL. If NULL, $path is used.
$path The path to the menu items to be deleted. $mlid must be NULL.

Definition at line 1822 of file menu.inc.

References $result, _menu_delete_item(), db_fetch_array(), and db_query().

Referenced by book_remove_form_submit(), menu_delete_menu_confirm_submit(), menu_item_delete_form_submit(), and menu_link_maintain().

Here is the call graph for this function:

menu_link_load ( mlid  ) 

Get a menu link by its mlid, access checked and link translated for rendering.

This function should never be called from within node_load() or any other function used as a menu object load function since an infinite recursion may occur.

Parameters:
$mlid The mlid of the menu item.
Returns:
A menu link, with $item['access'] filled and link translated for rendering.

Definition at line 1651 of file menu.inc.

References _menu_link_translate(), db_fetch_array(), and db_query().

Referenced by _menu_delete_item(), and menu_edit_menu_submit().

Here is the call graph for this function:

menu_link_maintain ( module,
op,
link_path,
link_title 
)

Insert, update or delete an uncustomized menu link related to a module.

Parameters:
$module The name of the module.
$op Operation to perform: insert, update or delete.
$link_path The path this link points to.
$link_title Title of the link to insert or new title to update the link to. Unused for delete.
Returns:
The insert op returns the mlid of the new item. Others op return NULL.

Definition at line 2095 of file menu.inc.

References $op, db_query(), menu_cache_clear(), menu_link_delete(), and menu_link_save().

Here is the call graph for this function:

menu_link_save ( &$  item  ) 

Save a menu link.

Parameters:
$item An array representing a menu link item. The only mandatory keys are link_path and link_title. Possible keys are:
  • menu_name default is navigation
  • weight default is 0
  • expanded whether the item is expanded.
  • options An array of options,
See also:
l for more.
  • mlid Set to an existing value, or 0 or NULL to insert a new link.
  • plid The mlid of the parent.
  • router_path The path of the relevant router item.

Definition at line 1876 of file menu.inc.

References $result, _menu_clear_page_cache(), _menu_find_router_path(), _menu_link_move_children(), _menu_link_parents_set(), _menu_update_parental_status(), db_fetch_array(), db_last_insert_id(), db_query(), db_result(), drupal_alter(), menu_cache_clear(), menu_link_children_relative_depth(), menu_path_is_external(), and menu_router_build().

Referenced by _menu_delete_item(), _menu_navigation_links_rebuild(), book_admin_edit_submit(), menu_edit_item_submit(), menu_edit_menu_submit(), menu_link_maintain(), and menu_overview_form_submit().

Here is the call graph for this function:

menu_list_system_menus (  ) 

Return an array containing the names of system-defined (default) menus.

Definition at line 1248 of file menu.inc.

Referenced by menu_delete_menu_confirm_submit(), menu_delete_menu_page(), and menu_edit_menu().

menu_local_tasks ( level = 0,
return_root = FALSE 
)

Collects the local tasks (tabs) for a given level.

Parameters:
$level The level of tasks you ask for. Primary tasks are 0, secondary are 1.
$return_root Whether to return the root path for the current page.
Returns:
Themed output corresponding to the tabs of the requested level, or router path if $return_root == TRUE. This router path corresponds to a parent tab, if the current page is a default local task.

Definition at line 1334 of file menu.inc.

References $children, $depth, $result, _menu_translate(), arg(), db_fetch_array(), db_query(), menu_get_item(), and theme().

Referenced by menu_primary_local_tasks(), menu_secondary_local_tasks(), and menu_tab_root_path().

Here is the call graph for this function:

menu_navigation_links ( menu_name,
level = 0 
)

Return an array of links for a navigation menu.

Parameters:
$menu_name The name of the menu.
$level Optional, the depth of the menu to be returned.
Returns:
An array of links of the specified menu and level.

Definition at line 1284 of file menu.inc.

References $links, and menu_tree_page_data().

Referenced by menu_primary_links(), and menu_secondary_links().

Here is the call graph for this function:

menu_path_is_external ( path  ) 

Returns TRUE if a path is external (e.g. ).

Definition at line 2405 of file menu.inc.

References check_plain().

Referenced by menu_edit_item_validate(), menu_link_save(), and menu_valid_path().

Here is the call graph for this function:

menu_primary_links (  ) 

Return an array of links to be rendered as the Primary links.

Definition at line 1255 of file menu.inc.

References menu_navigation_links(), and variable_get().

Referenced by template_preprocess_page().

Here is the call graph for this function:

menu_primary_local_tasks (  ) 

Returns the rendered local tasks at the top level.

Definition at line 1455 of file menu.inc.

References menu_local_tasks().

Referenced by garland_menu_local_tasks(), and theme_menu_local_tasks().

Here is the call graph for this function:

menu_rebuild (  ) 

(Re)populate the database tables used by various menu functions.

This function will clear and populate the {menu_router} table, add entries to {menu_links} for new router items, then remove stale items from {menu_links}. If called from update.php or install.php, it will also schedule a call to itself on the first real page load from menu_execute_active_handler(), because the maintenance page environment is different and leaves stale data in the menu tables.

Definition at line 1693 of file menu.inc.

References _menu_clear_page_cache(), _menu_navigation_links_rebuild(), menu_cache_clear_all(), menu_router_build(), variable_del(), and variable_set().

Referenced by _locale_import_po(), drupal_flush_all_caches(), DrupalWebTestCase::drupalModuleDisable(), DrupalWebTestCase::drupalModuleEnable(), install_tasks(), menu_execute_active_handler(), node_type_delete_confirm_submit(), node_type_form_submit(), profile_admin_overview_submit(), profile_field_form_submit(), DrupalWebTestCase::setUp(), system_modules(), and system_themes_form_submit().

Here is the call graph for this function:

menu_router_build ( reset = FALSE  ) 

Collect, alter and store the menu definitions.

Definition at line 1708 of file menu.inc.

References _menu_router_build(), cache_get(), cache_set(), db_query(), drupal_alter(), and module_implements().

Referenced by menu_link_save(), and menu_rebuild().

Here is the call graph for this function:

menu_secondary_links (  ) 

Return an array of links to be rendered as the Secondary links.

Definition at line 1262 of file menu.inc.

References menu_navigation_links(), and variable_get().

Referenced by template_preprocess_page().

Here is the call graph for this function:

menu_secondary_local_tasks (  ) 

Returns the rendered local tasks at the second level.

Definition at line 1462 of file menu.inc.

References menu_local_tasks().

Referenced by garland_preprocess_page(), and theme_menu_local_tasks().

Here is the call graph for this function:

menu_set_active_item ( path  ) 

Set the active path, which determines which page is loaded.

Parameters:
$path A Drupal path - not a path alias.
Note that this may not have the desired effect unless invoked very early in the page load, such as during hook_boot, or unless you call menu_execute_active_handler() to generate your page output.

Definition at line 1523 of file menu.inc.

Referenced by drupal_access_denied(), drupal_not_found(), and user_page().

menu_set_active_menu_name ( menu_name = NULL  ) 

Set (or get) the active menu for the current page - determines the active trail.

Definition at line 1494 of file menu.inc.

Referenced by menu_get_active_menu_name().

menu_set_active_trail ( new_trail = NULL  ) 

Set (or get) the active trail for the current page - the path to root in the menu tree.

Definition at line 1530 of file menu.inc.

References arg(), drupal_is_front_page(), menu_get_active_menu_name(), menu_get_item(), menu_tree_page_data(), and t().

Referenced by menu_get_active_trail().

Here is the call graph for this function:

menu_set_item ( path,
router_item 
)

Replaces the statically cached item for a given path.

Parameters:
$path The path.
$router_item The router item. Usually you take a router entry from menu_get_item and set it back either modified or to a different path. This lets you modify the navigation block, the page title, the breadcrumb and the page help in one call.

Definition at line 335 of file menu.inc.

References menu_get_item().

Here is the call graph for this function:

menu_tab_root_path (  ) 

Returns the router path, or the path of the parent tab of a default local task.

Definition at line 1469 of file menu.inc.

References menu_local_tasks().

Referenced by menu_get_active_help().

Here is the call graph for this function:

menu_tail_to_arg ( arg,
map,
index 
)

Definition at line 657 of file menu.inc.

menu_tree ( menu_name = 'navigation'  ) 

Render a menu tree based on the current path.

The tree is expanded based on the current path and dynamic paths are also changed according to the defined to_arg functions (for example the 'My account' link is changed from user/% to a link with the current user's uid).

Parameters:
$menu_name The name of the menu.
Returns:
The rendered HTML of that menu on the current page.

Definition at line 757 of file menu.inc.

References menu_tree_output(), and menu_tree_page_data().

Here is the call graph for this function:

menu_tree_all_data ( menu_name = 'navigation',
item = NULL 
)

Get the data structure representing a named menu tree.

Since this can be the full tree including hidden items, the data returned may be used for generating an an admin interface or a select.

Parameters:
$menu_name The named menu links to return
$item A fully loaded menu link, or NULL. If a link is supplied, only the path to root will be included in the returned tree- as if this link represented the current page in a visible menu.
Returns:
An tree of menu links in an array, in the order they should be rendered.

Definition at line 822 of file menu.inc.

References _menu_tree_cid(), cache_get(), cache_set(), db_query(), menu_tree_check_access(), menu_tree_collect_node_links(), and menu_tree_data().

Here is the call graph for this function:

menu_tree_check_access ( &$  tree,
node_links = array() 
)

Check access and perform other dynamic operations for each link in the tree.

Definition at line 1027 of file menu.inc.

References $result, _menu_tree_check_access(), db_fetch_array(), db_query(), and db_rewrite_sql().

Referenced by menu_overview_form(), menu_tree_all_data(), and menu_tree_page_data().

Here is the call graph for this function:

menu_tree_collect_node_links ( &$  tree,
&$  node_links 
)

Recursive helper function - collect node links.

Definition at line 1009 of file menu.inc.

Referenced by menu_overview_form(), menu_tree_all_data(), and menu_tree_page_data().

menu_tree_data ( result = NULL,
parents = array(),
depth = 1 
)

Build the data representing a menu tree.

Parameters:
$result The database result.
$parents An array of the plid values that represent the path from the current page to the root of the menu tree.
$depth The depth of the current menu tree.
Returns:
See menu_tree_page_data for a description of the data structure.

Definition at line 1081 of file menu.inc.

References $depth, $result, and _menu_tree_data().

Referenced by menu_overview_form(), menu_tree_all_data(), and menu_tree_page_data().

Here is the call graph for this function:

menu_tree_output ( tree  ) 

Returns a rendered menu tree.

Parameters:
$tree A data structure representing the tree as returned from menu_tree_data.
Returns:
The rendered HTML of that data structure.

Definition at line 775 of file menu.inc.

References $output, and theme().

Referenced by menu_tree().

Here is the call graph for this function:

menu_tree_page_data ( menu_name = 'navigation'  ) 

Get the data structure representing a named menu tree, based on the current page.

The tree order is maintained by storing each parent in an individual field, see for more.

Parameters:
$menu_name The named menu links to return
Returns:
An array of menu links, in the order they should be rendered. The array is a list of associative arrays -- these have two keys, link and below. link is a menu item, ready for theming as a link. Below represents the submenu below the link if there is one, and it is a subtree that has the same structure described for the top-level array.

Definition at line 905 of file menu.inc.

References $result, _menu_tree_cid(), cache_get(), cache_set(), db_fetch_array(), db_query(), drupal_is_front_page(), menu_get_item(), menu_tree_check_access(), menu_tree_collect_node_links(), menu_tree_data(), and variable_get().

Referenced by menu_navigation_links(), menu_set_active_trail(), and menu_tree().

Here is the call graph for this function:

menu_unserialize ( data,
map 
)

The menu system uses serialized arrays stored in the database for arguments. However, often these need to change according to the current path. This function unserializes such an array and does the necessary change.

Integer values are mapped according to the $map parameter. For example, if unserialize($data) is array('view', 1) and $map is array('node', '12345') then 'view' will not be changed because it is not an integer, but 1 will as it is an integer. As $map[1] is '12345', 1 will be replaced with '12345'. So the result will be array('node_load', '12345').

Parameters:
@data A serialized array.
@map An array of potential replacements.
Returns:
The $data array unserialized and mapped.

Definition at line 308 of file menu.inc.

Referenced by _menu_check_access(), _menu_item_localize(), and menu_get_item().

menu_valid_path ( form_item  ) 

Validates the path of a menu link being created or edited.

Returns:
TRUE if it is a valid path AND the current user has access permission, FALSE otherwise.

Definition at line 2453 of file menu.inc.

References _menu_link_translate(), db_fetch_array(), db_query(), menu_get_item(), and menu_path_is_external().

Referenced by menu_edit_item_validate(), and system_site_information_settings_validate().

Here is the call graph for this function:


Generated on Mon Jun 2 15:08:56 2008 for SimpleTest by  1.5.5