Index: includes/path.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/path.inc,v retrieving revision 1.13 diff -u -p -r1.13 path.inc --- includes/path.inc 23 Dec 2006 22:04:52 -0000 1.13 +++ includes/path.inc 3 Jan 2007 10:22:38 -0000 @@ -58,7 +58,18 @@ function drupal_lookup_path($action, $pa if (isset($map[$path])) { return $map[$path]; } - $alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path)); + $skiplist = variable_get('path_skiplist', array()); + $path_match = 0; + for ($i = 0; !$path_match && $i < count($skiplist); $i++) { + $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($skiplist[$i], '/')) .')$/'; + $path_match = preg_match($regexp, $path); + } + if ($path_match > 0) { + $alias = FALSE; + } + elseif (!$alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path))) { + $alias = FALSE; + } $map[$path] = $alias; return $alias; } @@ -67,7 +78,16 @@ function drupal_lookup_path($action, $pa elseif ($action == 'source' && !isset($no_src[$path])) { // Look for the value $path within the cached $map if (!$src = array_search($path, $map)) { - if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) { + $skiplist = variable_get('path_skiplist', array()); + $path_match = 0; + for ($i = 0; !$path_match && $i < count($skiplist); $i++) { + $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($skiplist[$i], '/')) .')$/'; + $path_match = preg_match($regexp, $path); + } + if ($path_match > 0) { + $map[$src] = $path; + } + elseif ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) { $map[$src] = $path; } else { Index: modules/path/path.module =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.module,v retrieving revision 1.104 diff -u -p -r1.104 path.module --- modules/path/path.module 18 Dec 2006 11:16:51 -0000 1.104 +++ modules/path/path.module 3 Jan 2007 10:22:39 -0000 @@ -122,6 +122,43 @@ function path_admin_delete($pid = 0) { drupal_set_message(t('The alias has been deleted.')); } +/** + * Menu callback; presents the skiplist form. + */ +function path_admin_skiplist() { + $skiplist = variable_get( + 'path_skiplist', + array('*/add', '*/edit', '*/load', '*/outline', '*/render', '*/revisions', '*/track', '*/votes', 'admin', 'admin/*', 'aggregator', 'aggregator/*', 'book', 'comment/*', 'devel', 'devel/*', 'filter', 'filter/*', 'lm_paypal', 'lm_paypal/*', 'logout', 'node', 'poll', 'profile', 'tracker', 'tracker/*', 'user') + ); + $skiplist_flat = implode("\n", $skiplist); + + $form = array(); + $form['skiplist'] = array( + '#type' => 'textarea', + '#title' => t('Skiplist'), + '#default_value' => $skiplist_flat, + '#rows' => 40, + '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page."), + ); + $form['submit'] = array('#type' => 'submit', '#value' => t('Save skiplist')); + $form['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults')); + return $form; +} + +/** + * Save the updated skiplist. + **/ +function path_admin_skiplist_submit($form_id, $form_values) { + if ($form_values['op'] == t('Save skiplist')) { + variable_set('path_skiplist', explode("\n", $form_values['skiplist'])); + drupal_set_message(t('The skiplist has been saved.')); + } + elseif ($form_values['op'] == t('Reset to defaults')) { + variable_del('path_skiplist'); + drupal_set_message(t('The skiplist has been reset.')); + } +} + /**