Skip to content

Commit

Permalink
Merge pull request #27 from Turnerj/master
Browse files Browse the repository at this point in the history
Added/fixed basic Mollom audio support
  • Loading branch information
wilr committed May 31, 2015
2 parents 40f3d90 + a1c9bd0 commit d7f1e50
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
29 changes: 28 additions & 1 deletion code/formfields/MollomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class MollomField extends FormField {
* @var array
*/
private $fieldMapping = array();

/**
* @var string
*/
private $captchaType = 'image';

/**
* @config
Expand Down Expand Up @@ -52,7 +57,7 @@ public function getCaptcha() {
Requirements::css(MOLLOM_DIR . '/css/mollom.css');

$result = $this->getMollom()->createCaptcha(array(
'type' => 'image'
'type' => $this->getCaptchaType()
));

if(is_array($result)) {
Expand All @@ -64,6 +69,28 @@ public function getCaptcha() {

return null;
}

/**
* Set the captcha type. Mollom supports "image" and "audio" types.
*
* @return void
*/
public function setCaptchaType($Type) {
if (in_array($Type, array('image', 'audio'))) {
$this->captchaType = $Type;
}
}

/**
* Returns the captcha type that has been set. Default is "image".
*
* @return string
*/
public function getCaptchaType() {
return $this->captchaType;
}



/**
* Determines if the current user is exempt from spam detection
Expand Down
15 changes: 11 additions & 4 deletions templates/MollomField.ss
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<% if Captcha %>
<% if not $isReadonly %>
<div class="mollom-captcha">
<% if $CaptchaType == "image" %>
<div class="mollom-image-captcha">
<img src="$Captcha" alt="Type the characters you see in this picture." />
<input type="text" name="$Name" size="10" value="" autocomplete="off" required />
</div>
<!--
<% else_if $CaptchaType == "audio" %>
<div class="mollom-audio-captcha">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="110" height="50">
<audio src="$Captcha" preload="auto" controls>
<p>Your browser does not support audio captcha</p>
</audio>

<!-- <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="110" height="50">
<param name="allowFullScreen" value="false" />
<param name="movie" value="$CaptchaAudioFile" />
<param name="loop" value="false" />
Expand All @@ -16,9 +21,11 @@
<param name="wmode" value="transparent" />
<param name="bgcolor" value="#ffffff" />
<embed src="$CaptchaAudioFile" loop="false" menu="false" quality="high" wmode="transparent" bgcolor="#ffffff" width="110" height="50" align="baseline" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer_de" />
</object>
</object> -->

<input type="text" name="$Name" size="10" value="" autocomplete="off" required />
</div>
-->
<% end_if %>
</div>
<% else %>
<!-- Readonly form, Mollom is hidden and we don't need to validate ever -->
Expand Down

0 comments on commit d7f1e50

Please sign in to comment.