EclipseGc

kernel_menu.patch

Feb 29th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 7.73 KB | None | 0 0
  1. diff --git a/core/includes/menu.inc b/core/includes/menu.inc
  2. index 0ab3d8c..98b544d 100644
  3. --- a/core/includes/menu.inc
  4. +++ b/core/includes/menu.inc
  5. @@ -3475,7 +3475,6 @@ function _menu_router_build($callbacks) {
  6.    $menu = array();
  7.    $masks = array();
  8.    foreach ($callbacks as $path => $item) {
  9. -    $load_functions = array();
  10.      $to_arg_functions = array();
  11.      $fit = 0;
  12.      $move = FALSE;
  13. @@ -3493,20 +3492,10 @@ function _menu_router_build($callbacks) {
  14.        if (preg_match('/^%(|' . DRUPAL_PHP_FUNCTION_PATTERN . ')$/', $part, $matches)) {
  15.          if (empty($matches[1])) {
  16.            $match = TRUE;
  17. -          $load_functions[$k] = NULL;
  18.          }
  19.          else {
  20.            if (function_exists($matches[1] . '_to_arg')) {
  21.              $to_arg_functions[$k] = $matches[1] . '_to_arg';
  22. -            $load_functions[$k] = NULL;
  23. -            $match = TRUE;
  24. -          }
  25. -          if (function_exists($matches[1] . '_load')) {
  26. -            $function = $matches[1] . '_load';
  27. -            // Create an array of arguments that will be passed to the _load
  28. -            // function when this menu path is checked, if 'load arguments'
  29. -            // exists.
  30. -            $load_functions[$k] = isset($item['load arguments']) ? array($function => $item['load arguments']) : $function;
  31.              $match = TRUE;
  32.            }
  33.          }
  34. @@ -3526,7 +3515,6 @@ function _menu_router_build($callbacks) {
  35.        $fit = (1 << $number_parts) - 1;
  36.      }
  37.      $masks[$fit] = 1;
  38. -    $item['_load_functions'] = $load_functions;
  39.      $item['to_arg_functions'] = empty($to_arg_functions) ? '' : serialize($to_arg_functions);
  40.      $item += array(
  41.        'title' => '',
  42. @@ -3632,14 +3620,14 @@ function _menu_router_build($callbacks) {
  43.          // Same for load arguments: if a loader doesn't have any explict
  44.          // arguments, try to find arguments in the parent.
  45.          if (!isset($item['load arguments'])) {
  46. -          foreach ($item['_load_functions'] as $k => $function) {
  47. +          foreach ($item['load functions'] as $k => $function) {
  48.              // This loader doesn't have any explict arguments...
  49.              if (!is_array($function)) {
  50.                // ... check the parent for a loader at the same position
  51.                // using the same function name and defining arguments...
  52. -              if (isset($parent['_load_functions'][$k]) && is_array($parent['_load_functions'][$k]) && key($parent['_load_functions'][$k]) === $function) {
  53. +              if (isset($parent['load functions'][$k]) && is_array($parent['load functions'][$k]) && key($parent['load functions'][$k]) === $function) {
  54.                  // ... and inherit the arguments on the child.
  55. -                $item['_load_functions'][$k] = $parent['_load_functions'][$k];
  56. +                $item['load functions'][$k] = $parent['load functions'][$k];
  57.                }
  58.              }
  59.            }
  60. @@ -3657,7 +3645,7 @@ function _menu_router_build($callbacks) {
  61.        $item['access callback'] = intval($item['access callback']);
  62.      }
  63.  
  64. -    $item['load_functions'] = empty($item['_load_functions']) ? '' : serialize($item['_load_functions']);
  65. +    $item['load_functions'] = empty($item['load functions']) ? '' : serialize($item['load functions']);
  66.      $item += array(
  67.        'access arguments' => array(),
  68.        'access callback' => '',
  69. diff --git a/core/lib/Drupal/Core/UrlMatcher.php b/core/lib/Drupal/Core/UrlMatcher.php
  70. index 4b1cde7..2d86020 100644
  71. --- a/core/lib/Drupal/Core/UrlMatcher.php
  72. +++ b/core/lib/Drupal/Core/UrlMatcher.php
  73. @@ -50,6 +50,7 @@ class UrlMatcher extends SymfonyUrlMatcher {
  74.        $routes->add(hash('sha256', $router_item['path']), $this->convertDrupalItem($router_item));
  75.  
  76.        if ($ret = $this->matchCollection($pathinfo, $routes)) {
  77. +        //drupal_set_message('<pre>' . var_export('test', TRUE) . '</pre>');
  78.          // Stash the router item in the attributes while we're transitioning.
  79.          $ret['drupal_menu_item'] = $router_item;
  80.  
  81. @@ -82,7 +83,17 @@ class UrlMatcher extends SymfonyUrlMatcher {
  82.      // become more complicated because we'll need to get back candidates for a
  83.      // path and them resolve them based on things like method and scheme which
  84.      // we currently can't do.
  85. -    return menu_get_item($path);
  86. +    $item = menu_get_item($path);
  87. +    $path_elements = explode('/', $item['path']);
  88. +    $i = 0;
  89. +    foreach ($path_elements as $key => $element) {
  90. +      if ($element == '%') {
  91. +        $path_elements[$key] = "{arg$i}";
  92. +        $i++;
  93. +      }
  94. +    }
  95. +    $item['path'] = implode('/', $path_elements);
  96. +    return $item;
  97.    }
  98.  
  99.    protected function convertDrupalItem($router_item) {
  100. diff --git a/core/modules/node/node.module b/core/modules/node/node.module
  101. index 93f0ddc..0a27202 100644
  102. --- a/core/modules/node/node.module
  103. +++ b/core/modules/node/node.module
  104. @@ -2072,32 +2072,41 @@ function node_menu() {
  105.        'title' => $type->name,
  106.        'title callback' => 'check_plain',
  107.        'page callback' => 'node_add',
  108. -      'page arguments' => array($type->type),
  109. +      'page arguments' => array('type' => $type->type),
  110.        'access callback' => 'node_access',
  111.        'access arguments' => array('create', $type->type),
  112.        'description' => $type->description,
  113.        'file' => 'node.pages.inc',
  114.      );
  115.    }
  116. -  $items['node/%node'] = array(
  117. +  $items['node/%'] = array(
  118. +    'load functions' => array(
  119. +      1 => 'node_load',
  120. +    ),
  121.      'title callback' => 'node_page_title',
  122.      'title arguments' => array(1),
  123.      // The page callback also invokes drupal_set_title() in case
  124.      // the menu router's title is overridden by a menu link.
  125.      'page callback' => 'node_page_view',
  126. -    'page arguments' => array(1),
  127. +    'page arguments' => array('node' => 1),
  128.      'access callback' => 'node_access',
  129.      'access arguments' => array('view', 1),
  130.    );
  131. -  $items['node/%node/view'] = array(
  132. +  $items['node/%/view'] = array(
  133. +    'load functions' => array(
  134. +      1 => 'node_load',
  135. +    ),
  136.      'title' => 'View',
  137.      'type' => MENU_DEFAULT_LOCAL_TASK,
  138.      'weight' => -10,
  139.    );
  140. -  $items['node/%node/edit'] = array(
  141. +  $items['node/%/edit'] = array(
  142. +    'load functions' => array(
  143. +      1 => 'node_load',
  144. +    ),
  145.      'title' => 'Edit',
  146.      'page callback' => 'node_page_edit',
  147. -    'page arguments' => array(1),
  148. +    'page arguments' => array('node' => 1),
  149.      'access callback' => 'node_access',
  150.      'access arguments' => array('update', 1),
  151.      'weight' => 0,
  152. @@ -2105,10 +2114,13 @@ function node_menu() {
  153.      'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  154.      'file' => 'node.pages.inc',
  155.    );
  156. -  $items['node/%node/delete'] = array(
  157. +  $items['node/%/delete'] = array(
  158. +    'load functions' => array(
  159. +      1 => 'node_load',
  160. +    ),
  161.      'title' => 'Delete',
  162.      'page callback' => 'drupal_get_form',
  163. -    'page arguments' => array('node_delete_confirm', 1),
  164. +    'page arguments' => array('form_id' => 'node_delete_confirm', 1),
  165.      'access callback' => 'node_access',
  166.      'access arguments' => array('delete', 1),
  167.      'weight' => 1,
  168. diff --git a/core/modules/system/system.module b/core/modules/system/system.module
  169. index 332e559..7c56f26 100644
  170. --- a/core/modules/system/system.module
  171. +++ b/core/modules/system/system.module
  172. @@ -796,7 +796,7 @@ function system_menu() {
  173.      'title' => 'Performance',
  174.      'description' => 'Enable or disable page caching for anonymous users and set CSS and JS bandwidth optimization options.',
  175.      'page callback' => 'drupal_get_form',
  176. -    'page arguments' => array('system_performance_settings'),
  177. +    'page arguments' => array('form_id' => 'system_performance_settings'),
  178.      'access arguments' => array('administer site configuration'),
  179.      'file' => 'system.admin.inc',
  180.      'weight' => -20,
Advertisement
Add Comment
Please, Sign In to add comment