summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-10-17 14:46:34 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-10-17 14:46:34 +0000
commite95c8d5b08e4337cfeae8ed1ea418a0795661ef1 (patch)
tree2cd71a7de61ae193c8779e4bc62863cdecf96dfe /includes
parentf75cec459e04c1710d2a03905aa00e2d0f300107 (diff)
downloadbrdo-e95c8d5b08e4337cfeae8ed1ea418a0795661ef1.tar.gz
brdo-e95c8d5b08e4337cfeae8ed1ea418a0795661ef1.tar.bz2
#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
Diffstat (limited to 'includes')
-rw-r--r--includes/menu.inc35
1 files changed, 33 insertions, 2 deletions
diff --git a/includes/menu.inc b/includes/menu.inc
index b95980795..5660e8fdc 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -336,7 +336,34 @@ function _menu_load_objects($item, &$map) {
$path_map = $map;
foreach ($load_functions as $index => $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 ($return === FALSE) {
$item['access'] = FALSE;
@@ -1937,7 +1964,11 @@ function _menu_router_build($callbacks) {
$match = TRUE;
}
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;
}
}