Version Notes
Review Form With Image Field 1.0.0
Download this release
Release Info
Developer | kushagra daharwal |
Extension | Clarion_Reviewimage |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/Kush/Reviewimage/Block/Adminhtml/Review/Edit/Form.php +181 -0
- app/code/local/Kush/Reviewimage/Block/Review/Edit/Form.php +66 -0
- app/code/local/Kush/Reviewimage/Helper/Data.php +51 -0
- app/code/local/Kush/Reviewimage/Model/Resource/Review.php +403 -0
- app/code/local/Kush/Reviewimage/Model/Resource/Review/Collection.php +306 -0
- app/code/local/Kush/Reviewimage/Model/Review.php +101 -0
- app/code/local/Kush/Reviewimage/controllers/ProductController.php +142 -0
- app/code/local/Kush/Reviewimage/etc/adminhtml.xml +78 -0
- app/code/local/Kush/Reviewimage/etc/config.xml +110 -0
- app/code/local/Kush/Reviewimage/etc/system.xml +86 -0
- app/code/local/Kush/Reviewimage/sql/reviewimage_setup/mysql4-install-1.0.3.php +7 -0
- app/design/frontend/default/default/layout/reviewimage.xml +19 -0
- app/design/frontend/default/default/template/review/form.phtml +142 -0
- app/design/frontend/default/default/template/review/product/view/list.phtml +98 -0
- app/etc/modules/Kush_Reviewimage.xml +35 -0
- media/reviewimages/4.jpg +0 -0
- media/reviewimages/Installation_guide.pdf +0 -0
- media/reviewimages/above-sale-n.jpg +0 -0
- media/reviewimages/adasadad.jpg +0 -0
- media/reviewimages/bxshowfuikles.jpg +0 -0
- media/reviewimages/camra1.jpg +0 -0
- media/reviewimages/firstyw.jpg +0 -0
- media/reviewimages/graphic-tee-creative-2.jpg +0 -0
- media/reviewimages/men-1.jpg +0 -0
- media/reviewimages/modern_d.jpg +0 -0
- media/reviewimages/modern_y.jpg +0 -0
- media/reviewimages/new-hp-kurti-banner.jpg +0 -0
- media/reviewimages/r3-jeans-1.jpg +0 -0
- media/reviewimages/saw2w12w.jpg +0 -0
- media/reviewimages/secondww_lion.jpg +0 -0
- media/reviewimages/shaden-3final.jpg +0 -0
- media/reviewimages/we-12.jpg +0 -0
- media/reviewimages/web-11-a.jpg +0 -0
- media/reviewimages/womens-offer-new.jpg +0 -0
- package.xml +18 -0
app/code/local/Kush/Reviewimage/Block/Adminhtml/Review/Edit/Form.php
ADDED
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Adminhtml
|
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 |
+
* Adminhtml Review Edit Form
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Adminhtml
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
|
35 |
+
class Kush_Reviewimage_Block_Adminhtml_Review_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
36 |
+
{
|
37 |
+
protected function _prepareForm()
|
38 |
+
{
|
39 |
+
|
40 |
+
$review = Mage::registry('review_data');
|
41 |
+
$product = Mage::getModel('catalog/product')->load($review->getEntityPkValue());
|
42 |
+
$customer = Mage::getModel('customer/customer')->load($review->getCustomerId());
|
43 |
+
|
44 |
+
$form = new Varien_Data_Form(array(
|
45 |
+
'id' => 'edit_form',
|
46 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'), 'ret' => Mage::registry('ret'))),
|
47 |
+
'method' => 'post'
|
48 |
+
));
|
49 |
+
|
50 |
+
|
51 |
+
$fieldset = $form->addFieldset('review_details', array('legend' => Mage::helper('review')->__('Review Details'), 'class' => 'fieldset-wide'));
|
52 |
+
|
53 |
+
|
54 |
+
$fieldset->addField('product_name', 'note', array(
|
55 |
+
'label' => Mage::helper('review')->__('Product'),
|
56 |
+
'text' => '<a href="' . $this->getUrl('*/catalog_product/edit', array('id' => $product->getId())) . '" onclick="this.target=\'blank\'">' . $product->getName() . '</a>'
|
57 |
+
));
|
58 |
+
|
59 |
+
if ($customer->getId()) {
|
60 |
+
$customerText = Mage::helper('review')->__('<a href="%1$s" onclick="this.target=\'blank\'">%2$s %3$s</a> <a href="mailto:%4$s">(%4$s)</a>', $this->getUrl('*/customer/edit', array('id' => $customer->getId(), 'active_tab'=>'review')), $this->escapeHtml($customer->getFirstname()), $this->escapeHtml($customer->getLastname()), $this->escapeHtml($customer->getEmail()));
|
61 |
+
} else {
|
62 |
+
if (is_null($review->getCustomerId())) {
|
63 |
+
$customerText = Mage::helper('review')->__('Guest');
|
64 |
+
} elseif ($review->getCustomerId() == 0) {
|
65 |
+
$customerText = Mage::helper('review')->__('Administrator');
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
|
71 |
+
$fieldset->addField('customer', 'note', array(
|
72 |
+
'label' => Mage::helper('review')->__('Posted By'),
|
73 |
+
'text' => $customerText,
|
74 |
+
));
|
75 |
+
|
76 |
+
/*
|
77 |
+
* added new image custom field
|
78 |
+
*
|
79 |
+
*/
|
80 |
+
if(Mage::helper("reviewimage")->getActive() == '1'):
|
81 |
+
$imageUrl = Mage::getBaseUrl("media").'reviewimages/'.$review->getReviewimage();
|
82 |
+
$imageName = $review->getReviewimage();
|
83 |
+
|
84 |
+
$imageResized = Mage::getBaseDir('media').DS."creviewimages".DS.$imageName;
|
85 |
+
$dirImg = Mage::getBaseDir().str_replace("/",DS,strstr($imageUrl,'/media'));
|
86 |
+
|
87 |
+
if (!file_exists($imageResized)&&file_exists($dirImg)) :
|
88 |
+
$imageObj = new Varien_Image($dirImg);
|
89 |
+
$imageObj->constrainOnly(TRUE);
|
90 |
+
$imageObj->keepAspectRatio(TRUE);
|
91 |
+
$imageObj->keepFrame(FALSE);
|
92 |
+
$Resolution = Mage::helper("reviewimage")->getResolution();
|
93 |
+
$imageObj->resize($Resolution);
|
94 |
+
$imageObj->save($imageResized);
|
95 |
+
endif;
|
96 |
+
$newImageUrl = Mage::getBaseUrl('media')."creviewimages/".$imageName;
|
97 |
+
|
98 |
+
|
99 |
+
|
100 |
+
|
101 |
+
$image= "<image src='".$newImageUrl."'>";
|
102 |
+
|
103 |
+
$fieldset->addField('reviewimage', 'note', array(
|
104 |
+
'label' => Mage::helper('review')->__('Posted Review Image'),
|
105 |
+
'text' => $image,
|
106 |
+
));
|
107 |
+
|
108 |
+
endif;
|
109 |
+
/*
|
110 |
+
* added new image custom field
|
111 |
+
*
|
112 |
+
*/
|
113 |
+
|
114 |
+
$fieldset->addField('summary_rating', 'note', array(
|
115 |
+
'label' => Mage::helper('review')->__('Summary Rating'),
|
116 |
+
'text' => $this->getLayout()->createBlock('adminhtml/review_rating_summary')->toHtml(),
|
117 |
+
));
|
118 |
+
|
119 |
+
$fieldset->addField('detailed_rating', 'note', array(
|
120 |
+
'label' => Mage::helper('review')->__('Detailed Rating'),
|
121 |
+
'required' => true,
|
122 |
+
'text' => '<div id="rating_detail">'
|
123 |
+
. $this->getLayout()->createBlock('adminhtml/review_rating_detailed')->toHtml()
|
124 |
+
. '</div>',
|
125 |
+
));
|
126 |
+
|
127 |
+
|
128 |
+
$fieldset->addField('status_id', 'select', array(
|
129 |
+
'label' => Mage::helper('review')->__('Status'),
|
130 |
+
'required' => true,
|
131 |
+
'name' => 'status_id',
|
132 |
+
'values' => Mage::helper('review')->getReviewStatusesOptionArray(),
|
133 |
+
));
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Check is single store mode
|
137 |
+
*/
|
138 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
139 |
+
$field = $fieldset->addField('select_stores', 'multiselect', array(
|
140 |
+
'label' => Mage::helper('review')->__('Visible In'),
|
141 |
+
'required' => true,
|
142 |
+
'name' => 'stores[]',
|
143 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(),
|
144 |
+
));
|
145 |
+
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
146 |
+
$field->setRenderer($renderer);
|
147 |
+
$review->setSelectStores($review->getStores());
|
148 |
+
}
|
149 |
+
else {
|
150 |
+
$fieldset->addField('select_stores', 'hidden', array(
|
151 |
+
'name' => 'stores[]',
|
152 |
+
'value' => Mage::app()->getStore(true)->getId()
|
153 |
+
));
|
154 |
+
$review->setSelectStores(Mage::app()->getStore(true)->getId());
|
155 |
+
}
|
156 |
+
|
157 |
+
$fieldset->addField('nickname', 'text', array(
|
158 |
+
'label' => Mage::helper('review')->__('Nickname'),
|
159 |
+
'required' => true,
|
160 |
+
'name' => 'nickname'
|
161 |
+
));
|
162 |
+
|
163 |
+
$fieldset->addField('title', 'text', array(
|
164 |
+
'label' => Mage::helper('review')->__('Summary of Review'),
|
165 |
+
'required' => true,
|
166 |
+
'name' => 'title',
|
167 |
+
));
|
168 |
+
|
169 |
+
$fieldset->addField('detail', 'textarea', array(
|
170 |
+
'label' => Mage::helper('review')->__('Review'),
|
171 |
+
'required' => true,
|
172 |
+
'name' => 'detail',
|
173 |
+
'style' => 'height:24em;',
|
174 |
+
));
|
175 |
+
|
176 |
+
$form->setUseContainer(true);
|
177 |
+
$form->setValues($review->getData());
|
178 |
+
$this->setForm($form);
|
179 |
+
return parent::_prepareForm();
|
180 |
+
}
|
181 |
+
}
|
app/code/local/Kush/Reviewimage/Block/Review/Edit/Form.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Adminhtml
|
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 |
+
* Adminhtml Review Edit Form
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Adminhtml
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
|
35 |
+
class Kush_Reviewimage_Block_Adminhtml_Review_Edit_Form extends Mage_Adminhtml_Block_Review_Edit_Form
|
36 |
+
{
|
37 |
+
|
38 |
+
protected function _prepareForm()
|
39 |
+
{
|
40 |
+
$review = Mage::registry('review_data');
|
41 |
+
$product = Mage::getModel('catalog/product')->load($review->getEntityPkValue());
|
42 |
+
$customer = Mage::getModel('customer/customer')->load($review->getCustomerId());
|
43 |
+
|
44 |
+
$form = new Varien_Data_Form(array(
|
45 |
+
'id' => 'edit_form',
|
46 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'), 'ret' => Mage::registry('ret'))),
|
47 |
+
'method' => 'post'
|
48 |
+
));
|
49 |
+
|
50 |
+
$fieldset = $form->addFieldset('review_details', array('legend' => Mage::helper('review')->__('Review Details'), 'class' => 'fieldset-wide'));
|
51 |
+
|
52 |
+
|
53 |
+
echo $image= "<image height =60 width=60 src='".Mage::getBaseUrl("media").'reviewimages/'.$review->getReviewimage()."'>";
|
54 |
+
|
55 |
+
$fieldset->addField('reviewimage', 'note', array(
|
56 |
+
'label' => Mage::helper('review')->__('Posted Review Image'),
|
57 |
+
'text' => $image,
|
58 |
+
));
|
59 |
+
|
60 |
+
|
61 |
+
$form->setUseContainer(true);
|
62 |
+
$form->setValues($review->getData());
|
63 |
+
$this->setForm($form);
|
64 |
+
return parent::_prepareForm();
|
65 |
+
}
|
66 |
+
}
|
app/code/local/Kush/Reviewimage/Helper/Data.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Community
|
22 |
+
* @package Clarion_Bannerresponsive
|
23 |
+
* @copyright Copyright magento@clariontechnologies.co.in
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* helper data file
|
30 |
+
*
|
31 |
+
* @category Community
|
32 |
+
* @package Clarion_Bannerresponsive
|
33 |
+
* @author magento@clariontechnologies.co.in
|
34 |
+
*/
|
35 |
+
|
36 |
+
|
37 |
+
class Kush_Reviewimage_Helper_Data extends Mage_Core_Helper_Abstract
|
38 |
+
{
|
39 |
+
|
40 |
+
function getResolution()
|
41 |
+
{
|
42 |
+
return Mage::getStoreConfig("reviewimage/reimage/imageresolution");
|
43 |
+
|
44 |
+
}
|
45 |
+
function getActive()
|
46 |
+
{
|
47 |
+
return Mage::getStoreConfig("reviewimage/reimage/reimagefield");
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
app/code/local/Kush/Reviewimage/Model/Resource/Review.php
ADDED
@@ -0,0 +1,403 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Review
|
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 |
+
/**
|
29 |
+
* Review resource model
|
30 |
+
*
|
31 |
+
* @category Mage
|
32 |
+
* @package Mage_Review
|
33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
+
*/
|
35 |
+
class Kush_Reviewimage_Model_Resource_Review extends Mage_Review_Model_Resource_Review
|
36 |
+
{
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Review table
|
40 |
+
*
|
41 |
+
* @var string
|
42 |
+
*/
|
43 |
+
protected $_reviewTable;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Review Detail table
|
47 |
+
*
|
48 |
+
* @var string
|
49 |
+
*/
|
50 |
+
protected $_reviewDetailTable;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Review status table
|
54 |
+
*
|
55 |
+
* @var string
|
56 |
+
*/
|
57 |
+
protected $_reviewStatusTable;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Review entity table
|
61 |
+
*
|
62 |
+
* @var string
|
63 |
+
*/
|
64 |
+
protected $_reviewEntityTable;
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Review store table
|
68 |
+
*
|
69 |
+
* @var string
|
70 |
+
*/
|
71 |
+
protected $_reviewStoreTable;
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Review aggregate table
|
75 |
+
*
|
76 |
+
* @var string
|
77 |
+
*/
|
78 |
+
protected $_aggregateTable;
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Cache of deleted rating data
|
82 |
+
*
|
83 |
+
* @var array
|
84 |
+
*/
|
85 |
+
private $_deleteCache = array();
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Define main table. Define other tables name
|
89 |
+
*
|
90 |
+
*/
|
91 |
+
protected function _construct()
|
92 |
+
{
|
93 |
+
$this->_init('review/review', 'review_id');
|
94 |
+
$this->_reviewTable = $this->getTable('review/review');
|
95 |
+
$this->_reviewDetailTable = $this->getTable('review/review_detail');
|
96 |
+
$this->_reviewStatusTable = $this->getTable('review/review_status');
|
97 |
+
$this->_reviewEntityTable = $this->getTable('review/review_entity');
|
98 |
+
$this->_reviewStoreTable = $this->getTable('review/review_store');
|
99 |
+
$this->_aggregateTable = $this->getTable('review/review_aggregate');
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
104 |
+
{
|
105 |
+
$adapter = $this->_getWriteAdapter();
|
106 |
+
/**
|
107 |
+
* save detail
|
108 |
+
*/
|
109 |
+
$detail = array(
|
110 |
+
'title' => $object->getTitle(),
|
111 |
+
'detail' => $object->getDetail(),
|
112 |
+
'nickname' => $object->getNickname(),
|
113 |
+
'reviewimage' => $object->getReviewimage(),
|
114 |
+
);
|
115 |
+
$select = $adapter->select()
|
116 |
+
->from($this->_reviewDetailTable, 'detail_id')
|
117 |
+
->where('review_id = :review_id');
|
118 |
+
$detailId = $adapter->fetchOne($select, array(':review_id' => $object->getId()));
|
119 |
+
|
120 |
+
if ($detailId) {
|
121 |
+
$condition = array("detail_id = ?" => $detailId);
|
122 |
+
$adapter->update($this->_reviewDetailTable, $detail, $condition);
|
123 |
+
} else {
|
124 |
+
$detail['store_id'] = $object->getStoreId();
|
125 |
+
$detail['customer_id']= $object->getCustomerId();
|
126 |
+
$detail['review_id'] = $object->getId();
|
127 |
+
$adapter->insert($this->_reviewDetailTable, $detail);
|
128 |
+
}
|
129 |
+
|
130 |
+
|
131 |
+
/**
|
132 |
+
* save stores
|
133 |
+
*/
|
134 |
+
$stores = $object->getStores();
|
135 |
+
if (!empty($stores)) {
|
136 |
+
$condition = array('review_id = ?' => $object->getId());
|
137 |
+
$adapter->delete($this->_reviewStoreTable, $condition);
|
138 |
+
|
139 |
+
$insertedStoreIds = array();
|
140 |
+
foreach ($stores as $storeId) {
|
141 |
+
if (in_array($storeId, $insertedStoreIds)) {
|
142 |
+
continue;
|
143 |
+
}
|
144 |
+
|
145 |
+
$insertedStoreIds[] = $storeId;
|
146 |
+
$storeInsert = array(
|
147 |
+
'store_id' => $storeId,
|
148 |
+
'review_id'=> $object->getId()
|
149 |
+
);
|
150 |
+
$adapter->insert($this->_reviewStoreTable, $storeInsert);
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
// reaggregate ratings, that depend on this review
|
155 |
+
$this->_aggregateRatings(
|
156 |
+
$this->_loadVotedRatingIds($object->getId()),
|
157 |
+
$object->getEntityPkValue()
|
158 |
+
);
|
159 |
+
|
160 |
+
return $this;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Perform actions after object load
|
165 |
+
*
|
166 |
+
* @param Varien_Object $object
|
167 |
+
* @return Mage_Review_Model_Resource_Review
|
168 |
+
*/
|
169 |
+
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
170 |
+
{
|
171 |
+
$adapter = $this->_getReadAdapter();
|
172 |
+
$select = $adapter->select()
|
173 |
+
->from($this->_reviewStoreTable, array('store_id'))
|
174 |
+
->where('review_id = :review_id');
|
175 |
+
$stores = $adapter->fetchCol($select, array(':review_id' => $object->getId()));
|
176 |
+
if (empty($stores) && Mage::app()->isSingleStoreMode()) {
|
177 |
+
$object->setStores(array(Mage::app()->getStore(true)->getId()));
|
178 |
+
} else {
|
179 |
+
$object->setStores($stores);
|
180 |
+
}
|
181 |
+
return $this;
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Action before delete
|
186 |
+
*
|
187 |
+
* @param Mage_Core_Model_Abstract $object
|
188 |
+
* @return Mage_Review_Model_Resource_Review
|
189 |
+
*/
|
190 |
+
protected function _beforeDelete(Mage_Core_Model_Abstract $object)
|
191 |
+
{
|
192 |
+
// prepare rating ids, that depend on review
|
193 |
+
$this->_deleteCache = array(
|
194 |
+
'ratingIds' => $this->_loadVotedRatingIds($object->getId()),
|
195 |
+
'entityPkValue' => $object->getEntityPkValue()
|
196 |
+
);
|
197 |
+
return $this;
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Perform actions after object delete
|
202 |
+
*
|
203 |
+
* @param Mage_Core_Model_Abstract $object
|
204 |
+
* @return Mage_Review_Model_Resource_Review
|
205 |
+
*/
|
206 |
+
public function afterDeleteCommit(Mage_Core_Model_Abstract $object)
|
207 |
+
{
|
208 |
+
$this->aggregate($object);
|
209 |
+
|
210 |
+
// reaggregate ratings, that depended on this review
|
211 |
+
$this->_aggregateRatings(
|
212 |
+
$this->_deleteCache['ratingIds'],
|
213 |
+
$this->_deleteCache['entityPkValue']
|
214 |
+
);
|
215 |
+
$this->_deleteCache = array();
|
216 |
+
|
217 |
+
return $this;
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Retrieves total reviews
|
222 |
+
*
|
223 |
+
* @param int $entityPkValue
|
224 |
+
* @param bool $approvedOnly
|
225 |
+
* @param int $storeId
|
226 |
+
* @return int
|
227 |
+
*/
|
228 |
+
public function getTotalReviews($entityPkValue, $approvedOnly = false, $storeId = 0)
|
229 |
+
{
|
230 |
+
$adapter = $this->_getReadAdapter();
|
231 |
+
$select = $adapter->select()
|
232 |
+
->from($this->_reviewTable,
|
233 |
+
array(
|
234 |
+
'review_count' => new Zend_Db_Expr('COUNT(*)')
|
235 |
+
))
|
236 |
+
->where("{$this->_reviewTable}.entity_pk_value = :pk_value");
|
237 |
+
$bind = array(':pk_value' => $entityPkValue);
|
238 |
+
if ($storeId > 0) {
|
239 |
+
$select->join(array('store'=>$this->_reviewStoreTable),
|
240 |
+
$this->_reviewTable.'.review_id=store.review_id AND store.store_id = :store_id',
|
241 |
+
array());
|
242 |
+
$bind[':store_id'] = (int)$storeId;
|
243 |
+
}
|
244 |
+
if ($approvedOnly) {
|
245 |
+
$select->where("{$this->_reviewTable}.status_id = :status_id");
|
246 |
+
$bind[':status_id'] = Mage_Review_Model_Review::STATUS_APPROVED;
|
247 |
+
}
|
248 |
+
return $adapter->fetchOne($select, $bind);
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Aggregate
|
253 |
+
*
|
254 |
+
* @param Mage_Core_Model_Abstract $object
|
255 |
+
*/
|
256 |
+
public function aggregate($object)
|
257 |
+
{
|
258 |
+
$readAdapter = $this->_getReadAdapter();
|
259 |
+
$writeAdapter = $this->_getWriteAdapter();
|
260 |
+
if (!$object->getEntityPkValue() && $object->getId()) {
|
261 |
+
$object->load($object->getReviewId());
|
262 |
+
}
|
263 |
+
|
264 |
+
$ratingModel = Mage::getModel('rating/rating');
|
265 |
+
$ratingSummaries= $ratingModel->getEntitySummary($object->getEntityPkValue(), false);
|
266 |
+
|
267 |
+
foreach ($ratingSummaries as $ratingSummaryObject) {
|
268 |
+
if ($ratingSummaryObject->getCount()) {
|
269 |
+
$ratingSummary = round($ratingSummaryObject->getSum() / $ratingSummaryObject->getCount());
|
270 |
+
} else {
|
271 |
+
$ratingSummary = $ratingSummaryObject->getSum();
|
272 |
+
}
|
273 |
+
|
274 |
+
$reviewsCount = $this->getTotalReviews(
|
275 |
+
$object->getEntityPkValue(),
|
276 |
+
true,
|
277 |
+
$ratingSummaryObject->getStoreId()
|
278 |
+
);
|
279 |
+
$select = $readAdapter->select()
|
280 |
+
->from($this->_aggregateTable)
|
281 |
+
->where('entity_pk_value = :pk_value')
|
282 |
+
->where('entity_type = :entity_type')
|
283 |
+
->where('store_id = :store_id');
|
284 |
+
$bind = array(
|
285 |
+
':pk_value' => $object->getEntityPkValue(),
|
286 |
+
':entity_type' => $object->getEntityId(),
|
287 |
+
':store_id' =>$ratingSummaryObject->getStoreId()
|
288 |
+
);
|
289 |
+
$oldData = $readAdapter->fetchRow($select, $bind);
|
290 |
+
|
291 |
+
$data = new Varien_Object();
|
292 |
+
|
293 |
+
$data->setReviewsCount($reviewsCount)
|
294 |
+
->setEntityPkValue($object->getEntityPkValue())
|
295 |
+
->setEntityType($object->getEntityId())
|
296 |
+
->setRatingSummary(($ratingSummary > 0) ? $ratingSummary : 0)
|
297 |
+
->setStoreId($ratingSummaryObject->getStoreId());
|
298 |
+
|
299 |
+
$writeAdapter->beginTransaction();
|
300 |
+
try {
|
301 |
+
if ($oldData['primary_id'] > 0) {
|
302 |
+
$condition = array("{$this->_aggregateTable}.primary_id = ?" => $oldData['primary_id']);
|
303 |
+
$writeAdapter->update($this->_aggregateTable, $data->getData(), $condition);
|
304 |
+
} else {
|
305 |
+
$writeAdapter->insert($this->_aggregateTable, $data->getData());
|
306 |
+
}
|
307 |
+
$writeAdapter->commit();
|
308 |
+
} catch (Exception $e) {
|
309 |
+
$writeAdapter->rollBack();
|
310 |
+
}
|
311 |
+
}
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* Get rating IDs from review votes
|
316 |
+
*
|
317 |
+
* @param int $reviewId
|
318 |
+
* @return array
|
319 |
+
*/
|
320 |
+
protected function _loadVotedRatingIds($reviewId)
|
321 |
+
{
|
322 |
+
$adapter = $this->_getReadAdapter();
|
323 |
+
if (empty($reviewId)) {
|
324 |
+
return array();
|
325 |
+
}
|
326 |
+
$select = $adapter->select()
|
327 |
+
->from(array('v' => $this->getTable('rating/rating_option_vote')), 'r.rating_id')
|
328 |
+
->joinInner(array('r' => $this->getTable('rating/rating')), 'v.rating_id=r.rating_id')
|
329 |
+
->where('v.review_id = :revire_id');
|
330 |
+
return $adapter->fetchCol($select, array(':revire_id' => $reviewId));
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Aggregate this review's ratings.
|
335 |
+
* Useful, when changing the review.
|
336 |
+
*
|
337 |
+
* @param array $ratingIds
|
338 |
+
* @param int $entityPkValue
|
339 |
+
* @return Mage_Review_Model_Resource_Review
|
340 |
+
*/
|
341 |
+
protected function _aggregateRatings($ratingIds, $entityPkValue)
|
342 |
+
{
|
343 |
+
if ($ratingIds && !is_array($ratingIds)) {
|
344 |
+
$ratingIds = array((int)$ratingIds);
|
345 |
+
}
|
346 |
+
if ($ratingIds && $entityPkValue
|
347 |
+
&& ($resource = Mage::getResourceSingleton('rating/rating_option'))
|
348 |
+
) {
|
349 |
+
foreach ($ratingIds as $ratingId) {
|
350 |
+
$resource->aggregateEntityByRatingId(
|
351 |
+
$ratingId, $entityPkValue
|
352 |
+
);
|
353 |
+
}
|
354 |
+
}
|
355 |
+
return $this;
|
356 |
+
}
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Reaggregate this review's ratings.
|
360 |
+
*
|
361 |
+
* @param int $reviewId
|
362 |
+
* @param int $entityPkValue
|
363 |
+
*/
|
364 |
+
public function reAggregateReview($reviewId, $entityPkValue)
|
365 |
+
{
|
366 |
+
$this->_aggregateRatings($this->_loadVotedRatingIds($reviewId), $entityPkValue);
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* Get review entity type id by code
|
371 |
+
*
|
372 |
+
* @param string $entityCode
|
373 |
+
* @return int|bool
|
374 |
+
*/
|
375 |
+
public function getEntityIdByCode($entityCode)
|
376 |
+
{
|
377 |
+
$adapter = $this->_getReadAdapter();
|
378 |
+
$select = $adapter->select()
|
379 |
+
->from($this->_reviewEntityTable, array('entity_id'))
|
380 |
+
->where('entity_code = :entity_code');
|
381 |
+
return $adapter->fetchOne($select, array(':entity_code' => $entityCode));
|
382 |
+
}
|
383 |
+
|
384 |
+
/**
|
385 |
+
* Delete reviews by product id.
|
386 |
+
* Better to call this method in transaction, because operation performed on two separated tables
|
387 |
+
*
|
388 |
+
* @param int $productId
|
389 |
+
* @return Mage_Review_Model_Resource_Review
|
390 |
+
*/
|
391 |
+
public function deleteReviewsByProductId($productId)
|
392 |
+
{
|
393 |
+
$this->_getWriteAdapter()->delete($this->_reviewTable, array(
|
394 |
+
'entity_pk_value=?' => $productId,
|
395 |
+
'entity_id=?' => $this->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE)
|
396 |
+
));
|
397 |
+
$this->_getWriteAdapter()->delete($this->getTable('review/review_aggregate'), array(
|
398 |
+
'entity_pk_value=?' => $productId,
|
399 |
+
'entity_type=?' => $this->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE)
|
400 |
+
));
|
401 |
+
return $this;
|
402 |
+
}
|
403 |
+
}
|
app/code/local/Kush/Reviewimage/Model/Resource/Review/Collection.php
ADDED
@@ -0,0 +1,306 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Review
|
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 |
+
/**
|
29 |
+
* Review collection resource model
|
30 |
+
*
|
31 |
+
* @category Mage
|
32 |
+
* @package Mage_Review
|
33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
+
*/
|
35 |
+
class Kush_Reviewimage_Model_Resource_Review_Collection extends Mage_Review_Model_Resource_Review_Collection
|
36 |
+
{
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Review table
|
40 |
+
*
|
41 |
+
* @var string
|
42 |
+
*/
|
43 |
+
protected $_reviewTable;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Review detail table
|
47 |
+
*
|
48 |
+
* @var string
|
49 |
+
*/
|
50 |
+
protected $_reviewDetailTable;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Review status table
|
54 |
+
*
|
55 |
+
* @var string
|
56 |
+
*/
|
57 |
+
protected $_reviewStatusTable;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Review entity table
|
61 |
+
*
|
62 |
+
* @var string
|
63 |
+
*/
|
64 |
+
protected $_reviewEntityTable;
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Review store table
|
68 |
+
*
|
69 |
+
* @var string
|
70 |
+
*/
|
71 |
+
protected $_reviewStoreTable;
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Add store data flag
|
75 |
+
* @var bool
|
76 |
+
*/
|
77 |
+
protected $_addStoreDataFlag = false;
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Define module
|
81 |
+
*
|
82 |
+
*/
|
83 |
+
protected function _construct()
|
84 |
+
{
|
85 |
+
$this->_init('review/review');
|
86 |
+
$this->_reviewTable = $this->getTable('review/review');
|
87 |
+
$this->_reviewDetailTable = $this->getTable('review/review_detail');
|
88 |
+
$this->_reviewStatusTable = $this->getTable('review/review_status');
|
89 |
+
$this->_reviewEntityTable = $this->getTable('review/review_entity');
|
90 |
+
$this->_reviewStoreTable = $this->getTable('review/review_store');
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* init select
|
96 |
+
*
|
97 |
+
* @return Mage_Review_Model_Resource_Review_Product_Collection
|
98 |
+
*/
|
99 |
+
protected function _initSelect()
|
100 |
+
{
|
101 |
+
parent::_initSelect();
|
102 |
+
$this->getSelect()
|
103 |
+
->join(array('detailc' => $this->_reviewDetailTable),
|
104 |
+
'main_table.review_id = detailc.review_id',
|
105 |
+
array('detail_id', 'title', 'detail', 'nickname', 'customer_id','reviewimage'));
|
106 |
+
return $this;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Enter description here ...
|
111 |
+
*
|
112 |
+
* @param unknown_type $customerId
|
113 |
+
* @return Mage_Review_Model_Resource_Review_Collection
|
114 |
+
*/
|
115 |
+
public function addCustomerFilter($customerId)
|
116 |
+
{
|
117 |
+
$this->addFilter('customer',
|
118 |
+
$this->getConnection()->quoteInto('detail.customer_id=?', $customerId),
|
119 |
+
'string');
|
120 |
+
return $this;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Add store filter
|
125 |
+
*
|
126 |
+
* @param int|array $storeId
|
127 |
+
* @return Mage_Review_Model_Resource_Review_Collection
|
128 |
+
*/
|
129 |
+
public function addStoreFilter($storeId)
|
130 |
+
{
|
131 |
+
$inCond = $this->getConnection()->prepareSqlCondition('store.store_id', array('in' => $storeId));
|
132 |
+
$this->getSelect()->join(array('store'=>$this->_reviewStoreTable),
|
133 |
+
'main_table.review_id=store.review_id',
|
134 |
+
array());
|
135 |
+
$this->getSelect()->where($inCond);
|
136 |
+
return $this;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Add stores data
|
141 |
+
*
|
142 |
+
* @return Mage_Review_Model_Resource_Review_Collection
|
143 |
+
*/
|
144 |
+
public function addStoreData()
|
145 |
+
{
|
146 |
+
$this->_addStoreDataFlag = true;
|
147 |
+
return $this;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Add entity filter
|
152 |
+
*
|
153 |
+
* @param int|string $entity
|
154 |
+
* @param int $pkValue
|
155 |
+
* @return Mage_Review_Model_Resource_Review_Collection
|
156 |
+
*/
|
157 |
+
public function addEntityFilter($entity, $pkValue)
|
158 |
+
{
|
159 |
+
if (is_numeric($entity)) {
|
160 |
+
$this->addFilter('entity',
|
161 |
+
$this->getConnection()->quoteInto('main_table.entity_id=?', $entity),
|
162 |
+
'string');
|
163 |
+
} elseif (is_string($entity)) {
|
164 |
+
$this->_select->join($this->_reviewEntityTable,
|
165 |
+
'main_table.entity_id='.$this->_reviewEntityTable.'.entity_id',
|
166 |
+
array('entity_code'));
|
167 |
+
|
168 |
+
$this->addFilter('entity',
|
169 |
+
$this->getConnection()->quoteInto($this->_reviewEntityTable.'.entity_code=?', $entity),
|
170 |
+
'string');
|
171 |
+
}
|
172 |
+
|
173 |
+
$this->addFilter('entity_pk_value',
|
174 |
+
$this->getConnection()->quoteInto('main_table.entity_pk_value=?', $pkValue),
|
175 |
+
'string');
|
176 |
+
|
177 |
+
return $this;
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Add status filter
|
182 |
+
*
|
183 |
+
* @param int|string $status
|
184 |
+
* @return Mage_Review_Model_Resource_Review_Collection
|
185 |
+
*/
|
186 |
+
public function addStatusFilter($status)
|
187 |
+
{
|
188 |
+
if (is_string($status)) {
|
189 |
+
$statuses = array_flip(Mage::helper('review')->getReviewStatuses());
|
190 |
+
$status = isset($statuses[$status]) ? $statuses[$status] : 0;
|
191 |
+
}
|
192 |
+
if (is_numeric($status)) {
|
193 |
+
$this->addFilter('status',
|
194 |
+
$this->getConnection()->quoteInto('main_table.status_id=?', $status),
|
195 |
+
'string');
|
196 |
+
}
|
197 |
+
return $this;
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Set date order
|
202 |
+
*
|
203 |
+
* @param string $dir
|
204 |
+
* @return Mage_Review_Model_Resource_Review_Collection
|
205 |
+
*/
|
206 |
+
public function setDateOrder($dir = 'DESC')
|
207 |
+
{
|
208 |
+
$this->setOrder('main_table.created_at', $dir);
|
209 |
+
return $this;
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Add rate votes
|
214 |
+
*
|
215 |
+
* @return Mage_Review_Model_Resource_Review_Collection
|
216 |
+
*/
|
217 |
+
public function addRateVotes()
|
218 |
+
{
|
219 |
+
foreach ($this->getItems() as $item) {
|
220 |
+
$votesCollection = Mage::getModel('rating/rating_option_vote')
|
221 |
+
->getResourceCollection()
|
222 |
+
->setReviewFilter($item->getId())
|
223 |
+
->setStoreFilter(Mage::app()->getStore()->getId())
|
224 |
+
->addRatingInfo(Mage::app()->getStore()->getId())
|
225 |
+
->load();
|
226 |
+
$item->setRatingVotes($votesCollection);
|
227 |
+
}
|
228 |
+
|
229 |
+
return $this;
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Add reviews total count
|
234 |
+
*
|
235 |
+
* @return Mage_Review_Model_Resource_Review_Collection
|
236 |
+
*/
|
237 |
+
public function addReviewsTotalCount()
|
238 |
+
{
|
239 |
+
$this->_select->joinLeft(
|
240 |
+
array('r' => $this->_reviewTable),
|
241 |
+
'main_table.entity_pk_value = r.entity_pk_value',
|
242 |
+
array('total_reviews' => new Zend_Db_Expr('COUNT(r.review_id)'))
|
243 |
+
)
|
244 |
+
->group('main_table.review_id');
|
245 |
+
|
246 |
+
/*
|
247 |
+
* Allow analytic functions usage
|
248 |
+
*/
|
249 |
+
$this->_useAnalyticFunction = true;
|
250 |
+
|
251 |
+
return $this;
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Load data
|
256 |
+
*
|
257 |
+
* @param boolean $printQuery
|
258 |
+
* @param boolean $logQuery
|
259 |
+
* @return Mage_Review_Model_Resource_Review_Collection
|
260 |
+
*/
|
261 |
+
public function load($printQuery = false, $logQuery = false)
|
262 |
+
{
|
263 |
+
if ($this->isLoaded()) {
|
264 |
+
return $this;
|
265 |
+
}
|
266 |
+
Mage::dispatchEvent('review_review_collection_load_before', array('collection' => $this));
|
267 |
+
parent::load($printQuery, $logQuery);
|
268 |
+
if ($this->_addStoreDataFlag) {
|
269 |
+
$this->_addStoreData();
|
270 |
+
}
|
271 |
+
return $this;
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Add store data
|
276 |
+
*
|
277 |
+
*/
|
278 |
+
protected function _addStoreData()
|
279 |
+
{
|
280 |
+
$adapter = $this->getConnection();
|
281 |
+
|
282 |
+
$reviewsIds = $this->getColumnValues('review_id');
|
283 |
+
$storesToReviews = array();
|
284 |
+
if (count($reviewsIds)>0) {
|
285 |
+
$inCond = $adapter->prepareSqlCondition('review_id', array('in' => $reviewsIds));
|
286 |
+
$select = $adapter->select()
|
287 |
+
->from($this->_reviewStoreTable)
|
288 |
+
->where($inCond);
|
289 |
+
$result = $adapter->fetchAll($select);
|
290 |
+
foreach ($result as $row) {
|
291 |
+
if (!isset($storesToReviews[$row['review_id']])) {
|
292 |
+
$storesToReviews[$row['review_id']] = array();
|
293 |
+
}
|
294 |
+
$storesToReviews[$row['review_id']][] = $row['store_id'];
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
+
foreach ($this as $item) {
|
299 |
+
if (isset($storesToReviews[$item->getId()])) {
|
300 |
+
$item->setStores($storesToReviews[$item->getId()]);
|
301 |
+
} else {
|
302 |
+
$item->setStores(array());
|
303 |
+
}
|
304 |
+
}
|
305 |
+
}
|
306 |
+
}
|
app/code/local/Kush/Reviewimage/Model/Review.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Review
|
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 |
+
* Review model
|
29 |
+
*
|
30 |
+
* @method Mage_Review_Model_Resource_Review _getResource()
|
31 |
+
* @method Mage_Review_Model_Resource_Review getResource()
|
32 |
+
* @method string getCreatedAt()
|
33 |
+
* @method Mage_Review_Model_Review setCreatedAt(string $value)
|
34 |
+
* @method Mage_Review_Model_Review setEntityId(int $value)
|
35 |
+
* @method int getEntityPkValue()
|
36 |
+
* @method Mage_Review_Model_Review setEntityPkValue(int $value)
|
37 |
+
* @method int getStatusId()
|
38 |
+
* @method Mage_Review_Model_Review setStatusId(int $value)
|
39 |
+
*
|
40 |
+
* @category Mage
|
41 |
+
* @package Mage_Review
|
42 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
43 |
+
*/
|
44 |
+
class Kush_Reviewimage_Model_Review extends Mage_Review_Model_Review
|
45 |
+
{
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Event prefix for observer
|
49 |
+
*
|
50 |
+
* @var string
|
51 |
+
*/
|
52 |
+
protected $_eventPrefix = 'review';
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @deprecated after 1.3.2.4
|
56 |
+
*
|
57 |
+
*/
|
58 |
+
const ENTITY_PRODUCT = 1;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Review entity codes
|
62 |
+
*
|
63 |
+
*/
|
64 |
+
const ENTITY_PRODUCT_CODE = 'product';
|
65 |
+
const ENTITY_CUSTOMER_CODE = 'customer';
|
66 |
+
const ENTITY_CATEGORY_CODE = 'category';
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
|
74 |
+
public function validate()
|
75 |
+
{
|
76 |
+
$errors = array();
|
77 |
+
|
78 |
+
if (!Zend_Validate::is($this->getTitle(), 'NotEmpty')) {
|
79 |
+
$errors[] = Mage::helper('review')->__('Review summary can\'t be empty');
|
80 |
+
}
|
81 |
+
|
82 |
+
if (!Zend_Validate::is($this->getNickname(), 'NotEmpty')) {
|
83 |
+
$errors[] = Mage::helper('review')->__('Nickname can\'t be empty');
|
84 |
+
}
|
85 |
+
|
86 |
+
if (!Zend_Validate::is($this->getReviewimage(), 'NotEmpty')) {
|
87 |
+
$errors[] = Mage::helper('review')->__('Review Image can\'t be empty');
|
88 |
+
}
|
89 |
+
|
90 |
+
|
91 |
+
if (!Zend_Validate::is($this->getDetail(), 'NotEmpty')) {
|
92 |
+
$errors[] = Mage::helper('review')->__('Review can\'t be empty');
|
93 |
+
}
|
94 |
+
|
95 |
+
if (empty($errors)) {
|
96 |
+
return true;
|
97 |
+
}
|
98 |
+
return $errors;
|
99 |
+
}
|
100 |
+
|
101 |
+
}
|
app/code/local/Kush/Reviewimage/controllers/ProductController.php
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Review
|
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 |
+
* Review controller
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Review
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
require_once("Mage/Review/controllers/ProductController.php");
|
35 |
+
class Kush_Reviewimage_ProductController extends Mage_Review_ProductController
|
36 |
+
{
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Submit new review action
|
41 |
+
*
|
42 |
+
*/
|
43 |
+
public function postAction()
|
44 |
+
{
|
45 |
+
if (!$this->_validateFormKey()) {
|
46 |
+
// returns to the product item page
|
47 |
+
$this->_redirectReferer();
|
48 |
+
return;
|
49 |
+
}
|
50 |
+
if ($data = Mage::getSingleton('review/session')->getFormData(true)) {
|
51 |
+
$rating = array();
|
52 |
+
if (isset($data['ratings']) && is_array($data['ratings'])) {
|
53 |
+
$rating = $data['ratings'];
|
54 |
+
}
|
55 |
+
} else {
|
56 |
+
$data = $this->getRequest()->getPost();
|
57 |
+
$rating = $this->getRequest()->getParam('ratings', array());
|
58 |
+
}
|
59 |
+
|
60 |
+
if(isset($_FILES['reviewimage']['name']) && $_FILES['reviewimage']['name'] != '') {
|
61 |
+
try {
|
62 |
+
/* Starting upload */
|
63 |
+
$uploader = new Varien_File_Uploader('reviewimage');
|
64 |
+
|
65 |
+
// Any extention would work
|
66 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
67 |
+
$uploader->setAllowRenameFiles(false);
|
68 |
+
|
69 |
+
// Set the file upload mode
|
70 |
+
// false -> get the file directly in the specified folder
|
71 |
+
// true -> get the file in the product like folders
|
72 |
+
// (file.jpg will go in something like /media/f/i/file.jpg)
|
73 |
+
$uploader->setFilesDispersion(false);
|
74 |
+
|
75 |
+
// We set media as the upload dir
|
76 |
+
$path = Mage::getBaseDir('media').DS.reviewimages.DS;
|
77 |
+
$uploader->save($path, $_FILES['reviewimage']['name'] );
|
78 |
+
|
79 |
+
} catch (Exception $e) {
|
80 |
+
|
81 |
+
}
|
82 |
+
|
83 |
+
//this way the name is saved in DB
|
84 |
+
$data['reviewimage'] = $_FILES['reviewimage']['name'];
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
if (($product = $this->_initProduct()) && !empty($data)) {
|
89 |
+
$session = Mage::getSingleton('core/session');
|
90 |
+
/* @var $session Mage_Core_Model_Session */
|
91 |
+
$review = Mage::getModel('review/review')->setData($data);
|
92 |
+
/* @var $review Mage_Review_Model_Review */
|
93 |
+
|
94 |
+
$validate = $review->validate();
|
95 |
+
if ($validate === true) {
|
96 |
+
try {
|
97 |
+
$review->setEntityId($review->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE))
|
98 |
+
->setEntityPkValue($product->getId())
|
99 |
+
->setStatusId(Mage_Review_Model_Review::STATUS_PENDING)
|
100 |
+
->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
|
101 |
+
->setStoreId(Mage::app()->getStore()->getId())
|
102 |
+
->setStores(array(Mage::app()->getStore()->getId()))
|
103 |
+
->save();
|
104 |
+
|
105 |
+
foreach ($rating as $ratingId => $optionId) {
|
106 |
+
Mage::getModel('rating/rating')
|
107 |
+
->setRatingId($ratingId)
|
108 |
+
->setReviewId($review->getId())
|
109 |
+
->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
|
110 |
+
->addOptionVote($optionId, $product->getId());
|
111 |
+
}
|
112 |
+
|
113 |
+
$review->aggregate();
|
114 |
+
$session->addSuccess($this->__('Your review has been accepted for moderation.'));
|
115 |
+
}
|
116 |
+
catch (Exception $e) {
|
117 |
+
$session->setFormData($data);
|
118 |
+
$session->addError($this->__('Unable to post the review.'));
|
119 |
+
}
|
120 |
+
}
|
121 |
+
else {
|
122 |
+
$session->setFormData($data);
|
123 |
+
if (is_array($validate)) {
|
124 |
+
foreach ($validate as $errorMessage) {
|
125 |
+
$session->addError($errorMessage);
|
126 |
+
}
|
127 |
+
}
|
128 |
+
else {
|
129 |
+
$session->addError($this->__('Unable to post the review.'));
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
if ($redirectUrl = Mage::getSingleton('review/session')->getRedirectUrl(true)) {
|
135 |
+
$this->_redirectUrl($redirectUrl);
|
136 |
+
return;
|
137 |
+
}
|
138 |
+
$this->_redirectReferer();
|
139 |
+
}
|
140 |
+
|
141 |
+
|
142 |
+
}
|
app/code/local/Kush/Reviewimage/etc/adminhtml.xml
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Community
|
23 |
+
* @package Clarion_Bannerresponsive
|
24 |
+
* @copyright Copyright magento@clariontechnologies.co.in
|
25 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
26 |
+
*/
|
27 |
+
-->
|
28 |
+
<config>
|
29 |
+
<menu>
|
30 |
+
<catalog>
|
31 |
+
<children>
|
32 |
+
<reviews_ratings translate="title" module="review">
|
33 |
+
<title>Reviews and Ratings</title>
|
34 |
+
<children>
|
35 |
+
<reviews translate="title" module="review">
|
36 |
+
<title>Customer Reviews</title>
|
37 |
+
<children>
|
38 |
+
<reviewsimages translate="title" module="reviewimage">
|
39 |
+
<title>Reviews Image Configuration</title>
|
40 |
+
<action>adminhtml/system_config/edit/section/reviewimage</action>
|
41 |
+
</reviewsimages>
|
42 |
+
</children>
|
43 |
+
</reviews>
|
44 |
+
<ratings translate="title" module="review">
|
45 |
+
<title>Manage Ratings</title>
|
46 |
+
<action>adminhtml/rating/</action>
|
47 |
+
</ratings>
|
48 |
+
</children>
|
49 |
+
<sort_order>50</sort_order>
|
50 |
+
</reviews_ratings>
|
51 |
+
</children>
|
52 |
+
</catalog>
|
53 |
+
|
54 |
+
</menu>
|
55 |
+
<acl>
|
56 |
+
<resources>
|
57 |
+
<all>
|
58 |
+
<title>Allow Everything</title>
|
59 |
+
</all>
|
60 |
+
<admin>
|
61 |
+
<children>
|
62 |
+
<system>
|
63 |
+
<children>
|
64 |
+
<config>
|
65 |
+
<children>
|
66 |
+
<reviewimage>
|
67 |
+
<title>Review Image</title>
|
68 |
+
</reviewimage>
|
69 |
+
</children>
|
70 |
+
</config>
|
71 |
+
</children>
|
72 |
+
</system>
|
73 |
+
</children>
|
74 |
+
</admin>
|
75 |
+
</resources>
|
76 |
+
</acl>
|
77 |
+
|
78 |
+
</config>
|
app/code/local/Kush/Reviewimage/etc/config.xml
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Kush_Reviewimage>
|
5 |
+
<version>1.0.3</version>
|
6 |
+
</Kush_Reviewimage>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<review>
|
11 |
+
<args>
|
12 |
+
<modules>
|
13 |
+
<Kush_Reviewimage before="Mage_Review">Kush_Reviewimage</Kush_Reviewimage>
|
14 |
+
</modules>
|
15 |
+
</args>
|
16 |
+
</review>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<reviewimage>
|
21 |
+
<file>reviewimage.xml</file>
|
22 |
+
</reviewimage>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<adminhtml>
|
27 |
+
<acl>
|
28 |
+
<resources>
|
29 |
+
<all>
|
30 |
+
<title>Allow Everything</title>
|
31 |
+
</all>
|
32 |
+
<admin>
|
33 |
+
<children>
|
34 |
+
<system>
|
35 |
+
<children>
|
36 |
+
<config>
|
37 |
+
<children>
|
38 |
+
<reviewimage>
|
39 |
+
<title>Review Image</title>
|
40 |
+
</reviewimage>
|
41 |
+
</children>
|
42 |
+
</config>
|
43 |
+
</children>
|
44 |
+
</system>
|
45 |
+
</children>
|
46 |
+
</admin>
|
47 |
+
</resources>
|
48 |
+
</acl>
|
49 |
+
</adminhtml>
|
50 |
+
<global>
|
51 |
+
<resources>
|
52 |
+
<reviewimage_setup>
|
53 |
+
<setup>
|
54 |
+
<module>Kush_Reviewimage</module>
|
55 |
+
</setup>
|
56 |
+
<connection>
|
57 |
+
<use>core_setup</use>
|
58 |
+
</connection>
|
59 |
+
</reviewimage_setup>
|
60 |
+
<reviewimage_write>
|
61 |
+
<connection>
|
62 |
+
<use>core_write</use>
|
63 |
+
</connection>
|
64 |
+
</reviewimage_write>
|
65 |
+
<reviewimage_read>
|
66 |
+
<connection>
|
67 |
+
<use>core_read</use>
|
68 |
+
</connection>
|
69 |
+
</reviewimage_read>
|
70 |
+
</resources>
|
71 |
+
<models>
|
72 |
+
<review>
|
73 |
+
<rewrite>
|
74 |
+
<review>Kush_Reviewimage_Model_Review</review><!--reviews models rewrite here-->
|
75 |
+
</rewrite>
|
76 |
+
</review>
|
77 |
+
|
78 |
+
|
79 |
+
<review_resource>
|
80 |
+
<rewrite>
|
81 |
+
<review>Kush_Reviewimage_Model_Resource_Review</review>
|
82 |
+
</rewrite>
|
83 |
+
</review_resource>
|
84 |
+
|
85 |
+
<review_resource>
|
86 |
+
<rewrite>
|
87 |
+
<review_collection>Kush_Reviewimage_Model_Resource_Review_Collection</review_collection>
|
88 |
+
</rewrite>
|
89 |
+
</review_resource>
|
90 |
+
</models>
|
91 |
+
<blocks>
|
92 |
+
<adminhtml>
|
93 |
+
<rewrite><review_edit_form>Kush_Reviewimage_Block_Adminhtml_Review_Edit_Form</review_edit_form></rewrite>
|
94 |
+
</adminhtml>
|
95 |
+
</blocks>
|
96 |
+
<helpers>
|
97 |
+
<reviewimage>
|
98 |
+
<class>Kush_Reviewimage_Helper</class>
|
99 |
+
</reviewimage>
|
100 |
+
</helpers>
|
101 |
+
</global>
|
102 |
+
<default>
|
103 |
+
<reviewimage>
|
104 |
+
<reimage>
|
105 |
+
<reimagefield>1</reimagefield>
|
106 |
+
<imageresolution>198</imageresolution>
|
107 |
+
</reimage>
|
108 |
+
</reviewimage>
|
109 |
+
</default>
|
110 |
+
</config>
|
app/code/local/Kush/Reviewimage/etc/system.xml
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Community
|
23 |
+
* @package Clarion_Bannerresponsive
|
24 |
+
* @copyright Copyright magento@clariontechnologies.co.in
|
25 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
26 |
+
*/
|
27 |
+
-->
|
28 |
+
<config>
|
29 |
+
<tabs>
|
30 |
+
<kush translate="label" module="reviewimage">
|
31 |
+
<label>Reviewimage Configuration</label>
|
32 |
+
<sort_order>10</sort_order>
|
33 |
+
</kush>
|
34 |
+
</tabs>
|
35 |
+
<sections>
|
36 |
+
<reviewimage translate="label" module="reviewimage">
|
37 |
+
<label> Configuration</label>
|
38 |
+
<tab>kush</tab>
|
39 |
+
<frontend_type>text</frontend_type>
|
40 |
+
<sort_order>677</sort_order>
|
41 |
+
<show_in_default>1</show_in_default>
|
42 |
+
<show_in_website>1</show_in_website>
|
43 |
+
<show_in_store>1</show_in_store>
|
44 |
+
<groups>
|
45 |
+
<reimage translate="label" module="reviewimage">
|
46 |
+
<label>Enable or Disable</label>
|
47 |
+
<frontend_type>text</frontend_type>
|
48 |
+
<sort_order>140</sort_order>
|
49 |
+
<show_in_default>1</show_in_default>
|
50 |
+
<show_in_website>1</show_in_website>
|
51 |
+
<show_in_store>1</show_in_store>
|
52 |
+
<fields>
|
53 |
+
<reimagefield translate="label">
|
54 |
+
<label>Enable:</label>
|
55 |
+
<comment></comment>
|
56 |
+
<frontend_type>select</frontend_type>
|
57 |
+
<sort_order>210</sort_order>
|
58 |
+
<show_in_default>1</show_in_default>
|
59 |
+
<show_in_website>1</show_in_website>
|
60 |
+
<show_in_store>1</show_in_store>
|
61 |
+
<can_be_empty>1</can_be_empty>
|
62 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
63 |
+
<!--<source_model>allcurrency/type</source_model>-->
|
64 |
+
</reimagefield>
|
65 |
+
|
66 |
+
<imageresolution translate="label">
|
67 |
+
<label>Image Resolution</label>
|
68 |
+
<comment>Hight And Width For Review Image</comment>
|
69 |
+
<frontend_type>text</frontend_type>
|
70 |
+
<sort_order>220</sort_order>
|
71 |
+
<show_in_default>1</show_in_default>
|
72 |
+
<show_in_website>1</show_in_website>
|
73 |
+
<show_in_store>1</show_in_store>
|
74 |
+
<can_be_empty>1</can_be_empty>
|
75 |
+
</imageresolution>
|
76 |
+
</fields>
|
77 |
+
|
78 |
+
</reimage>
|
79 |
+
|
80 |
+
|
81 |
+
</groups>
|
82 |
+
|
83 |
+
|
84 |
+
</reviewimage>
|
85 |
+
</sections>
|
86 |
+
</config>
|
app/code/local/Kush/Reviewimage/sql/reviewimage_setup/mysql4-install-1.0.3.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
$installer->startSetup();
|
4 |
+
$installer->run("ALTER TABLE `review_detail` ADD `reviewimage` VARCHAR( 255 ) NOT NULL AFTER `detail` ;");
|
5 |
+
|
6 |
+
$installer->endSetup();
|
7 |
+
?>
|
app/design/frontend/default/default/layout/reviewimage.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
|
5 |
+
</default>
|
6 |
+
<review_product_list translate="label">
|
7 |
+
|
8 |
+
<reference name="root">
|
9 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
10 |
+
</reference>
|
11 |
+
|
12 |
+
<reference name="product.info.product_additional_data">
|
13 |
+
<action method="setTemplate"><template>review/product/view/list.phtml</template></action>
|
14 |
+
<reference name="product.review.form">
|
15 |
+
<action method="setTemplate"><template>review/form.phtml</template></action>
|
16 |
+
</reference>
|
17 |
+
</reference>
|
18 |
+
</review_product_list>
|
19 |
+
</layout>
|
app/design/frontend/default/default/template/review/form.phtml
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Reviews') ?></h2>
|
29 |
+
<?php if ($this->getAllowWriteReviewFlag()): ?>
|
30 |
+
<form action="<?php echo $this->getAction() ?>" method="post" id="review-form" enctype="multipart/form-data">
|
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 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('product-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 |
+
<?php if(Mage::helper("reviewimage")->getActive() == '1'):?>
|
83 |
+
<li>
|
84 |
+
<label for="reviewimage" class="required"><em>*</em><?php echo $this->__('Review Image') ?></label>
|
85 |
+
<div class="input-box">
|
86 |
+
<input type="file" name="reviewimage" class="input-text required-entry"/>
|
87 |
+
</div>
|
88 |
+
|
89 |
+
</li>
|
90 |
+
<?php endif;?>
|
91 |
+
<li>
|
92 |
+
<label for="review_field" class="required"><em>*</em><?php echo $this->__('Review') ?></label>
|
93 |
+
<div class="input-box">
|
94 |
+
<textarea name="detail" id="review_field" cols="5" rows="3" class="required-entry"><?php echo $this->escapeHtml($data->getDetail()) ?></textarea>
|
95 |
+
</div>
|
96 |
+
</li>
|
97 |
+
</ul>
|
98 |
+
</fieldset>
|
99 |
+
<div class="buttons-set">
|
100 |
+
<button type="submit" title="<?php echo $this->__('Submit Review') ?>" class="button"><span><span><?php echo $this->__('Submit Review') ?></span></span></button>
|
101 |
+
</div>
|
102 |
+
</form>
|
103 |
+
<script type="text/javascript">
|
104 |
+
//<![CDATA[
|
105 |
+
var dataForm = new VarienForm('review-form');
|
106 |
+
Validation.addAllThese(
|
107 |
+
[
|
108 |
+
['validate-rating', '<?php echo $this->__('Please select one of each of the ratings above') ?>', function(v) {
|
109 |
+
var trs = $('product-review-table').select('tr');
|
110 |
+
var inputs;
|
111 |
+
var error = 1;
|
112 |
+
|
113 |
+
for( var j=0; j < trs.length; j++ ) {
|
114 |
+
var tr = trs[j];
|
115 |
+
if( j > 0 ) {
|
116 |
+
inputs = tr.select('input');
|
117 |
+
|
118 |
+
for( i in inputs ) {
|
119 |
+
if( inputs[i].checked == true ) {
|
120 |
+
error = 0;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
if( error == 1 ) {
|
125 |
+
return false;
|
126 |
+
} else {
|
127 |
+
error = 1;
|
128 |
+
}
|
129 |
+
}
|
130 |
+
}
|
131 |
+
return true;
|
132 |
+
}]
|
133 |
+
]
|
134 |
+
);
|
135 |
+
//]]>
|
136 |
+
</script>
|
137 |
+
<?php else: ?>
|
138 |
+
<p class="review-nologged" id="review-form">
|
139 |
+
<?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()) ?>
|
140 |
+
</p>
|
141 |
+
<?php endif ?>
|
142 |
+
</div>
|
app/design/frontend/default/default/template/review/product/view/list.phtml
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
28 |
+
<?php $_items = $this->getReviewsCollection()->getItems();?>
|
29 |
+
<div class="box-collateral box-reviews" id="customer-reviews">
|
30 |
+
<?php if (count($_items)):?>
|
31 |
+
<h2><?php echo $this->__('Customer Reviews') ?></h2>
|
32 |
+
<?php echo $this->getChildHtml('toolbar') ?>
|
33 |
+
<dl>
|
34 |
+
<?php foreach ($_items as $_review):?>
|
35 |
+
|
36 |
+
|
37 |
+
<dt>
|
38 |
+
<a href="<?php echo $this->getReviewUrl($_review->getId()) ?>"><?php echo $this->escapeHtml($_review->getTitle()) ?></a> <?php echo $this->__('Review by <span>%s</span>', $this->escapeHtml($_review->getNickname())) ?>
|
39 |
+
</dt>
|
40 |
+
<?php if(Mage::helper("reviewimage")->getActive() == '1'):?>
|
41 |
+
<?php if($_review->getReviewimage()):?>
|
42 |
+
<?php
|
43 |
+
/*
|
44 |
+
* image resize function
|
45 |
+
*/
|
46 |
+
$imageUrl = Mage::getBaseUrl("media").'reviewimages/'.$_review->getReviewimage();
|
47 |
+
|
48 |
+
$imageName = $_review->getReviewimage();
|
49 |
+
$imageResized = Mage::getBaseDir('media').DS."creviewimages".DS.$imageName;
|
50 |
+
$dirImg = Mage::getBaseDir().str_replace("/",DS,strstr($imageUrl,'/media'));
|
51 |
+
|
52 |
+
if (!file_exists($imageResized)&&file_exists($dirImg)) :
|
53 |
+
$imageObj = new Varien_Image($dirImg);
|
54 |
+
$imageObj->constrainOnly(TRUE);
|
55 |
+
$imageObj->keepAspectRatio(TRUE);
|
56 |
+
$imageObj->keepFrame(FALSE);
|
57 |
+
$Resolution = Mage::helper("reviewimage")->getResolution();
|
58 |
+
$imageObj->resize($Resolution);
|
59 |
+
$imageObj->save($imageResized);
|
60 |
+
endif;
|
61 |
+
$newImageUrl = Mage::getBaseUrl('media')."creviewimages/".$imageName;
|
62 |
+
/*
|
63 |
+
* image resize function
|
64 |
+
*/
|
65 |
+
?>
|
66 |
+
<dt style="margin:5px 5px;"><image src="<?php echo $newImageUrl;?>"/></dt>
|
67 |
+
<?php endif;?>
|
68 |
+
<?php endif;?>
|
69 |
+
<dd>
|
70 |
+
<?php $_votes = $_review->getRatingVotes(); ?>
|
71 |
+
<?php if (count($_votes)): ?>
|
72 |
+
<table class="ratings-table">
|
73 |
+
<col width="1" />
|
74 |
+
<col />
|
75 |
+
<tbody>
|
76 |
+
<?php foreach ($_votes as $_vote): ?>
|
77 |
+
<tr>
|
78 |
+
<th><?php echo $this->escapeHtml($_vote->getRatingCode()) ?></th>
|
79 |
+
<td>
|
80 |
+
<div class="rating-box">
|
81 |
+
<div class="rating" style="width:<?php echo $_vote->getPercent() ?>%;"></div>
|
82 |
+
</div>
|
83 |
+
</td>
|
84 |
+
|
85 |
+
</tr>
|
86 |
+
<?php endforeach; ?>
|
87 |
+
</tbody>
|
88 |
+
</table>
|
89 |
+
<?php endif; ?>
|
90 |
+
<?php echo nl2br($this->escapeHtml($_review->getDetail())) ?>
|
91 |
+
<small class="date"><?php echo $this->__('(Posted on %s)', $this->formatDate($_review->getCreatedAt()), 'long') ?></small>
|
92 |
+
</dd>
|
93 |
+
<?php endforeach; ?>
|
94 |
+
</dl>
|
95 |
+
<?php echo $this->getChildHtml('toolbar') ?>
|
96 |
+
<?php endif;?>
|
97 |
+
<?php echo $this->getChildHtml('review_form') ?>
|
98 |
+
</div>
|
app/etc/modules/Kush_Reviewimage.xml
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_CurrencySymbol
|
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 |
+
<Kush_Reviewimage>
|
31 |
+
<active>true</active>
|
32 |
+
<codePool>local</codePool>
|
33 |
+
</Kush_Reviewimage>
|
34 |
+
</modules>
|
35 |
+
</config>
|
media/reviewimages/4.jpg
ADDED
Binary file
|
media/reviewimages/Installation_guide.pdf
ADDED
Binary file
|
media/reviewimages/above-sale-n.jpg
ADDED
Binary file
|
media/reviewimages/adasadad.jpg
ADDED
Binary file
|
media/reviewimages/bxshowfuikles.jpg
ADDED
Binary file
|
media/reviewimages/camra1.jpg
ADDED
Binary file
|
media/reviewimages/firstyw.jpg
ADDED
Binary file
|
media/reviewimages/graphic-tee-creative-2.jpg
ADDED
Binary file
|
media/reviewimages/men-1.jpg
ADDED
Binary file
|
media/reviewimages/modern_d.jpg
ADDED
Binary file
|
media/reviewimages/modern_y.jpg
ADDED
Binary file
|
media/reviewimages/new-hp-kurti-banner.jpg
ADDED
Binary file
|
media/reviewimages/r3-jeans-1.jpg
ADDED
Binary file
|
media/reviewimages/saw2w12w.jpg
ADDED
Binary file
|
media/reviewimages/secondww_lion.jpg
ADDED
Binary file
|
media/reviewimages/shaden-3final.jpg
ADDED
Binary file
|
media/reviewimages/we-12.jpg
ADDED
Binary file
|
media/reviewimages/web-11-a.jpg
ADDED
Binary file
|
media/reviewimages/womens-offer-new.jpg
ADDED
Binary file
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Clarion_Reviewimage</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Review Form With Image Field</summary>
|
10 |
+
<description>Default magento dosent give this after installing this image upload field will display in review form.</description>
|
11 |
+
<notes>Review Form With Image Field 1.0.0</notes>
|
12 |
+
<authors><author><name>kushagra daharwal</name><user>kushagra</user><email>kushagra.daharwal@clariontechnologies.co.in</email></author></authors>
|
13 |
+
<date>2014-04-02</date>
|
14 |
+
<time>11:33:58</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Kush_Reviewimage.xml" hash="f79cca862b46da9a0dde3f29d81d2cfd"/></dir></target><target name="magelocal"><dir name="Kush"><dir name="Reviewimage"><dir name="Block"><dir name="Adminhtml"><dir name="Review"><dir name="Edit"><file name="Form.php" hash="1d5ce08ce9547f7a4b5c02cb68d0b04c"/></dir></dir></dir><dir name="Review"><dir name="Edit"><file name="Form.php" hash="d94a56d39dc949bb82aef696565ac5a6"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="41e8f40134c803ca913ad26fb4dd21b9"/></dir><dir name="Model"><dir name="Resource"><dir name="Review"><file name="Collection.php" hash="04904bf97bcc293539e9af4d41323d4a"/></dir><file name="Review.php" hash="e796a0da2784ab890ca3de241b740c1f"/></dir><file name="Review.php" hash="382edade68e65d3b792536bc3895ef8d"/></dir><dir name="controllers"><file name="ProductController.php" hash="fbd9b2f22257170a069e1a7a3d6f5917"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1510baa86869c3695fd1b0e9fad493f7"/><file name="config.xml" hash="17c37262d9d7cc7da7b7014a67413696"/><file name="system.xml" hash="0892252f2a519280b2ff61a831cc488b"/></dir><dir name="sql"><dir name="reviewimage_setup"><file name="mysql4-install-1.0.3.php" hash="ba7859db824cb9d6833ba8eea1ffb821"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="reviewimage.xml" hash="08d96b4a4ae63ccc9ac1faa38e153476"/></dir><dir name="template"><dir name="review"><file name="form.phtml" hash="858e5ba31252de3dc98de93d08e658c4"/><dir name="product"><dir name="view"><file name="list.phtml" hash="b430aa6419bd76c3aa0e78ab83718d6b"/></dir></dir></dir></dir></dir></dir></dir></target><target name="magemedia"><dir name="reviewimages"><file name="4.jpg" hash="78cd090d4be6f1b89c38873a7aeb93f5"/><file name="Installation_guide.pdf" hash="5c378e29f6ab6d72c10316ea342ffc93"/><file name="above-sale-n.jpg" hash="f7a71328ad4749a3daa21164fc197517"/><file name="adasadad.jpg" hash="680953cf98773d0ff4df81fdd0e681e2"/><file name="bxshowfuikles.jpg" hash="9142bbd5054368a9977725795c0050e4"/><file name="camra1.jpg" hash="78cd090d4be6f1b89c38873a7aeb93f5"/><file name="firstyw.jpg" hash="7554095a0e5510f6b1859915be703daf"/><file name="graphic-tee-creative-2.jpg" hash="19b8013fc20b5df3ececb36c15b0dee7"/><file name="men-1.jpg" hash="d6252cdedd1a333bff1a227b16a54fb2"/><file name="modern_d.jpg" hash="a2bf0aa46b09983c3c2fa60bf7ccb17d"/><file name="modern_y.jpg" hash="7186bf8894d6e2eeea8ae7283bc5fb09"/><file name="new-hp-kurti-banner.jpg" hash="aa0e5948c84c32f1391dcd0756c1a1e0"/><file name="r3-jeans-1.jpg" hash="2b0dd77b6fe04cd86d39159f5509a31b"/><file name="saw2w12w.jpg" hash="d5ae4e36ed288f803ee5bd8d980df1a3"/><file name="secondww_lion.jpg" hash="1b23c13c6891937b32302f84d8dc6f63"/><file name="shaden-3final.jpg" hash="3f353029307a587c600f90d5e1089848"/><file name="we-12.jpg" hash="5a3d34f5e41b8805f758e3b9db8a888a"/><file name="web-11-a.jpg" hash="77810c7e72f84860aaa4e8972ca5149e"/><file name="womens-offer-new.jpg" hash="0814e516f0fc998db925fe2ec5026173"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>kush_reviewimage</name><channel>community</channel><min>1.0.0</min><max>8.0.0</max></package></required></dependencies>
|
18 |
+
</package>
|