? files
? menu-context.patch
? menu_args.patch
? views2.sql
? sites/logrus.com
? sites/all/modules
Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.217
diff -u -p -r1.217 menu.inc
--- includes/menu.inc	16 Oct 2007 13:48:11 -0000	1.217
+++ includes/menu.inc	16 Oct 2007 21:29:25 -0000
@@ -336,7 +336,33 @@ 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. First, if it was set up like this, the $function
+          // is the key to the array, and the array is the list of arguments.
+          list($function, $args) = each($function);
+
+          // Some arguments are placeholders for dynamic items:
+          foreach ($args as $i => $arg) {
+            if ($arg == '%index') {
+              // Sometimes we need to know which argument this is.
+              $args[$i] = $index;
+            }
+            if ($arg == '%index') {
+              // This is a reference, which means 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 +1963,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;
           }
         }
