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	3 Sep 2009 22:25:41 -0000
@@ -1,93 +1,93 @@
 <?php
 //$Id: show_required.module,v 1.1.2.1 2009/05/19 20:49:21 arcaneadam Exp $
-/*******************
-*    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;
-}
 
-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);
+/**
+ * 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'),
+  );
+  return $items;
 }
 
+/**
+ * Page callback.
+ */
+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_asterisk" title="'. t('This field is required.') .'">*</span>',
+  );
+  $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')),
+    '#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 *@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),
+  );
+  $form['show_required_styling'] = array(
+    '#title' => t('Styling Info'),
+    '#type' => 'fieldset',
+  );
+  $form['show_required_styling']['info'] = 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);
+}
 
-/*******************
-*  Hook form_alter *
-*******************/
 
+/**
+ * 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)){
- //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 = 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_asterisk" 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_asterisk" 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)
-   {   
-   
-   
-       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;
-}
+/**
+ * Mutidimentional search for in_array function
+ * only matches the key, values don't count.
+ */
+function show_required_in_array_multi_key($needle, $haystack) {
+  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;
+}
\ No newline at end of file
