Commit e95c8d5b authored by Gábor Hojtsy's avatar Gábor Hojtsy

#184022 bx chx and merlinofchaos with documentation improvements from me:...

#184022 bx chx and merlinofchaos with documentation improvements from me: %index and %map menu path placeholders for Views module to be able to use the new menu system
parent f75cec45
...@@ -336,7 +336,34 @@ function _menu_load_objects($item, &$map) { ...@@ -336,7 +336,34 @@ function _menu_load_objects($item, &$map) {
$path_map = $map; $path_map = $map;
foreach ($load_functions as $index => $function) { foreach ($load_functions as $index => $function) {
if ($function) { if ($function) {
$return = $function(isset($path_map[$index]) ? $path_map[$index] : ''); $value = isset($path_map[$index]) ? $path_map[$index] : '';
if (is_array($function)) {
// Set up arguments for the load function. These were pulled from
// 'load arguments' in the hook_menu() entry, but they need
// some processing. In this case the $function is the key to the
// load_function array, and the value is the list of arguments.
list($function, $args) = each($function);
// Some arguments are placeholders for dynamic items to process.
foreach ($args as $i => $arg) {
if ($arg == '%index') {
// Pass on argument index to the load function, so multiple
// occurances of the same placeholder can be identified.
$args[$i] = $index;
}
if ($arg == '%map') {
// Pass on menu map by reference. The accepting function must
// also declare this as a reference if it wants to modify
// the map.
$args[$i] = &$map;
}
}
array_unshift($args, $value);
$return = call_user_func_array($function, $args);
}
else {
$return = $function($value);
}
// If callback returned an error or there is no callback, trigger 404. // If callback returned an error or there is no callback, trigger 404.
if ($return === FALSE) { if ($return === FALSE) {
$item['access'] = FALSE; $item['access'] = FALSE;
...@@ -1937,7 +1964,11 @@ function _menu_router_build($callbacks) { ...@@ -1937,7 +1964,11 @@ function _menu_router_build($callbacks) {
$match = TRUE; $match = TRUE;
} }
if (function_exists($matches[1] .'_load')) { if (function_exists($matches[1] .'_load')) {
$load_functions[$k] = $matches[1] .'_load'; $function = $matches[1] .'_load';
// Create an array of arguments that will be passed to the _load
// function when this menu path is checked, if 'load arguments'
// exists.
$load_functions[$k] = isset($item['load arguments']) ? array($function => $item['load arguments']) : $function;
$match = TRUE; $match = TRUE;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment