? 608916_20100423_2.patch
Index: purl.admin.css
===================================================================
RCS file: purl.admin.css
diff -N purl.admin.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ purl.admin.css	24 Apr 2010 00:27:10 -0000
@@ -0,0 +1,10 @@
+.purl-disabled-form th.remove { width:5%; }
+
+.purl-disabled-form th.path { width:50%; }
+
+.purl-disabled-form .form-checkboxes .form-item {
+  display:inline;
+  margin-right:20px;
+  }
+
+.purl-disabled-form textarea { width:95%; }
\ No newline at end of file
Index: purl.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/purl/Attic/purl.admin.inc,v
retrieving revision 1.1.2.10
diff -u -p -r1.1.2.10 purl.admin.inc
--- purl.admin.inc	18 Dec 2009 16:11:32 -0000	1.1.2.10
+++ purl.admin.inc	24 Apr 2010 00:27:10 -0000
@@ -269,3 +269,114 @@ function purl_item_edit_validate($form, 
 function purl_item_edit_submit($form, &$form_state) {
   menu_cache_clear($form_state['values']['menu']['menu_name']);
 }
+
+/**
+ * Form: PURL disabled paths.
+ */
+function purl_disabled_path_form($form_state) {
+  $form = array('#tree' => TRUE);
+
+  // Retrieve options array of PURL providers.
+  $options = array();
+  foreach (purl_providers() as $provider => $info) {
+    $options[$provider] = $info['name'];
+  }
+
+  // Iterate through existing disabled paths and generate provider options.
+  if ($purl_disabled_path = variable_get('purl_disabled_path', array())) {
+    $form['purl_disabled_path'] = array('#tree' => TRUE);
+    foreach ($purl_disabled_path as $pathset => $providers) {
+      $form['purl_disabled_path'][$pathset] = array(
+        '#tree' => TRUE,
+        '#type' => 'checkboxes',
+        '#options' => $options,
+        '#default_value' => $providers,
+      );
+      $form['remove'][$pathset] = array(
+        '#type' => 'checkbox',
+      );
+    }
+    $form['save'] = array(
+      '#type' => 'submit',
+      '#value' => t('Save'),
+      '#weight' => 10,
+    );
+  }
+
+  $form['add']['pathset'] = array(
+    '#type' => 'textarea',
+    '#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.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
+    '#resizable' => FALSE,
+    '#rows' => 4,
+  );
+  $form['add']['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Add pathset'),
+    '#submit' => array('purl_disabled_path_form_add_submit'),
+  );
+  return $form;
+}
+
+/**
+ * Save adjustments to purl_disabled_path paths.
+ */
+function purl_disabled_path_form_submit($form, &$form_state) {
+  $purl_disabled_path = variable_get('purl_disabled_path', array());
+  if (!empty($form_state['values']['purl_disabled_path'])) {
+    $purl_disabled_path = $form_state['values']['purl_disabled_path'];
+  }
+  foreach (array_keys(array_filter($form_state['values']['remove'])) as $pathset) {
+    if (isset($purl_disabled_path[$pathset])) {
+      unset($purl_disabled_path[$pathset]);
+    }
+  }
+  variable_set('purl_disabled_path', $purl_disabled_path);
+}
+
+/**
+ * Add a new path to purl_disabled_path paths.
+ */
+function purl_disabled_path_form_add_submit($form, &$form_state) {
+  if (!empty($form_state['values']['add']['pathset'])) {
+    $path = $form_state['values']['add']['pathset'];
+    $purl_disabled_path = variable_get('purl_disabled_path', array());
+    $purl_disabled_path[$path] = array();
+    variable_set('purl_disabled_path', $purl_disabled_path);
+  }
+}
+
+/**
+ * Theme function for theme('purl_disabled_path_form').
+ */
+function theme_purl_disabled_path_form($form) {
+  drupal_add_css(drupal_get_path("module", "purl") ."/purl.admin.css");
+
+  // Add form.
+  $header = array(array('data' => t('Add pathset'), 'class' => 'path', 'colspan' => 3));
+  $rows = array(array(
+    array('data' => drupal_render($form['add']['pathset']), 'colspan' => 2),
+    drupal_render($form['add']['submit']),
+  ));
+
+  // Existing paths.
+  if (!empty($form['purl_disabled_path'])) {
+    $rows[] = array(
+      array('data' => t('Remove'), 'header' => TRUE, 'class' => 'remove'),
+      array('data' => t('Path'), 'header' => TRUE, 'class' => 'path'),
+      array('data' => t('Disable rewriting'), 'header' => TRUE, 'class' => 'disable'),
+    );
+    foreach (element_children($form['purl_disabled_path']) as $pathset) {
+      $row = array();
+      $row[] = drupal_render($form['remove'][$pathset]);
+
+      $row[] = "<pre>". check_plain($pathset) ."</pre>";
+      $row[] = drupal_render($form['purl_disabled_path'][$pathset]);
+      $rows[] = $row;
+    }
+    $rows[] = array(array('data' => drupal_render($form['save']), 'colspan' => 3));
+  }
+
+  $output = theme('table', $header, $rows, array('class' => 'purl-disabled-form'));
+  $output .= drupal_render($form);
+  return $output;
+}
Index: purl.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/purl/purl.module,v
retrieving revision 1.1.2.40
diff -u -p -r1.1.2.40 purl.module
--- purl.module	23 Apr 2010 22:19:55 -0000	1.1.2.40
+++ purl.module	24 Apr 2010 00:27:11 -0000
@@ -14,9 +14,8 @@ function purl_boot() {
  */
 function purl_theme($existing, $type, $theme, $path) {
   return array(
-    'purl_settings_form' => array(
-      'arguments' => array('form' => NULL),
-    ),
+    'purl_settings_form' => array('arguments' => array('form' => NULL)),
+    'purl_disabled_path_form' => array('arguments' => array('form' => NULL)),
   );
 }
 
@@ -87,6 +86,16 @@ function purl_menu() {
     'access arguments' => array('administer site configuration'),
     'weight' => 11,
   );
+  $items['admin/settings/purl/disabled'] = array(
+    'type' => MENU_LOCAL_TASK,
+    'title' => 'Disabled paths',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('purl_disabled_path_form'),
+    'file' => 'purl.admin.inc',
+    'access callback' => 'user_access',
+    'access arguments' => array('administer site configuration'),
+    'weight' => 12,
+  );
   return $items;
 }
 
@@ -873,16 +882,41 @@ function purl_get_processor($method) {
  *   purl_path_element object
  * @param $o
  *   url options array.
+ * @param $p
+ *   path that is being rewritten.
  * @return true if processing should be skipped, false otherwise.
  */
-function _purl_skip($e, $o) {
+function _purl_skip($e, $o, $p = NULL) {
   if (!empty($o['purl']['disabled'])) {
-    return true;
+    return TRUE;
   }
   if (isset($o['purl']['remove'])) {
     return in_array($e->provider, $o['purl']['remove']);
   }
-  return false;
+  return purl_disabled_path($p, $e->provider);
+}
+
+/**
+ * Determine whether rewriting is disabled for a given path/provider pair.
+ */
+function purl_disabled_path($path, $provider, $reset = FALSE) {
+  static $cache;
+  if (!isset($cache) || $reset) {
+    foreach (variable_get('purl_disabled_path', array()) as $pathset => $providers) {
+      foreach (array_keys(array_filter($providers)) as $p) {
+        $cache[$p][$pathset] = $pathset;
+      }
+    }
+    drupal_alter('purl_disabled_path', $cache);
+  }
+  if (isset($cache[$provider]) && !empty($path)) {
+    foreach ($cache[$provider] as $pathset) {
+      if (drupal_match_path($path, $pathset)) {
+        return TRUE;
+      }
+    }
+  }
+  return FALSE;
 }
 
 /**
Index: includes/purl_domain.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/purl/includes/Attic/purl_domain.inc,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 purl_domain.inc
--- includes/purl_domain.inc	23 Apr 2010 22:14:23 -0000	1.1.2.6
+++ includes/purl_domain.inc	24 Apr 2010 00:27:11 -0000
@@ -48,7 +48,7 @@ class purl_domain implements purl_proces
   public function rewrite(&$path, &$options, $element) {
     $options['absolute'] = TRUE;
     if ($base_url = $this->base_url()) {
-      if (!_purl_skip($element, $options)) {
+      if (!_purl_skip($element, $options, $path)) {
         $base = parse_url($base_url);
         $options['base_url'] = "{$base['scheme']}://{$element->value}{$base['path']}";
       }
Index: includes/purl_pair.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/purl/includes/Attic/purl_pair.inc,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 purl_pair.inc
--- includes/purl_pair.inc	18 Dec 2009 16:11:32 -0000	1.1.2.4
+++ includes/purl_pair.inc	24 Apr 2010 00:27:11 -0000
@@ -57,7 +57,7 @@ class purl_pair extends purl_path {
   }
 
   public function rewrite(&$path, &$options, $element) {
-    if (!_purl_skip($element, $options)) {
+    if (!_purl_skip($element, $options, $path)) {
       $items = explode('/', $path);
       array_unshift($items, "{$element->value}/{$element->id}");
       $path = implode('/', $items);
Index: includes/purl_path.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/purl/includes/Attic/purl_path.inc,v
retrieving revision 1.1.2.5
diff -u -p -r1.1.2.5 purl_path.inc
--- includes/purl_path.inc	5 Jan 2010 02:48:37 -0000	1.1.2.5
+++ includes/purl_path.inc	24 Apr 2010 00:27:11 -0000
@@ -82,7 +82,7 @@ class purl_path implements purl_processo
     // and we won't do any rewriting.
     $alt = $this->remove($path, $element);
 
-    if ($alt == $path && !_purl_skip($element, $options)) {
+    if ($alt == $path && !_purl_skip($element, $options, $path)) {
       $items = explode('/', $path);
       array_unshift($items, $element->value);
       $path = implode('/', $items);
Index: includes/purl_querystring.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/purl/includes/Attic/purl_querystring.inc,v
retrieving revision 1.1.2.5
diff -u -p -r1.1.2.5 purl_querystring.inc
--- includes/purl_querystring.inc	4 Jan 2010 23:03:49 -0000	1.1.2.5
+++ includes/purl_querystring.inc	24 Apr 2010 00:27:11 -0000
@@ -78,7 +78,7 @@ class purl_querystring implements purl_p
    * Just need to add the value to the front of the path.
    */
   public function rewrite(&$path, &$options, $element) {
-    if (!_purl_skip($element, $options)) {
+    if (!_purl_skip($element, $options, $path)) {
       $qs = array();
       parse_str($options['query'], $qs);
       $qs[$element->value] = $element->id;
Index: includes/purl_subdomain.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/purl/includes/Attic/purl_subdomain.inc,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 purl_subdomain.inc
--- includes/purl_subdomain.inc	23 Apr 2010 22:54:43 -0000	1.1.2.8
+++ includes/purl_subdomain.inc	24 Apr 2010 00:27:11 -0000
@@ -46,7 +46,7 @@ class purl_subdomain implements purl_pro
   public function rewrite(&$path, &$options, $element) {
     $options['absolute'] = TRUE;
     if ($base_url = $this->base_url()) {
-      if (!_purl_skip($element, $options)) {
+      if (!_purl_skip($element, $options, $path)) {
         $base = parse_url($base_url);
         $options['base_url'] = "{$base['scheme']}://{$element->value}.{$base['host']}{$base['path']}";
       }
