Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Upgrade to be 3.0 compatible.

  • Loading branch information...
commit e8555cdf7403c0d0e17da57a82151b3b8e3bf1b1 1 parent 3f19146
Robert Curry authored July 06, 2012
39  INSTALL.md
Source Rendered
@@ -3,27 +3,26 @@
3 3
 ## Installation
4 4
 
5 5
 1. Unzip this file (mollom-0.3.tar.gz) inside your SilverStripe installation directory.
6  
-It should be at the same level as 'cms' and 'sapphire' modules.
  6
+It should be at the same level as 'cms' and 'framework' modules.
7 7
 
8 8
 2. Ensure the directory name for the module is 'mollom'. 
9 9
 
10 10
 3. Visit your SilverStripe site.
11 11
 
12  
-4. Add db/build to the end of the website URL. For example: http://localhost:8888/mysite/db/build.
  12
+4. Add dev/build to the end of the website URL. For example: http://localhost:8888/mysite/dev/build.
13 13
 
14 14
 5. We now need to setup some basic features to get the module up and running. Open up _config.php
15  
-inside Mollom module directory ('mollom/_config.php') with your favourite text editor.
  15
+inside the mysite module directory ('mysite/_config.php') with your favourite text editor.
16 16
 Read the instructions below to setup the initial configuration of the module.
17 17
 
18  
-
19 18
 ## Setting up the Mollom API key
20 19
 
21  
-Copy the following code into your mysite/_config.php file, and eplace the strings
22  
-"enter-your-mollom-public-key" and "enter-your-mollom-private-key" 
23  
-with the public key and private key you obtained from Mollom (http://mollom.com/)
  20
+Copy the following code into your mysite/_config.php file, and replace the strings
  21
+'enter-your-mollom-public-key' and 'enter-your-mollom-private-key'
  22
+with the public key and private key you obtained from [Mollom](http://mollom.com/)
24 23
 
25  
-	MollomServer::setPublicKey("enter-your-mollom-public-key");
26  
-	MollomServer::setPrivateKey("enter-your-mollom-private-key");
  24
+	MollomServer::setPublicKey('enter-your-mollom-public-key');
  25
+	MollomServer::setPrivateKey('enter-your-mollom-private-key');
27 26
 	SpamProtectorManager::set_spam_protector('MollomSpamProtector');
28 27
 
29 28
 ### What does this do?
@@ -40,23 +39,23 @@ Suppose you create a contact form in a page type called 'ContactPage.php' (in 'm
40 39
 	 * Sample contact form
41 40
 	 */
42 41
 	function ContactForm() {
43  
-		$fields = new FieldSet(
44  
-	      	new TextField("Name", "Name"),
45  
-			new EmailField("Email",  "Email"),
46  
-			new TextField("Website", "Website"),
47  
-			new TextareaField("Content", "Message")
  42
+		$fields = new FieldList(
  43
+	      	new TextField('Name', 'Name'),
  44
+			new EmailField('Email',  'Email'),
  45
+			new TextField('Website', 'Website'),
  46
+			new TextareaField('Content', 'Message')
48 47
 	  	);
49 48
 
50  
-		$actions = new FieldSet(
  49
+		$actions = new FieldList(
51 50
 	      	new FormAction('doContactForm', 'Submit')
52 51
 	  	);
53 52
 
54 53
 	  	$form = new Form($this, "ContactForm", $fields, $actions);
55 54
 	
56 55
 		// form fields and mollom fields mapping
57  
-		$fieldMap = array('Name' => 'author_name', 'Email' => 'author_email', 'Website' => 'author_url', 'Content' => 'post_body')
  56
+		$fieldMap = array('Name' => 'author_name', 'Email' => 'author_mail', 'Website' => 'author_url', 'Content' => 'post_body');
58 57
 	
59  
-		// Update the form to add the protecter field to it
  58
+		// Update the form to add the protector field to it
60 59
 		$protector = SpamProtectorManager::update_form($form, null, $fieldMap);
61 60
 	
62 61
 		return $form;
@@ -68,8 +67,8 @@ Also you may want to switch Mollom into developers mode (Log into Mollom's websi
68 67
 
69 68
 ### What does this do?
70 69
 
71  
-This setup a contact form with a mollom field. When page first loaded, it displays
72  
-a normal form without the protector field. 
  70
+This setup a contact form with a mollom field. When the page is first loaded, it
  71
+displays a normal form without the protector field.
73 72
 
74 73
 After user fills the form and submits it, the content of the form is sent to Mollom
75 74
 service for spam checking. If Mollom service verifies that the submission is not a
@@ -77,4 +76,4 @@ spam, the control will pass on to doContactForm() function. If the service says
77 76
 submission is a spam, user will be redirected to the homepage without further 
78 77
 processing with the form data. On the other hand, if the service is not sure whether
79 78
 the submission is a spam or a ham, user will be presented with Captcha image and
80  
-audio and a text field for issuing the Captcha solution. 
  79
+audio and a text field for issuing the Captcha solution.
2  README.md
Source Rendered
@@ -8,7 +8,7 @@
8 8
   <will (at) silverstripe (dot) com>
9 9
 
10 10
 ## Requirements
11  
-* Silverstripe 2.4
  11
+* Silverstripe 3.0.0
12 12
 * PHP 5 Mollom library < http://mollom.crsolutions.be/ > (already included)
13 13
 * Silverstripe SpamProtection module
14 14
 
3  _config.php
... ...
@@ -1,2 +1,3 @@
1 1
 <?php
2  
-SS_Report::register('ReportAdmin', 'MollomReport');
  2
+
  3
+LeftAndMain::require_css('mollom/css/MollomAdmin.css');
30  code/MollomAdmin.php
... ...
@@ -0,0 +1,30 @@
  1
+<?php
  2
+/** 
  3
+ * Backend Report Interface for Mollom Status
  4
+ *
  5
+ * @package spamprotection
  6
+ * @subpackage mollom
  7
+ */
  8
+
  9
+class MollomAdmin extends LeftAndMain {
  10
+	
  11
+	static $url_segment = "mollom";
  12
+	
  13
+	static $menu_title = "Mollom";
  14
+
  15
+	static $menu_priority = -0.5;
  16
+
  17
+	function init() {
  18
+		MollomServer::initServerList();
  19
+
  20
+		return parent::init();
  21
+	}
  22
+
  23
+	function getPublicKey() {
  24
+		return MollomServer::getPublicKey();
  25
+	}
  26
+
  27
+	function isKeyVerified() {
  28
+		return MollomServer::verifyKey();
  29
+	}
  30
+}
17  code/MollomField.php
@@ -30,15 +30,15 @@ class MollomField extends SpamProtectorField {
30 30
 		'author_id' => ''
31 31
 	);
32 32
 
33  
-	function Field() {
  33
+	function Field($properties = array()) {
34 34
 		$attributes = array(
35 35
 			'type' => 'text',
36 36
 			'class' => 'text' . ($this->extraClass() ? $this->extraClass() : ''),
37 37
 			'id' => $this->id(),
38  
-			'name' => $this->Name(),
  38
+			'name' => $this->getName(),
39 39
 			'value' => $this->Value(),
40 40
 			'title' => $this->Title(),
41  
-			'tabindex' => $this->getTabIndex(),
  41
+			'tabindex' => $this->getAttribute('tabindex'),
42 42
 			'maxlength' => ($this->maxLength) ? $this->maxLength : null,
43 43
 			'size' => ($this->maxLength) ? min( $this->maxLength, 30 ) : null 
44 44
 		);
@@ -83,8 +83,8 @@ private function showCaptcha() {
83 83
 	/**
84 84
 	 * Return the Field Holder if Required
85 85
 	 */
86  
-	function FieldHolder() {
87  
-		return ($this->showCaptcha()) ? parent::FieldHolder() : null;
  86
+	function FieldHolder($properties = array()) {
  87
+		return ($this->showCaptcha()) ? parent::FieldHolder($properties) : null;
88 88
 	}
89 89
 	
90 90
 	/**
@@ -127,7 +127,6 @@ function validate($validator) {
127 127
 					_t(
128 128
 						'MollomCaptchaField.INCORRECTSOLUTION', 
129 129
 						"You didn't type in the correct captcha text. Please type it in again.",
130  
-						PR_MEDIUM,
131 130
 						"Mollom Captcha provides words in an image, and expects a user to type them in a textfield"
132 131
 					), 
133 132
 					"validation", 
@@ -138,7 +137,7 @@ function validate($validator) {
138 137
 			}
139 138
 		}
140 139
 
141  
-		// populate mollem fields
  140
+		// populate mollom fields
142 141
 		foreach($spamFields as $key => $field) {
143 142
 			if(array_key_exists($field, $this->mollomFields)) {
144 143
 				$this->mollomFields[$field] = (isset($_REQUEST[$key])) ? $_REQUEST[$key] : "";
@@ -165,14 +164,13 @@ function validate($validator) {
165 164
 			$this->clearMollomSession();
166 165
 			return true;
167 166
 		} 
168  
-		// response is could be spam, or we just want to be sure.
  167
+		// response could be spam, or we just want to be sure.
169 168
 		else if($response['spam'] == 'unsure') {
170 169
 			$validator->validationError(
171 170
 				$this->name, 
172 171
 				_t(
173 172
 					'MollomCaptchaField.CAPTCHAREQUESTED', 
174 173
 					"Please answer the captcha question",
175  
-					PR_MEDIUM,
176 174
 					"Mollom Captcha provides words in an image, and expects a user to type them in a textfield"
177 175
 				), 
178 176
 				"warning"
@@ -189,7 +187,6 @@ function validate($validator) {
189 187
 				_t(
190 188
 					'MollomCaptchaField.SPAM', 
191 189
 					"Your submission has been rejected because it was treated as spam.",
192  
-					PR_MEDIUM,
193 190
 					"Mollom Captcha provides words in an image, and expects a user to type them in a textfield"
194 191
 				), 
195 192
 				"error"
54  code/MollomReport.php
... ...
@@ -1,54 +0,0 @@
1  
-<?php
2  
-/** 
3  
- * Backend Report Interface for Mollom Status
4  
- *
5  
- * @package spamprotection
6  
- * @subpackage mollom
7  
- */
8  
-
9  
-class MollomReport extends SS_Report {
10  
-	
11  
-	protected $title = "Mollom";
12  
-	
13  
-	protected $description = "Mollom Usage and Statistics";
14  
-	
15  
-	/**
16  
-	 * Returns empty field set and use echo() to return output instead. 
17  
-	 *
18  
-	 * Using form fields and fieldset can done but we need to introduce FieldGroup (according to the ReportAdmin form template, {@see ReportAdminForm.ss}).
19  
-	 * On top of that, we need to css to style the output profile in order to produce a readable output. 
20  
-	 */
21  
-	function getCMSFields() {
22  
-		$URL = "http://mollom.com/statistics.swf?key=". MollomServer::getPublicKey();
23  
-		$errMsg = "";
24  
-		
25  
-		MollomServer::initServerList();
26  
-		
27  
-		if(MollomServer::getPublicKey()) {
28  
-			if(!MollomServer::verifyKey()) {
29  
-				$errMsg = _t('Mollom.KEYWRONG', 'Your key is not valid. Please try another key');
30  
-			}
31  
-		}
32  
-		else {
33  
-			$errMsg = _t('Mollom.NOKEY', 'You have not configured your key. Please add it to mysite/_config.php.');
34  
-		}
35  
-
36  
-		echo "<h3>Mollom Key Status</h3>";
37  
-		
38  
-		if (empty($errMsg)) {
39  
-			echo "
40  
-				<p><a href='http://mollom.com/terms-of-service' target='_blank'>". _t('Mollom.TERMS', 'View Molloms Terms of Use'). "</a></p>
41  
-			
42  
-				<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\">
43  
-					<param name=\"movie\" value=\"$URL\">
44  
-					<embed src=\"$URL\" quality=\"high\" width=\"100%\" height=\"100%\" name=\"movie\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"> 
45  
-				</object>
46  
-			";
47  
-		}
48  
-		else {
49  
-			echo "<p>$errMsg</p>";
50  
-		}
51  
-		
52  
-		return new FieldSet();
53  
-	}
54  
-}
9  css/MollomAdmin.css
... ...
@@ -0,0 +1,9 @@
  1
+.icon-mollomadmin.icon-16 {
  2
+	background: url("../images/mollom.png");
  3
+}
  4
+
  5
+.mollom-graph-container {
  6
+	max-width: 1024px;
  7
+	height: 430px;
  8
+	border: 1px solid #aaa;
  9
+}
BIN  images/mollom.png
14  lang/en.yml
... ...
@@ -0,0 +1,14 @@
  1
+en:
  2
+  Mollom:
  3
+    KEYEXISTS: Your key exists and is working.
  4
+    KEYSTATUS: Mollom Key Status
  5
+    KEYWRONG: Your key is not valid. Please try another key.
  6
+    NOKEY: You have not configured your key. Please add it to mysite/_config.php.
  7
+    TERMS: View Mollom's Terms of Use
  8
+  MollomCaptchaField:
  9
+    CAPTCHAREQUESTED: Please answer the captcha question.
  10
+    INCORRECTSOLUTION: You didn't type in the correct captcha text. Please type it in again.
  11
+    SPAM: Your submission has been rejected because it was treated as spam.
  12
+  MollomServer:
  13
+    PLURALNAME: Mollom Servers
  14
+    SINGULARNAME: Mollom Server
36  lang/en_US.php
... ...
@@ -1,36 +0,0 @@
1  
-<?php
2  
-
3  
-global $lang;
4  
-
5  
-$lang['en_US']['Mollom']['KEYEXISTS'] = 'Your key exists and is working';
6  
-$lang['en_US']['Mollom']['KEYSTATUS'] = 'Mollom Key Status';
7  
-$lang['en_US']['Mollom']['KEYWRONG'] = 'Your key is not valid. Please try another key';
8  
-$lang['en_US']['Mollom']['NOKEY'] = 'You have not configured your key. Please add it to mysite/_config.php.';
9  
-$lang['en_US']['Mollom']['TERMS'] = 'View Molloms Terms of Use';
10  
-$lang['en_US']['MollomCaptchaField']['CAPTCHAREQUESTED'] = array(
11  
-	'Please answer the captcha question',
12  
-	PR_MEDIUM,
13  
-	'Mollom Captcha provides words in an image, and expects a user to type them in a textfield'
14  
-);
15  
-$lang['en_US']['MollomCaptchaField']['INCORRECTSOLUTION'] = array(
16  
-	'You didn\'t type in the correct captcha text. Please type it in again.',
17  
-	PR_MEDIUM,
18  
-	'Mollom Captcha provides words in an image, and expects a user to type them in a textfield'
19  
-);
20  
-$lang['en_US']['MollomCaptchaField']['SPAM'] = array(
21  
-	'Your submission has been rejected because it was treated as spam.',
22  
-	PR_MEDIUM,
23  
-	'Mollom Captcha provides words in an image, and expects a user to type them in a textfield'
24  
-);
25  
-$lang['en_US']['MollomServer']['PLURALNAME'] = array(
26  
-	'Mollom Servers',
27  
-	50,
28  
-	'Pural name of the object, used in dropdowns and to generally identify a collection of this object in the interface'
29  
-);
30  
-$lang['en_US']['MollomServer']['SINGULARNAME'] = array(
31  
-	'Mollom Server',
32  
-	50,
33  
-	'Singular name of the object, used in dropdowns and to generally identify a single object in the interface'
34  
-);
35  
-
36  
-?>
10  lib/Mollom.php
@@ -122,7 +122,7 @@ class Mollom
122 122
 	 * @return	string
123 123
 	 * @param	mixed $value
124 124
 	 */
125  
-	private function buildValue($value)
  125
+	private static function buildValue($value)
126 126
 	{
127 127
 		// get type
128 128
 		$type = gettype($value);
@@ -182,7 +182,7 @@ public static function checkCaptcha($sessionId, $solution)
182 182
 		// do the call
183 183
 		$responseString = self::doCall('checkCaptcha', $parameters);
184 184
 		// validate
185  
-		if(!isset($responseString->params->param->value->boolean)) throw new Exception('Invalid response in checkCapthca.');
  185
+		if(!isset($responseString->params->param->value->boolean)) throw new Exception('Invalid response in checkCaptcha.');
186 186
 
187 187
 		// return
188 188
 		if((string) $responseString->params->param->value->boolean == '1') return true;
@@ -193,7 +193,7 @@ public static function checkCaptcha($sessionId, $solution)
193 193
 
194 194
 
195 195
 	/**
196  
-	 * Check if the data is spam or not, and gets an assessment of the datas quality
  196
+	 * Check if the data is spam or not, and gets an assessment of the data's quality
197 197
 	 *
198 198
 	 * This function will be used most. The more data you submit the more accurate the claasification will be.
199 199
 	 * 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)
203 203
 	 * The function will return an array with 3 elements:
204 204
 	 * - spam			the spam-status (unknown/ham/spam/unsure)
205 205
 	 * - quality		an assessment of the content's quality (between 0 and 1)
206  
-	 * - session_id		Molloms session_id
  206
+	 * - session_id		Mollom's session_id
207 207
 	 *
208 208
 	 * @return	array
209 209
 	 * @param	string[optional] $sessionId
@@ -234,7 +234,7 @@ public static function checkContent($sessionId = null, $postTitle = null, $postB
234 234
 		if($authorOpenId != null) $parameters['author_openid'] = (string) $authorOpenId;
235 235
 		if($authorId != null) $parameters['author_id'] = (string) $authorId;
236 236
 
237  
-		// set autor ip
  237
+		// set author ip
238 238
 		$authorIp = self::getIpAddress();
239 239
 		if($authorIp != null) $parameters['author_ip'] = (string) $authorIp;
240 240
 
32  templates/Includes/MollomAdmin_Content.ss
... ...
@@ -0,0 +1,32 @@
  1
+<div class="cms-content center cms-tabset $BaseCSSClasses" data-layout-type="border" data-pjax-fragment="Content">
  2
+
  3
+	<div class="cms-content-header north">
  4
+		<% with EditForm %>
  5
+			<div class="cms-content-header-info">
  6
+				<% include BackLink_Button %>
  7
+				<h2 id="page-title-heading">
  8
+				<% with Controller %>
  9
+					<% include CMSBreadcrumbs %>
  10
+				<% end_with %>
  11
+				</h2>
  12
+			</div>
  13
+		<% end_with %>
  14
+	</div>
  15
+
  16
+	<div class="cms-content-fields center cms-panel-padded">
  17
+		<% if not PublicKey %>
  18
+			<p class="message bad"><% _t('Mollom.NOKEY', 'You have not configured your key. Please add it to mysite/_config.php.') %></p>
  19
+		<% else_if not isKeyVerified %>
  20
+			<p class="message bad"><% _t('Mollom.KEYWRONG', 'Your key is not valid. Please try another key.') %></p>
  21
+		<% else %>
  22
+			<p><a class="ui-button ss-ui-button" href='http://mollom.com/terms-of-service' target='_blank'><% _t('Mollom.TERMS',"View Mollom's Terms of Use") %></a></p>
  23
+			<div class="mollom-graph-container">
  24
+				<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=\"430px\" id=\"movie\">
  25
+					<param name=\"movie\" value=\"http://mollom.com/statistics.swf?key=$PublicKey\">
  26
+					<embed src=\"http://mollom.com/statistics.swf?key=$PublicKey\" quality=\"high\" width=\"100%\" height=\"430px\" name=\"movie\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"> 
  27
+				</object>
  28
+			</div>
  29
+		<% end_if %>
  30
+	</div>
  31
+	
  32
+</div>

0 notes on commit e8555cd

Please sign in to comment.
Something went wrong with that request. Please try again.