function menu_execute_active_handler in Drupal 4
Same name and namespace in other branches
- 5 includes/menu.inc \menu_execute_active_handler()
- 6 includes/menu.inc \menu_execute_active_handler()
- 7 includes/menu.inc \menu_execute_active_handler()
Execute the handler associated with the active menu item.
This is called early in the page request. The active menu item is at this point determined exclusively by the URL. The handler that is called here may, as a side effect, change the active menu item so that later menu functions (that display the menus and breadcrumbs, for example) act as if the user were in a different location on the site.
Related topics
3 calls to menu_execute_active_handler()
- drupal_access_denied in includes/
common.inc - Generates a 403 error if the request is not allowed.
- drupal_not_found in includes/
common.inc - Generates a 404 error if the request can not be handled.
- index.php in ./
index.php
File
- includes/
menu.inc, line 385 - API for the Drupal menu system.
Code
function menu_execute_active_handler() {
if (_menu_site_is_offline()) {
return MENU_SITE_OFFLINE;
}
$menu = menu_get_menu();
// Determine the menu item containing the callback.
$path = $_GET['q'];
while ($path && !isset($menu['callbacks'][$path])) {
$path = substr($path, 0, strrpos($path, '/'));
}
if (!isset($menu['callbacks'][$path])) {
return MENU_NOT_FOUND;
}
if (!function_exists($menu['callbacks'][$path]['callback'])) {
return MENU_NOT_FOUND;
}
if (!_menu_item_is_accessible(menu_get_active_item())) {
return MENU_ACCESS_DENIED;
}
// We found one, and are allowed to execute it.
$arguments = isset($menu['callbacks'][$path]['callback arguments']) ? $menu['callbacks'][$path]['callback arguments'] : array();
$arg = substr($_GET['q'], strlen($path) + 1);
if (strlen($arg)) {
$arguments = array_merge($arguments, explode('/', $arg));
}
return call_user_func_array($menu['callbacks'][$path]['callback'], $arguments);
}