Studioforty9_Recaptcha - Version 1.5.5

Version Notes

Tested on Magento versions: 1.7.0.2, 1.8.0.0, 1.8.1.0, 1.9.0.1, 1.9.1.0 and 1.9.2.4. See https://travis-ci.org/StudioForty9/Recaptcha for more.

Download this release

Release Info

Developer StudioForty9
Extension Studioforty9_Recaptcha
Version 1.5.5
Comparing to
See all releases


Code changes from version 1.5.1 to 1.5.5

app/code/community/Studioforty9/Recaptcha/Block/Explicit.php CHANGED
@@ -67,38 +67,20 @@ class Studioforty9_Recaptcha_Block_Explicit extends Mage_Core_Block_Template
67
  'uk_UA' => 'uk',
68
  'vi_VN' => 'vi'
69
  );
70
-
71
  /**
72
- * Get the reCAPTACHA javascript code.
73
  *
74
- * @param string $id
75
- * @return string
76
  */
77
- public function getRecaptchaScript()
78
  {
79
- if (! Mage::helper('studioforty9_recaptcha')->isEnabled()) {
80
- return '';
81
- }
82
-
83
- $language = Mage::app()->getLocale()->getLocale()->toString();
84
- $lang = 'en';
85
-
86
- foreach ($this->_languages as $options => $_lang) {
87
- if (stristr($options, $language)) {
88
- $lang = $_lang;
89
- }
90
  }
91
 
92
- $query = array(
93
- 'onload' => 'onloadCallback',
94
- 'render' => 'explicit',
95
- 'hl' => $lang
96
- );
97
-
98
- return sprintf(
99
- '<script src="https://www.google.com/recaptcha/api.js?%s" async defer></script>',
100
- http_build_query($query)
101
- );
102
  }
103
 
104
  /**
@@ -109,7 +91,7 @@ class Studioforty9_Recaptcha_Block_Explicit extends Mage_Core_Block_Template
109
  */
110
  public function getSiteKey()
111
  {
112
- return Mage::helper('studioforty9_recaptcha')->getSiteKey();
113
  }
114
 
115
  /**
@@ -120,7 +102,7 @@ class Studioforty9_Recaptcha_Block_Explicit extends Mage_Core_Block_Template
120
  */
121
  public function getTheme()
122
  {
123
- return Mage::helper('studioforty9_recaptcha')->getTheme();
124
  }
125
 
126
  /**
@@ -131,7 +113,7 @@ class Studioforty9_Recaptcha_Block_Explicit extends Mage_Core_Block_Template
131
  */
132
  public function getType()
133
  {
134
- return Mage::helper('studioforty9_recaptcha')->getType();
135
  }
136
 
137
  /**
@@ -142,7 +124,39 @@ class Studioforty9_Recaptcha_Block_Explicit extends Mage_Core_Block_Template
142
  */
143
  public function getSize()
144
  {
145
- return Mage::helper('studioforty9_recaptcha')->getSize();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  }
147
 
148
  /**
@@ -154,4 +168,14 @@ class Studioforty9_Recaptcha_Block_Explicit extends Mage_Core_Block_Template
154
  {
155
  return uniqid();
156
  }
 
 
 
 
 
 
 
 
 
 
157
  }
67
  'uk_UA' => 'uk',
68
  'vi_VN' => 'vi'
69
  );
70
+
71
  /**
72
+ * Is the block allowed to display.
73
  *
74
+ * @param string $route
75
+ * @return bool
76
  */
77
+ public function isAllowed($route = '')
78
  {
79
+ if ($this->hasData('allow')) {
80
+ return (bool) $this->getData('allow');
 
 
 
 
 
 
 
 
 
81
  }
82
 
83
+ return $this->_getHelper()->isAllowed($route);
 
 
 
 
 
 
 
 
 
84
  }
85
 
86
  /**
91
  */
92
  public function getSiteKey()
93
  {
94
+ return $this->_getHelper()->getSiteKey();
95
  }
96
 
97
  /**
102
  */
103
  public function getTheme()
104
  {
105
+ return $this->_getHelper()->getTheme();
106
  }
107
 
108
  /**
113
  */
114
  public function getType()
115
  {
116
+ return $this->_getHelper()->getType();
117
  }
118
 
119
  /**
124
  */
125
  public function getSize()
126
  {
127
+ return $this->_getHelper()->getSize();
128
+ }
129
+
130
+ /**
131
+ * Get the reCAPTACHA javascript code.
132
+ *
133
+ * @return string
134
+ */
135
+ public function getRecaptchaScript()
136
+ {
137
+ if (! $this->_getHelper()->isEnabled()) {
138
+ return '';
139
+ }
140
+
141
+ $language = Mage::app()->getLocale()->getLocale()->toString();
142
+ $lang = 'en';
143
+
144
+ foreach ($this->_languages as $options => $_lang) {
145
+ if (stristr($options, $language)) {
146
+ $lang = $_lang;
147
+ }
148
+ }
149
+
150
+ $query = array(
151
+ 'onload' => 'onloadCallback',
152
+ 'render' => 'explicit',
153
+ 'hl' => $lang
154
+ );
155
+
156
+ return sprintf(
157
+ '<script src="https://www.google.com/recaptcha/api.js?%s" async defer></script>',
158
+ http_build_query($query)
159
+ );
160
  }
161
 
162
  /**
168
  {
169
  return uniqid();
170
  }
171
+
172
+ /**
173
+ * Get the recaptcha helper.
174
+ *
175
+ * @return Studioforty9_Recaptcha_Helper_Data
176
+ */
177
+ protected function _getHelper()
178
+ {
179
+ return Mage::helper('studioforty9_recaptcha');
180
+ }
181
  }
app/code/community/Studioforty9/Recaptcha/Helper/Data.php CHANGED
@@ -114,6 +114,24 @@ class Studioforty9_Recaptcha_Helper_Data extends Mage_Core_Helper_Abstract
114
  return $routes;
115
  }
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  /**
118
  * Is the module allowed to run.
119
  *
@@ -126,8 +144,8 @@ class Studioforty9_Recaptcha_Helper_Data extends Mage_Core_Helper_Abstract
126
  if (! $this->isModuleActive() || ! $this->isEnabled()) {
127
  return false;
128
  }
129
-
130
- return in_array(strtolower($route), $this->getEnabledRoutes());
131
  }
132
 
133
  /**
114
  return $routes;
115
  }
116
 
117
+ /**
118
+ * Is the provided route enabled.
119
+ *
120
+ * @codeCoverageIgnore
121
+ * @param string $route
122
+ * @return bool
123
+ */
124
+ public function isEnabledRoute($route)
125
+ {
126
+ foreach ($this->getEnabledRoutes() as $enabledRoute) {
127
+ if (false !== strpos($route, $enabledRoute)) {
128
+ return true;
129
+ }
130
+ }
131
+
132
+ return false;
133
+ }
134
+
135
  /**
136
  * Is the module allowed to run.
137
  *
144
  if (! $this->isModuleActive() || ! $this->isEnabled()) {
145
  return false;
146
  }
147
+
148
+ return $this->isEnabledRoute($route);
149
  }
150
 
151
  /**
app/code/community/Studioforty9/Recaptcha/Model/Source/Routes.php CHANGED
@@ -30,12 +30,12 @@ class Studioforty9_Recaptcha_Model_Source_Routes
30
  {
31
  $routes = new Studioforty9_Recaptcha_Model_Routes();
32
 
33
- $routes->add('contacts_index_post', Mage::helper('studioforty9_recaptcha')->__('Contact Form'));
34
- $routes->add('review_product_post', Mage::helper('studioforty9_recaptcha')->__('Product Review Form'));
35
- $routes->add('customer_account_createpost', Mage::helper('studioforty9_recaptcha')->__('Account Registration Form'));
36
- $routes->add('sendfriend_product_sendmail', Mage::helper('studioforty9_recaptcha')->__('Send to Friend Form'));
37
- $routes->add('customer_account_loginpost', Mage::helper('studioforty9_recaptcha')->__('Login Form'));
38
- $routes->add('customer_account_forgotpasswordpost', Mage::helper('studioforty9_recaptcha')->__('Forgot Password Form'));
39
 
40
  Mage::dispatchEvent('studioforty9_recaptcha_routes', array('routes' => $routes));
41
 
30
  {
31
  $routes = new Studioforty9_Recaptcha_Model_Routes();
32
 
33
+ $routes->add('contacts_index', Mage::helper('studioforty9_recaptcha')->__('Contact Form'));
34
+ $routes->add('review_product', Mage::helper('studioforty9_recaptcha')->__('Product Review Form'));
35
+ $routes->add('customer_account_create', Mage::helper('studioforty9_recaptcha')->__('Account Registration Form'));
36
+ $routes->add('sendfriend_product_send', Mage::helper('studioforty9_recaptcha')->__('Send to Friend Form'));
37
+ $routes->add('customer_account_login', Mage::helper('studioforty9_recaptcha')->__('Login Form'));
38
+ $routes->add('customer_account_forgotpassword', Mage::helper('studioforty9_recaptcha')->__('Forgot Password Form'));
39
 
40
  Mage::dispatchEvent('studioforty9_recaptcha_routes', array('routes' => $routes));
41
 
app/design/frontend/base/default/template/studioforty9/recaptcha/explicit.phtml CHANGED
@@ -11,9 +11,10 @@
11
  * @link https://github.com/studioforty9/recaptcha
12
  * @see Studioforty9_Recaptcha_Block_Explicit
13
  */
14
-
15
  $id = $this->getRecaptchaId();
16
  ?>
 
 
17
  <div class="recaptcha" style="overflow:hidden;position:relative;margin-bottom:10px;">
18
  <input type="checkbox" id="cb-<?php echo $id ?>" name="cb-<?php echo $id ?>" value="" class="hide required-entry" style="visibility:hidden; position:absolute; left:-1000000px" />
19
  <div id="el-<?php echo $id ?>"></div>
@@ -35,3 +36,4 @@ $id = $this->getRecaptchaId();
35
  </script>
36
  <?php echo $this->getRecaptchaScript(); ?>
37
  </div>
 
11
  * @link https://github.com/studioforty9/recaptcha
12
  * @see Studioforty9_Recaptcha_Block_Explicit
13
  */
 
14
  $id = $this->getRecaptchaId();
15
  ?>
16
+ <?php if ($this->isAllowed($this->getAction()->getFullActionName())): ?>
17
+
18
  <div class="recaptcha" style="overflow:hidden;position:relative;margin-bottom:10px;">
19
  <input type="checkbox" id="cb-<?php echo $id ?>" name="cb-<?php echo $id ?>" value="" class="hide required-entry" style="visibility:hidden; position:absolute; left:-1000000px" />
20
  <div id="el-<?php echo $id ?>"></div>
36
  </script>
37
  <?php echo $this->getRecaptchaScript(); ?>
38
  </div>
39
+ <?php endif; ?>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Studioforty9_Recaptcha</name>
4
- <version>1.5.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/BSD-3-Clause">BSDL</license>
7
  <channel>community</channel>
@@ -38,9 +38,9 @@
38
  &lt;/ol&gt;</description>
39
  <notes>Tested on Magento versions: 1.7.0.2, 1.8.0.0, 1.8.1.0, 1.9.0.1, 1.9.1.0 and 1.9.2.4. See https://travis-ci.org/StudioForty9/Recaptcha for more.</notes>
40
  <authors><author><name>StudioForty9</name><user>SF9</user><email>info@studioforty9.com</email></author><author><name>Eoghan O'Brien</name><user>eoghanobrien</user><email>eoghan@studioforty9.com</email></author></authors>
41
- <date>2016-05-24</date>
42
- <time>17:18:06</time>
43
- <contents><target name="magecommunity"><dir name="Studioforty9"><dir name="Recaptcha"><dir name="Block"><file name="Explicit.php" hash="d56e608891282004de285b5a40804df5"/></dir><dir name="Helper"><file name="Data.php" hash="da52d3d7828f04e5c7e6db81567a2bbe"/><file name="Redirect.php" hash="3a0dfe2a79bf395ba45edbca0ca16c55"/><file name="Request.php" hash="083e432d3b69f118e31e202d5d6bf529"/><file name="Response.php" hash="acc03647d3919ffaa4aa0f45e336bf94"/></dir><dir name="Model"><file name="Observer.php" hash="8425348550d576749457a8a5b21f2777"/><file name="Routes.php" hash="09a7359d55f75d8031d3ef29103c900a"/><dir name="Source"><file name="Routes.php" hash="13d8dbd74b117203da1d7ca385f82b01"/><file name="Size.php" hash="dc1b9c0190fde703bd4ffd45c7bd87fa"/><file name="Theme.php" hash="5f8d4d6be9ba357072e5173d0c50d8ec"/><file name="Type.php" hash="aa36c2f38ce52abefad917dcc5d035ef"/></dir></dir><dir name="data"><dir name="studioforty9_recaptcha_setup"><file name="data-upgrade-1.2.0-1.5.0.php" hash="bbda9e75bb6044cddaec70331c8895b3"/></dir></dir><dir name="etc"><file name="config.xml" hash="114abb74ba67a68fb89b561194388c4f"/><file name="system.xml" hash="f33c38c12c4394045d2d61327663d0fe"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="studioforty9_recaptcha.xml" hash="21c5dea497e5a7e57e96e021baae1267"/></dir><dir name="template"><dir name="studioforty9"><dir name="recaptcha"><file name="explicit.phtml" hash="82981eae34dd665ab3554182e7662e01"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Studioforty9_Recaptcha.csv" hash="6387abc316e524840fa3b1fcc49dc25d"/></dir></target><target name="mageetc"><dir name="modules"><file name="Studioforty9_Recaptcha.xml" hash="60fdb87cce48c569c234971b230010a0"/></dir></target></contents>
44
  <compatible/>
45
  <dependencies><required><php><min>5.3.0</min><max>7.9.99</max></php></required></dependencies>
46
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Studioforty9_Recaptcha</name>
4
+ <version>1.5.5</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/BSD-3-Clause">BSDL</license>
7
  <channel>community</channel>
38
  &lt;/ol&gt;</description>
39
  <notes>Tested on Magento versions: 1.7.0.2, 1.8.0.0, 1.8.1.0, 1.9.0.1, 1.9.1.0 and 1.9.2.4. See https://travis-ci.org/StudioForty9/Recaptcha for more.</notes>
40
  <authors><author><name>StudioForty9</name><user>SF9</user><email>info@studioforty9.com</email></author><author><name>Eoghan O'Brien</name><user>eoghanobrien</user><email>eoghan@studioforty9.com</email></author></authors>
41
+ <date>2016-06-17</date>
42
+ <time>15:14:10</time>
43
+ <contents><target name="magecommunity"><dir name="Studioforty9"><dir name="Recaptcha"><dir name="Block"><file name="Explicit.php" hash="4fac36fbc4a001831e4eccbbf633f382"/></dir><dir name="Helper"><file name="Data.php" hash="7e0da631d5ddf09520023390f778ca67"/><file name="Redirect.php" hash="3a0dfe2a79bf395ba45edbca0ca16c55"/><file name="Request.php" hash="083e432d3b69f118e31e202d5d6bf529"/><file name="Response.php" hash="acc03647d3919ffaa4aa0f45e336bf94"/></dir><dir name="Model"><file name="Observer.php" hash="8425348550d576749457a8a5b21f2777"/><file name="Routes.php" hash="09a7359d55f75d8031d3ef29103c900a"/><dir name="Source"><file name="Routes.php" hash="9fdc3445daddeb33e17e7ef1192e4e8a"/><file name="Size.php" hash="dc1b9c0190fde703bd4ffd45c7bd87fa"/><file name="Theme.php" hash="5f8d4d6be9ba357072e5173d0c50d8ec"/><file name="Type.php" hash="aa36c2f38ce52abefad917dcc5d035ef"/></dir></dir><dir name="data"><dir name="studioforty9_recaptcha_setup"><file name="data-upgrade-1.2.0-1.5.0.php" hash="bbda9e75bb6044cddaec70331c8895b3"/></dir></dir><dir name="etc"><file name="config.xml" hash="114abb74ba67a68fb89b561194388c4f"/><file name="system.xml" hash="f33c38c12c4394045d2d61327663d0fe"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="studioforty9_recaptcha.xml" hash="21c5dea497e5a7e57e96e021baae1267"/></dir><dir name="template"><dir name="studioforty9"><dir name="recaptcha"><file name="explicit.phtml" hash="674c73e65166f529254c603bf3ea5638"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Studioforty9_Recaptcha.csv" hash="6387abc316e524840fa3b1fcc49dc25d"/></dir></target><target name="mageetc"><dir name="modules"><file name="Studioforty9_Recaptcha.xml" hash="60fdb87cce48c569c234971b230010a0"/></dir></target></contents>
44
  <compatible/>
45
  <dependencies><required><php><min>5.3.0</min><max>7.9.99</max></php></required></dependencies>
46
  </package>