Index: show_required.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/show_required/show_required.module,v
retrieving revision 1.2
diff -u -p -r1.2 show_required.module
--- show_required.module	15 Sep 2010 16:36:13 -0000	1.2
+++ show_required.module	15 Sep 2010 19:14:57 -0000
@@ -1,5 +1,5 @@
 <?php
-//$ Id: $
+// $Id$
 
 /**
  * Implementation of hook_help().
@@ -7,22 +7,24 @@
 function show_required_help($path, $arg) {
   switch ($path) {
     case 'admin/help#show_required':
-      return '<p>'. t("Show required label allows you to add a message to any form with a required object to let users know what the * next to field labels is for.") .'</p>';
+      return '<p>' . t("Show required label allows you to add a message to any form with a required object to let users know what the * next to field labels is for.") . '</p>';
+
     case 'admin/settings/show_required':
-      return '<p>'. t("Show required label allows you to add a message to any form with a required object to let users know what the * next to field labels is for.") .'</p>';
+      return '<p>' . t("Show required label allows you to add a message to any form with a required object to let users know what the * next to field labels is for.") . '</p>';
+
   }
 }
 
 /**
  * Implementation of 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'),
+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;
@@ -31,32 +33,32 @@ function show_required_menu(){
 /**
  * Implementation of module settings form
  */
-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: !asteriskRequired Field. The asterisk will always be added.', array('!asterisk' => '<span class="form-required show_required_asterisk" title="'. t('This field is required.') .'">*</span>')),
-    '#field_prefix'=>'<span class="form-required show_required_asterik" title="' . t('This field is required.') . '">*</span>',
+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: !asteriskRequired Field. The asterisk will always be added.', array('!asterisk' => '<span class="form-required show_required_asterisk" title="' . t('This field is required.') . '">*</span>')),
+    '#field_prefix' => '<span class="form-required show_required_asterik" title="' . t('This field is required.') . '">*</span>',
   );
-  $form['show_required_location']=array(
+  $form['show_required_location'] = array(
     '#title' => t("Location of *@label label", array('@label' => variable_get('show_required_label', 'Required Field'))),
-    '#type'=>'radios',
-    '#options'=>array(
-      'above'=>t('Above Form'),
-      'below'=>t('Below Form'),
-      'both'=>t('Both'),
+    '#type' => 'radios',
+    '#options' => array(
+      'above' => t('Above Form'),
+      'below' => t('Below Form'),
+      'both' => t('Both'),
     ),
-    '#default_value'=>variable_get('show_required_location','below'),
+    '#default_value' => variable_get('show_required_location', 'below'),
   );
-  $form['show_required_exclude']=array(
-    '#title'=>t('Exclude from the following'),
+  $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 *@label from showing up on. Example: !example', array('@label' => variable_get('show_required_label', 'Required Field'), '!example' => '<p>show_required_settings<br />system_site_information_settings</p>')),
-    '#type'=>'textarea',
-    '#default_value'=>variable_get('show_required_exclude',NULL),
+    '#type' => 'textarea',
+    '#default_value' => variable_get('show_required_exclude', NULL),
   );
-  $form['show_required_styling']=array(
-    '#value' => "<p>". t('You can style the text by using the CSS class/ID "@classid". The * is wrapped in a span with the class "@class". An example is below.', array('@classid' => 'show_required', '@class' => 'show_required_asterisk')) ."</p><code>" . '&lt;div id="show_required" class="show_required"&gt;&lt;span class="form-required show_required_asterisk" title="'. t('This field is required.') .'"&gt;*&lt;/span&gt;'.  t(variable_get('show_required_label', 'Required Field')) .'&lt;/div&gt;</code>',
+  $form['show_required_styling'] = array(
+    '#value' => "<p>" . t('You can style the text by using the CSS class/ID "@classid". The * is wrapped in a span with the class "@class". An example is below.', array('@classid' => 'show_required', '@class' => 'show_required_asterisk')) . "</p><code>" . '&lt;div id="show_required" class="show_required"&gt;&lt;span class="form-required show_required_asterisk" 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);
@@ -67,36 +69,36 @@ function show_required_settings(){
  * Implementation of 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)){
+  $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>';
-	  }
-	}
+    $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>';
+      }
+    }
   }  
 }
 
 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){   
+  if (array_key_exists($needle, $haystack) && $haystack[$needle] != NULL) {   
     return TRUE;
   }
-  foreach ($haystack as $key => $value){
-    if (is_array($value) ){
+  foreach ($haystack as $key => $value) {
+    if (is_array($value)) {
       $work = show_required_in_array_multi_key($needle, $value);
-      if ($work){
-		return TRUE;	  
+      if ($work) {
+		    return TRUE;	  
       }
     }
   }
   return FALSE;
-}
\ No newline at end of file
+}
