Index: panels_page/panels_page.module =================================================================== RCS file: /cvs/drupal/contributions/modules/panels/panels_page/Attic/panels_page.module,v retrieving revision 1.1.2.49 diff -u -r1.1.2.49 panels_page.module --- panels_page/panels_page.module 28 May 2008 16:48:49 -0000 1.1.2.49 +++ panels_page/panels_page.module 2 Jun 2008 14:44:53 -0000 @@ -178,43 +178,52 @@ foreach ($panels as $panel_page) { if (strpos($panel_page->path, '%') !== FALSE) { $path = explode('/', $panel_page->path); - $match = TRUE; - foreach ($path as $id => $chunk) { - if ($chunk != '%' && $chunk != arg($id)) { - $match = FALSE; - break; + + // First pass: + // Check if the path we're on sufficiently matches $panel_page->path. + // Sufficiently means, all fixed parts that come before the last + // %-wildcard do match, while trailing fixed parts don't matter. + // We start with the last part and take up checking after reaching a %. + $check = FALSE; + foreach (array_reverse($path, TRUE) as $id => $chunk) { + if ($chunk == '%') { + $check = TRUE; + continue; + } + if ($check && $chunk != arg($id)) { + // Skip outer foreach loop to continue with the next $panel_page. + continue 2; } } - // It's a MATCH! Construct the URL - if ($match) { - $args = array($panel_page, FALSE); - reset($panel_page->arguments); - foreach ($path as $id => $chunk) { - if ($chunk != '%') { - continue; + + $args = array($panel_page, FALSE); + + // Second pass: + $argument = reset($panel_page->arguments); // Get first argument. + foreach ($path as $id => $chunk) { + if ($chunk != '%') { + continue; + } + // For arguments that are embedded in the URL, we require the + // argument handler to return a context, if there is an argument handler. + if ($argument) { + // Try to avoid loading the plugins code unless necessary. + if (!$plugins_loaded) { + panels_load_include('plugins'); + $plugins_loaded = TRUE; } - // For arguments that are embedded in the URL, we require the - // argument handler to return a context, if there is an argument handler. - $argument = current($panel_page->arguments); - if ($argument) { - // Try to avoid loading the plugins code unless necessary. - if (!$plugins_loaded) { - panels_load_include('plugins'); - $plugins_loaded = TRUE; - } - $context = panels_argument_get_context($argument, arg($id)); - if (!$context) { - break; - } - $panel_page->context[panels_argument_context_id($argument)] = $context; + $context = panels_argument_get_context($argument, arg($id)); + if (!$context) { + break; } - $path[$id] = arg($id); - $args[] = arg($id); - next($panel_page->arguments); + $panel_page->context[panels_argument_context_id($argument)] = $context; } - _panels_page_create_menu_item($items, $panel_page, implode('/', $path), $args); - // DEBUG: Above is now creating only the basic menu item, not the admin items. + $path[$id] = arg($id); + $args[] = arg($id); + $argument = next($panel_page->arguments); // Get next argument. } + _panels_page_create_menu_item($items, $panel_page, implode('/', $path), $args); + // DEBUG: Above is now creating only the basic menu item, not the admin items. } } }