Permalink
Browse files

Upgrade to be 3.0 compatible.

  • Loading branch information...
1 parent 3f19146 commit e8555cdf7403c0d0e17da57a82151b3b8e3bf1b1 @robert-h-curry robert-h-curry committed Jul 6, 2012
View
@@ -3,27 +3,26 @@
## Installation
1. Unzip this file (mollom-0.3.tar.gz) inside your SilverStripe installation directory.
-It should be at the same level as 'cms' and 'sapphire' modules.
+It should be at the same level as 'cms' and 'framework' modules.
2. Ensure the directory name for the module is 'mollom'.
3. Visit your SilverStripe site.
-4. Add db/build to the end of the website URL. For example: http://localhost:8888/mysite/db/build.
+4. Add dev/build to the end of the website URL. For example: http://localhost:8888/mysite/dev/build.
5. We now need to setup some basic features to get the module up and running. Open up _config.php
-inside Mollom module directory ('mollom/_config.php') with your favourite text editor.
+inside the mysite module directory ('mysite/_config.php') with your favourite text editor.
Read the instructions below to setup the initial configuration of the module.
-
## Setting up the Mollom API key
-Copy the following code into your mysite/_config.php file, and eplace the strings
-"enter-your-mollom-public-key" and "enter-your-mollom-private-key"
-with the public key and private key you obtained from Mollom (http://mollom.com/)
+Copy the following code into your mysite/_config.php file, and replace the strings
+'enter-your-mollom-public-key' and 'enter-your-mollom-private-key'
+with the public key and private key you obtained from [Mollom](http://mollom.com/)
- MollomServer::setPublicKey("enter-your-mollom-public-key");
- MollomServer::setPrivateKey("enter-your-mollom-private-key");
+ MollomServer::setPublicKey('enter-your-mollom-public-key');
+ MollomServer::setPrivateKey('enter-your-mollom-private-key');
SpamProtectorManager::set_spam_protector('MollomSpamProtector');
### What does this do?
@@ -40,23 +39,23 @@ Suppose you create a contact form in a page type called 'ContactPage.php' (in 'm
* Sample contact form
*/
function ContactForm() {
- $fields = new FieldSet(
- new TextField("Name", "Name"),
- new EmailField("Email", "Email"),
- new TextField("Website", "Website"),
- new TextareaField("Content", "Message")
+ $fields = new FieldList(
+ new TextField('Name', 'Name'),
+ new EmailField('Email', 'Email'),
+ new TextField('Website', 'Website'),
+ new TextareaField('Content', 'Message')
);
- $actions = new FieldSet(
+ $actions = new FieldList(
new FormAction('doContactForm', 'Submit')
);
$form = new Form($this, "ContactForm", $fields, $actions);
// form fields and mollom fields mapping
- $fieldMap = array('Name' => 'author_name', 'Email' => 'author_email', 'Website' => 'author_url', 'Content' => 'post_body')
+ $fieldMap = array('Name' => 'author_name', 'Email' => 'author_mail', 'Website' => 'author_url', 'Content' => 'post_body');
- // Update the form to add the protecter field to it
+ // Update the form to add the protector field to it
$protector = SpamProtectorManager::update_form($form, null, $fieldMap);
return $form;
@@ -68,13 +67,13 @@ Also you may want to switch Mollom into developers mode (Log into Mollom's websi
### What does this do?
-This setup a contact form with a mollom field. When page first loaded, it displays
-a normal form without the protector field.
+This setup a contact form with a mollom field. When the page is first loaded, it
+displays a normal form without the protector field.
After user fills the form and submits it, the content of the form is sent to Mollom
service for spam checking. If Mollom service verifies that the submission is not a
spam, the control will pass on to doContactForm() function. If the service says the
submission is a spam, user will be redirected to the homepage without further
processing with the form data. On the other hand, if the service is not sure whether
the submission is a spam or a ham, user will be presented with Captcha image and
-audio and a text field for issuing the Captcha solution.
+audio and a text field for issuing the Captcha solution.
View
@@ -8,7 +8,7 @@
<will (at) silverstripe (dot) com>
## Requirements
-* Silverstripe 2.4
+* Silverstripe 3.0.0
* PHP 5 Mollom library < http://mollom.crsolutions.be/ > (already included)
* Silverstripe SpamProtection module
View
@@ -1,2 +1,3 @@
<?php
-SS_Report::register('ReportAdmin', 'MollomReport');
+
+LeftAndMain::require_css('mollom/css/MollomAdmin.css');
View
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Backend Report Interface for Mollom Status
+ *
+ * @package spamprotection
+ * @subpackage mollom
+ */
+
+class MollomAdmin extends LeftAndMain {
+
+ static $url_segment = "mollom";
+
+ static $menu_title = "Mollom";
+
+ static $menu_priority = -0.5;
+
+ function init() {
+ MollomServer::initServerList();
+
+ return parent::init();
+ }
+
+ function getPublicKey() {
+ return MollomServer::getPublicKey();
+ }
+
+ function isKeyVerified() {
+ return MollomServer::verifyKey();
+ }
+}
View
@@ -30,15 +30,15 @@ class MollomField extends SpamProtectorField {
'author_id' => ''
);
- function Field() {
+ function Field($properties = array()) {
$attributes = array(
'type' => 'text',
'class' => 'text' . ($this->extraClass() ? $this->extraClass() : ''),
'id' => $this->id(),
- 'name' => $this->Name(),
+ 'name' => $this->getName(),
'value' => $this->Value(),
'title' => $this->Title(),
- 'tabindex' => $this->getTabIndex(),
+ 'tabindex' => $this->getAttribute('tabindex'),
'maxlength' => ($this->maxLength) ? $this->maxLength : null,
'size' => ($this->maxLength) ? min( $this->maxLength, 30 ) : null
);
@@ -83,8 +83,8 @@ private function showCaptcha() {
/**
* Return the Field Holder if Required
*/
- function FieldHolder() {
- return ($this->showCaptcha()) ? parent::FieldHolder() : null;
+ function FieldHolder($properties = array()) {
+ return ($this->showCaptcha()) ? parent::FieldHolder($properties) : null;
}
/**
@@ -127,7 +127,6 @@ function validate($validator) {
_t(
'MollomCaptchaField.INCORRECTSOLUTION',
"You didn't type in the correct captcha text. Please type it in again.",
- PR_MEDIUM,
"Mollom Captcha provides words in an image, and expects a user to type them in a textfield"
),
"validation",
@@ -138,7 +137,7 @@ function validate($validator) {
}
}
- // populate mollem fields
+ // populate mollom fields
foreach($spamFields as $key => $field) {
if(array_key_exists($field, $this->mollomFields)) {
$this->mollomFields[$field] = (isset($_REQUEST[$key])) ? $_REQUEST[$key] : "";
@@ -165,14 +164,13 @@ function validate($validator) {
$this->clearMollomSession();
return true;
}
- // response is could be spam, or we just want to be sure.
+ // response could be spam, or we just want to be sure.
else if($response['spam'] == 'unsure') {
$validator->validationError(
$this->name,
_t(
'MollomCaptchaField.CAPTCHAREQUESTED',
"Please answer the captcha question",
- PR_MEDIUM,
"Mollom Captcha provides words in an image, and expects a user to type them in a textfield"
),
"warning"
@@ -189,7 +187,6 @@ function validate($validator) {
_t(
'MollomCaptchaField.SPAM',
"Your submission has been rejected because it was treated as spam.",
- PR_MEDIUM,
"Mollom Captcha provides words in an image, and expects a user to type them in a textfield"
),
"error"
View
@@ -1,54 +0,0 @@
-<?php
-/**
- * Backend Report Interface for Mollom Status
- *
- * @package spamprotection
- * @subpackage mollom
- */
-
-class MollomReport extends SS_Report {
-
- protected $title = "Mollom";
-
- protected $description = "Mollom Usage and Statistics";
-
- /**
- * Returns empty field set and use echo() to return output instead.
- *
- * Using form fields and fieldset can done but we need to introduce FieldGroup (according to the ReportAdmin form template, {@see ReportAdminForm.ss}).
- * On top of that, we need to css to style the output profile in order to produce a readable output.
- */
- function getCMSFields() {
- $URL = "http://mollom.com/statistics.swf?key=". MollomServer::getPublicKey();
- $errMsg = "";
-
- MollomServer::initServerList();
-
- if(MollomServer::getPublicKey()) {
- if(!MollomServer::verifyKey()) {
- $errMsg = _t('Mollom.KEYWRONG', 'Your key is not valid. Please try another key');
- }
- }
- else {
- $errMsg = _t('Mollom.NOKEY', 'You have not configured your key. Please add it to mysite/_config.php.');
- }
-
- echo "<h3>Mollom Key Status</h3>";
-
- if (empty($errMsg)) {
- echo "
- <p><a href='http://mollom.com/terms-of-service' target='_blank'>". _t('Mollom.TERMS', 'View Molloms Terms of Use'). "</a></p>
-
- <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"100%\" height=\"100%\" id=\"movie\">
- <param name=\"movie\" value=\"$URL\">
- <embed src=\"$URL\" quality=\"high\" width=\"100%\" height=\"100%\" name=\"movie\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\">
- </object>
- ";
- }
- else {
- echo "<p>$errMsg</p>";
- }
-
- return new FieldSet();
- }
-}
View
@@ -0,0 +1,9 @@
+.icon-mollomadmin.icon-16 {
+ background: url("../images/mollom.png");
+}
+
+.mollom-graph-container {
+ max-width: 1024px;
+ height: 430px;
+ border: 1px solid #aaa;
+}
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,14 @@
+en:
+ Mollom:
+ KEYEXISTS: Your key exists and is working.
+ KEYSTATUS: Mollom Key Status
+ KEYWRONG: Your key is not valid. Please try another key.
+ NOKEY: You have not configured your key. Please add it to mysite/_config.php.
+ TERMS: View Mollom's Terms of Use
+ MollomCaptchaField:
+ CAPTCHAREQUESTED: Please answer the captcha question.
+ INCORRECTSOLUTION: You didn't type in the correct captcha text. Please type it in again.
+ SPAM: Your submission has been rejected because it was treated as spam.
+ MollomServer:
+ PLURALNAME: Mollom Servers
+ SINGULARNAME: Mollom Server
View
@@ -1,36 +0,0 @@
-<?php
-
-global $lang;
-
-$lang['en_US']['Mollom']['KEYEXISTS'] = 'Your key exists and is working';
-$lang['en_US']['Mollom']['KEYSTATUS'] = 'Mollom Key Status';
-$lang['en_US']['Mollom']['KEYWRONG'] = 'Your key is not valid. Please try another key';
-$lang['en_US']['Mollom']['NOKEY'] = 'You have not configured your key. Please add it to mysite/_config.php.';
-$lang['en_US']['Mollom']['TERMS'] = 'View Molloms Terms of Use';
-$lang['en_US']['MollomCaptchaField']['CAPTCHAREQUESTED'] = array(
- 'Please answer the captcha question',
- PR_MEDIUM,
- 'Mollom Captcha provides words in an image, and expects a user to type them in a textfield'
-);
-$lang['en_US']['MollomCaptchaField']['INCORRECTSOLUTION'] = array(
- 'You didn\'t type in the correct captcha text. Please type it in again.',
- PR_MEDIUM,
- 'Mollom Captcha provides words in an image, and expects a user to type them in a textfield'
-);
-$lang['en_US']['MollomCaptchaField']['SPAM'] = array(
- 'Your submission has been rejected because it was treated as spam.',
- PR_MEDIUM,
- 'Mollom Captcha provides words in an image, and expects a user to type them in a textfield'
-);
-$lang['en_US']['MollomServer']['PLURALNAME'] = array(
- 'Mollom Servers',
- 50,
- 'Pural name of the object, used in dropdowns and to generally identify a collection of this object in the interface'
-);
-$lang['en_US']['MollomServer']['SINGULARNAME'] = array(
- 'Mollom Server',
- 50,
- 'Singular name of the object, used in dropdowns and to generally identify a single object in the interface'
-);
-
-?>
View
@@ -122,7 +122,7 @@ class Mollom
* @return string
* @param mixed $value
*/
- private function buildValue($value)
+ private static function buildValue($value)
{
// get type
$type = gettype($value);
@@ -182,7 +182,7 @@ public static function checkCaptcha($sessionId, $solution)
// do the call
$responseString = self::doCall('checkCaptcha', $parameters);
// validate
- if(!isset($responseString->params->param->value->boolean)) throw new Exception('Invalid response in checkCapthca.');
+ if(!isset($responseString->params->param->value->boolean)) throw new Exception('Invalid response in checkCaptcha.');
// return
if((string) $responseString->params->param->value->boolean == '1') return true;
@@ -193,7 +193,7 @@ public static function checkCaptcha($sessionId, $solution)
/**
- * Check if the data is spam or not, and gets an assessment of the datas quality
+ * Check if the data is spam or not, and gets an assessment of the data's quality
*
* This function will be used most. The more data you submit the more accurate the claasification will be.
* If the spamstatus is 'unsure', you could send the user an extra check (eg. a captcha).
@@ -203,7 +203,7 @@ public static function checkCaptcha($sessionId, $solution)
* The function will return an array with 3 elements:
* - spam the spam-status (unknown/ham/spam/unsure)
* - quality an assessment of the content's quality (between 0 and 1)
- * - session_id Molloms session_id
+ * - session_id Mollom's session_id
*
* @return array
* @param string[optional] $sessionId
@@ -234,7 +234,7 @@ public static function checkContent($sessionId = null, $postTitle = null, $postB
if($authorOpenId != null) $parameters['author_openid'] = (string) $authorOpenId;
if($authorId != null) $parameters['author_id'] = (string) $authorId;
- // set autor ip
+ // set author ip
$authorIp = self::getIpAddress();
if($authorIp != null) $parameters['author_ip'] = (string) $authorIp;
Oops, something went wrong.

0 comments on commit e8555cd

Please sign in to comment.