Version Notes
Releasing version 1.0.0.1, Add magento native image captcha to product review form.
Download this release
Release Info
Developer | Haresh |
Extension | linksture_product_review_captcha |
Version | 1.0.0.1 |
Comparing to | |
See all releases |
Version 1.0.0.1
- app/code/community/Linksture/Productreview/Block/Captcha/Zend.php +63 -0
- app/code/community/Linksture/Productreview/Helper/Data.php +4 -0
- app/code/community/Linksture/Productreview/Model/Observer.php +25 -0
- app/code/community/Linksture/Productreview/etc/config.xml +90 -0
- app/code/community/Linksture/Productreview/etc/system.xml +42 -0
- app/design/frontend/default/default/layout/reviewcaptcha.xml +14 -0
- app/design/frontend/default/default/template/review/form.phtml +141 -0
- app/etc/modules/Linksture_Productreview.xml +36 -0
- package.xml +18 -0
- skin/frontend/default/default/js/captcha.js +100 -0
app/code/community/Linksture/Productreview/Block/Captcha/Zend.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Mage_Captcha
|
23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Captcha block
|
29 |
+
*
|
30 |
+
* @category Core
|
31 |
+
* @package Mage_Captcha
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Linksture_Productreview_Block_Captcha_Zend extends Mage_Captcha_Block_Captcha_Zend
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Renders captcha HTML (if required)
|
38 |
+
*
|
39 |
+
* @return string
|
40 |
+
*/
|
41 |
+
protected function _toHtml()
|
42 |
+
{
|
43 |
+
/**
|
44 |
+
* Functionality : To differenciate condition for 'review-form' form id. No need to chek is required for it.
|
45 |
+
* Developer : Developer 919
|
46 |
+
* Created Date : 2014-08-22
|
47 |
+
* Updated Date : 2014-08-22
|
48 |
+
*/
|
49 |
+
if($this->getFormId() == 'review-form')
|
50 |
+
{
|
51 |
+
$this->getCaptchaModel()->generate();
|
52 |
+
return Mage_Core_Block_Template::_toHtml();
|
53 |
+
}
|
54 |
+
else
|
55 |
+
{
|
56 |
+
if ($this->getCaptchaModel()->isRequired()) {
|
57 |
+
$this->getCaptchaModel()->generate();
|
58 |
+
return parent::_toHtml();
|
59 |
+
}
|
60 |
+
return '';
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
app/code/community/Linksture/Productreview/Helper/Data.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Linksture_Productreview_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
app/code/community/Linksture/Productreview/Model/Observer.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Linksture_Productreview_Model_Observer extends Mage_Captcha_Model_Observer
|
4 |
+
{
|
5 |
+
|
6 |
+
|
7 |
+
public function checkProductReview($observer)
|
8 |
+
{
|
9 |
+
$productId = $observer->getControllerAction()->getRequest()->getParam('id');
|
10 |
+
$returnUrl = Mage::getUrl('review/product/list', array('id'=> $productId));
|
11 |
+
$formId = 'review-form';
|
12 |
+
$captchaModel = Mage::helper('captcha')->getCaptcha($formId);
|
13 |
+
|
14 |
+
$controller = $observer->getControllerAction();
|
15 |
+
if (!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))) {
|
16 |
+
Mage::getSingleton('core/session')->addError('Incorrect CAPTCHA.');
|
17 |
+
Mage::app()->getResponse()->setRedirect($returnUrl)->sendResponse();
|
18 |
+
exit;
|
19 |
+
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
|
app/code/community/Linksture/Productreview/etc/config.xml
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<Linksture_Productreview>
|
6 |
+
<version>1.1.0.0.0</version>
|
7 |
+
</Linksture_Productreview>
|
8 |
+
</modules>
|
9 |
+
<global>
|
10 |
+
<models>
|
11 |
+
<productreview>
|
12 |
+
<class>Linksture_Productreview_Model</class>
|
13 |
+
|
14 |
+
</productreview>
|
15 |
+
|
16 |
+
</models>
|
17 |
+
|
18 |
+
<events>
|
19 |
+
<controller_action_predispatch_review_product_post>
|
20 |
+
<observers>
|
21 |
+
<productreview>
|
22 |
+
<class>productreview/observer</class>
|
23 |
+
<method>checkProductReview</method>
|
24 |
+
</productreview>
|
25 |
+
</observers>
|
26 |
+
</controller_action_predispatch_review_product_post>
|
27 |
+
</events>
|
28 |
+
|
29 |
+
<blocks>
|
30 |
+
<captcha>
|
31 |
+
<rewrite>
|
32 |
+
<captcha_zend>Linksture_Productreview_Block_Captcha_Zend</captcha_zend>
|
33 |
+
</rewrite>
|
34 |
+
</captcha>
|
35 |
+
</blocks>
|
36 |
+
<helpers>
|
37 |
+
<productreview><!-- class group -->
|
38 |
+
<class>Linksture_Productreview_Helper</class><!-- class prefix -->
|
39 |
+
</productreview>
|
40 |
+
</helpers>
|
41 |
+
|
42 |
+
|
43 |
+
</global>
|
44 |
+
|
45 |
+
<frontend>
|
46 |
+
<routers>
|
47 |
+
<productreview>
|
48 |
+
<use>standard</use>
|
49 |
+
<args>
|
50 |
+
<module>Linksture_Productreview</module>
|
51 |
+
<frontName>productreview</frontName>
|
52 |
+
</args>
|
53 |
+
</productreview>
|
54 |
+
</routers>
|
55 |
+
|
56 |
+
|
57 |
+
|
58 |
+
<layout>
|
59 |
+
<updates>
|
60 |
+
<productreview>
|
61 |
+
<file>reviewcaptcha.xml</file>
|
62 |
+
</productreview>
|
63 |
+
</updates>
|
64 |
+
</layout>
|
65 |
+
|
66 |
+
</frontend>
|
67 |
+
|
68 |
+
<adminhtml>
|
69 |
+
<acl>
|
70 |
+
<resources>
|
71 |
+
<admin>
|
72 |
+
<children>
|
73 |
+
<system>
|
74 |
+
<children>
|
75 |
+
<config>
|
76 |
+
<children>
|
77 |
+
<reviewcaptcha_section translate="title" module="productreview">
|
78 |
+
|
79 |
+
</reviewcaptcha_section>
|
80 |
+
</children>
|
81 |
+
</config>
|
82 |
+
</children>
|
83 |
+
</system>
|
84 |
+
</children>
|
85 |
+
</admin>
|
86 |
+
</resources>
|
87 |
+
</acl>
|
88 |
+
|
89 |
+
</adminhtml>
|
90 |
+
</config>
|
app/code/community/Linksture/Productreview/etc/system.xml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<reviewcaptcha_tab translate="label">
|
5 |
+
<label>Linksture Review Captcha</label>
|
6 |
+
<sort_order>150</sort_order>
|
7 |
+
</reviewcaptcha_tab>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<reviewcaptcha_section translate="label">
|
11 |
+
<label>Review Captcha</label>
|
12 |
+
<tab>reviewcaptcha_tab</tab>
|
13 |
+
<sort_order>130</sort_order>
|
14 |
+
<show_in_default>1</show_in_default>
|
15 |
+
<show_in_website>1</show_in_website>
|
16 |
+
<show_in_store>1</show_in_store>
|
17 |
+
<groups>
|
18 |
+
<reviewcaptcha_group>
|
19 |
+
<label>General</label>
|
20 |
+
<frontend_type>text</frontend_type>
|
21 |
+
<sort_order>20</sort_order>
|
22 |
+
<show_in_default>1</show_in_default>
|
23 |
+
<show_in_website>1</show_in_website>
|
24 |
+
<show_in_store>1</show_in_store>
|
25 |
+
<fields>
|
26 |
+
<reviewcaptcha_field translate="label">
|
27 |
+
|
28 |
+
<label>Enable/Disable</label>
|
29 |
+
<frontend_type>select</frontend_type>
|
30 |
+
<sort_order>40</sort_order>
|
31 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
<show_in_website>1</show_in_website>
|
34 |
+
<show_in_store>1</show_in_store>
|
35 |
+
|
36 |
+
</reviewcaptcha_field>
|
37 |
+
</fields>
|
38 |
+
</reviewcaptcha_group>
|
39 |
+
</groups>
|
40 |
+
</reviewcaptcha_section>
|
41 |
+
</sections>
|
42 |
+
</config>
|
app/design/frontend/default/default/layout/reviewcaptcha.xml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<review_product_list translate="label">
|
4 |
+
<reference name="head">
|
5 |
+
|
6 |
+
<action method="addItem" ifconfig="reviewcaptcha_section/reviewcaptcha_group/reviewcaptcha_field">
|
7 |
+
<type>skin_js</type>
|
8 |
+
<name>js/captcha.js</name>
|
9 |
+
<params/>
|
10 |
+
</action>
|
11 |
+
</reference>
|
12 |
+
</review_product_list>
|
13 |
+
|
14 |
+
</layout>
|
app/design/frontend/default/default/template/review/form.phtml
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<div class="form-add">
|
28 |
+
<h2><?php echo $this->__('Write Your Own Review') ?></h2>
|
29 |
+
<?php if ($this->getAllowWriteReviewFlag()): ?>
|
30 |
+
<form action="<?php echo $this->getAction() ?>" method="post" id="review-form">
|
31 |
+
<?php echo $this->getBlockHtml('formkey'); ?>
|
32 |
+
<fieldset>
|
33 |
+
<?php echo $this->getChildHtml('form_fields_before')?>
|
34 |
+
<h3><?php echo $this->__("You're reviewing:"); ?> <span><?php echo $this->escapeHtml($this->getProductInfo()->getName()) ?></span></h3>
|
35 |
+
<?php if( $this->getRatings() && $this->getRatings()->getSize()): ?>
|
36 |
+
<h4><?php echo $this->__('How do you rate this product?') ?> <em class="required">*</em></h4>
|
37 |
+
<span id="input-message-box"></span>
|
38 |
+
<table cellpadding="0" class="data-table" id="product-review-table">
|
39 |
+
<col />
|
40 |
+
<col width="1" />
|
41 |
+
<col width="1" />
|
42 |
+
<col width="1" />
|
43 |
+
<col width="1" />
|
44 |
+
<col width="1" />
|
45 |
+
<thead>
|
46 |
+
<tr>
|
47 |
+
<th> </th>
|
48 |
+
<th><span class="nobr"><?php echo $this->__('1 star') ?></span></th>
|
49 |
+
<th><span class="nobr"><?php echo $this->__('2 stars') ?></span></th>
|
50 |
+
<th><span class="nobr"><?php echo $this->__('3 stars') ?></span></th>
|
51 |
+
<th><span class="nobr"><?php echo $this->__('4 stars') ?></span></th>
|
52 |
+
<th><span class="nobr"><?php echo $this->__('5 stars') ?></span></th>
|
53 |
+
</tr>
|
54 |
+
</thead>
|
55 |
+
<tbody>
|
56 |
+
<?php foreach ($this->getRatings() as $_rating): ?>
|
57 |
+
<tr>
|
58 |
+
<th><?php echo $this->escapeHtml($_rating->getRatingCode()) ?></th>
|
59 |
+
<?php foreach ($_rating->getOptions() as $_option): ?>
|
60 |
+
<td class="value"><input type="radio" name="ratings[<?php echo $_rating->getId() ?>]" id="<?php echo $this->escapeHtml($_rating->getRatingCode()) ?>_<?php echo $_option->getValue() ?>" value="<?php echo $_option->getId() ?>" class="radio" /></td>
|
61 |
+
<?php endforeach; ?>
|
62 |
+
</tr>
|
63 |
+
<?php endforeach; ?>
|
64 |
+
</tbody>
|
65 |
+
</table>
|
66 |
+
<input type="hidden" name="validate_rating" class="validate-rating" value="" />
|
67 |
+
<script type="text/javascript">decorateTable('sproduct-review-table')</script>
|
68 |
+
<?php endif; ?>
|
69 |
+
<ul class="form-list">
|
70 |
+
<li>
|
71 |
+
<label for="nickname_field" class="required"><em>*</em><?php echo $this->__('Nickname') ?></label>
|
72 |
+
<div class="input-box">
|
73 |
+
<input type="text" name="nickname" id="nickname_field" class="input-text required-entry" value="<?php echo $this->escapeHtml($data->getNickname()) ?>" />
|
74 |
+
</div>
|
75 |
+
</li>
|
76 |
+
<li>
|
77 |
+
<label for="summary_field" class="required"><em>*</em><?php echo $this->__('Summary of Your Review') ?></label>
|
78 |
+
<div class="input-box">
|
79 |
+
<input type="text" name="title" id="summary_field" class="input-text required-entry" value="<?php echo $this->escapeHtml($data->getTitle()) ?>" />
|
80 |
+
</div>
|
81 |
+
</li>
|
82 |
+
<li>
|
83 |
+
<label for="review_field" class="required"><em>*</em><?php echo $this->__('Review') ?></label>
|
84 |
+
<div class="input-box">
|
85 |
+
<textarea name="detail" id="review_field" cols="5" rows="3" class="required-entry"><?php echo $this->escapeHtml($data->getDetail()) ?></textarea>
|
86 |
+
</div>
|
87 |
+
</li>
|
88 |
+
<?php $captchaStatus = Mage::getStoreConfig('reviewcaptcha_section/reviewcaptcha_group/reviewcaptcha_field'); ?>
|
89 |
+
<?php if($captchaStatus==1):?>
|
90 |
+
<li>
|
91 |
+
<?php echo $this->getLayout()->createBlock('captcha/captcha')->setFormId('review-form')->setImgWidth(320)->setImgHeight(50)->toHtml(); ?>
|
92 |
+
</li>
|
93 |
+
<?php endif;?>
|
94 |
+
</ul>
|
95 |
+
</fieldset>
|
96 |
+
<?php echo $this->getChildHtml('form.additional.info'); ?>
|
97 |
+
<div class="buttons-set">
|
98 |
+
<button type="submit" title="<?php echo $this->__('Submit Review') ?>" class="button"><span><span><?php echo $this->__('Submit Review') ?></span></span></button>
|
99 |
+
</div>
|
100 |
+
</form>
|
101 |
+
|
102 |
+
<script type="text/javascript">
|
103 |
+
//<![CDATA[
|
104 |
+
var dataForm = new VarienForm('review-form');
|
105 |
+
Validation.addAllThese(
|
106 |
+
[
|
107 |
+
['validate-rating', '<?php echo $this->__('Please select one of each of the ratings above') ?>', function(v) {
|
108 |
+
var trs = $('product-review-table').select('tr');
|
109 |
+
var inputs;
|
110 |
+
var error = 1;
|
111 |
+
|
112 |
+
for( var j=0; j < trs.length; j++ ) {
|
113 |
+
var tr = trs[j];
|
114 |
+
if( j > 0 ) {
|
115 |
+
inputs = tr.select('input');
|
116 |
+
|
117 |
+
for( i in inputs ) {
|
118 |
+
if( inputs[i].checked == true ) {
|
119 |
+
error = 0;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
if( error == 1 ) {
|
124 |
+
return false;
|
125 |
+
} else {
|
126 |
+
error = 1;
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
+
return true;
|
131 |
+
}]
|
132 |
+
]
|
133 |
+
);
|
134 |
+
//]]>
|
135 |
+
</script>
|
136 |
+
<?php else: ?>
|
137 |
+
<p class="review-nologged" id="review-form">
|
138 |
+
<?php echo $this->__('Only registered users can write reviews. Please, <a href="%s">log in</a> or <a href="%s">register</a>', $this->getLoginLink(), Mage::helper('customer')->getRegisterUrl()) ?>
|
139 |
+
</p>
|
140 |
+
<?php endif ?>
|
141 |
+
</div>
|
app/etc/modules/Linksture_Productreview.xml
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/afl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Mage
|
23 |
+
* @package Mage_Widget
|
24 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
25 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
26 |
+
*/
|
27 |
+
-->
|
28 |
+
<config>
|
29 |
+
<modules>
|
30 |
+
<Linksture_Productreview>
|
31 |
+
<active>true</active>
|
32 |
+
<codePool>community</codePool>
|
33 |
+
|
34 |
+
</Linksture_Productreview>
|
35 |
+
</modules>
|
36 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>linksture_product_review_captcha</name>
|
4 |
+
<version>1.0.0.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Add magento native image captcha to product review form.</summary>
|
10 |
+
<description>Add magento native image captcha to product review form.</description>
|
11 |
+
<notes>Releasing version 1.0.0.1, Add magento native image captcha to product review form.</notes>
|
12 |
+
<authors><author><name>Haresh</name><user>linksture</user><email>haresh@linksture.com</email></author></authors>
|
13 |
+
<date>2014-08-29</date>
|
14 |
+
<time>08:34:18</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Linksture_Productreview.xml" hash="e5303dce4d35a1f1cd834e57b81aae85"/></dir></target><target name="magecommunity"><dir name="Linksture"><dir name="Productreview"><dir name="Block"><dir name="Captcha"><file name="Zend.php" hash="54ea8ff3635cfe2ca10eb8b319fd5859"/></dir></dir><dir name="Helper"><file name="Data.php" hash="71ef779f05af5db7c20562daa8cc0b3d"/></dir><dir name="Model"><file name="Observer.php" hash="0b1a1bc8f2fea758278e8d7cc09ec89b"/></dir><dir name="etc"><file name="config.xml" hash="f8ed9cf1113008b7a48963e748a7629d"/><file name="system.xml" hash="2ba9c16199e5a759da558386607a7376"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="reviewcaptcha.xml" hash="851a314c535509608604e27a957c934b"/></dir><dir name="template"><dir name="review"><file name="form.phtml" hash="c51e0c2e27d346e2022a0c5d82694b5b"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="js"><file name="captcha.js" hash="6b65c3644bd2d971b08870b51d3555f8"/></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|
skin/frontend/default/default/js/captcha.js
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Magento
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
7 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
8 |
+
* It is also available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/afl-3.0.php
|
10 |
+
* If you did not receive a copy of the license and are unable to
|
11 |
+
* obtain it through the world-wide-web, please send an email
|
12 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
13 |
+
*
|
14 |
+
* DISCLAIMER
|
15 |
+
*
|
16 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
17 |
+
* versions in the future. If you wish to customize Magento for your
|
18 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
19 |
+
*
|
20 |
+
* @category Mage
|
21 |
+
* @package js
|
22 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
23 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
24 |
+
*/
|
25 |
+
var Captcha = Class.create();
|
26 |
+
Captcha.prototype = {
|
27 |
+
initialize: function(url, formId){
|
28 |
+
this.url = url;
|
29 |
+
this.formId = formId;
|
30 |
+
},
|
31 |
+
refresh: function(elem) {
|
32 |
+
formId = this.formId;
|
33 |
+
if (elem) Element.addClassName(elem, 'refreshing');
|
34 |
+
new Ajax.Request(this.url, {
|
35 |
+
onSuccess: function (response) {
|
36 |
+
if (response.responseText.isJSON()) {
|
37 |
+
var json = response.responseText.evalJSON();
|
38 |
+
/**
|
39 |
+
* Functionality : To update review form captcha image
|
40 |
+
* Developer : Developer 919
|
41 |
+
* Created Date : 2014-08-22
|
42 |
+
* Updated Date : 2014-08-22
|
43 |
+
*/
|
44 |
+
if (!json.error && json.imgSrc) {
|
45 |
+
if(formId == 'review-form')
|
46 |
+
{
|
47 |
+
$$(".captcha-img").each( function(img){ img.src=json.imgSrc } );
|
48 |
+
}
|
49 |
+
else
|
50 |
+
{
|
51 |
+
$(formId).writeAttribute('src', json.imgSrc);
|
52 |
+
}
|
53 |
+
if (elem) Element.removeClassName(elem, 'refreshing');
|
54 |
+
} else {
|
55 |
+
if (elem) Element.removeClassName(elem, 'refreshing');
|
56 |
+
}
|
57 |
+
}
|
58 |
+
},
|
59 |
+
method: 'post',
|
60 |
+
parameters: {
|
61 |
+
'formId' : this.formId
|
62 |
+
}
|
63 |
+
});
|
64 |
+
}
|
65 |
+
};
|
66 |
+
|
67 |
+
document.observe('billing-request:completed', function(event) {
|
68 |
+
if (typeof window.checkout != 'undefined') {
|
69 |
+
if (window.checkout.method == 'guest' && $('guest_checkout')){
|
70 |
+
$('guest_checkout').captcha.refresh()
|
71 |
+
}
|
72 |
+
if (window.checkout.method == 'register' && $('register_during_checkout')){
|
73 |
+
$('register_during_checkout').captcha.refresh()
|
74 |
+
}
|
75 |
+
}
|
76 |
+
});
|
77 |
+
|
78 |
+
|
79 |
+
document.observe('login:setMethod', function(event) {
|
80 |
+
var switchCaptchaElement = function(shown, hidden) {
|
81 |
+
var inputPrefix = 'captcha-input-box-', imagePrefix = 'captcha-image-box-';
|
82 |
+
if ($(inputPrefix + hidden)) {
|
83 |
+
$(inputPrefix + hidden).hide();
|
84 |
+
$(imagePrefix + hidden).hide();
|
85 |
+
}
|
86 |
+
if ($(inputPrefix + shown)) {
|
87 |
+
$(inputPrefix + shown).show();
|
88 |
+
$(imagePrefix + shown).show();
|
89 |
+
}
|
90 |
+
};
|
91 |
+
|
92 |
+
switch (event.memo.method) {
|
93 |
+
case 'guest':
|
94 |
+
switchCaptchaElement('guest_checkout', 'register_during_checkout');
|
95 |
+
break;
|
96 |
+
case 'register':
|
97 |
+
switchCaptchaElement('register_during_checkout', 'guest_checkout');
|
98 |
+
break;
|
99 |
+
}
|
100 |
+
});
|