Index: show_required.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/show_required/show_required.module,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 show_required.module
--- show_required.module	19 May 2009 20:49:21 -0000	1.1.2.1
+++ show_required.module	2 Jul 2010 11:06:42 -0000
@@ -1,93 +1,77 @@
 <?php
-//$Id: show_required.module,v 1.1.2.1 2009/05/19 20:49:21 arcaneadam Exp $
+//$ Id: $
 /*******************
 *    Hook menu     *
 *******************/
 function show_required_menu(){
-$items['admin/settings/show_required']=array(
-'title'=>'Show Required Label',
-'access callback'=>'user_access',
-'access arguments'=>array('access administration pages'),
-'page callback'=>'drupal_get_form',
-'page arguments'=>array('show_required_settings'),
-);
-return $items;
+	$items['admin/settings/show_required']=array(
+		'title' => 'Show Required Label',
+		'access callback' => 'user_access',
+		'access arguments' => array('access administration pages'),
+		'page callback' => 'drupal_get_form',
+		'page arguments' => array('show_required_settings'),
+	);
+
+	return $items;
 }
 
 function show_required_settings(){
-$form['show_required_label']=array(
-'#title'=>t('Label'),
-'#default_value'=>variable_get('show_required_label','Required Field'),
-'#type'=>'textfield',
-'#description'=>t('The text that will display at the bottom of the forms. Example') .' <span class="form-required show_required_asterik" title="' . t('This field is required.') . '">*</span>'.t('Required Field. The asterik will always be added.'),
-'#field_prefix'=>'<span class="form-required show_required_asterik" title="' . t('This field is required.') . '">*</span>',
-);
-$form['show_required_location']=array(
-'#title'=>t("Location of *".variable_get('show_required_label','Required Field')." label"),
-'#type'=>'radios',
-'#options'=>array('above'=>t('Above Form'),'below'=>t('Below Form'),'both'=>t('Both')),
-'#default_value'=>variable_get('show_required_location','below'),
-);
-$form['show_required_exclude']=array(
-'#title'=>t('Exclude from the following'),
-'#description'=>t('Enter the form ID of individual forms, one per line, that you would like to exclude from having the *'.variable_get('show_required_label','Required Field').' from showing up on. Example:').'<p>show_required_settings<br />system_site_information_settings</p>' ,
-'#type'=>'textarea',
-'#default_value'=>variable_get('show_required_exclude',NULL),
-);
-$form['show_required_styling']=array(
-'#value'=>"<strong>".t('Styling Info')."</strong><p>".t('You can style the text by using the CSS class/ID "show_required". The * is wrapped in a span with the class "show_required_asterik". An example is below.')."</p><code>".'&lt;div id="show_required" class="show_required"&gt;&lt;span class="form-required show_required_asterik" title="' . t('This field is required.') . '"&gt;*&lt;/span&gt;' .  t(variable_get('show_required_label','Required Field')) . '&lt;/div&gt;</code>',
-);
-return system_settings_form($form);
+	$form['show_required_label']=array(
+		'#title' => t('Label'), 
+		'#default_value' => variable_get('show_required_label', 'Required Field'), 
+		'#type' => 'textfield', 
+		'#description' => t('The text that will display at the bottom of the forms. Example') .' <span class="form-required show_required_asterik" title="' . t('This field is required.') . '">*</span>'.t('Required Field. The asterik will always be added.'), 
+		'#field_prefix' => '<span class="form-required show_required_asterik" title="' . t('This field is required.') . '">*</span>', 
+	);
+
+	$form['show_required_location']=array(
+		'#title' => t("location of *".variable_get('show_required_label', 'Required Field')." label"), 
+		'#type' => 'radios', 
+		'#options' => array('above' => t('Above Form'), 'below' => t('Below Form'), 'both' => t('Both')), 
+		'#default_value' => variable_get('show_required_location', 'below'), 
+	);
+
+	$form['show_required_exclude']=array(
+		'#title' => t('Show on every page except the listed pages.'), 
+		// '#description' => t('Enter the form ID of individual forms,  one per line,  that you would like to exclude from having the *'.variable_get('show_required_label', 'Required Field').' from showing up on. Example:').'<p>show_required_settings<br />system_site_information_settings</p>' , 
+		'#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>')),
+		'#type' => 'textarea', 
+		'#default_value' => variable_get('show_required_exclude', NULL), 
+	);
+
+	$form['show_required_styling']=array(
+		'#value' => "<strong>".t('Styling Info')."</strong><p>".t('You can style the text by using the CSS class/ID "show_required". The * is wrapped in a span with the class "show_required_asterik". An example is below.')."</p><code>".'&lt;div id="show_required" class="show_required"&gt;&lt;span class="form-required show_required_asterik" title="' . t('This field is required.') . '"&gt;*&lt;/span&gt;' .  t(variable_get('show_required_label', 'Required Field')) . '&lt;/div&gt;</code>', 
+	);
+
+	return system_settings_form($form);
 }
 
 
 /*******************
 *  Hook form_alter *
 *******************/
-
 function show_required_form_alter(&$form, $form_state, $form_id) {
-$excludes=explode("\r\n",variable_get('show_required_exclude',NULL));
-if(!in_array($form_id,$excludes)){
- //check for any elements that have the #required key
-  $required = show_required_in_array_multi_key('#required',$form);
-  if($required){
-  $loc=variable_get('show_required_location','below');
-    if ($loc == 'above' || $loc == 'both'){
-  $form['#prefix']='<div id="show_required" class="show_required"><span class="form-required show_required_asterik" title="' . t('This field is required.') . '">*</span>' .  t(variable_get('show_required_label','Required Field')) . '</div>';
-    }
-    if ($loc == 'below' || $loc == 'both'){
-  //tack on the *Required Field text to the end of the form.
- 	$form['#suffix']='<div id="show_required" class="show_required"><span class="form-required show_required_asterik" title="' . t('This field is required.') . '">*</span>' . t(variable_get('show_required_label','Required Field')) . '</div>';
-    }
+	$excludes = variable_get('show_required_exclude', NULL);
+	$required_msg = '<div id="show_required" class="show_required"><span class="form-required show_required_asterik" title="' . t('This field is required.') . '">*</span>' .  t(variable_get('show_required_label', 'Required Field')) . '</div>';
 
+  // Match path if necessary
+  $path = drupal_get_path_alias($_GET['q']);
+  // Compare with the internal and path alias (if any).
+  $page_match = drupal_match_path($path, $excludes);
+  
+	if ($path != $_GET['q']) {
+    $page_match = $page_match || drupal_match_path($_GET['q'], $excludes);
   }
-  }  
-}
 
-//
-function show_required_in_array_multi_key($needle, $haystack)
-{
-   // mutidimentional search for in_array function
-   // only matches the key, values don't count.
-   if ( array_key_exists($needle, $haystack) && $haystack[$needle] != NULL)
-   {   
-   
-   
-       return TRUE;
-   }
-
-   foreach ( $haystack as $key => $value )
-   {
-       if ( is_array($value) )
-       {
-           $work = show_required_in_array_multi_key($needle, $value);
-           if ( $work )
-           {
-		   		
-               return TRUE;
-			  
-           }
-       }
-   }
-   return FALSE;
-}
+	if( !$page_match ){
+		$location = variable_get('show_required_location', 'below');
+
+ 		if ($location == 'above' || $location == 'both'){
+			$form['#prefix'] = $required_msg;
+ 		}
+
+ 		if ($location == 'below' || $location == 'both'){
+			$form['#suffix'] = $required_msg;
+ 		}
+  }  
+}
\ No newline at end of file
