Index: betterselect.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/betterselect/betterselect.module,v
retrieving revision 1.4.2.7
diff -u -r1.4.2.7 betterselect.module
--- betterselect.module	27 Feb 2009 15:05:29 -0000	1.4.2.7
+++ betterselect.module	1 Feb 2010 20:48:31 -0000
@@ -65,6 +65,15 @@
     '#description' => t('Add an extra div to each betterselect option, with a class indicating depth in taxonomy hierarchy. Good for styling parent/child.'),
     '#default_value' => variable_get('betterselect_add_depth_classes', FALSE),
   );
+  
+  $form['betterselect_general']['betterselect_exclude_fields'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Excluded fields (uses preg_match)'),
+    '#cols' => 120,
+    '#rows' => 7,
+    '#description' => t('Enter regular expressions to exclude pages and fields from conversion (eg "/[path regexp]/;/[fieldname_regexp]/"). One entry per row.'),
+    '#default_value' =>  variable_get('betterselect_exclude_fields', '/^\/admin.*$/;/.*/'),
+  );
 
   return system_settings_form($form);
 }
@@ -83,7 +92,7 @@
  * Form process callback; translates multiselect fields into checkboxes.
  */
 function betterselect_process($element, $edit, $form_state, $complete_form) {
-  if (isset($element['#multiple']) && $element['#multiple'] == TRUE && !(variable_get('betterselect_node_form_only', FALSE) == TRUE && $complete_form['#id'] != 'node-form')) {
+  if (isset($element['#multiple']) && $element['#multiple'] == TRUE && !(variable_get('betterselect_node_form_only', FALSE) == TRUE && $complete_form['#id'] != 'node-form') && !betterselect_is_page_excluded($complete_form, $element)) {
 
     // If we're dealing with taxonomy, fix the option titles.
     if (is_object($element['#options'][0])) {
@@ -243,3 +252,25 @@
     }
   }
 }
+
+/**
+ * Check if the current page is supposed to be excluded
+ * based on the regexps in betterselect_exclude_fields
+ */
+function betterselect_is_page_excluded($complete_form, $element) {
+  // Get the action-string
+  $action = $complete_form['#action'];
+  // Remove ?q= if needed
+  $action = preg_replace("/^\/\?q\=/", "/", $action, 1);
+  // Retrieve all regular expressions into an array
+  $exclude_patterns = explode("\n", variable_get('betterselect_exclude_fields', '/^\/admin.*$/;/.*/'));
+  foreach ($exclude_patterns as $cur_pattern) {
+    $cur_pattern = explode(';', trim($cur_pattern));
+    if (preg_match($cur_pattern[0], $action) != 0) {
+      if (preg_match($cur_pattern[1], $element['#name']) != 0) {
+        return TRUE;
+      }
+    }
+  }
+  return FALSE;	
+}
\ No newline at end of file
