﻿Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.2
diff -u -p -r1.2 mollom.module
--- mollom.module	31 Mar 2008 12:49:52 -0000	1.2
+++ mollom.module	30 May 2009 12:05:15 -0000
@@ -123,7 +123,7 @@ function mollom_captcha($type, $session_
       $output .= ' <param name="autoplay" value="false" />';
       $output .= ' <param name="controller" value="true" />';
       $output .= '</object>';
-      $output .= ' (<a href="#" id="image-captcha">'. t('use image CAPTCHA') .'</a>)';
+      $output .= ' '. theme('mollom_image_captcha_link');
     }
   }
   
@@ -131,8 +131,8 @@ function mollom_captcha($type, $session_
     $response = mollom('mollom.getImageCaptcha', array('author_ip' => ip_address(), 'session_id' => $session_id));
 
     if ($response) {
-      $output = '<a href="http://mollom.com"><img src="'. check_plain(url($response['url'])) .'" alt="Mollom CAPTCHA" /></a>';
-      $output .= ' (<a href="#" id="audio-captcha">'. t('play audio CAPTCHA') .'</a>)';
+      $output = ' '. theme('mollom_captcha_image', $response);
+      $output .= ' '. theme('mollom_audio_captcha_link');
     }
   }
     
@@ -737,7 +737,56 @@ function _mollom_fallback() {
     watchdog('mollom', 'Problem with spam filter: @errno - %error_msg', array('@errno' => xmlrpc_errno(), '%error_msg' => xmlrpc_error_msg()), WATCHDOG_ERROR);
   }
 }
-   
+
+/**
+ * Implementation of hook_theme.
+ */
+function mollom_theme() {
+  return array(
+    'mollom_captcha' => array(
+      'arguments' => array('response' => NULL),
+    ),
+    'mollom_captcha_image' => array(
+      'arguments' => array('response' => NULL),
+    ),
+    'mollom_audio_captcha_link' => array(
+      'arguments' => array(),
+    ),
+    'mollom_image_captcha_link' => array(
+      'arguments' => array(),
+    ),
+  );
+}
+
+/**
+ * Theme function of the Mollom captcha.
+ */
+function theme_mollom_captcha($response) {
+  $output = '<div id="captcha">';
+  $output .= ' '. theme('mollom_captcha_image', $response);
+  $output .= ' '. theme('mollom_audio_captcha_link');
+  $output .= '</div>';
+  return $output;
+}
+
+function theme_mollom_captcha_image($response) {
+  return '<a href="http://mollom.com"><img src="'. check_plain(url($response['url'])) .'" alt="Mollom CAPTCHA" /></a>';
+}
+
+/**
+ * Theme function of the Mollom audio captcha link.
+ */
+function theme_mollom_audio_captcha_link() {
+  return '(<a href="#" id="audio-captcha">'. t('play audio CAPTCHA') .'</a>)';
+}
+
+/**
+ * Theme function of the Mollom audio captcha link.
+ */
+function theme_mollom_image_captcha_link() {
+  return '(<a href="#" id="image-captcha">'. t('use image CAPTCHA') .'</a>)';
+}
+
 /**
  * This the a form API validator function that will be called to perform text analysis on a form.
  */
@@ -983,7 +1032,7 @@ function _mollom_insert_captcha(&$form, 
         '#name' => 'captcha',
         '#id' => 'edit-captcha',
         '#title' => t('CAPTCHA'),
-        '#prefix' => '<div id="captcha"><a href="http://mollom.com"><img src="'. url($response['url']) .'" alt="Mollom CAPTCHA" /></a> (<a href="#" id="audio-captcha">play audio CAPTCHA</a>)</div>',
+        '#prefix' => theme('mollom_captcha', $response),
         '#required' => TRUE,
         '#size' => 10,
         '#description' => t("Type in the characters shown in the above; if you can't read them, submit the form and a new image will be generated."),
