RateItCool_ProductReviews - Version 1.0.0

Version Notes

Integration in all product lists

Download this release

Release Info

Developer Thomas Gravel
Extension RateItCool_ProductReviews
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/RateItCool/ProductReviews/Block/Helper.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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@magento.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.magento.com for more information.
20
+ *
21
+ * @category RateItCool
22
+ * @package RateItCool_ProductReviews
23
+ * @author Cool Services GbR <thomas.gravel@rateit.cool>
24
+ * @copyright Copyright (c) 2015 Cool Services GbR (https://www.rateit.cool)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ /**
29
+ * Product Reviews helper
30
+ *
31
+ * @category RateItCool
32
+ * @package RateItCool_ProductReviews
33
+ * @author Cool Services GbR <thomas.gravel@rateit.cool>
34
+ */
35
+ class RateItCool_ProductReviews_Block_Helper extends Mage_Core_Block_Template
36
+ {
37
+ protected $_availableTemplates = array(
38
+ 'default' => 'productreviews/helper/summary.phtml',
39
+ 'short' => 'productreviews/helper/summary_short.phtml'
40
+ );
41
+
42
+ protected $_apiUserName = 'demo';
43
+ protected $_apiKey = 'password';
44
+
45
+ public function __construct()
46
+ {
47
+ $this->_apiUserName = Mage::getStoreConfig('catalog/RateItCool_ProductReviews/api_user');
48
+ $this->_apiKey = Mage::getStoreConfig('catalog/RateItCool_ProductReviews/api_key');
49
+ parent::__construct();
50
+ }
51
+
52
+ public function getSummaryHtml($product, $templateType, $displayIfNoReviews)
53
+ {
54
+ // pick template among available
55
+ if (empty($this->_availableTemplates[$templateType])) {
56
+ $templateType = 'default';
57
+ }
58
+ $this->setTemplate($this->_availableTemplates[$templateType]);
59
+ $this->setProduct($product);
60
+
61
+ return $this->toHtml();
62
+ }
63
+
64
+ public function getGpnValue()
65
+ {
66
+ if ($this->getProduct()->getEan() != NULL) {
67
+ return $this->getProduct()->getEan();
68
+ } else if ($this->getProduct()->getSku() != NULL) {
69
+ return $this->getProduct()->getSku();
70
+ } else {
71
+ return $this->getProduct()->getId();
72
+ }
73
+ }
74
+
75
+ public function getGpnType()
76
+ {
77
+ if ($this->getProduct()->getEan() != NULL) {
78
+ return 'ean';
79
+ } else {
80
+ return $this->_apiUserName;
81
+ }
82
+ }
83
+
84
+ public function getReviewsUrl()
85
+ {
86
+ return Mage::getUrl('review/product/list', array(
87
+ 'id' => $this->getProduct()->getId(),
88
+ 'category' => $this->getProduct()->getCategoryId()
89
+ ));
90
+ }
91
+
92
+ /**
93
+ * Add an available template by type
94
+ *
95
+ * It should be called before getSummaryHtml()
96
+ *
97
+ * @param string $type
98
+ * @param string $template
99
+ */
100
+ public function addTemplate($type, $template)
101
+ {
102
+ Mage::Log('RateItCool addTemplate');
103
+ $this->_availableTemplates[$type] = $template;
104
+ }
105
+ }
app/code/community/RateItCool/ProductReviews/Block/Product/View.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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@magento.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.magento.com for more information.
20
+ *
21
+ * @category RateItCool
22
+ * @package RateItCool_ProductReviews
23
+ * @author Cool Services GbR <thomas.gravel@rateit.cool>
24
+ * @copyright Copyright (c) 2015 Cool Services GbR (https://www.rateit.cool)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ /**
29
+ * Product Reviews Page
30
+ *
31
+ * @category RateItCool
32
+ * @package RateItCool_ProductReviews
33
+ * @author Cool Services GbR <thomas.gravel@rateit.cool>
34
+ */
35
+ class RateItCool_ProductReviews_Block_Product_View extends Mage_Catalog_Block_Product_View
36
+ {
37
+ protected $_reviewsCollection;
38
+
39
+ /**
40
+ * Render block HTML
41
+ *
42
+ * @return string
43
+ */
44
+ protected function _toHtml()
45
+ {
46
+ $this->getProduct()->setShortDescription(null);
47
+
48
+ return parent::_toHtml();
49
+ }
50
+
51
+ /**
52
+ * Replace review summary html with more detailed review summary
53
+ * Reviews collection count will be jerked here
54
+ *
55
+ * @param Mage_Catalog_Model_Product $product
56
+ * @param string $templateType
57
+ * @param bool $displayIfNoReviews
58
+ * @return string
59
+ */
60
+ public function getReviewsSummaryHtml(Mage_Catalog_Model_Product $product, $templateType = false, $displayIfNoReviews = false)
61
+ {
62
+ return
63
+ $this->getLayout()->createBlock('rating/entity_detailed')
64
+ ->setEntityId($this->getProduct()->getId())
65
+ ->toHtml()
66
+ .
67
+ $this->getLayout()->getBlock('product_review_list.count')
68
+ ->assign('count', $this->getReviewsCollection()->getSize())
69
+ ->toHtml()
70
+ ;
71
+ }
72
+
73
+ public function getReviewsCollection()
74
+ {
75
+ if (null === $this->_reviewsCollection) {
76
+ $this->_reviewsCollection = Mage::getModel('review/review')->getCollection()
77
+ ->addStoreFilter(Mage::app()->getStore()->getId())
78
+ ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
79
+ ->addEntityFilter('product', $this->getProduct()->getId())
80
+ ->setDateOrder();
81
+ }
82
+ return $this->_reviewsCollection;
83
+ }
84
+
85
+ /**
86
+ * Force product view page behave like without options
87
+ *
88
+ * @return false
89
+ */
90
+ public function hasOptions()
91
+ {
92
+ return false;
93
+ }
94
+ }
app/code/community/RateItCool/ProductReviews/Block/Product/View/List.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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@magento.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.magento.com for more information.
20
+ *
21
+ * @category RateItCool
22
+ * @package RateItCool_ProductReviews
23
+ * @author Cool Services GbR <thomas.gravel@rateit.cool>
24
+ * @copyright Copyright (c) 2015 Cool Services GbR (https://www.rateit.cool)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ /**
29
+ * Detailed Product Reviews
30
+ *
31
+ * @category RateItCool
32
+ * @package RateItCool_ProductReviews
33
+ * @author Cool Services GbR <thomas.gravel@rateit.cool>
34
+ */
35
+ class RateItCool_ProductReviews_Block_Product_View_List extends Mage_Review_Block_Product_View
36
+ {
37
+ protected $_forceHasOptions = false;
38
+
39
+ public function getProductId()
40
+ {
41
+ return Mage::registry('product')->getId();
42
+ }
43
+
44
+ public function getGpnValue()
45
+ {
46
+ if (Mage::registry('product')->getEan() != NULL) {
47
+ return Mage::registry('product')->getEan();
48
+ } else if (Mage::registry('product')->getSku() != NULL) {
49
+ return Mage::registry('product')->getSku();
50
+ } else {
51
+ return Mage::registry('product')->getId();
52
+ }
53
+ }
54
+
55
+ public function getGpnType()
56
+ {
57
+ if (Mage::registry('product')->getEan() != NULL) {
58
+ return 'ean';
59
+ } else {
60
+ return $this->_apiUserName;
61
+ }
62
+ }
63
+
64
+ public function getReviewUrl($id)
65
+ {
66
+ return Mage::getUrl('review/product/view', array('id' => $id));
67
+ }
68
+ }
app/code/community/RateItCool/ProductReviews/Block/View.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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@magento.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.magento.com for more information.
20
+ *
21
+ * @category RateItCool
22
+ * @package RateItCool_ProductReviews
23
+ * @author Cool Services GbR <thomas.gravel@rateit.cool>
24
+ * @copyright Copyright (c) 2015 Cool Services GbR (https://www.rateit.cool)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ /**
29
+ * Review detailed view block
30
+ *
31
+ * @category RateItCool
32
+ * @package RateItCool_ProductReviews
33
+ * @author Cool Services GbR <thomas.gravel@rateit.cool>
34
+ */
35
+
36
+ class RateItCool_ProductReviews_Block_View extends Mage_Catalog_Block_Product_Abstract
37
+ {
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ $this->setTemplate('productreviews/view.phtml');
42
+ }
43
+
44
+ /**
45
+ * Retrieve current product model from registry
46
+ *
47
+ * @return Mage_Catalog_Model_Product
48
+ */
49
+ public function getProductData()
50
+ {
51
+ return Mage::registry('current_product');
52
+ }
53
+
54
+ /**
55
+ * Retrieve current review model from registry
56
+ *
57
+ * @return Mage_Review_Model_Review
58
+ */
59
+ public function getReviewData()
60
+ {
61
+ return Mage::registry('current_review');
62
+ }
63
+
64
+ /**
65
+ * Prepare link to review list for current product
66
+ *
67
+ * @return string
68
+ */
69
+ public function getBackUrl()
70
+ {
71
+ return Mage::getUrl('*/*/list', array('id' => $this->getProductData()->getId()));
72
+ }
73
+
74
+ /**
75
+ * Retrieve rating summary for current product
76
+ *
77
+ * @return string
78
+ */
79
+ public function getGpnType()
80
+ {
81
+ Mage::Log('getGpnType()');
82
+ Mage::Log(var_export($this->getProductData()->getEan(), true));
83
+ if( $this->getProductData()->getEan() != NULL ) {
84
+ return 'ean';
85
+ }
86
+ return '';
87
+ }
88
+
89
+ /**
90
+ * Retrieve rating summary for current product
91
+ *
92
+ * @return string
93
+ */
94
+ public function getGpnValue()
95
+ {
96
+ //Mage::Log(var_export($this->getProductData()->getEan()));
97
+ // return $this->getProductData()->getEan();
98
+ /*
99
+ if( !$this->getRatingSummaryCache() ) {
100
+ $this->setRatingSummaryCache(Mage::getModel('rating/rating')->getEntitySummary($this->getProductData()->getId()));
101
+ }
102
+ return $this->getRatingSummaryCache();
103
+ */
104
+ return '4711';
105
+ }
106
+
107
+ /**
108
+ * Retrieve total review count for current product
109
+ *
110
+ * @return string
111
+ */
112
+ public function getTotalReviews()
113
+ {
114
+ if( !$this->getTotalReviewsCache() ) {
115
+ $this->setTotalReviewsCache(Mage::getModel('review/review')->getTotalReviews($this->getProductData()->getId(), false, Mage::app()->getStore()->getId()));
116
+ }
117
+ return $this->getTotalReviewsCache();
118
+ }
119
+
120
+ /**
121
+ * Format date in long format
122
+ *
123
+ * @param string $date
124
+ * @return string
125
+ */
126
+ public function dateFormat($date)
127
+ {
128
+ return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_LONG);
129
+ }
130
+ }
app/code/community/RateItCool/ProductReviews/Helper/Data.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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@magento.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.magento.com for more information.
20
+ *
21
+ * @category RateItCool
22
+ * @package RateItCool_ProductReviews
23
+ * @author Cool Services GbR <thomas.gravel@rateit.cool>
24
+ * @copyright Copyright (c) 2015 Cool Services GbR (https://www.rateit.cool)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ /**
29
+ * Product Reviews helper
30
+ *
31
+ * @category RateItCool
32
+ * @package RateItCool_ProductReviews
33
+ * @author Cool Services GbR <thomas.gravel@rateit.cool>
34
+ */
35
+ class RateItCool_ProductReviews_Helper_Data extends Mage_Core_Helper_Abstract
36
+ {
37
+
38
+ }
app/code/community/RateItCool/ProductReviews/Model/Product.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-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@magento.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.magento.com for more information.
21
+ *
22
+ * @category RateItCool
23
+ * @package RateItCool_ProductReviews
24
+ * @author Cool Services GbR <thomas.gravel@rateit.cool>
25
+ * @copyright Copyright (c) 2015 Cool Services GbR (https://www.rateit.cool)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ */
28
+
29
+ /**
30
+ * Product Reviews Product Model rewrite
31
+ *
32
+ * @category RateItCool
33
+ * @package RateItCool_ProductReviews
34
+ * @author Cool Services GbR <thomas.gravel@rateit.cool>
35
+ */
36
+ class RateItCool_ProductReviews_Model_Product extends Mage_Catalog_Model_Product {
37
+
38
+ /**
39
+ * Returns rating summary (always return true)
40
+ *
41
+ * @return mixed
42
+ */
43
+ public function getRatingSummary()
44
+ {
45
+ return true;
46
+ }
47
+ }
app/code/community/RateItCool/ProductReviews/etc/config.xml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <!-- The root node for Magento module configuration -->
4
+ <config>
5
+ <modules>
6
+ <RateItCool_ProductReviews>
7
+ <version>0.0.1</version>
8
+ </RateItCool_ProductReviews>
9
+ </modules>
10
+ <global>
11
+ <models>
12
+ <catalog>
13
+ <rewrite>
14
+ <product>RateItCool_ProductReviews_Model_Product</product>
15
+ </rewrite>
16
+ </catalog>
17
+ </models>
18
+ <resources>
19
+ <review_setup>
20
+ <setup>
21
+ <module>RateItCool_ProductReviews</module>
22
+ </setup>
23
+ </review_setup>
24
+ </resources>
25
+ <blocks>
26
+ <review>
27
+ <class>RateItCool_ProductReviews_Block</class>
28
+ </review>
29
+ </blocks>
30
+ <helpers>
31
+ <RateItCool_ProductReviews>
32
+ <class>RateItCool_ProductReviews_Helper</class>
33
+ </RateItCool_ProductReviews>
34
+ </helpers>
35
+ </global>
36
+ <frontend>
37
+ <layout>
38
+ <updates>
39
+ <RateItCool_ProductReviews module="RateItCool_ProductReviews">
40
+ <file>productreviews.xml</file>
41
+ </RateItCool_ProductReviews>
42
+ </updates>
43
+ </layout>
44
+ <routers>
45
+ <review>
46
+ <use>standard</use>
47
+ <args>
48
+ <module>RateItCool_ProductReviews</module>
49
+ <frontName>review</frontName>
50
+ </args>
51
+ </review>
52
+ </routers>
53
+ </frontend>
54
+ <default>
55
+ <catalog>
56
+ <RateItCool_ProductReviews>
57
+ <api_user>demo</api_user>
58
+ <api_key>password</api_key>
59
+ </RateItCool_ProductReviews>
60
+ </catalog>
61
+ </default>
62
+ </config>
app/code/community/RateItCool/ProductReviews/etc/system.xml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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@magento.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.magento.com for more information.
21
+ *
22
+ * @category Mage
23
+ * @package Mage_Review
24
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+ -->
28
+ <config>
29
+ <sections>
30
+ <catalog>
31
+ <groups>
32
+ <RateItCool_ProductReviews translate="label" module="RateItCool_ProductReviews">
33
+ <label>Product Reviews from rateit.cool</label>
34
+ <frontend_type>text</frontend_type>
35
+ <sort_order>100</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>0</show_in_store>
39
+ <fields>
40
+ <api_user translate="label">
41
+ <label>API User</label>
42
+ <frontend_type>text</frontend_type>
43
+ <sort_order>1</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ </api_user>
48
+ <api_key translate="label">
49
+ <label>API Key</label>
50
+ <frontend_type>text</frontend_type>
51
+ <sort_order>2</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ </api_key>
56
+ </fields>
57
+ </RateItCool_ProductReviews>
58
+ </groups>
59
+ </catalog>
60
+ </sections>
61
+ </config>
app/design/frontend/base/default/template/productreviews/helper/summary.phtml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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@magento.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.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div class="ratings rate-it-cool-product-detail" data-gpnvalue="<?php echo $this->getGpnValue(); ?>" data-gpntype="<?php echo $this->getGpnType(); ?>">
28
+ <div class="rating-box">
29
+ <div class="rating rate-it-cool-review-summary-empty rate-it-cool-review-summary" style=""></div>
30
+ </div>
31
+ <div class="ratingCount">(<span class="rate-it-cool-review-counts">0</span>)</div>
32
+ <!--
33
+ <p class="rating-links rateit-cool-review-link" style="display:none;">
34
+ <a href="<?php echo $this->getReviewsUrl() ?>"><?php echo $this->__('ShowReviews') ?></a>
35
+ </p>
36
+ -->
37
+ </div>
app/design/frontend/base/default/template/productreviews/helper/summary_short.phtml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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@magento.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.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div class="ratings rate-it-cool-product" data-gpnvalue="<?php echo $this->getGpnValue(); ?>" data-gpntype="<?php echo $this->getGpnType(); ?>">
28
+ <div class="rating-box">
29
+ <div class="rating rate-it-cool-review-summary-empty rate-it-cool-review-summary" style=""></div>
30
+ </div>
31
+ </div>
app/design/frontend/base/default/template/productreviews/javascript.phtml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ ?>
4
+ <script>
5
+ RateItCoolAPI.init({
6
+ username: '<?php echo Mage::getStoreConfig('catalog/RateItCool_ProductReviews/api_user'); ?>',
7
+ password: '<?php echo Mage::getStoreConfig('catalog/RateItCool_ProductReviews/api_key'); ?>',
8
+ limit: '3',
9
+ noConflict: false
10
+ });
11
+ </script>
app/design/frontend/base/default/template/productreviews/metatag.phtml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+
3
+ ?>
4
+ <meta name="rateit-cool-site-verification" content="<?php echo Mage::getStoreConfig('catalog/RateItCool_ProductReviews/api_key'); ?>" />
app/design/frontend/base/default/template/productreviews/product/view/list.phtml ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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@magento.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.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+
28
+ <div class="box-collateral box-reviews rate-it-cool-product-feedbacks"
29
+ data-gpntype="<?php echo $this->getGpnType(); ?>"
30
+ data-gpnvalue="<?php echo $this->getGpnValue(); ?>"
31
+ data-language="<?php echo Mage::app()->getLocale()->getLocaleCode(); ?>"
32
+ data-count=""
33
+ data-extraParameter="" id="customer-reviews">
34
+
35
+ </div>
36
+
37
+ <div id="rate-it-cool-product-feedbacks-template" style="display:none;">
38
+ <div class="feedbackElements">
39
+ <div class="overview">
40
+ <?php echo $this->__('Reviews'); ?>
41
+ <table class="feedbackOverview">
42
+ <tr>
43
+ <td class="ratings">
44
+ <div class="rating-box">
45
+ <div class="rating" style="width:100%;"></div>
46
+ </div>
47
+ </td>
48
+ <td class="count">
49
+ <a class="showOnlyStars" data-stars="5" href="#" title="<?php echo $this->__('Show only reviews with 5 stars'); ?>">
50
+ $five
51
+ </a>
52
+ </td>
53
+ </tr>
54
+ <tr>
55
+ <td class="ratings">
56
+ <div class="rating-box">
57
+ <div class="rating" style="width:80%;"></div>
58
+ </div>
59
+ </td>
60
+ <td class="count">
61
+ <a class="showOnlyStars" data-stars="4" href="#" title="<?php echo $this->__('Show only reviews with 4 stars'); ?>">
62
+ $four
63
+ </a>
64
+ </td>
65
+ </tr>
66
+ <tr>
67
+ <td class="ratings">
68
+ <div class="rating-box">
69
+ <div class="rating" style="width:60%;"></div>
70
+ </div>
71
+ </td>
72
+ <td class="count">
73
+ <a class="showOnlyStars" data-stars="3" href="#" title="<?php echo $this->__('Show only reviews with 3 stars'); ?>">
74
+ $three
75
+ </a>
76
+ </td>
77
+ </tr>
78
+ <tr>
79
+ <td class="ratings">
80
+ <div class="rating-box">
81
+ <div class="rating" style="width:40%;"></div>
82
+ </div>
83
+ </td>
84
+ <td class="count">
85
+ <a class="showOnlyStars" data-stars="2" href="#" title="<?php echo $this->__('Show only reviews with 2 stars'); ?>">
86
+ $two
87
+ </a>
88
+ </td>
89
+ </tr>
90
+ <tr>
91
+ <td class="ratings">
92
+ <div class="rating-box">
93
+ <div class="rating" style="width:20%;"></div>
94
+ </div>
95
+ </td>
96
+ <td class="count">
97
+ <a class="showOnlyStars" data-stars="1" href="#" title="<?php echo $this->__('Show only reviews with 1 stars'); ?>">
98
+ $one
99
+ </a>
100
+ </td>
101
+ </tr>
102
+ </table>
103
+ </div>
104
+ <div class="recommend">
105
+ <?php echo $this->__('Customer recommended this product'); ?>: $recommend%
106
+ <span style="float:right;">
107
+ <select data-extraParameter="" name="reorderReviews">
108
+ <option value="time;desc"><?php echo $this->__('Show the latest reviews first'); ?></option>
109
+ <option value="time;asc"><?php echo $this->__('Show the oldest reviews first'); ?></option>
110
+ <option value="stars;desc"><?php echo $this->__('Show best reviews first'); ?></option>
111
+ <option value="stars;asc"><?php echo $this->__('Show the worst reviews first'); ?></option>
112
+ <option value="helpful;desc"><?php echo $this->__('Show the best helpful reviews first'); ?></option>
113
+ <option value="helpful;asc"><?php echo $this->__('Show the worst helpful reviews first'); ?></option>
114
+ </select>
115
+ </span>
116
+ </div>
117
+ <dl class="list">
118
+ $list
119
+ </dl>
120
+ <div class="showmoreContainer">
121
+ <div class="showmore" style="display: $showNewtLink;">
122
+ <a href="#" class="showMoreFeedbacks" data-extraParameter="" data-count="$count" data-language="$language" data-gpntype="$gpntype" data-gpnvalue="$gpnvalue"><?php echo $this->__('Show more reviews...'); ?></a>
123
+ </div>
124
+ </div>
125
+ </div>
126
+
127
+ <dl class="feedbackElement" style="display:none;">
128
+ <dt>
129
+ <div class="ratings">
130
+ <div class="rating-box">
131
+ <div class="rating" style="width:$review.stars%;"></div>
132
+ </div>
133
+ </div>
134
+ <span class="date">($review.time)</span>
135
+ <h3>$review.title</h3>
136
+
137
+ </dt>
138
+ <dd>
139
+ $review.content
140
+ <div class="helpful">
141
+ <?php echo $this->__('Is the review helpful for you?'); ?>
142
+ <span class="positive" data-positive="$review.positive" data-language="$review.language" data-gpntype="$review.gpntype" data-gpnvalue="$review.gpnvalue" data-feedbackid="$review.id">
143
+ <?php echo $this->__('Yes'); ?> (<span class="positiveValue">$review.positive</span>)
144
+ </span> |
145
+ <span class="negative" data-negative="$review.negative" data-language="$review.language" data-gpntype="$review.gpntype" data-gpnvalue="$review.gpnvalue" data-feedbackid="$review.id">
146
+ <?php echo $this->__('No'); ?> (<span class="negativeValue">$review.negative</span>)
147
+ </span>
148
+ </p>
149
+ <p class="incorrect">
150
+ <?php echo $this->__('Feedback %s report %s','<span class="report" data-language="$review.language" data-gpntype="$review.gpntype" data-gpnvalue="$review.gpnvalue" data-feedbackid="$review.id">','</span>'); ?>
151
+ </p>
152
+
153
+ </dd>
154
+ </dl>
155
+
156
+ </div>
app/design/frontend/base/default/template/productreviews/view.phtml ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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@magento.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.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <pre>DEFAULT productreviews->view.phtml</pre>
28
+ <?php if($this->getProductData()->getId()): ?>
29
+ <div class="product-review">
30
+ <div class="page-title">
31
+ <h1><?php echo $this->__('Review Details') ?></h1>
32
+ </div>
33
+ <div class="product-img-box">
34
+ <a href="<?php echo $this->getProductData()->getProductUrl() ?>" title="<?php echo $this->escapeHtml($this->getProductData()->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($this->getProductData(), 'small_image')->resize(125, 125); ?>" height="125" width="125" alt="<?php echo $this->escapeHtml($this->getProductData()->getName()) ?>" /></a>
35
+ <?php if( $this->getRating() && $this->getRating()->getSize()): ?>
36
+ <p class="label"><?php echo $this->__('Average Customer Rating') ?>:</p>
37
+ <?php echo $this->getReviewsSummaryHtml($this->getProductData()) ?>
38
+ <?php endif; ?>
39
+ </div>
40
+ <div class="product-details">
41
+ <h2 class="product-name"><?php echo $this->escapeHtml($this->getProductData()->getName()) ?></h2>
42
+ <?php if( $this->getRating() && $this->getRating()->getSize()): ?>
43
+ <h3><?php echo $this->__('Product Rating:') ?></h3>
44
+ <table class="ratings-table">
45
+ <?php foreach ($this->getRating() as $_rating): ?>
46
+ <?php if($_rating->getPercent()): ?>
47
+ <tr>
48
+ <th><?php echo $this->__($this->escapeHtml($_rating->getRatingCode())) ?></th>
49
+ <td>
50
+ <div class="rating-box">
51
+ <div class="rating" style="width:<?php echo ceil($_rating->getPercent()) ?>%;"></div>
52
+ </div>
53
+ </td>
54
+ </tr>
55
+ <?php endif; ?>
56
+ <?php endforeach; ?>
57
+ </table>
58
+ </dl>
59
+ <?php endif; ?>
60
+ <dl>
61
+ <dt>
62
+ <?php echo $this->__('Product Review (submitted on %s):', $this->dateFormat($this->getReviewData()->getCreatedAt())) ?>
63
+ </dt>
64
+ <dd>
65
+ <?php echo nl2br($this->escapeHtml($this->getReviewData()->getDetail())) ?>
66
+ </dd>
67
+ </dl>
68
+ </div>
69
+ <div class="buttons-set">
70
+ <p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->__('Back to Product Reviews') ?></a></p>
71
+ </div>
72
+ </div>
73
+ <?php endif; ?>
app/etc/modules/RateItCool_ProductReviews.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-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
+ * @category RateItCool
17
+ * @package RateItCool_ProductReviews
18
+ * @copyright Copyright (c) 2015 Cool Services GbR (http://www.rateit.cool)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ -->
22
+ <config>
23
+ <modules>
24
+ <RateItCool_ProductReviews>
25
+ <active>true</active>
26
+ <codePool>community</codePool>
27
+ </RateItCool_ProductReviews>
28
+ </modules>
29
+ </config>
app/locale/en_US/RateItCool_ProductReviews.csv ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Reviews","Reviews"
2
+ "Show only reviews with 5 stars","Show only reviews with 5 stars"
3
+ "Show only reviews with 4 stars","Show only reviews with 4 stars"
4
+ "Show only reviews with 3 stars","Show only reviews with 3 stars"
5
+ "Show only reviews with 2 stars","Show only reviews with 2 stars"
6
+ "Show only reviews with 1 star","Show only reviews with 1 star"
7
+ "Customer recommended this product","Customer recommended this product"
8
+ "Show the latest reviews first","Show the latest reviews first"
9
+ "Show the oldest reviews first","Show the oldest reviews first"
10
+ "Show best reviews first","Show best reviews first"
11
+ "Show the worst reviews first","Show the worst reviews first"
12
+ "Show the best helpful reviews first","Show the best helpful reviews first"
13
+ "Show the worst helpful reviews first","Show the worst helpful reviews first"
14
+ "Show more reviews...","Show more reviews..."
15
+ "Is the review helpful for you?","Is the review helpful for you?"
16
+ "Report review?","Report review?"
17
+ "Yes","Yes"
18
+ "No","No"
19
+ "Feedback %s report %s","Feedback %s report %s"
20
+ "ShowReviews","ShowReviews"
js/rateitcool/rateit.cool.js ADDED
@@ -0,0 +1,610 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ var RateItCoolAPI = (function($){
3
+ var _username = 'demo',
4
+ _password = 'password',
5
+ _version = '1.0.0',
6
+ _limit = 3,
7
+ _jQuery = $,
8
+ _oldjQuery = $;
9
+
10
+ var _ratingsProductList = function () {
11
+ var productlistSpans = _jQuery('.rate-it-cool-product');
12
+ if (productlistSpans && productlistSpans.length > 0) {
13
+
14
+ var gpntype = '',
15
+ gpnvalues = {},
16
+ gpnvalue = '',
17
+ error = true;
18
+ for ( var i = 0; i < productlistSpans.length; i++ ) {
19
+ if (_jQuery(productlistSpans[ i ]).attr('data-gpntype') !== undefined) {
20
+ gpntype = _jQuery(productlistSpans[ i ]).attr('data-gpntype');
21
+ }
22
+ if (_jQuery(productlistSpans[ i ]).attr('data-gpnvalue') !== undefined) {
23
+ gpnvalue = _jQuery(productlistSpans[ i ]).attr('data-gpnvalue');
24
+ if (gpnvalue.length > 0) {
25
+ if (gpnvalues[gpntype] == undefined) {
26
+ gpnvalues[gpntype] = [];
27
+ }
28
+ gpnvalues[gpntype].push( gpnvalue );
29
+ error = false;
30
+ }
31
+ }
32
+ }
33
+ if (!error) {
34
+ _jQuery.each(gpnvalues, function(gpntype, values) {
35
+ if (values.length > 0) {
36
+ _jQuery.ajax({
37
+ //url : 'https://api.rateit.cool/stars/' + gpntype + '/' + gpnvalues.join(','),
38
+ url : 'http://localhost:8080/stars/' + gpntype + '/' + values.join(','),
39
+ method: 'GET',
40
+ dataType : 'json',
41
+ crossDomain: true,
42
+ async: false,
43
+ beforeSend: function(xhr) {
44
+ xhr.setRequestHeader("Authorization", "Basic " + btoa(_username + ":" + _password));
45
+ xhr.setRequestHeader("X-Api-Version", _version);
46
+ },
47
+ success : function(data) {
48
+ if (data.length > 0) {
49
+ data.forEach(function(oneRatingResponse) {
50
+ var destinationElement = _jQuery('.rate-it-cool-product[data-gpnvalue=' + oneRatingResponse.gpnvalue + ']');
51
+ destinationElement.find('.rate-it-cool-review-counts').text(oneRatingResponse.total);
52
+ destinationElement.find('.rate-it-cool-review-summary').removeClass('rate-it-cool-review-summary-empty').attr('style','width: ' + Number((oneRatingResponse.summary * 20).toFixed(0)) + '%;');
53
+ destinationElement.find('.rateit-cool-review-link').show();
54
+ });
55
+ }
56
+ }
57
+ });
58
+ }
59
+ });
60
+ }
61
+ }
62
+ };
63
+
64
+ var _ratingsProductDetail = function () {
65
+
66
+ var productlistSpans = _jQuery('.rate-it-cool-product-detail'),
67
+ gpntype = '',
68
+ gpnvalue = '';
69
+
70
+ if (productlistSpans && productlistSpans.length > 0) {
71
+
72
+ if (_jQuery(productlistSpans[0]).attr('data-gpntype') !== undefined) {
73
+ gpntype = _jQuery(productlistSpans[0]).attr('data-gpntype');
74
+ }
75
+ if (_jQuery(productlistSpans[0]).attr('data-gpnvalue') !== undefined) {
76
+ gpnvalue = _jQuery(productlistSpans[0]).attr('data-gpnvalue');
77
+ }
78
+ var destinationElement = _jQuery(productlistSpans[0]);
79
+ if (gpntype && gpnvalue) {
80
+ _jQuery.ajax({
81
+ // url : 'https://api.rateit.cool/stars/' + gpntype + '/' + gpnvalue,
82
+ url : 'http://localhost:8080/stars/' + gpntype + '/' + gpnvalue,
83
+ method: 'GET',
84
+ dataType : 'json',
85
+ crossDomain: true,
86
+ async: false,
87
+ beforeSend: function(xhr) {
88
+ xhr.setRequestHeader("Authorization", "Basic " + btoa(_username + ":" + _password));
89
+ xhr.setRequestHeader("X-Api-Version", _version);
90
+ },
91
+ success : function(data) {
92
+ if (data.length > 0) {
93
+ var oneRatingResponse = data[0];
94
+ destinationElement.find('.rate-it-cool-review-counts').text(oneRatingResponse.total);
95
+ destinationElement.find('.rate-it-cool-review-summary').removeClass('rate-it-cool-review-summary-empty').attr('style','width: ' + Number((oneRatingResponse.summary * 20).toFixed(0)) + '%;');
96
+ destinationElement.find('.rateit-cool-review-link').show();
97
+ }
98
+ }
99
+ });
100
+ }
101
+ }
102
+ };
103
+
104
+ var _ratingProductFeedbacks = function (productfeedbackSpans, parameters) {
105
+ var gpntype = '',
106
+ gpnvalue = '',
107
+ language = '',
108
+ templateOneFeedback = _jQuery('#rate-it-cool-product-feedbacks-template .feedbackElement').html(),
109
+ templateList = _jQuery('#rate-it-cool-product-feedbacks-template .feedbackElements').html();
110
+
111
+ if (productfeedbackSpans.length > 0) {
112
+ if (_jQuery(productfeedbackSpans[0]).attr('data-gpntype') !== undefined) {
113
+ gpntype = _jQuery(productfeedbackSpans[0]).attr('data-gpntype');
114
+ }
115
+ if (_jQuery(productfeedbackSpans[0]).attr('data-gpnvalue') !== undefined) {
116
+ gpnvalue = _jQuery(productfeedbackSpans[0]).attr('data-gpnvalue');
117
+ }
118
+ if (_jQuery(productfeedbackSpans[0]).attr('data-language') !== undefined) {
119
+ language = _jQuery(productfeedbackSpans[0]).attr('data-language');
120
+ }
121
+ var destinationElement = _jQuery(productfeedbackSpans[0]);
122
+ var extendedString = '';
123
+ if (parameters.sort !== undefined) {
124
+ extendedString += '&sort=' + parameters.sort;
125
+ }
126
+ if (parameters.sortField !== undefined) {
127
+ extendedString += '&sortField=' + parameters.sortField
128
+ }
129
+ if (gpntype && gpnvalue && language) {
130
+
131
+ _jQuery.ajax({
132
+ //url : 'https://api.rateit.cool/feedback/' + gpntype + '/' + gpnvalue + '/' + language + '?limit=' + _limit + '&full=true' + extendedString,
133
+ url : 'http://localhost:8080/feedback/' + gpntype + '/' + gpnvalue + '/' + language + '?limit=' + _limit + '&full=true' + extendedString,
134
+ method: 'GET',
135
+ dataType : 'json',
136
+ crossDomain: true,
137
+ async: false,
138
+ beforeSend: function(xhr) {
139
+ xhr.setRequestHeader("Authorization", "Basic " + btoa(_username + ":" + _password));
140
+ xhr.setRequestHeader("X-Api-Version", _version);
141
+ },
142
+ success : function(data) {
143
+ if (data.elements && data.elements.length > 0) {
144
+ var oneRatingResponse = data[0]
145
+ , feedbackElements = []
146
+ , counts = data.total.all;
147
+ if (data.language > 0) {
148
+ counts = data.language;
149
+ }
150
+ if (data.region > 0) {
151
+ counts = data.region;
152
+ }
153
+ templateList = templateList.replace('$five', data.overview.stars.five)
154
+ .replace('$four', data.overview.stars.four)
155
+ .replace('$three', data.overview.stars.three)
156
+ .replace('$two', data.overview.stars.two)
157
+ .replace('$one', data.overview.stars.one)
158
+ .replace('$total.all', data.total.all)
159
+ .replace('$total.language', data.total.language)
160
+ .replace('$total.region', data.total.region)
161
+ .replace('$count', data.elements.length)
162
+ .replace('$showNewtLink', (counts > data.elements.length?'block':'none'))
163
+ .split('$gpntype').join(data.gpntype)
164
+ .split('$gpnvalue').join(data.gpnvalue)
165
+ .split('$language').join(language)
166
+ .replace('$recommend', Number(((data.overview.recommend / data.overview.total) *100 ).toFixed(0))) ;
167
+ data.elements.forEach(function(feedback) {
168
+ // create elemnt from template
169
+ var oneFeedback = templateOneFeedback;
170
+ oneFeedback = oneFeedback.replace('$review.stars', (feedback.stars * 20))
171
+ .replace('$review.time', new Date(feedback.time).toLocaleString())
172
+ .replace('$review.title', feedback.title)
173
+ .replace('$review.content', feedback.content)
174
+ .split('$review.id').join(feedback._id)
175
+ .split('$review.gpntype').join(data.gpntype)
176
+ .split('$review.gpnvalue').join(data.gpnvalue)
177
+ .split('$review.language').join(feedback.language + '_' + feedback.region)
178
+ .split('$review.positive').join(feedback.positive)
179
+ .split('$review.negative').join(feedback.negative);
180
+
181
+ feedbackElements.push(oneFeedback);
182
+ });
183
+ destinationElement.html(templateList.replace('$list',feedbackElements.join('')));
184
+ }
185
+ }
186
+ });
187
+ }
188
+ }
189
+ };
190
+
191
+ var _ratingProductFeedbacksRefresh = function (productfeedbackSpans, parameters, callback) {
192
+ var gpntype = '',
193
+ gpnvalue = '',
194
+ language = '',
195
+ templateOneFeedback = _jQuery('#rate-it-cool-product-feedbacks-template .feedbackElement').html(),
196
+ templateList = _jQuery('#rate-it-cool-product-feedbacks-template .feedbackElements').html();
197
+
198
+ // delete template from page
199
+ //$('#rate-it-cool-product-feedbacks-template').remove();
200
+
201
+ if (productfeedbackSpans.length > 0) {
202
+ if (_jQuery(productfeedbackSpans[0]).attr('data-gpntype') !== undefined) {
203
+ gpntype = _jQuery(productfeedbackSpans[0]).attr('data-gpntype');
204
+ }
205
+ if (_jQuery(productfeedbackSpans[0]).attr('data-gpnvalue') !== undefined) {
206
+ gpnvalue = _jQuery(productfeedbackSpans[0]).attr('data-gpnvalue');
207
+ }
208
+ if (_jQuery(productfeedbackSpans[0]).attr('data-language') !== undefined) {
209
+ language = _jQuery(productfeedbackSpans[0]).attr('data-language');
210
+ }
211
+ var destinationElement = _jQuery(productfeedbackSpans[0]);
212
+ var extendedString = '';
213
+ if (parameters.sortField !== undefined && parameters.sort !== undefined) {
214
+ extendedString = parameters.extraParameter;
215
+ extendedString += '&sort=' + parameters.sort;
216
+ extendedString += '&sortField=' + parameters.sortField;
217
+ _jQuery('.showMoreFeedbacks').attr('data-extraParameter', extendedString);
218
+ } else if (parameters.stars !== undefined) {
219
+ extendedString += '&stars=' + parameters.stars;
220
+ _jQuery('.showMoreFeedbacks').attr('data-extraParameter', extendedString);
221
+ _jQuery('[name=reorderReviews]').attr('data-extraParameter', extendedString);
222
+ }
223
+
224
+ if (gpntype && gpnvalue && language) {
225
+
226
+ _jQuery.ajax({
227
+ //url : 'https://api.rateit.cool/feedback/' + gpntype + '/' + gpnvalue + '/' + language + '?limit=' + _limit + extendedString,
228
+ url : 'http://localhost:8080/feedback/' + gpntype + '/' + gpnvalue + '/' + language + '?limit=' + _limit + extendedString,
229
+ method: 'GET',
230
+ dataType : 'json',
231
+ crossDomain: true,
232
+ async: false,
233
+ beforeSend: function(xhr) {
234
+ xhr.setRequestHeader("Authorization", "Basic " + btoa(_username + ":" + _password));
235
+ xhr.setRequestHeader("X-Api-Version", _version);
236
+ },
237
+ success : function(data) {
238
+ var counts = data.total.all;
239
+ if (data.language > 0) {
240
+ counts = data.language;
241
+ }
242
+ if (data.region > 0) {
243
+ counts = data.region;
244
+ }
245
+ if (_limit >= counts) {
246
+ // disable next link
247
+ _jQuery('.showMoreFeedbacks').parent().hide();
248
+ } else {
249
+ // set skip count
250
+ _jQuery('.showMoreFeedbacks').parent().show();
251
+ _jQuery('.showMoreFeedbacks').attr('data-count', (_limit) );
252
+ }
253
+ if (data.elements && data.elements.length > 0) {
254
+
255
+ var feedbackElements = [];
256
+
257
+ data.elements.forEach(function(feedback) {
258
+ // create elemnt from template
259
+ var oneFeedback = templateOneFeedback;
260
+ oneFeedback = oneFeedback.replace('$review.stars', (feedback.stars * 20))
261
+ .replace('$review.time', new Date(feedback.time).toLocaleString())
262
+ .replace('$review.title', feedback.title)
263
+ .replace('$review.content', feedback.content)
264
+ .split('$review.id').join(feedback._id)
265
+ .split('$review.gpntype').join(data.gpntype)
266
+ .split('$review.gpnvalue').join(data.gpnvalue)
267
+ .split('$review.language').join(feedback.language + '_' + feedback.region)
268
+ .split('$review.positive').join(feedback.positive)
269
+ .split('$review.negative').join(feedback.negative);
270
+
271
+ feedbackElements.push(oneFeedback);
272
+ });
273
+ _jQuery('.rate-it-cool-product-feedbacks .list').html(feedbackElements.join(''));
274
+ callback();
275
+ }
276
+ }
277
+ });
278
+ }
279
+ }
280
+ };
281
+
282
+ var _registerClickFeedbackSend = function() {
283
+ _jQuery('.rateit-cool-send-feedback a').on('click', function(e){
284
+ e.preventDefault();
285
+ var gpntype = _jQuery('form[name=' + _jQuery(this).attr('data-formname') + ']').find('[name=gpntype]').val(),
286
+ gpnvalue = _jQuery('form[name=' + _jQuery(this).attr('data-formname') + ']').find('[name=gpnvalue]').val(),
287
+ language = _jQuery('form[name=' + _jQuery(this).attr('data-formname') + ']').find('[name=language]').val(),
288
+ feedbackElement = {
289
+ stars: parseInt(_jQuery('form[name=' + _jQuery(this).attr('data-formname') + ']').find('[name=stars]').val()),
290
+ title: _jQuery('form[name=' + _jQuery(this).attr('data-formname') + ']').find('[name=feedbackTitle]').val(),
291
+ content: _jQuery('form[name=' + _jQuery(this).attr('data-formname') + ']').find('[name=feedbackContent]').val(),
292
+ recommend: (_jQuery('form[name=' + _jQuery(this).attr('data-formname') + ']').find('[name=recommend]').is(':checked')?1:0)
293
+ },
294
+ destinationElement = _jQuery(this);
295
+
296
+ if (gpntype && gpnvalue && language && feedbackElement.title !== '' && feedbackElement.content !== '' && feedbackElement.stars > 0) {
297
+ _jQuery.ajax({
298
+ //url : 'https://api.rateit.cool/feedback/' + gpntype + '/' + gpnvalue + '/' + language,
299
+ url : 'http://localhost:8080/feedback/' + gpntype + '/' + gpnvalue + '/' + language,
300
+ method: 'POST',
301
+ data: JSON.stringify(feedbackElement),
302
+ dataType : 'json',
303
+ crossDomain: true,
304
+ async: false,
305
+ beforeSend: function(xhr) {
306
+ xhr.setRequestHeader("Authorization", "Basic " + btoa(_username + ":" + _password));
307
+ xhr.setRequestHeader("X-Api-Version", _version);
308
+ },
309
+ success: function(data) {
310
+ _jQuery('#' + destinationElement.attr('data-formname')).removeClass('error').addClass('success');
311
+ _jQuery('form[name=' + destinationElement.attr('data-formname') + ']').hide();
312
+ _jQuery('form[name=' + destinationElement.attr('data-formname') + ']').parent().find('.rateit-cool-send-feedback-error').hide();
313
+ _jQuery('form[name=' + destinationElement.attr('data-formname') + ']').parent().find('.rateit-cool-send-feedback-success').show();
314
+ },
315
+ error: function() {
316
+ _jQuery('#' + destinationElement.attr('data-formname')).removeClass('success').addClass('error');
317
+ _jQuery('form[name=' + destinationElement.attr('data-formname') + ']').parent().find('.rateit-cool-send-feedback-success').hide();
318
+ _jQuery('form[name=' + destinationElement.attr('data-formname') + ']').parent().find('.rateit-cool-send-feedback-error').show();
319
+ }
320
+ });
321
+ } else {
322
+ if (feedbackElement.title === '') {
323
+ _jQuery('#' + destinationElement.attr('data-formname')).find('[name=feedbackTitle]').addClass('missing-value');
324
+ }
325
+ if (feedbackElement.content === '') {
326
+ _jQuery('#' + destinationElement.attr('data-formname')).find('[name=feedbackContent]').addClass('missing-value');
327
+ }
328
+ if (feedbackElement.stars <= 0) {
329
+ _jQuery('#' + destinationElement.attr('data-formname')).find('.star').addClass('missing-value');
330
+ }
331
+ }
332
+ });
333
+ };
334
+
335
+ var _fillStarsOnClick = function() {
336
+ // fill stars on click
337
+ _jQuery('.reviewStars span.value1').on('click', function(e) {
338
+ e.preventDefault();
339
+ _jQuery(this).parent().find('.star2').removeClass('star2').addClass('star0');
340
+ _jQuery(this).removeClass('star0').addClass('star2');
341
+ _jQuery(this).parent().find('[name=stars]').val(1);
342
+ _jQuery(this).parent().find('.star-text').html(_jQuery(this).attr('title'));
343
+ });
344
+
345
+ _jQuery('.reviewStars span.value2').on('click', function(e) {
346
+ e.preventDefault();
347
+ _jQuery(this).parent().find('.star2').removeClass('star2').addClass('star0');
348
+ _jQuery(this).parent().find('.value1').removeClass('star0').addClass('star2');
349
+ _jQuery(this).removeClass('star0').addClass('star2');
350
+ _jQuery(this).parent().find('[name=stars]').val(2);
351
+ _jQuery(this).parent().find('.star-text').html(_jQuery(this).attr('title'));
352
+ });
353
+
354
+ _jQuery('.reviewStars span.value3').on('click', function(e) {
355
+ e.preventDefault();
356
+ _jQuery(this).parent().find('.star2').removeClass('star2').addClass('star0');
357
+ _jQuery(this).parent().find('.value1').removeClass('star0').addClass('star2');
358
+ _jQuery(this).parent().find('.value2').removeClass('star0').addClass('star2');
359
+ _jQuery(this).removeClass('star0').addClass('star2');
360
+ _jQuery(this).parent().find('[name=stars]').val(3);
361
+ _jQuery(this).parent().find('.star-text').html(_jQuery(this).attr('title'));
362
+ });
363
+
364
+ _jQuery('.reviewStars span.value4').on('click', function(e) {
365
+ e.preventDefault();
366
+ _jQuery(this).parent().find('.star2').removeClass('star2').addClass('star0');
367
+ _jQuery(this).parent().find('.value1').removeClass('star0').addClass('star2');
368
+ _jQuery(this).parent().find('.value2').removeClass('star0').addClass('star2');
369
+ _jQuery(this).parent().find('.value3').removeClass('star0').addClass('star2');
370
+ _jQuery(this).removeClass('star0').addClass('star2');
371
+ _jQuery(this).parent().find('[name=stars]').val(4);
372
+ _jQuery(this).parent().find('.star-text').html(_jQuery(this).attr('title'));
373
+ });
374
+
375
+ _jQuery('.reviewStars span.value5').on('click', function(e) {
376
+ e.preventDefault();
377
+ _jQuery(this).parent().find('.star2').removeClass('star2').addClass('star0');
378
+ _jQuery(this).parent().find('.value1').removeClass('star0').addClass('star2');
379
+ _jQuery(this).parent().find('.value2').removeClass('star0').addClass('star2');
380
+ _jQuery(this).parent().find('.value3').removeClass('star0').addClass('star2');
381
+ _jQuery(this).parent().find('.value4').removeClass('star0').addClass('star2');
382
+ _jQuery(this).removeClass('star0').addClass('star2');
383
+ _jQuery(this).parent().find('[name=stars]').val(5);
384
+ _jQuery(this).parent().find('.star-text').html(_jQuery(this).attr('title'));
385
+ });
386
+ // fill stars on click end
387
+ };
388
+
389
+ var _sendHelpfulOnClick = function () {
390
+ _jQuery('.helpful').delegate('.positive', 'click', function(e) {
391
+ e.preventDefault();
392
+ var feedbackId = _jQuery(this).attr('data-feedbackid'),
393
+ gpntype = _jQuery(this).attr('data-gpntype'),
394
+ gpnvalue = _jQuery(this).attr('data-gpnvalue'),
395
+ language = _jQuery(this).attr('data-language'),
396
+ positive = parseInt(_jQuery(this).attr('data-positive')),
397
+ destinationElement = _jQuery(this).find('.positiveValue'),
398
+ thisElement = _jQuery(this);
399
+ if (feedbackId && gpntype && gpnvalue && language) {
400
+ thisElement.attr('data-positive', (positive+1));
401
+ _jQuery(destinationElement).html(positive+1);
402
+ _jQuery.ajax({
403
+ //url : 'https://api.rateit.cool/feedback/' + gpntype + '/' + gpnvalue + '/' + language + '?helpful=positive&id='+feedbackId,
404
+ url : 'http://localhost:8080/feedback/' + gpntype + '/' + gpnvalue + '/' + language + '?helpful=positive&id='+feedbackId,
405
+ method: 'PUT',
406
+ dataType : 'json',
407
+ crossDomain: true,
408
+ async: false,
409
+ beforeSend: function(xhr) {
410
+ xhr.setRequestHeader("Authorization", "Basic " + btoa(_username + ":" + _password));
411
+ xhr.setRequestHeader("X-Api-Version", _version);
412
+ },
413
+ success : function(data) {
414
+ thisElement.attr('data-positive', (positive+1));
415
+ _jQuery(destinationElement).html(positive+1);
416
+ }
417
+ });
418
+ }
419
+ });
420
+ };
421
+
422
+ var _sendIncorrectOnClick = function () {
423
+ _jQuery('.incorrect').delegate('.incorrect', 'click', function(e) {
424
+ e.preventDefault();
425
+ var feedbackId = _jQuery(this).attr('data-feedbackid'),
426
+ gpntype = _jQuery(this).attr('data-gpntype'),
427
+ gpnvalue = _jQuery(this).attr('data-gpnvalue'),
428
+ language = _jQuery(this).attr('data-language'),
429
+ thisElement = _jQuery(this);
430
+
431
+ if (feedbackId && gpntype && gpnvalue && language) {
432
+ _jQuery.ajax({
433
+ //url : 'https://api.rateit.cool/feedback/' + gpntype + '/' + gpnvalue + '/' + language + '?incorrect=1&id='+feedbackId,
434
+ url : 'http://localhost:8080/feedback/' + gpntype + '/' + gpnvalue + '/' + language + '?incorrect=1&id='+feedbackId,
435
+ method: 'PUT',
436
+ dataType : 'json',
437
+ crossDomain: true,
438
+ async: false,
439
+ beforeSend: function(xhr) {
440
+ xhr.setRequestHeader("Authorization", "Basic " + btoa(_username + ":" + _password));
441
+ xhr.setRequestHeader("X-Api-Version", _version);
442
+ },
443
+ success : function(data) {
444
+ }
445
+ });
446
+ }
447
+ });
448
+ };
449
+
450
+ var _sendNotHelpfulOnClick = function() {
451
+ _jQuery('.helpful').delegate('.negative', 'click', function(e) {
452
+ e.preventDefault();
453
+ var feedbackId = _jQuery(this).attr('data-feedbackid'),
454
+ gpntype = _jQuery(this).attr('data-gpntype'),
455
+ gpnvalue = _jQuery(this).attr('data-gpnvalue'),
456
+ language = _jQuery(this).attr('data-language'),
457
+ negative = parseInt(_jQuery(this).attr('data-negative')),
458
+ destinationElement = _jQuery(this).find('.negativeValue'),
459
+ thisElement = _jQuery(this);
460
+
461
+ thisElement.attr('data-negative', (negative+1));
462
+ _jQuery(destinationElement).html(negative+1);
463
+
464
+ if (feedbackId && gpntype && gpnvalue && language) {
465
+ _jQuery.ajax({
466
+ //url : 'https://api.rateit.cool/feedback/' + gpntype + '/' + gpnvalue + '/' + language + '?helpful=negative&id='+feedbackId,
467
+ url : 'http://localhost:8080/feedback/' + gpntype + '/' + gpnvalue + '/' + language + '?helpful=negative&id='+feedbackId,
468
+ method: 'PUT',
469
+ dataType : 'json',
470
+ crossDomain: true,
471
+ async: false,
472
+ beforeSend: function(xhr) {
473
+ xhr.setRequestHeader("Authorization", "Basic " + btoa(_username + ":" + _password));
474
+ xhr.setRequestHeader("X-Api-Version", _version);
475
+ },
476
+ success : function(data) {
477
+ }
478
+ });
479
+ }
480
+ });
481
+ };
482
+
483
+ var _reorderAfterChangeOrder = function () {
484
+ _jQuery('select[name=reorderReviews]').on('change', function(e) {
485
+ var sortFieldValue = _jQuery(this).val(),
486
+ sortFieldSortArray = _jQuery(this).val().split(';'),
487
+ sortField = sortFieldSortArray[0],
488
+ sort = sortFieldSortArray[1],
489
+ extraParameter = _jQuery(this).attr('data-extraParameter'),
490
+ optionText = _jQuery('.rate-it-cool-product-feedbacks select[name=reorderReviews] option[value="' + sortFieldValue + '"]').text();
491
+
492
+ _ratingProductFeedbacksRefresh(_jQuery('.rate-it-cool-product-feedbacks'),
493
+ {sortField: sortField, sort: sort, extraParameter: extraParameter},
494
+ function() {
495
+ _jQuery('.rate-it-cool-product-feedbacks select[name=reorderReviews]').parent().find('.js--fancy-select-text').text(optionText);
496
+ }
497
+ );
498
+ });
499
+ };
500
+
501
+ var _showFeedbacksWithStarsOnClick = function() {
502
+ _jQuery('a.showOnlyStars').on('click',function(e) {
503
+ e.preventDefault();
504
+ var stars = _jQuery(this).attr('data-stars');
505
+ _ratingProductFeedbacksRefresh(_jQuery('.rate-it-cool-product-feedbacks'), {stars: stars}, function() {
506
+
507
+ });
508
+ });
509
+ };
510
+
511
+ var _showMoreFeedbacksOnClick = function () {
512
+ _jQuery('.showMoreFeedbacks').on('click', function(e) {
513
+ e.preventDefault();
514
+ var gpntype = _jQuery(this).attr('data-gpntype'),
515
+ gpnvalue = _jQuery(this).attr('data-gpnvalue'),
516
+ language = _jQuery(this).attr('data-language'),
517
+ count = parseInt(_jQuery(this).attr('data-count')),
518
+ templateOneFeedback = _jQuery('#rate-it-cool-product-feedbacks-template .feedbackElement').html(),
519
+ extraParameter = _jQuery(this).attr('data-extraParameter'),
520
+ feedbackElements = [];
521
+ if (gpntype && gpnvalue && language && count && extraParameter != undefined) {
522
+ _jQuery.ajax({
523
+ //url : 'https://api.rateit.cool/feedback/' + gpntype + '/' + gpnvalue + '/' + language + '?limit=5&skip=' + count + extraParameter,
524
+ url : 'http://localhost:8080/feedback/' + gpntype + '/' + gpnvalue + '/' + language + '?limit=5&skip=' + count + extraParameter,
525
+ method: 'GET',
526
+ dataType : 'json',
527
+ crossDomain: true,
528
+ async: false,
529
+ beforeSend: function(xhr) {
530
+ xhr.setRequestHeader("Authorization", "Basic " + btoa(_username + ":" + _password));
531
+ xhr.setRequestHeader("X-Api-Version", _version);
532
+ },
533
+ success : function(data) {
534
+ var rescounts = data.total.all;
535
+ if (data.language > 0) {
536
+ rescounts = data.language;
537
+ }
538
+ if (data.region > 0) {
539
+ rescounts = data.region;
540
+ }
541
+ if ((count + data.elements.length) >= rescounts) {
542
+ // disable next link
543
+ _jQuery('.showMoreFeedbacks').parent().hide();
544
+ } else {
545
+ // set skip count
546
+ _jQuery('.showMoreFeedbacks').attr('data-count', (count + data.elements.length) );
547
+ }
548
+ if (data.elements && data.elements.length > 0) {
549
+ // render each feedback
550
+ data.elements.forEach(function(feedback) {
551
+ // create elemnt from template
552
+ var oneFeedback = templateOneFeedback;
553
+ oneFeedback = oneFeedback.replace('$review.stars', (feedback.stars * 20))
554
+ .replace('$review.time', new Date(feedback.time).toLocaleString())
555
+ .replace('$review.title', feedback.title)
556
+ .replace('$review.content', feedback.content)
557
+ .split('$review.id').join(feedback._id)
558
+ .split('$review.gpntype').join(data.gpntype)
559
+ .split('$review.gpnvalue').join(data.gpnvalue)
560
+ .split('$review.language').join(feedback.language + '_' + feedback.region)
561
+ .split('$review.positive').join(feedback.positive)
562
+ .split('$review.negative').join(feedback.negative);
563
+ _jQuery('.rate-it-cool-product-feedbacks .list').append(oneFeedback);
564
+ });
565
+ }
566
+ }
567
+ });
568
+ }
569
+
570
+ });
571
+ }
572
+
573
+ var _ready = function() {
574
+ // get ratings in a list
575
+ _ratingsProductList();
576
+ // get rating for detail page
577
+ _ratingsProductDetail();
578
+ // get the feedbacks
579
+ _ratingProductFeedbacks(_jQuery('.rate-it-cool-product-feedbacks'), {});
580
+
581
+ // onchange event
582
+ _reorderAfterChangeOrder();
583
+
584
+ // onclick events
585
+ _registerClickFeedbackSend();
586
+ _fillStarsOnClick();
587
+ _sendHelpfulOnClick();
588
+ _sendNotHelpfulOnClick();
589
+ _showFeedbacksWithStarsOnClick();
590
+ _showMoreFeedbacksOnClick();
591
+ _sendIncorrectOnClick();
592
+ }
593
+
594
+ return {
595
+ init: function(params) {
596
+ _username = params.username;
597
+ _password = params.password;
598
+ _limit = params.limit;
599
+ if (params.noConflict) {
600
+ _jQuery = jQuery.noConflict();
601
+ $ = _oldjQuery;
602
+ jQuery = $;
603
+ }
604
+ _jQuery(document).ready(function() {
605
+ _ready();
606
+ });
607
+ }
608
+ };
609
+
610
+ })(jQuery);
package.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>RateItCool_ProductReviews</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>MTL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>rateit.cool is a cloudbased service that allows all shops to collect &amp; use product reviews together.</summary>
10
+ <description>You have many products in your shop without any reviews? Get much more reviews with all other shops and show product reviews to all of your products. Create 200% more sales with product reviews and 65% more sales with many product reviews for each product. (Research from Big Social Media at 2014) &#xD;
11
+ &#xD;
12
+ Easy to use the rateit.cool service. You can get product reviews in 10 minutes without any IT project. Test the service and be impressed.&#xD;
13
+ &#xD;
14
+ Integrate the rateit.cool service at your homepage, your shop or app. Show the product reviews everywhere you want. &#xD;
15
+ &#xD;
16
+ You already have product reviews? No problem: You can upload these product reviews to rateit.cool.&#xD;
17
+ &#xD;
18
+ The plugin provides the stars per product&#xD;
19
+ - within the productlist&#xD;
20
+ - within the topseller&#xD;
21
+ - on the article detail view.&#xD;
22
+ &#xD;
23
+ Furthermore review texts are displayed on the article detail view. For the collection of product reviews a form is available in the order history. &#xD;
24
+ &#xD;
25
+ The service the plugin calls is settled on the number of service requests. This number corresponds to the page impressions in the shop for the list of products, the product detail page, and the pages with topseller integration.</description>
26
+ <notes>Integration in all product lists</notes>
27
+ <authors><author><name>Thomas Gravel</name><user>RateItCoolReviews</user><email>thomas.gravel@rateit.cool</email></author></authors>
28
+ <date>2015-09-03</date>
29
+ <time>13:03:41</time>
30
+ <contents><target name="magecommunity"><dir name="RateItCool"><dir name="ProductReviews"><dir name="Block"><file name="Helper.php" hash="abaf66ef406911a81901a518f96990f1"/><dir name="Product"><dir name="View"><file name="List.php" hash="17c1f9e6e6f79d40fdc14fd39b1d24d6"/></dir><file name="View.php" hash="f4dc4a5bcf0ad9ad91639e7181ed0f51"/></dir><file name="View.php" hash="b9f20349b9c0bf07534607b3e28b1020"/></dir><dir name="Helper"><file name="Data.php" hash="2a9f2f7a0eefb8c26c4c4ce3116879cf"/></dir><dir name="Model"><file name="Product.php" hash="618e195b5344dc8c687c8e493dc94634"/></dir><dir name="etc"><file name="config.xml" hash="243f94965b5a8eb808bf33f9137096ea"/><file name="system.xml" hash="f04c9a8051826fa1773a3c95a587bd4f"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="productreviews"><dir name="helper"><file name="summary.phtml" hash="bf986ff812fe27a2fe6d75a5d3921518"/><file name="summary_short.phtml" hash="b7cefced1edd907dbe062dea7b5fd727"/></dir><file name="javascript.phtml" hash="3d5a2736bd215769e6c47ff0557b4a44"/><file name="metatag.phtml" hash="8019fb54db1017b4e120423d548230bc"/><dir name="product"><dir name="view"><file name="list.phtml" hash="7dfb5ebad9c7819f025d7e2682d61eb6"/></dir></dir><file name="view.phtml" hash="4651fb9bf0f1bff168be7ce8d2b51ecb"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="RateItCool_ProductReviews.xml" hash="2de7f921ef87e18450027a5206d4ed93"/></dir></target><target name="magelocale"><dir name="en_US"><file name="RateItCool_ProductReviews.csv" hash="371a66e4c167ca1d4cee6d943fc02fa8"/></dir></target><target name="mageweb"><dir name="js"><dir name="rateitcool"><file name="rateit.cool.js" hash="dec05d9af1c9ed74ad4a7f967858271d"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="rateitcool"><file name="rateit.cool.css" hash="51aa8f6371c7c7c84fcb774497dc4715"/></dir></dir></dir></dir></target></contents>
31
+ <compatible/>
32
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
33
+ </package>
skin/frontend/base/default/rateitcool/rateit.cool.css ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .ratings .ratingCount {
2
+ float:left;
3
+ width:20px;
4
+ margin-top:5px;
5
+ }
6
+ .ratings .rating.rate-it-cool-review-summary-empty {
7
+ width:0%;
8
+ }
9
+ .feedbackOverview td.count {
10
+ padding-left: 5px;
11
+ }
12
+ .rate-it-cool-product-feedbacks .overview, .rate-it-cool-product-feedbacks .recommend {
13
+ margin: 10px 0;
14
+ padding-bottom: 10px;
15
+ border-bottom: solid 1px #ccc;
16
+ }
17
+ .rate-it-cool-product-feedbacks .list dd {
18
+ margin: 10px 0;
19
+ padding-bottom: 10px;
20
+ border-bottom: solid 1px #ccc;
21
+ }
22
+ .rate-it-cool-product-feedbacks .helpful {
23
+ margin-top: 10px;
24
+ }
25
+ .rate-it-cool-product-feedbacks .helpful .negative,
26
+ .rate-it-cool-product-feedbacks .helpful .positive,
27
+ .rate-it-cool-product-feedbacks .incorrect .report {
28
+ cursor: pointer;
29
+ color: #3399cc;
30
+ }
31
+ .rate-it-cool-product-feedbacks .showmore {
32
+ float:right;
33
+ padding: 5px 0;
34
+ }
35
+ .rate-it-cool-product-feedbacks .showmoreContainer {
36
+ padding: 5px 0;
37
+ }
38
+ .rate-it-cool-product-feedbacks .date {
39
+ float:right;
40
+ }