--- /cvs/drupal/contributions/modules/extra_voting_forms/extra_voting_forms.module	2007/12/20 23:14:47	1.1
+++ /cvs/drupal/contributions/modules/extra_voting_forms/extra_voting_forms.module	2008/04/11 22:00:45	1.1.2.1
@@ -1,6 +1,6 @@
 <?php
 
-// $Id: extra_voting_forms.module,v 1.42 2007/12/06 02:16:12 mercmobily Exp $
+// $Id: extra_voting_forms.module,v 1.1 2007/12/20 23:14:47 mercmobily Exp $
 
 /**
  * @file
@@ -1182,13 +1182,6 @@
     $karma_score_display='<span class="karma_score">'.$existing_vote_display.'</span>';
   }
 
-
-  // Make up the string to tell the system if a form refers to
-  // something with negative value
-  if($default < 0){
-    $negative_karma_str='<div class="has_negative_karma"></div>';
-  }
-
   switch($form_style) {
     // Form type 1 (Karma Vote Up/Down, multiple values)
     case 1:
@@ -1233,78 +1226,38 @@
 
 
       // Generate form
-       # <div class="extra_voting_forms karma_'.$o->sk_type.'_'.$form_style.'">
-      $form .= '
-        <div class="extra_voting_forms karma_'.$form_style.'">
-        <form action="'.$action.'" method="get" class="karma_form'.$is_promoted_class.'" id="'.($form_style==1?'z':'y').$o->sk_id.'">
-          '.$negative_karma_str.'
-          '.$karma_score_display.'
-          <span class="karma_buttons">
-            <select name="karma_vote" '.$voting_not_allowed_str.'>'
-              .$options.'
-            </select>
-            <input type="hidden" name="oid" value="'.$o->sk_id.'"/>
-            <input type="hidden" name="otype" value="'.$o->sk_type.'"/>
-            <input type="hidden" name="form_style" value="'.$form_style.'"/>
-            <input type="hidden" name="form_type" value="form"/>
-            <input type="submit" name="submit" value="Vote" '.$voting_not_allowed_str.'/>
-            '.extra_voting_forms_js_destination_field($o,$draw_js_destination_variable).'
-          </span>
-        </form>
-        </div>';
+
+      $js_dest_var = extra_voting_forms_js_destination_field($o,$draw_js_destination_variable);
+
+      $form .= theme_extra_voting_forms($form_style, $action, $is_promoted_class, $o,
+        $karma_score_display, $default, $voting_not_allowed_str, $js_dest_var);
+
       break;
 
     // Form type 3 (Karma Vote Up/Down, Two values only)
     case 3:
 
       // Generate form type 3
-      $form .= '
-        <div class="extra_voting_forms karma_'.$form_style.'">
-        <form action="'.$action.'" method="get" class="karma_form'.$is_promoted_class.'" id="x'.$o->sk_id.'">
-          '.$negative_karma_str.'
-          '.$karma_score_display.'
-          <span class="karma_buttons">
-            <label class="karma_up'.($default>0?'_clicked':'_not_clicked').$clickable_string.'" for="u'.$o->sk_id.'">
-              <input id="u'.$o->sk_id.'" type="radio" name="karma_vote" value="'.variable_get('extra_voting_forms_updown_voting_up_'.$o->sk_type, '').'"'.($default>0?' checked="checked"':'').'/>
-              <span>Up</span>
-            </label>
-            <label class="karma_down'.($default<0?'_clicked':'_not_clicked').$clickable_string.'" for="d'.$o->sk_id.'">
-              <input id="d'.$o->sk_id.'" type="radio" name="karma_vote" value="'.variable_get('extra_voting_forms_updown_voting_down_'.$o->sk_type, '').'"'.($default<0?' class="karma_clicked" checked="checked"':'').'/>
-              <span>Down</span>
-            </label>
-            <input type="hidden" name="oid" value="'.$o->sk_id.'"/>
-            <input type="hidden" name="otype" value="'.$o->sk_type.'"/>
-            <input type="hidden" name="form_style" value="'.$form_style.'"/>
-            <input type="hidden" name="form_type" value="form"/>
-            <input type="submit" name="submit" value="Vote" '.$voting_not_allowed_str.'/>
-            '.extra_voting_forms_js_destination_field($o,$draw_js_destination_variable).'
-          </span>
-        </form></div>';
+      $up_type_str = variable_get('extra_voting_forms_updown_voting_up_'.$o->sk_type, '');
+      $down_type_str = variable_get('extra_voting_forms_updown_voting_down_'.$o->sk_type, '');
+      $js_dest_var = extra_voting_forms_js_destination_field($o,$draw_js_destination_variable);
+
+      $form .= theme('extra_voting_forms_3', $action, $is_promoted_class, $o, $karma_score_display,
+        $default, $clickable_string, $up_type_str, $down_type_str, $voting_not_allowed_str, $js_dest_var);
+
       break;
 
       // Form type 4 (Karma Vote Up, Single value)
     case 4:
 
       // Generate form type 4
-      $form .= '
-        <div class="extra_voting_forms karma_'.$form_style.'">
-        <form action="'.$action.'" method="get" class="karma_form'.$is_promoted_class.'" id="w'.$o->sk_id.'">
-          '.$negative_karma_str.'
-          '.$karma_score_display.'
-          <span class="karma_buttons">
-            <label class="karma_up'.($default>0?'_clicked':'not_clicked').$clickable_string.'" for="u'.$o->sk_id.'">
-              <input id="u'.$o->sk_id.'" type="radio" name="karma_vote" value="'. variable_get('extra_voting_forms_updown_voting_up_'.$o->sk_type, '').'"/>
-              <span>Up</span>
-            </label>
-            <input type="hidden" name="oid" value="'.$o->sk_id.'"/>
-            <input type="hidden" name="otype" value="'.$o->sk_type.'"/>
-            <input type="hidden" name="form_style" value="'.$form_style.'"/>
-            <input type="hidden" name="form_type" value="form"/>
-            <input type="submit" name="submit" value="Vote" '.$voting_not_allowed_str.'/>
-            '.extra_voting_forms_js_destination_field($o,$draw_js_destination_variable).'
-          </span>
-        </form></div>';
-    break;
+      $up_type_str = variable_get('extra_voting_forms_updown_voting_up_'.$o->sk_type, '');
+      $js_dest_var = extra_voting_forms_js_destination_field($o,$draw_js_destination_variable);
+
+      $form .= theme('extra_voting_forms_4', $action, $is_promoted_class, $o, $karma_score_display,
+        $default, $clickable_string, $up_type_str, $voting_not_allowed_str, $js_dest_var);
+
+      break;
   }
 
   // Make up the finished form
@@ -1417,3 +1370,102 @@
  * **************************************************************
 */
 
+/* **************************************************************
+ *                        *** BEGIN ***
+ *                       THEME FUNCTIONS
+ * **************************************************************
+*/
+
+/**
+ * Return a themed select voting form for styles 1 or 2
+ */
+function theme_extra_voting_forms($form_style, $action, $is_promoted_class, $o,
+  $karma_score_display, $default, $voting_not_allowed_str, $js_dest_var) {
+
+  $form .= '
+    <div class="extra_voting_forms karma_'.$form_style.'">
+    <form action="'.$action.'" method="get" class="karma_form'.$is_promoted_class.'" id="'.($form_style==1?'z':'y').$o->sk_id.'">
+      '.(($default < 0)?'<div class="has_negative_karma"></div>':'').'
+      '.$karma_score_display.'
+      <span class="karma_buttons">
+        <select name="karma_vote" '.$voting_not_allowed_str.'>'
+          .$options.'
+        </select>
+        <input type="hidden" name="oid" value="'.$o->sk_id.'"/>
+        <input type="hidden" name="otype" value="'.$o->sk_type.'"/>
+        <input type="hidden" name="form_style" value="'.$form_style.'"/>
+        <input type="hidden" name="form_type" value="form"/>
+        <input type="submit" name="submit" value="Vote" '.$voting_not_allowed_str.'/>
+        '.$js_dest_var.'
+      </span>
+    </form>
+    </div>';
+
+  return $form;
+}
+
+/**
+ * Return a themed 2 button up/down voting form
+ */
+function theme_extra_voting_forms_3($action, $is_promoted_class, $o, $karma_score_display,
+  $default, $clickable_string, $up_type_str, $down_type_str, $voting_not_allowed_str, $js_dest_var) {
+
+  $form .= '
+    <div class="extra_voting_forms karma_3">
+    <form action="'.$action.'" method="get" class="karma_form'.$is_promoted_class.'" id="x'.$o->sk_id.'">
+      '.(($default < 0)?'<div class="has_negative_karma"></div>':'').'
+      '.$karma_score_display.'
+      <span class="karma_buttons">
+        <label class="karma_up'.($default>0?'_clicked':'_not_clicked').$clickable_string.'" for="u'.$o->sk_id.'">
+          <input id="u'.$o->sk_id.'" type="radio" name="karma_vote" value="'.$up_type_str.'"'.($default>0?' checked="checked"':'').'/>
+          <span>Up</span>
+        </label>
+        <label class="karma_down'.($default<0?'_clicked':'_not_clicked').$clickable_string.'" for="d'.$o->sk_id.'">
+          <input id="d'.$o->sk_id.'" type="radio" name="karma_vote" value="'.$down_type_str.'"'.($default<0?' class="karma_clicked" checked="checked"':'').'/>
+          <span>Down</span>
+        </label>
+        <input type="hidden" name="oid" value="'.$o->sk_id.'"/>
+        <input type="hidden" name="otype" value="'.$o->sk_type.'"/>
+        <input type="hidden" name="form_style" value="3"/>
+        <input type="hidden" name="form_type" value="form"/>
+        <input type="submit" name="submit" value="Vote" '.$voting_not_allowed_str.'/>
+        '.$js_dest_var.'
+      </span>
+    </form></div>';
+
+  return $form;
+}
+
+/**
+ * Return a themed 1 button voting form
+ */
+function theme_extra_voting_forms_4($action, $is_promoted_class, $o, $karma_score_display,
+  $default, $clickable_string, $up_type_str, $voting_not_allowed_str, $js_dest_var) {
+
+  $form .= '
+    <div class="extra_voting_forms karma_4">
+    <form action="'.$action.'" method="get" class="karma_form'.$is_promoted_class.'" id="w'.$o->sk_id.'">
+      '.(($default < 0)?'<div class="has_negative_karma"></div>':'').'
+      '.$karma_score_display.'
+      <span class="karma_buttons">
+        <label class="karma_up'.($default>0?'_clicked':'not_clicked').$clickable_string.'" for="u'.$o->sk_id.'">
+          <input id="u'.$o->sk_id.'" type="radio" name="karma_vote" value="'.$up_type_str.'"/>
+          <span>Up</span>
+        </label>
+        <input type="hidden" name="oid" value="'.$o->sk_id.'"/>
+        <input type="hidden" name="otype" value="'.$o->sk_type.'"/>
+        <input type="hidden" name="form_style" value="4"/>
+        <input type="hidden" name="form_type" value="form"/>
+        <input type="submit" name="submit" value="Vote" '.$voting_not_allowed_str.'/>
+        '.$js_dest_var.'
+      </span>
+    </form></div>';
+
+  return $form;
+}
+
+/* **************************************************************
+ *                        *** END OF ***
+ *                        THEME FUNCTIONS
+ * **************************************************************
+*/
