? diff ? m.zip ? menu.patch ? tab.patch ? tab_0.patch ? title.patch ? x.php ? sites/localhost Index: index.php =================================================================== RCS file: /cvs/drupal/drupal/index.php,v retrieving revision 1.91 diff -u -p -r1.91 index.php --- index.php 12 Dec 2006 09:32:18 -0000 1.91 +++ index.php 4 Feb 2007 02:56:28 -0000 @@ -12,6 +12,7 @@ require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); +menu_rebuild(); $return = menu_execute_active_handler(); // Menu status constants are integers; page content is a string. @@ -34,4 +35,4 @@ elseif (isset($return)) { } -drupal_page_footer(); \ No newline at end of file +drupal_page_footer(); Index: includes/menu.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/menu.inc,v retrieving revision 1.152 diff -u -p -r1.152 menu.inc --- includes/menu.inc 31 Jan 2007 21:55:37 -0000 1.152 +++ includes/menu.inc 4 Feb 2007 02:56:29 -0000 @@ -172,6 +172,20 @@ define('MENU_SITE_OFFLINE', 4); */ /** + * @Name Menu operations + * @{ + * Menu helper possible operations. + */ + +define('MENU_HANDLE_REQUEST', 0); +define('MENU_RENDER_LINK', 1); +define('MENU_RENDER_TAB', 2); + +/** + * @} End of "Menu helper directions + */ + +/** * Returns the ancestors (and relevant placeholders) for any given path. * * For example, the ancestors of node/12345/edit are: @@ -273,10 +287,10 @@ function menu_unserialize($data, $map) { * with keys like title, access callback, access arguments etc. */ function menu_set_item($path, $item) { - menu_get_item($path, TRUE, $item); + menu_get_item($path, $item); } -function menu_get_item($path = NULL, $execute = TRUE, $item = NULL) { +function menu_get_item($path = NULL, $item = NULL) { static $items; if (!isset($path)) { $path = $_GET['q']; @@ -289,14 +303,13 @@ function menu_get_item($path = NULL, $ex $parts = array_slice($map, 0, 6); list($ancestors, $placeholders) = menu_get_ancestors($parts); if ($item = db_fetch_object(db_query_range('SELECT * FROM {menu} WHERE path IN ('. implode (',', $placeholders) .') ORDER BY fit DESC', $ancestors, 0, 1))) { - $item->access = _menu_access($item, $map); + list($item->access, $map) = _menu_access($item, $map); if ($map === FALSE) { $items[$path] = FALSE; return FALSE; } - if ($execute) { - $item->page_arguments = array_merge(menu_unserialize($item->page_arguments, $map), array_slice($parts, $item->number_parts)); - } + $item->map = $map; + $item->page_arguments = array_merge(menu_unserialize($item->page_arguments, $map), array_slice($parts, $item->number_parts)); } $items[$path] = $item; } @@ -313,24 +326,45 @@ function menu_execute_active_handler() { return MENU_NOT_FOUND; } -function _menu_access($item, &$map) { - if ($item->map_callback) { - $map = call_user_func_array($item->map_callback, array_merge(array($map), unserialize($item->map_arguments))); - if ($map === FALSE) { - return FALSE; +function _menu_access($item, $map, $operation = MENU_HANDLE_REQUEST) { + $path = ''; + if ($item->functions) { + $functions = unserialize($item->functions); + $path_map = ($operation == MENU_HANDLE_REQUEST) ? $map : explode('/', $item->path); + foreach ($functions as $index => $function) { + // Create a real path. + if ($operation != MENU_HANDLE_REQUEST) { + $return = $function($operation, !empty($map[$index]) ? $map[$index] : ''); + if (!empty($map[$index]) || $return) { + $path_map[$index] = $return; + } + } + // We now have a real path regardless of operation, map it. + $return = $function(MENU_HANDLE_REQUEST, !empty($path_map[$index]) ? $path_map[$index] : ''); + if ($return === FALSE) { + return array(FALSE, FALSE, ''); + } + $map[$index] = $return; + } + if ($operation != MENU_HANDLE_REQUEST) { + $path = implode('/', $path_map); } } + else { + $path = $item->path; + } $callback = $item->access_callback; if (is_numeric($callback)) { - return $callback; + return array($callback, $map, $path); } $arguments = menu_unserialize($item->access_arguments, $map); // As call_user_func_array is quite slow and user_access is a very common // callback, it is worth making a special case for it. if ($callback == 'user_access') { - return (count($arguments) == 1) ? user_access($arguments[0]) : user_access($arguments[0], $arguments[1]); + $access = (count($arguments) == 1) ? user_access($arguments[0]) : user_access($arguments[0], $arguments[1]); + return array($access, $map, $path); } - return call_user_func_array($callback, $arguments); + return array(call_user_func_array($callback, $arguments), $map, $path); } /** @@ -346,12 +380,13 @@ function _menu_tree($result = NULL, $dep static $original_map; $remnant = array('link' => '', 'has_children' => FALSE); $tree = ''; + $map = arg(NULL); while ($item = db_fetch_object($result)) { - $map = arg(NULL, $item->path); - if (!_menu_access($item, $map)) { + list($access, , $path) = _menu_access($item, $map, MENU_RENDER_LINK); + if (!$access) { continue; } - $menu_link = array('link' => $item->menu_link, 'has_children' => $item->has_children); + $menu_link = array('link' => l($item->title, $path), 'has_children' => $item->has_children); if ($item->depth > $depth) { list($remnant, $menu) = _menu_tree($result, $item->depth, $menu_link); $tree .= theme('menu_tree', $link, $menu); @@ -430,50 +465,70 @@ function menu_rebuild() { $function($menu); } $mid = 1; - // First pass. foreach ($menu as $path => $item) { $item = &$menu[$path]; $parts = explode('/', $path, 6); + $match_path_parts = $parts; $number_parts = count($parts); // We store the highest index of parts here to save some work in the weight // calculation loop. $slashes = $number_parts - 1; - // If there is no %, it fits maximally. - if (strpos($path, '%') === FALSE) { - $fit = (1 << $number_parts) - 1; - } - else { - // We need to calculate the fitness. - $fit = 0; - foreach ($parts as $k => $part) { - // ($part != '%') is the bit we want and we shift it to its place - // by shifting to left by ($slashes - $k) bits. - $fit |= ($part != '%') << ($slashes - $k); + $fit = 0; + $functions = array(); + // extract functions + foreach ($parts as $k => $part) { + if (preg_match('/\[([a-z_]*)\]/', $part, $matches) && function_exists($matches[1])) { + $functions[$k] = $matches[1]; + $match_path_parts[$k] = '%'; + } + else { + $fit |= 1 << ($slashes - $k); } } - if (!isset($item['_visible'])) { - $item['_visible'] = (!isset($item['type']) || ($item['type'] & MENU_VISIBLE_IN_TREE)) ? 1 : 0; + $functions = empty($functions) ? '' : serialize($functions); + $item['functions'] = $functions; + // If there is no %, it fits maximally. + if (!$fit) { + $fit = (1 << $number_parts) - 1; } $depth = 1; - if (!isset($item['_mid'])) { - $item['_mid'] = $mid++; - } + $item += array( + 'title' => '', + 'weight' => 0, + 'type' => MENU_NORMAL_ITEM, + 'functions' => $functions, + '_number_parts' => $number_parts, + '_parts' => $parts, + '_fit' => $fit, + '_mid' => $mid++, + '_path' => implode('/', $match_path_parts), + ); + $item += array( + '_visible' => (bool)($item['type'] & MENU_VISIBLE_IN_TREE), + '_tab' => (bool)($item['type'] & MENU_IS_LOCAL_TASK), + ); $parents = array($item['_mid']); + if ($item['_visible'] && isset($item['parent'])) { + $parent_parts = explode('/', $item['parent'], 6); + $slashes = count($parent_parts) - 1; + } + else { + $parent_parts = $parts; + } for ($i = $slashes; $i; $i--) { - $parent_path = implode('/', array_slice($parts, 0, $i)); + $parent_path = implode('/', array_slice($parent_parts, 0, $i)); // We need to calculate depth to be able to sort. depth needs visibility. if (isset($menu[$parent_path])) { $parent = &$menu[$parent_path]; - // It's possible that the parent was not processed yet. - if (!isset($parent['_mid'])) { - $parent['_mid'] = $mid++; - } if (!isset($parent['_visible'])) { - $parent['_visible'] = (!isset($parent['type']) || ($parent['type'] & MENU_VISIBLE_IN_TREE)) ? 1 : 0; + $parent['_visible'] = !isset($parent['type']) || (bool)($parent['type'] & MENU_VISIBLE_IN_TREE); } if ($item['_visible'] && $parent['_visible']) { $parent['_has_children'] = 1; $depth++; + if (!isset($parent['_mid'])) { + $parent['_mid'] = $mid++; + } $parents[] = $parent['_mid']; if (!isset($item['_pid'])) { $item['_pid'] = $parent['_mid']; @@ -487,16 +542,10 @@ function menu_rebuild() { $parents = implode(',', array_reverse($parents)); // Store variables and set defaults. $item += array( - '_fit' => $fit, - '_number_parts' => $number_parts, - '_parts' => $parts, '_pid' => 0, '_depth' => $depth, '_parents' => $parents, '_has_children' => 0, - 'title' => '', - 'weight' => 0, - 'type' => MENU_NORMAL_ITEM, ); $sort[$path] = ($item['_visible'] ? $depth : $number_parts) . sprintf('%05d', $item['weight']) . $item['title']; unset($item); @@ -512,7 +561,7 @@ function menu_rebuild() { // If a callback is not found, we try to find the first parent that // has this callback. When found, its callback argument will also be // copied but only if there is none in the current item. - foreach (array('access', 'map', 'page') as $type) { + foreach (array('access', 'page') as $type) { if (!isset($item["$type callback"]) && isset($parent["$type callback"])) { $item["$type callback"] = $parent["$type callback"]; if (!isset($item["$type arguments"]) && isset($parent["$type arguments"])) { @@ -525,9 +574,6 @@ function menu_rebuild() { if (!isset($item['access callback'])) { $menu[$path]['access callback'] = isset($item['access arguments']) ? 'user_access' : 0; } - if (!isset($item['map callback']) && isset($item['map arguments'])) { - $item['map callback'] = 'menu_map'; - } if (is_bool($item['access callback'])) { $item['access callback'] = intval($item['access callback']); } @@ -538,42 +584,38 @@ function menu_rebuild() { } $vancode = $prefix . int2vancode($next[$prefix]++); $menu[$path]['_prefix'] = $vancode .'.'; - $link = l($item['title'], $path, isset($item['attributes']) ? $item['attributes'] : array(), isset($item['query']) ? $item['query'] : NULL, isset($item['fragment']) ? $item['fragment'] : NULL); } else { $vancode = ''; - $link = ''; } - $tab = ($item['type'] & MENU_IS_LOCAL_TASK) ? 1 : 0; - $default_tab = $item['type'] == MENU_DEFAULT_LOCAL_TASK; - if (!isset($item['parent'])) { - if ($tab) { + if ($item['_tab']) { + if (!isset($item['parent'])) { $item['parent'] = implode('/', array_slice($item['_parts'], 0, $item['_number_parts'] - 1)); } - else { - $item['parent'] = $path; - } + } + else { + // Non-tab items specified the parent for visible links, and it's + // stored in parents, parent stores the tab parent. + $item['parent'] = $path; } $insert_item = $item + array( 'access arguments' => array(), 'access callback' => '', 'page arguments' => array(), 'page callback' => '', - 'map arguments' => array(), - 'map callback' => '', ); db_query("INSERT INTO {menu} ( - mid, pid, path, - access_callback, access_arguments, page_callback, page_arguments, map_callback, map_arguments, fit, - number_parts, vancode, menu_link, visible, parents, depth, has_children, tab, default_tab, title, parent) - VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, '%s', %d, %d, %d, %d, '%s', '%s')", - $insert_item['_mid'], $insert_item['_pid'], $path, $insert_item['access callback'], - serialize($insert_item['access arguments']), $insert_item['page callback'], - serialize($insert_item['page arguments']), $insert_item['map callback'], - serialize($insert_item['map arguments']), $insert_item['_fit'], - $insert_item['_number_parts'], $vancode .'+', $link, $insert_item['_visible'], - $insert_item['_parents'], $insert_item['_depth'], $insert_item['_has_children'], - $tab, $default_tab, $insert_item['title'], $insert_item['parent']); + mid, pid, path, functions, + access_callback, access_arguments, page_callback, page_arguments, fit, + number_parts, vancode, visible, parents, depth, has_children, tab, title, parent, type) + VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s')", + $insert_item['_mid'], $insert_item['_pid'], $item['_path'], $item['functions'], + $insert_item['access callback'], serialize($insert_item['access arguments']), + $insert_item['page callback'], serialize($insert_item['page arguments']), + $insert_item['_fit'], $insert_item['_number_parts'], $vancode .'+', + $insert_item['_visible'], $insert_item['_parents'], $insert_item['_depth'], + $insert_item['_has_children'], $item['_tab'], $insert_item['title'], + $insert_item['parent'], $insert_item['type']); unset($item); } } @@ -594,17 +636,12 @@ function menu_primary_local_tasks() { $router_item = menu_get_item(); $result = db_query("SELECT * FROM {menu} WHERE parent = '%s' AND tab = 1 ORDER BY vancode", $router_item->parent); $tabs = array(); + $map = arg(NULL); while ($item = db_fetch_object($result)) { - $map = explode('/', $item->path); - foreach ($map as $key => $value) { - if ($value == '%') { - $map[$key] = arg($key); - } - } - $path = implode('/', $map); - if (_menu_access($item, $map, TRUE)) { + list($access, , $path) = _menu_access($item, $map, MENU_RENDER_TAB); + if ($access) { $link = l($item->title, $path); - if ((!$router_item->tab && $item->default_tab) || ($path == $_GET['q'])) { + if ((!$router_item->tab && $item->type == MENU_DEFAULT_LOCAL_TASK) || ($path == $_GET['q'])) { $tabs[] = array('class' => 'active', 'data' => $link); } else { @@ -631,4 +668,4 @@ function menu_get_active_breadcrumb() { function menu_get_active_title() { $item = menu_get_item(); return $item->title; -} \ No newline at end of file +} Index: modules/aggregator/aggregator.module =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.module,v retrieving revision 1.327 diff -u -p -r1.327 aggregator.module --- modules/aggregator/aggregator.module 31 Jan 2007 21:26:55 -0000 1.327 +++ modules/aggregator/aggregator.module 4 Feb 2007 02:56:30 -0000 @@ -51,19 +51,17 @@ function aggregator_menu() { 'type' => MENU_LOCAL_TASK, 'parent' => 'admin/content/aggregator', ); - $items['admin/content/aggregator/remove/%'] = array( + $items['admin/content/aggregator/remove/[aggregator_feed_from_arg]'] = array( 'title' => t('Remove items'), 'page callback' => 'aggregator_admin_remove_feed', 'page arguments' => array(4), - 'map arguments' => array('aggregator_get_feed', 4), 'access arguments' => array('administer news feeds'), 'type' => MENU_CALLBACK, ); - $items['admin/content/aggregator/update/%'] = array( + $items['admin/content/aggregator/update/[aggregator_feed_from_arg]'] = array( 'title' => t('Update items'), 'page callback' => 'aggregator_admin_refresh_feed', 'page arguments' => array(4), - 'map arguments' => array('aggregator_get_feed', 4), 'access arguments' => array('administer news feeds'), 'type' => MENU_CALLBACK, ); @@ -137,24 +135,23 @@ function aggregator_menu() { 'weight' => 1, ); } - $items['aggregator/sources/%'] = array( + $items['aggregator/sources/[aggregator_feed_from_arg]'] = array( 'page callback' => 'aggregator_page_source', - 'map arguments' => array('aggregator_get_feed', 2), 'type' => MENU_CALLBACK, ); - $items['aggregator/sources/%/view'] = array( + $items['aggregator/sources/[aggregator_feed_from_arg]/view'] = array( 'title' => t('View'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, ); - $items['aggregator/sources/%/categorize'] = array( + $items['aggregator/sources/[aggregator_feed_from_arg]/categorize'] = array( 'title' => t('Categorize'), 'page callback' => 'drupal_get_form', 'page arguments' => array('aggregator_page_source'), 'access arguments' => array('administer news feeds'), 'type' => MENU_LOCAL_TASK, ); - $items['aggregator/sources/%/configure'] = array( + $items['aggregator/sources/[aggregator_feed_from_arg]/configure'] = array( 'title' => t('Configure'), 'page callback' => 'drupal_get_form', 'page arguments' => array('aggregator_form_feed', 2), @@ -162,20 +159,18 @@ function aggregator_menu() { 'type' => MENU_LOCAL_TASK, 'weight' => 1, ); - $items['admin/content/aggregator/edit/feed/%'] = array( + $items['admin/content/aggregator/edit/feed/[aggregator_feed_from_arg]'] = array( 'title' => t('Edit feed'), 'page callback' => 'drupal_get_form', 'page arguments' => array('aggregator_form_feed', 5), 'access arguments' => array('administer news feeds'), - 'map arguments' => array('aggregator_get_feed', 5), 'type' => MENU_CALLBACK, ); - $items['admin/content/aggregator/edit/category/%'] = array( + $items['admin/content/aggregator/edit/category/[aggregator_category_from_arg]'] = array( 'title' => t('Edit category'), 'page callback' => 'drupal_get_form', 'page arguments' => array('aggregator_form_category', 5), 'access arguments' => array('administer news feeds'), - 'map arguments' => array('aggregator_get_category', 5), 'type' => MENU_CALLBACK, ); @@ -186,6 +181,20 @@ function aggregator_init() { drupal_add_css(drupal_get_path('module', 'aggregator') .'/aggregator.css'); } +function aggregator_feed_from_arg($operation, $arg) { + if ($operation == MENU_HANDLE_REQUEST) { + return is_numeric($arg) ? aggregator_get_feed($arg) : FALSE; + } + return $arg; +} + +function aggregator_category_from_arg($operation, $arg) { + if ($operation == MENU_HANDLE_REQUEST) { + return is_numeric($arg) ? aggregator_get_category($arg) : FALSE; + } + return $arg; +} + function aggregator_admin_settings() { $items = array(0 => t('none')) + drupal_map_assoc(array(3, 5, 10, 15, 20, 25), '_aggregator_items'); $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval'); @@ -1035,7 +1044,7 @@ function aggregator_page_last() { */ function aggregator_page_source() { $feed = db_fetch_object(db_query('SELECT * FROM {aggregator_feed} WHERE fid = %d', arg(2))); - drupal_set_title($feed->title); + drupal_set_title(check_plain($feed->title)); $info = theme('aggregator_feed', $feed); return _aggregator_page_list('SELECT * FROM {aggregator_item} WHERE fid = '. $feed->fid .' ORDER BY timestamp DESC, iid DESC', arg(3), $info); Index: modules/blog/blog.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blog/blog.module,v retrieving revision 1.273 diff -u -p -r1.273 blog.module --- modules/blog/blog.module 31 Jan 2007 15:49:23 -0000 1.273 +++ modules/blog/blog.module 4 Feb 2007 02:56:30 -0000 @@ -105,6 +105,9 @@ function blog_feed_last() { * Menu callback; displays a Drupal page containing recent blog entries. */ function blog_page($a = NULL, $b = NULL) { + if (is_object($a)) { + $a = $a->uid; + } if (is_numeric($a)) { // $a is a user ID if ($b == 'feed') { @@ -256,7 +259,7 @@ function blog_menu() { 'access arguments' => array('access content'), 'type' => MENU_SUGGESTED_ITEM, ); - $items['blog/%'] = array( + $items['blog/[user_from_arg]'] = array( 'title' => t('My blog'), 'page arguments' => array(1), 'access arguments' => array('edit own blog'), Index: modules/book/book.module =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.module,v retrieving revision 1.410 diff -u -p -r1.410 book.module --- modules/book/book.module 31 Jan 2007 15:49:23 -0000 1.410 +++ modules/book/book.module 4 Feb 2007 02:56:31 -0000 @@ -114,13 +114,12 @@ function book_menu() { 'page arguments' => array(2, 3), 'type' => MENU_CALLBACK, ); - $items['node/%/outline'] = array( + $items['node/[node: nid]/outline'] = array( 'title' => t('Outline'), 'page callback' => 'drupal_get_form', 'page arguments' => array('book_outline', 1), 'access callback' => '_book_outline_access', 'access arguments' => array(1), - 'map arguments' => array('node_load', 1), 'type' => MENU_LOCAL_TASK, 'weight' => 2, ); Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.523 diff -u -p -r1.523 comment.module --- modules/comment/comment.module 31 Jan 2007 15:49:23 -0000 1.523 +++ modules/comment/comment.module 4 Feb 2007 02:56:32 -0000 @@ -195,15 +195,14 @@ function comment_menu() { 'access arguments' => array('post comments'), 'type' => MENU_CALLBACK, ); - $items['comment/reply'] = array( + $items['comment/reply/[node_from_arg]'] = array( 'title' => t('Reply to comment'), 'page callback' => 'comment_reply', 'access callback' => 'node_access', 'access arguments' => array('view', 2), - 'map arguments' => array('node_load', 2), 'type' => MENU_CALLBACK, ); - $items['node/%/%'] = array( + $items['node/[node_from_arg]/%'] = array( 'title' => t('View'), 'page callback' => 'node_page_view', 'page arguments' => array(1, 2), Index: modules/contact/contact.module =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.module,v retrieving revision 1.76 diff -u -p -r1.76 contact.module --- modules/contact/contact.module 31 Jan 2007 15:49:24 -0000 1.76 +++ modules/contact/contact.module 4 Feb 2007 02:56:32 -0000 @@ -84,14 +84,13 @@ function contact_menu() { 'access arguments' => array('access site-wide contact form'), 'type' => MENU_SUGGESTED_ITEM, ); - $items['user/%/contact'] = array( + $items['user/[user_from_arg]/contact'] = array( 'title' => t('Contact'), 'page callback' => 'contact_user_page', 'page arguments' => array(1), 'type' => MENU_LOCAL_TASK, 'access callback' => '_contact_user_tab_access', 'access arguments' => array(1), - 'map arguments' => array('user_load', 1), 'weight' => 2, ); return $items; Index: modules/filter/filter.module =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v retrieving revision 1.162 diff -u -p -r1.162 filter.module --- modules/filter/filter.module 31 Jan 2007 15:49:24 -0000 1.162 +++ modules/filter/filter.module 4 Feb 2007 02:56:33 -0000 @@ -81,26 +81,25 @@ function filter_menu() { 'access callback' => TRUE, 'type' => MENU_SUGGESTED_ITEM, ); - $items['admin/settings/filters/%'] = array( + $items['admin/settings/filters/[filter_from_arg]'] = array( 'type' => MENU_CALLBACK, 'page arguments' => array('filter_admin_format_form', 3), 'access arguments' => array('administer filters'), - 'map arguments' => array('filter_formats', 3), ); - $items['admin/settings/filters/%/list'] = array( + $items['admin/settings/filters/[filter_from_arg]/list'] = array( 'title' => t('View'), 'page arguments' => array('filter_admin_format_form', 3), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 0, ); - $items['admin/settings/filters/%/configure'] = array( + $items['admin/settings/filters/[filter_from_arg]/configure'] = array( 'title' => t('Configure'), 'page arguments' => array('filter_admin_configure', 3), 'type' => MENU_LOCAL_TASK, 'weight' => 1, ); - $items['admin/settings/filters/%/order'] = array( + $items['admin/settings/filters/[filter_from_arg]/order'] = array( 'title' => t('Rearrange'), 'page arguments' => array('filter_admin_order', 3), 'type' => MENU_LOCAL_TASK, @@ -109,6 +108,13 @@ function filter_menu() { return $items; } +function filter_from_arg($operation, $arg) { + if ($operation == MENU_HANDLE_REQUEST) { + return is_numeric($arg) ? filter_formats($arg) : FALSE; + } + return $arg; +} + /** * Implementation of hook_perm(). */ Index: modules/forum/forum.module =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v retrieving revision 1.382 diff -u -p -r1.382 forum.module --- modules/forum/forum.module 1 Feb 2007 21:44:36 -0000 1.382 +++ modules/forum/forum.module 4 Feb 2007 02:56:34 -0000 @@ -75,19 +75,20 @@ function forum_menu() { 'type' => MENU_LOCAL_TASK, 'parent' => 'admin/content/forum', ); - $items['admin/content/forum/edit'] = array( + $items['admin/content/forum/edit/[forum_from_arg]'] = array( 'page callback' => 'forum_form_main', - 'map arguments' => array('_forum_get_term', 5, array()), 'type' => MENU_CALLBACK, ); - $items['admin/content/forum/edit/container/%'] = array( + $items['admin/content/forum/edit/container/[forum_from_arg]'] = array( 'title' => t('Edit container'), 'page arguments' => array('container', 5), + 'type' => MENU_CALLBACK, ); - $items['admin/content/forum/edit/forum/%'] = array( + $items['admin/content/forum/edit/forum/[forum_from_arg]'] = array( 'title' => t('Edit forum'), 'page callback' => 'forum_form_main', 'page arguments' => array('forum', 5), + 'type' => MENU_CALLBACK, ); return $items; } @@ -96,8 +97,11 @@ function forum_init() { drupal_add_css(drupal_get_path('module', 'forum') .'/forum.css'); } -function _forum_get_term($tid) { - return (array)taxonomy_get_term($tid); +function forum_from_arg($operation, $arg) { + if ($operation == MENU_HANDLE_REQUEST) { + return is_numeric($arg) ? (array)taxonomy_get_term($tid) : FALSE; + } + return $arg; } /** Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.780 diff -u -p -r1.780 node.module --- modules/node/node.module 31 Jan 2007 15:49:25 -0000 1.780 +++ modules/node/node.module 4 Feb 2007 02:56:36 -0000 @@ -1166,33 +1166,32 @@ function node_menu() { } } - $items['node/%'] = array( + $items['node/[node_from_arg]'] = array( 'title' => t('View'), 'page callback' => 'node_page_view', 'page arguments' => array(1), 'access callback' => 'node_access', 'access arguments' => array('view', 1), - 'map arguments' => array('node_load', 1), 'type' => MENU_CALLBACK); - $items['node/%/view'] = array( + $items['node/[node_from_arg]/view'] = array( 'title' => t('View'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10); - $items['node/%/edit'] = array( + $items['node/[node_from_arg]/edit'] = array( 'title' => t('Edit'), 'page callback' => 'node_page_edit', 'page arguments' => array(1), 'access arguments' => array('update', 1), 'weight' => 1, 'type' => MENU_LOCAL_TASK); - $items['node/%/delete'] = array( + $items['node/[node_from_arg]/delete'] = array( 'title' => t('Delete'), 'page callback' => 'drupal_get_form', 'page arguments' => array('node_delete_confirm', 1), 'access arguments' => array('delete', 1), 'weight' => 1, 'type' => MENU_CALLBACK); - $items['node/%/revisions'] = array( + $items['node/[node_from_arg]/revisions'] = array( 'title' => t('Revisions'), 'page callback' => 'node_revisions', 'access callback' => '_node_revision_access', @@ -1210,6 +1209,13 @@ function node_init() { drupal_add_css(drupal_get_path('module', 'node') .'/node.css'); } +function node_from_arg($direction, $arg) { + if ($direction == MENU_HANDLE_REQUEST) { + return is_numeric($arg) ? node_load($arg) : FALSE; + } + return $arg; +} + function node_last_changed($nid) { $node = db_fetch_object(db_query('SELECT changed FROM {node} WHERE nid = %d', $nid)); return ($node->changed); @@ -2464,7 +2470,7 @@ function node_update_index() { */ function node_form_alter($form_id, &$form) { // Advanced node search form - if ($form_id == 'search_form' && arg(1) == 'node' && user_access('use advanced search')) { + if ($form_id == 'search_form' && $form['module']['#value'] == 'node' && user_access('use advanced search')) { // Keyword boxes: $form['advanced'] = array( '#type' => 'fieldset', Index: modules/poll/poll.module =================================================================== RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v retrieving revision 1.223 diff -u -p -r1.223 poll.module --- modules/poll/poll.module 24 Jan 2007 14:48:36 -0000 1.223 +++ modules/poll/poll.module 4 Feb 2007 02:56:36 -0000 @@ -239,14 +239,14 @@ function poll_menu() { 'type' => MENU_SUGGESTED_ITEM, ); - $items['poll/cancel/%'] = array( + $items['poll/cancel/[node: nid]'] = array( 'title' => t('Cancel'), 'page callback' => 'poll_cancel', 'page arguments' => array(2), 'access arguments' => array('cancel own vote'), 'type' => MENU_CALLBACK, ); - $items['node/%/votes'] = array( + $items['node/[node: nid]/votes'] = array( 'title' => t('Votes'), 'page callback' => 'poll_votes', 'access callback' => '_poll_menu_access', @@ -254,7 +254,7 @@ function poll_menu() { 'weight' => 3, 'type' => MENU_LOCAL_TASK, ); - $items['node/%/results'] = array( + $items['node/[node: nid]/results'] = array( 'title' => t('Results'), 'page callback' => 'poll_results', 'access callback' => '_poll_menu_access', Index: modules/search/search.module =================================================================== RCS file: /cvs/drupal/drupal/modules/search/search.module,v retrieving revision 1.211 diff -u -p -r1.211 search.module --- modules/search/search.module 31 Jan 2007 21:26:56 -0000 1.211 +++ modules/search/search.module 4 Feb 2007 02:56:37 -0000 @@ -140,7 +140,6 @@ function search_menu() { $items['search'] = array( 'title' => t('Search'), 'page callback' => 'search_view', - 'page arguments' => array('node'), 'access arguments' => array('search content'), 'type' => MENU_SUGGESTED_ITEM, ); @@ -167,13 +166,14 @@ function search_menu() { ); foreach (module_implements('search') as $name) { - $items['search/'. $name] = array( + $items['search/'. $name .'/[search_get_keys]'] = array( 'title' => module_invoke($name, 'search', 'name', TRUE), 'page callback' => 'search_view', 'page arguments' => array($name), 'access callback' => '_search_menu', 'access arguments' => array($name), 'type' => $name == 'node' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, + 'parent' => 'search', ); } return $items; @@ -882,16 +882,21 @@ function do_search($keywords, $type, $jo * Helper function for grabbing search keys. */ function search_get_keys() { - // Extract keys as remainder of path - // Note: support old GET format of searches for existing links. - $path = explode('/', $_GET['q'], 3); - return count($path) == 3 ? $path[2] : $_REQUEST['keys']; + static $return; + if (!isset($return)) { + // Extract keys as remainder of path + // Note: support old GET format of searches for existing links. + $path = explode('/', $_GET['q'], 3); + $keys = empty($_REQUEST['keys']) ? '' : $_REQUEST['keys']; + $return = count($path) == 3 ? $path[2] : $keys; + } + return $return; } /** * Menu callback; presents the search form and/or search results. */ -function search_view($type = '') { +function search_view($type = 'node') { // Search form submits with POST but redirects to GET. This way we can keep // the search query URL clean as a whistle: // search/type/keyword+keyword @@ -905,6 +910,7 @@ function search_view($type = '') { $keys = search_get_keys(); // Only perform search if there is non-whitespace search term: + $results = ''; if (trim($keys)) { // Log the search keys: watchdog('search', t('%keys (@type).', array('%keys' => $keys, '@type' => module_invoke($type, 'search', 'name'))), WATCHDOG_NOTICE, l(t('results'), 'search/'. $type .'/'. $keys)); Index: modules/statistics/statistics.module =================================================================== RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v retrieving revision 1.251 diff -u -p -r1.251 statistics.module --- modules/statistics/statistics.module 31 Jan 2007 15:49:25 -0000 1.251 +++ modules/statistics/statistics.module 4 Feb 2007 02:56:37 -0000 @@ -143,14 +143,15 @@ function statistics_menu() { 'type' => MENU_NORMAL_ITEM, 'weight' => 3, ); - $items['user/%/track/navigation'] = array( + $items['user/[user_from_arg]/track/navigation'] = array( 'title' => t('Track page visits'), 'page callback' => 'statistics_user_tracker', + 'access callback' => 'user_access', 'access arguments' => array('access statistics'), 'type' => MENU_LOCAL_TASK, 'weight' => 2, ); - $items['node/%/track'] = array( + $items['node/[node: nid]/track'] = array( 'title' => t('Track'), 'page callback' => 'statistics_node_tracker', 'access callback' => 'user_access', Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.76 diff -u -p -r1.76 system.install --- modules/system/system.install 31 Jan 2007 21:26:56 -0000 1.76 +++ modules/system/system.install 4 Feb 2007 02:56:39 -0000 @@ -327,31 +327,31 @@ function system_install() { ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); db_query("CREATE TABLE {menu} ( + mid int NOT NULL default '0', + pid int NOT NULL default '0', path varchar(255) NOT NULL default '', + functions varchar(255) NOT NULL default '', access_callback varchar(255) NOT NULL default '', access_arguments text, page_callback varchar(255) NOT NULL default '', page_arguments text, - map_callback varchar(255) NOT NULL default '', - map_arguments text, fit int NOT NULL default '0', number_parts int NOT NULL default '0', vancode varchar(255) NOT NULL default '', - mid int NOT NULL default '0', - pid int NOT NULL default '0', visible int NOT NULL default '0', - menu_link varchar(255) NOT NULL default '', parents varchar(255) NOT NULL default '', depth int NOT NULL default '0', has_children int NOT NULL default '0', tab int NOT NULL default 0, title varchar(255) NOT NULL default '', - default_tab int NOT NULL default '0', parent varchar(255) NOT NULL default '', + type int NOT NULL default 0, PRIMARY KEY (path), KEY vancode (vancode), KEY fit (fit), KEY visible (visible) + KEY pid (pid), + KEY parent (parent) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); db_query("CREATE TABLE {node} ( @@ -802,30 +802,30 @@ function system_install() { mid int NOT NULL default '0', pid int NOT NULL default '0', path varchar(255) NOT NULL default '', + functions varchar(255) NOT NULL default '', access_callback varchar(255) NOT NULL default '', access_arguments text, page_callback varchar(255) NOT NULL default '', page_arguments text, - map_callback varchar(255) NOT NULL default '', - map_arguments text, - fit int NOT NULL default 0, - number_parts int NOT NULL default 0, + fit int NOT NULL default '0', + number_parts int NOT NULL default '0', vancode varchar(255) NOT NULL default '', visible int NOT NULL default '0', - menu_link varchar(255) NOT NULL default '', parents varchar(255) NOT NULL default '', depth int NOT NULL default '0', has_children int NOT NULL default '0', - tab int NOT NULL default '0', + tab int NOT NULL default 0, title varchar(255) NOT NULL default '', - default_tab int NOT NULL default '0', parent varchar(255) NOT NULL default '', + type int NOT NULL default 0, PRIMARY KEY (path) )"); db_query("CREATE INDEX {menu}_vancode_idx ON {menu} (vancode)"); db_query("CREATE INDEX {menu}_fit_idx ON {menu} (fit)"); db_query("CREATE INDEX {menu}_visible_idx ON {menu} (visible)"); + db_query("CREATE INDEX {menu}_parent_idx ON {menu} (parent)"); + db_query("CREATE INDEX {menu}_pid_idx ON {menu} (parent)"); db_query("CREATE TABLE {node} ( nid serial CHECK (nid >= 0), Index: modules/taxonomy/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v retrieving revision 1.337 diff -u -p -r1.337 taxonomy.module --- modules/taxonomy/taxonomy.module 31 Jan 2007 21:26:56 -0000 1.337 +++ modules/taxonomy/taxonomy.module 4 Feb 2007 02:56:40 -0000 @@ -91,7 +91,7 @@ function taxonomy_menu() { 'parent' => 'admin/content/taxonomy', ); - $items['admin/content/taxonomy/edit/vocabulary/%'] = array( + $items['admin/content/taxonomy/edit/vocabulary/[taxonomy_vocabulary_from_arg]'] = array( 'title' => t('Edit vocabulary'), 'page callback' => 'taxonomy_admin_vocabulary_edit', 'page arguments' => array(5), @@ -117,32 +117,39 @@ function taxonomy_menu() { 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); - $items['admin/content/taxonomy/%'] = array( + $items['admin/content/taxonomy/[taxonomy_vocabulary_from_arg]'] = array( 'title' => t('List terms'), 'page callback' => 'taxonomy_overview_terms', 'page arguments' => array(3), 'access arguments' => array('administer taxonomy'), - 'map arguments' => array('taxonomy_get_vocabulary', 3), 'type' => MENU_CALLBACK, ); - $items['admin/content/taxonomy/%/list'] = array( + $items['admin/content/taxonomy/[taxonomy_vocabulary_from_arg]/list'] = array( 'title' => t('List'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, ); - $items['admin/content/taxonomy/%/add/term'] = array( + $items['admin/content/taxonomy/[taxonomy_vocabulary_from_arg]/add/term'] = array( 'title' => t('Add term'), 'page callback' => 'drupal_get_form', 'page arguments' => array('taxonomy_form_term', 3), 'type' => MENU_LOCAL_TASK, - 'parent' => 'admin/content/taxonomy/%', + 'parent' => 'admin/content/taxonomy/[taxonomy_vocabulary_from_arg]', ); return $items; } +function taxonomy_vocabulary_from_arg($operation, $arg) { + if ($operation == MENU_HANDLE_REQUEST) { + return is_numeric($arg) ? taxonomy_get_vocabulary($arg) : FALSE; + } + return $arg; +} + + /** * List and manage vocabularies. */ Index: modules/tracker/tracker.module =================================================================== RCS file: /cvs/drupal/drupal/modules/tracker/tracker.module,v retrieving revision 1.144 diff -u -p -r1.144 tracker.module --- modules/tracker/tracker.module 24 Jan 2007 14:48:36 -0000 1.144 +++ modules/tracker/tracker.module 4 Feb 2007 02:56:40 -0000 @@ -1,4 +1,4 @@ - MENU_DEFAULT_LOCAL_TASK, 'access callback' => 'user_is_logged_in', ); - $items['tracker/%'] = array( + $items['tracker/[user_from_arg]'] = array( 'title' => t('My recent posts'), 'type' => MENU_LOCAL_TASK, 'access callback' => 'user_is_logged_in', + 'access arguments' => array(1), ); - $items['user/%/track'] = array( + $items['user/[user_from_arg]/track'] = array( 'title' => t('Track'), 'page callback' => 'tracker_track_user', + 'access callback' => 'user_access', 'access arguments' => array('access content'), 'type' => MENU_LOCAL_TASK, ); - $items['user/%/track/posts'] = array( + $items['user/[user_from_arg]/track/posts'] = array( 'title' => t('Track posts'), 'type' => MENU_DEFAULT_LOCAL_TASK, ); Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.753 diff -u -p -r1.753 user.module --- modules/user/user.module 2 Feb 2007 15:25:25 -0000 1.753 +++ modules/user/user.module 4 Feb 2007 02:56:42 -0000 @@ -730,11 +730,15 @@ function user_menu() { ); // Registration and login pages. - $items['user/login'] = array( + $items['user'] = array( 'title' => t('Log in'), 'page callback' => 'drupal_get_form', 'page arguments' => array('user_login'), 'access callback' => 'user_is_anonymous', + ); + + $items['user/login'] = array( + 'title' => t('Log in'), 'type' => MENU_DEFAULT_LOCAL_TASK, ); @@ -857,7 +861,6 @@ function user_menu() { 'page callback' => 'user_admin', 'page arguments' => array('search'), 'access arguments' => array('administer users'), - 'type' => MENU_NORMAL_ITEM, ); } @@ -868,32 +871,22 @@ function user_menu() { 'weight' => 10, ); - $items['user'] = array( - 'title' => t('My account'), - 'page callback' => 'user_view', - 'page arguments' => array(1), - 'access callback' => 'user_view_access', - 'access arguments' => array(1), - 'map callback' => 'user_load_self', - ); - - $items['user/%'] = array( + $items['user/[user_from_arg]'] = array( 'title' => t('My account'), 'page callback' => 'user_view', 'page arguments' => array(1), 'access callback' => 'user_view_access', 'access arguments' => array(1), - 'map arguments' => array('user_load', 1), - 'type' => MENU_CALLBACK, + 'parent' => '', ); - $items['user/%/view'] = array( + $items['user/[user_from_arg]/view'] = array( 'title' => t('View'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, ); - $items['user/%/delete'] = array( + $items['user/[user_from_arg]/delete'] = array( 'title' => t('Delete'), 'page callback' => 'user_edit', 'access callback' => 'user_access', @@ -901,7 +894,7 @@ function user_menu() { 'type' => MENU_CALLBACK, ); - $items['user/%/edit'] = array( + $items['user/[user_from_arg]/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('user_edit'), @@ -913,7 +906,7 @@ function user_menu() { $empty_account = new stdClass(); if (($categories = _user_categories($empty_account)) && (count($categories) > 1)) { foreach ($categories as $key => $category) { - $items['user/%/edit/'. $category['name']] = array( + $items['user/[user_from_arg]/edit/'. $category['name']] = array( 'title' => $category['title'], 'page arguments' => array('user_edit', 3), 'type' => $category['name'] == 'account' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, @@ -928,6 +921,17 @@ function user_init() { drupal_add_css(drupal_get_path('module', 'user') .'/user.css', 'module'); } +function user_from_arg($operation, $arg) { + switch ($operation) { + case MENU_RENDER_TAB: + return $arg; + case MENU_RENDER_LINK: + return $GLOBALS['user']->uid; + case MENU_HANDLE_REQUEST: + return is_numeric($arg) ? user_load($arg) : FALSE; + } +} + /** * Accepts an user object, $account, or a DA name and returns an associative * array of modules and DA names. Called at external login. @@ -1588,6 +1592,7 @@ function user_edit_submit($form_id, $for function user_view($account) { global $user; + drupal_set_title(check_plain($account->name)); // Retrieve and merge all profile fields: $fields = array(); foreach (module_list() as $module) {