lipscore - Version 1.2.17

Version Notes

Minor fix: demo API key is checked considering current configuration scope.

Download this release

Release Info

Developer Henning Frettem
Extension lipscore
Version 1.2.17
Comparing to
See all releases


Version 1.2.17

Files changed (52) hide show
  1. app/code/community/Lipscore/RatingsReviews/Block/Catalog/Product/View.php +18 -0
  2. app/code/community/Lipscore/RatingsReviews/Block/Init.php +45 -0
  3. app/code/community/Lipscore/RatingsReviews/Block/Purchase/Abstract.php +30 -0
  4. app/code/community/Lipscore/RatingsReviews/Block/Purchase/Multishipping.php +49 -0
  5. app/code/community/Lipscore/RatingsReviews/Block/Purchase/Onepage.php +52 -0
  6. app/code/community/Lipscore/RatingsReviews/Block/Review/Helper.php +20 -0
  7. app/code/community/Lipscore/RatingsReviews/Block/Review/TabTitle.php +6 -0
  8. app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Coupons.php +26 -0
  9. app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Field/Abstract.php +31 -0
  10. app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Field/Apikey.php +25 -0
  11. app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Field/Reminderperiod.php +67 -0
  12. app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Fieldset/Coupons.php +11 -0
  13. app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Fieldset/Dashboardlink.php +9 -0
  14. app/code/community/Lipscore/RatingsReviews/Helper/Abstract.php +19 -0
  15. app/code/community/Lipscore/RatingsReviews/Helper/Config.php +12 -0
  16. app/code/community/Lipscore/RatingsReviews/Helper/Coupon.php +50 -0
  17. app/code/community/Lipscore/RatingsReviews/Helper/Data.php +3 -0
  18. app/code/community/Lipscore/RatingsReviews/Helper/Locale.php +44 -0
  19. app/code/community/Lipscore/RatingsReviews/Helper/Product.php +53 -0
  20. app/code/community/Lipscore/RatingsReviews/Helper/Purchase.php +49 -0
  21. app/code/community/Lipscore/RatingsReviews/Helper/Reminder.php +94 -0
  22. app/code/community/Lipscore/RatingsReviews/Logger.php +66 -0
  23. app/code/community/Lipscore/RatingsReviews/Model/Config.php +68 -0
  24. app/code/community/Lipscore/RatingsReviews/Model/Config/Env.php +49 -0
  25. app/code/community/Lipscore/RatingsReviews/Model/Coupon/Generator.php +66 -0
  26. app/code/community/Lipscore/RatingsReviews/Model/Observer.php +102 -0
  27. app/code/community/Lipscore/RatingsReviews/Model/Purchase/Reminder.php +59 -0
  28. app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Identifiertype.php +16 -0
  29. app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Locale.php +18 -0
  30. app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Pricerule.php +45 -0
  31. app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Productattr/Brand.php +40 -0
  32. app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Productattr/Identifier.php +38 -0
  33. app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Reminderperiod.php +13 -0
  34. app/code/community/Lipscore/RatingsReviews/controllers/Purchases/RemindersController.php +123 -0
  35. app/code/community/Lipscore/RatingsReviews/etc/adminhtml.xml +26 -0
  36. app/code/community/Lipscore/RatingsReviews/etc/config.xml +150 -0
  37. app/code/community/Lipscore/RatingsReviews/etc/environments/production.xml +5 -0
  38. app/code/community/Lipscore/RatingsReviews/etc/system.xml +258 -0
  39. app/design/adminhtml/default/default/layout/lipscore_ratingsreviews.xml +10 -0
  40. app/design/frontend/base/default/layout/lipscore_ratingsreviews.xml +38 -0
  41. app/design/frontend/base/default/template/lipscore/init.phtml +22 -0
  42. app/design/frontend/base/default/template/lipscore/purchase/view.phtml +17 -0
  43. app/design/frontend/base/default/template/lipscore/rating/view.phtml +13 -0
  44. app/design/frontend/base/default/template/lipscore/reviews/tab_title.phtml +3 -0
  45. app/design/frontend/base/default/template/lipscore/reviews/view.phtml +18 -0
  46. app/design/frontend/base/default/template/lipscore/richsnippet.phtml +9 -0
  47. app/etc/modules/Lipscore_RatingsReviews.xml +18 -0
  48. package.xml +21 -0
  49. skin/adminhtml/default/default/js/lipscore.js +54 -0
  50. skin/adminhtml/default/default/lipscore.css +2 -0
  51. skin/frontend/base/default/css/lipscore.css +1 -0
  52. skin/frontend/base/default/js/lipscore.js +18 -0
app/code/community/Lipscore/RatingsReviews/Block/Catalog/Product/View.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Block_Catalog_Product_View extends Mage_Catalog_Block_Product_View
4
+ {
5
+ /**
6
+ * Get product reviews summary
7
+ *
8
+ * @param Mage_Catalog_Model_Product $product
9
+ * @param bool $templateType
10
+ * @param bool $displayIfNoReviews
11
+ * @return string
12
+ */
13
+ public function getReviewsSummaryHtml(Mage_Catalog_Model_Product $product, $templateType = false,
14
+ $displayIfNoReviews = false)
15
+ {
16
+ return parent::getReviewsSummaryHtml($product, 'long', $displayIfNoReviews);
17
+ }
18
+ }
app/code/community/Lipscore/RatingsReviews/Block/Init.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Block_Init extends Mage_Core_Block_Template
4
+ {
5
+ /**
6
+ * @var Lipscore_RatingsReviews_Model_Config
7
+ */
8
+ protected $_lipscoreConfig;
9
+
10
+ /**
11
+ * @var Lipscore_RatingsReviews_Model_Config_Env
12
+ */
13
+ protected $_envConfig;
14
+
15
+ public function __construct()
16
+ {
17
+ $this->_lipscoreConfig = Mage::getModel('lipscore_ratingsreviews/config');
18
+ $this->_envConfig = Mage::getModel('lipscore_ratingsreviews/config_env');
19
+
20
+ parent::_construct();
21
+ }
22
+
23
+ protected function _beforeToHtml()
24
+ {
25
+ try {
26
+ $this->setLipscoreApiKey($this->_lipscoreConfig->apiKey());
27
+ $this->setAssetsUrl($this->_envConfig->assetsUrl());
28
+ } catch (Exception $e) {
29
+ Lipscore_RatingsReviews_Logger::logException($e);
30
+ }
31
+
32
+ return parent::_beforeToHtml();
33
+ }
34
+
35
+ protected function getLipscoreLocale()
36
+ {
37
+ $locale = null;
38
+ try {
39
+ $locale = Mage::helper('lipscore_ratingsreviews/locale')->getLipscoreLocale();
40
+ } catch (Exception $e) {
41
+ Lipscore_RatingsReviews_Logger::logException($e);
42
+ }
43
+ return $locale ? $locale . '/' : '';
44
+ }
45
+ }
app/code/community/Lipscore/RatingsReviews/Block/Purchase/Abstract.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Lipscore_RatingsReviews_Block_Purchase_Abstract extends Mage_Core_Block_Template
4
+ {
5
+ protected function _beforeToHtml()
6
+ {
7
+ try {
8
+ $this->_prepareProductsInOrder();
9
+ $this->_preparePurchaseInfo();
10
+ } catch (Exception $e) {
11
+ Lipscore_RatingsReviews_Logger::logException($e);
12
+ }
13
+
14
+ return parent::_beforeToHtml();
15
+ }
16
+
17
+ protected abstract function _prepareProductsInOrder();
18
+ protected abstract function _preparePurchaseInfo();
19
+
20
+ protected function _prepareCouponInfo()
21
+ {
22
+ $couponHelper = $this->helper('lipscore_ratingsreviews/coupon');
23
+ $coupon = $couponHelper->generateCoupon();
24
+
25
+ if ($coupon) {
26
+ $this->setCouponCode($coupon->getCode());
27
+ $this->setCouponDescription($couponHelper->getCouponDescription());
28
+ }
29
+ }
30
+ }
app/code/community/Lipscore/RatingsReviews/Block/Purchase/Multishipping.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Block_Purchase_Multishipping extends Lipscore_RatingsReviews_Block_Purchase_Abstract
4
+ {
5
+ protected $_orders = array();
6
+
7
+ protected function _construct()
8
+ {
9
+ try {
10
+ $orderIds = Mage::getSingleton('checkout/type_multishipping')->getOrderIds();
11
+ if ($orderIds) {
12
+ $this->_orders = Mage::getModel('sales/order')
13
+ ->getCollection()
14
+ ->addFieldToFilter('entity_id', array('in' => $orderIds));
15
+ }
16
+ } catch (Exception $e) {
17
+ Lipscore_RatingsReviews_Logger::logException($e);
18
+ }
19
+
20
+ parent::_construct();
21
+ }
22
+
23
+ protected function _prepareProductsInOrder()
24
+ {
25
+ $productsData = array();
26
+
27
+ $productHelper = $this->helper('lipscore_ratingsreviews/product');
28
+
29
+ foreach ($this->_orders as $order) {
30
+ $orderItems = $order->getAllVisibleItems();
31
+ foreach ($orderItems as $item) {
32
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
33
+ $productsData[$product->getid()] = $productHelper->getProductData($product);
34
+ }
35
+ }
36
+
37
+ $this->setProductsData($productsData);
38
+ }
39
+
40
+ protected function _preparePurchaseInfo()
41
+ {
42
+ $purchaseHelper = $this->helper('lipscore_ratingsreviews/purchase');
43
+ $this->setCustomerEmail($purchaseHelper->getEmail());
44
+ $this->setCustomerName($purchaseHelper->getName());
45
+
46
+ // coupon
47
+ $this->_prepareCouponInfo();
48
+ }
49
+ }
app/code/community/Lipscore/RatingsReviews/Block/Purchase/Onepage.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Block_Purchase_Onepage extends Lipscore_RatingsReviews_Block_Purchase_Abstract
4
+ {
5
+ protected $_order = null;
6
+
7
+ protected function _construct()
8
+ {
9
+ try {
10
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
11
+ if ($orderId) {
12
+ $this->_order = Mage::getModel('sales/order')->load($orderId);
13
+ }
14
+ } catch (Exception $e) {
15
+ Lipscore_RatingsReviews_Logger::logException($e);
16
+ }
17
+
18
+ parent::_construct();
19
+ }
20
+
21
+ protected function _prepareProductsInOrder()
22
+ {
23
+ $productsData = array();
24
+
25
+ if ($this->_order) {
26
+ $productHelper = $this->helper('lipscore_ratingsreviews/product');
27
+
28
+ $orderItems = $this->_order->getAllVisibleItems();
29
+ foreach ($orderItems as $item) {
30
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
31
+ $productsData[] = $productHelper->getProductData($product);
32
+ }
33
+ }
34
+
35
+ $this->setProductsData($productsData);
36
+ }
37
+
38
+ protected function _preparePurchaseInfo()
39
+ {
40
+ if (!$this->_order) {
41
+ return;
42
+ }
43
+
44
+ $purchaseHelper = $this->helper('lipscore_ratingsreviews/purchase');
45
+
46
+ $this->setCustomerEmail($purchaseHelper->getEmail($this->_order));
47
+ $this->setCustomerName($purchaseHelper->getName($this->_order));
48
+
49
+ // coupon
50
+ $this->_prepareCouponInfo();
51
+ }
52
+ }
app/code/community/Lipscore/RatingsReviews/Block/Review/Helper.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Block_Review_Helper extends Mage_Review_Block_Helper
4
+ {
5
+ protected $_template = 'lipscore/rating/view.phtml';
6
+ protected static $_availableTypes = array(
7
+ 'long' => 'id="lipscore-rating"',
8
+ 'short' => 'class="lipscore-rating-small"'
9
+ );
10
+
11
+ public function getSummaryHtml($product, $templateType, $displayIfNoReviews)
12
+ {
13
+ empty(self::$_availableTypes[$templateType]) and $templateType = 'short';
14
+
15
+ $this->setRatingType(self::$_availableTypes[$templateType]);
16
+ $this->setProduct($product);
17
+
18
+ return $this->toHtml();
19
+ }
20
+ }
app/code/community/Lipscore/RatingsReviews/Block/Review/TabTitle.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Block_Review_TabTitle extends Mage_Review_Block_Helper
4
+ {
5
+ protected $_template = 'lipscore/reviews/tab_title.phtml';
6
+ }
app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Coupons.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Block_System_Config_Form_Coupons extends Mage_Adminhtml_Block_System_Config_Form
4
+ {
5
+ protected function _canShowField($field)
6
+ {
7
+ $generateCoupons = false;
8
+ try {
9
+ $generateCoupons = Mage::helper('lipscore_ratingsreviews/coupon')->isAutoGenerationSupported();
10
+ } catch (Exception $e) {
11
+ Lipscore_RatingsReviews_Logger::logException($e);
12
+ }
13
+
14
+ switch ($field->getName()) {
15
+ case 'coupons':
16
+ return $generateCoupons;
17
+ break;
18
+ case 'coupons_warning':
19
+ return !$generateCoupons;
20
+ break;
21
+ default:
22
+ return parent::_canShowField($field);
23
+ break;
24
+ }
25
+ }
26
+ }
app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Field/Abstract.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Lipscore_RatingsReviews_Block_System_Config_Form_Field_Abstract
3
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected $lipscoreConfig = null;
6
+
7
+ protected function getLipscoreConfig()
8
+ {
9
+ if (!$this->lipscoreConfig) {
10
+ $this->lipscoreConfig = Mage::helper('lipscore_ratingsreviews/config')->getScoped(
11
+ $this->getWebsite(), $this->getStore()
12
+ );
13
+ }
14
+ return $this->lipscoreConfig;
15
+ }
16
+
17
+ protected function getSection()
18
+ {
19
+ return $this->getRequest()->getParam('section', '');
20
+ }
21
+
22
+ protected function getWebsite()
23
+ {
24
+ return $this->getRequest()->getParam('website', '');
25
+ }
26
+
27
+ protected function getStore()
28
+ {
29
+ return $this->getRequest()->getParam('store', '');
30
+ }
31
+ }
app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Field/Apikey.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Lipscore_RatingsReviews_Block_System_Config_Form_Field_Apikey
3
+ extends Lipscore_RatingsReviews_Block_System_Config_Form_Field_Abstract
4
+ {
5
+ public function render(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+
8
+ try {
9
+ $apiKey = $this->getLipscoreConfig()->apiKey();
10
+ $demoApiKey = $this->getLipscoreConfig()->demoApiKey();
11
+ } catch (Exception $e) {
12
+ Lipscore_RatingsReviews_Logger::logException($e);
13
+ return parent::render($element);
14
+ }
15
+ $comment = ($apiKey == $demoApiKey) ? $this->_commentHtml() : '';
16
+
17
+ return parent::render($element) . $comment;
18
+ }
19
+
20
+ protected function _commentHtml()
21
+ {
22
+ $comment = 'Your Lipscore installation is set up using a Demo Account. Please sign up with your own account on <a href="http://lipscore.com/" target="_blank">www.lipscore.com</a> to get access to all available features.';
23
+ return "<tr><td colspan='4'><span class='lipscore-notice-msg'>$comment</span></td></tr>";
24
+ }
25
+ }
app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Field/Reminderperiod.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Lipscore_RatingsReviews_Block_System_Config_Form_Field_Reminderperiod
3
+ extends Lipscore_RatingsReviews_Block_System_Config_Form_Field_Abstract
4
+ {
5
+ public static $_periodSelect = 'reminder_period';
6
+
7
+ public function render(Varien_Data_Form_Element_Abstract $element)
8
+ {
9
+ $text = '';
10
+ try {
11
+ $text = $this->getNote() . $this->getPeriodLabel() . $this->getPeriodSelect() . $this->getReminderButton();
12
+ } catch (Exception $e) {
13
+ Lipscore_RatingsReviews_Logger::logException($e);
14
+ }
15
+ return $text;
16
+ }
17
+
18
+ public function getPeriodSelect()
19
+ {
20
+ $opts = Mage::getSingleton('lipscore_ratingsreviews/system_config_source_reminderperiod')->toOptionArray();
21
+
22
+ $select = $this->getLayout()->createBlock('adminhtml/html_select')
23
+ ->setName(self::$_periodSelect)
24
+ ->setId(self::$_periodSelect)
25
+ ->setOptions($opts);
26
+
27
+ return $select->getHtml();
28
+ }
29
+
30
+ public function getPeriodLabel()
31
+ {
32
+ return '<label for="' . self::$_periodSelect . '">' . $this->__('Period') . '</label>';
33
+ }
34
+
35
+ public function getReminderButton()
36
+ {
37
+ $url = $this->getReminderUrl();
38
+ $perioSelectId = self::$_periodSelect;
39
+
40
+ $apiKey = $this->getLipscoreConfig()->apiKey();
41
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
42
+ ->setData(array(
43
+ 'label' => $this->__('Send Reminders'),
44
+ 'disabled' => empty($apiKey),
45
+ 'title' => $this->__('Send Reminders'),
46
+ 'onclick' => "sendLipscoreReminder('$url', '$perioSelectId');",
47
+ ));
48
+ return $button->toHtml();
49
+ }
50
+
51
+ public function getNote()
52
+ {
53
+ $linkToDasboard = 'https://members.lipscore.com/';
54
+ $linkToCoupons = Mage::getModel('adminhtml/url')->getUrl('*/*/*', array('section' => 'lipscore_coupons'));
55
+
56
+ $msg = "After installation of Lipscore you can send emails to recent customers asking them to write reviews of the purchases they have done. This is done automatically for all future customers but customers from before Lipscore was installed will not get these emails unless you invoke it below. They will be delivered according to <a href='$linkToDasboard'>reminder delay settings</a> and will only be done once.";
57
+ $coupons = "To increase the chance of getting reviews you can also add coupons to these emails. Set up coupons <a href='$linkToCoupons'>here</a>.";
58
+
59
+ return "<p>$msg $coupons<p>";
60
+ }
61
+
62
+ protected function getReminderUrl()
63
+ {
64
+ $scopeParams = "section/{$this->getSection()}/website/{$this->getWebsite()}/store/{$this->getStore()}";
65
+ return Mage::getModel('adminhtml/url')->getUrl("*/purchases_reminders/send/$scopeParams");
66
+ }
67
+ }
app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Fieldset/Coupons.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Block_System_Config_Form_Fieldset_Coupons extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
4
+ {
5
+ public function render(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $warning = '<span class="critical">Warning!</span> ';
8
+ $message = 'This feature is unavailable: current Magento version doesn\'t support coupons auto generation.';
9
+ return '<div class="notification-global"><strong>' . $warning . $message . '</strong></div>';
10
+ }
11
+ }
app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Fieldset/Dashboardlink.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Block_System_Config_Form_Fieldset_Dashboardlink extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
4
+ {
5
+ public function render(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ return 'Advanced settings are available on <a href="https://members.lipscore.com/">your dashboard</a>';
8
+ }
9
+ }
app/code/community/Lipscore/RatingsReviews/Helper/Abstract.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Lipscore_RatingsReviews_Helper_Abstract extends Mage_Core_Helper_Abstract
4
+ {
5
+ /**
6
+ * @var Lipscore_RatingsReviews_Model_Config
7
+ */
8
+ protected $_lipscoreConfig;
9
+
10
+ public function __construct()
11
+ {
12
+ $this->_lipscoreConfig = Mage::getModel('lipscore_ratingsreviews/config');
13
+ }
14
+
15
+ public function setLipscoreConfig($lipscoreConfig)
16
+ {
17
+ $this->_lipscoreConfig = $lipscoreConfig;
18
+ }
19
+ }
app/code/community/Lipscore/RatingsReviews/Helper/Config.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Helper_Config extends Lipscore_RatingsReviews_Helper_Abstract
4
+ {
5
+ public function getScoped($websiteCode, $storeCode)
6
+ {
7
+ $website = $websiteCode ? Mage::getModel('core/website')->load($websiteCode) : null;
8
+ $store = $storeCode ? Mage::getModel('core/store')->load($storeCode) : null;
9
+
10
+ return Mage::getModel('lipscore_ratingsreviews/config', array('store' => $store, 'website' => $website));
11
+ }
12
+ }
app/code/community/Lipscore/RatingsReviews/Helper/Coupon.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Helper_Coupon extends Lipscore_RatingsReviews_Helper_Abstract
4
+ {
5
+ protected $_rule;
6
+ protected $_ruleModel;
7
+
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+
12
+ $this->_ruleModel = Mage::getModel('salesrule/rule');
13
+ $ruleId = $this->_lipscoreConfig->get('rule_id', 'coupon');
14
+ if ($ruleId) {
15
+ $this->_rule = $this->_ruleModel->load($ruleId);
16
+ }
17
+ }
18
+
19
+ function generateCoupon()
20
+ {
21
+ $coupon = null;
22
+
23
+ if ($this->_rule) {
24
+ $params = array(
25
+ 'rule_id' => $this->_rule->getId(),
26
+ 'qty' => 1,
27
+ 'length' => $this->_lipscoreConfig->get('length', 'coupon'),
28
+ 'format' => $this->_lipscoreConfig->get('format', 'coupon'),
29
+ 'prefix' => $this->_lipscoreConfig->get('prefix', 'coupon'),
30
+ 'suffix' => $this->_lipscoreConfig->get('suffix', 'coupon'),
31
+ 'dash' => $this->_lipscoreConfig->get('dash', 'coupon'),
32
+ );
33
+
34
+ $generator = Mage::getModel('lipscore_ratingsreviews/coupon_generator');
35
+ $coupon = $generator->generate($this->_rule, $params);
36
+ }
37
+
38
+ return $coupon;
39
+ }
40
+
41
+ public function getCouponDescription()
42
+ {
43
+ return $this->_rule ? $this->_rule->getDescription() : '';
44
+ }
45
+
46
+ public function isAutoGenerationSupported()
47
+ {
48
+ return method_exists($this->_ruleModel, 'getCouponMassGenerator');
49
+ }
50
+ }
app/code/community/Lipscore/RatingsReviews/Helper/Data.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Helper_Data extends Mage_Core_Helper_Abstract {}
app/code/community/Lipscore/RatingsReviews/Helper/Locale.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Helper_Locale extends Lipscore_RatingsReviews_Helper_Abstract
4
+ {
5
+ protected static $_availableLocales = array('en', 'it', 'no', 'es', 'br', 'ru', 'se');
6
+
7
+ public function getLipscoreLocale()
8
+ {
9
+ $locale = null;
10
+ try {
11
+ $locale = $this->_lipscoreConfig->locale();
12
+ } catch (Exception $e) {
13
+ Lipscore_RatingsReviews_Logger::logException($e);
14
+ }
15
+
16
+ if ($locale == 'auto') {
17
+ $locale = null;
18
+ try {
19
+ $locale = $this->getFromStore();
20
+ } catch (Exception $e) {
21
+ Lipscore_RatingsReviews_Logger::logException($e);
22
+ }
23
+ }
24
+ return $locale;
25
+ }
26
+
27
+ protected function getFromStore()
28
+ {
29
+ $localeCode = $this->_lipscoreConfig->getMageConfig('general/locale/code');
30
+ list($language, $region) = explode('_', $localeCode);
31
+
32
+ $locale = $this->getAvailableLocale($language);
33
+ if (is_null($locale)) {
34
+ $locale = $this->getAvailableLocale($region);
35
+ }
36
+ return $locale;
37
+ }
38
+
39
+ protected function getAvailableLocale($storeLocale)
40
+ {
41
+ $storeLocale = strtolower($storeLocale);
42
+ return in_array($storeLocale, self::$_availableLocales) ? $storeLocale : null;
43
+ }
44
+ }
app/code/community/Lipscore/RatingsReviews/Helper/Product.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Product helper
5
+ *
6
+ * @author oivanova
7
+ */
8
+
9
+ class Lipscore_RatingsReviews_Helper_Product extends Lipscore_RatingsReviews_Helper_Abstract
10
+ {
11
+ public function getProductData(Mage_Catalog_Model_Product $product = null)
12
+ {
13
+ $data = array();
14
+ try {
15
+ $data = $this->_productData($product);
16
+ } catch (Exception $e) {
17
+ Lipscore_RatingsReviews_Logger::logException($e);
18
+ }
19
+ return $data;
20
+ }
21
+
22
+ protected function _productData(Mage_Catalog_Model_Product $product = null)
23
+ {
24
+ $product or $product = Mage::registry('product');
25
+
26
+ $idType = $this->_lipscoreConfig->identifierType();
27
+ $idAttr = $this->_lipscoreConfig->identifierAttr();
28
+ $brandAttr = $this->_lipscoreConfig->brandAttr();
29
+
30
+ return array(
31
+ 'name' => $product->getName(),
32
+ 'brand' => $this->_getAttributeValue($product, $brandAttr),
33
+ 'idType' => $idType,
34
+ 'id' => $this->_getAttributeValue($product, $idAttr),
35
+ 'url' => $product->getProductUrl()
36
+ );
37
+ }
38
+
39
+ protected function _getAttributeValue(Mage_Catalog_Model_Product $product, $attrCode)
40
+ {
41
+ $attr = $product->getResource()->getAttribute($attrCode);
42
+
43
+ if (!$attr) {
44
+ return null;
45
+ }
46
+
47
+ if ('select' == $attr->getFrontendInput()) {
48
+ return $attr->getSource()->getOptionText($product->getData($attrCode));
49
+ } else {
50
+ return $product->getData($attrCode);
51
+ }
52
+ }
53
+ }
app/code/community/Lipscore/RatingsReviews/Helper/Purchase.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Helper_Purchase extends Lipscore_RatingsReviews_Helper_Abstract
4
+ {
5
+ public function getEmail(Mage_Sales_Model_Order $order = null)
6
+ {
7
+ $email = null;
8
+
9
+ if ($order) {
10
+ $email = $order->getBillingAddress()->getEmail();
11
+ if (!$email) {
12
+ $email = $order->getCustomerEmail();
13
+ }
14
+ } else {
15
+ $customer = $this->getCustomer();
16
+ if ($customer) {
17
+ $email = $customer->getEmail();
18
+ }
19
+ }
20
+
21
+ return $email;
22
+ }
23
+
24
+ public function getName(Mage_Sales_Model_Order $order = null)
25
+ {
26
+ $name = null;
27
+
28
+ if ($order) {
29
+ $addr = $order->getBillingAddress();
30
+ $name = $addr->getFirstname() . ' ' . $addr->getLastname();
31
+
32
+ if (!trim($name)) {
33
+ $name = $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname();
34
+ }
35
+ } else {
36
+ $customer = $this->getCustomer();
37
+ if ($customer) {
38
+ $name = $customer->getName();
39
+ }
40
+ }
41
+
42
+ return $name;
43
+ }
44
+
45
+ protected function getCustomer()
46
+ {
47
+ return Mage::getSingleton('customer/session')->getCustomer();
48
+ }
49
+ }
app/code/community/Lipscore/RatingsReviews/Helper/Reminder.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Helper_Reminder extends Lipscore_RatingsReviews_Helper_Abstract
4
+ {
5
+ protected $productHelper = null;
6
+ protected $purchaseHelper = null;
7
+ protected $couponHelper = null;
8
+ protected $localeHelper = null;
9
+
10
+ public function __construct()
11
+ {
12
+ $this->productHelper = Mage::helper('lipscore_ratingsreviews/product');
13
+ $this->purchaseHelper = Mage::helper('lipscore_ratingsreviews/purchase');
14
+ $this->couponHelper = Mage::helper('lipscore_ratingsreviews/coupon');
15
+ $this->localeHelper = Mage::helper('lipscore_ratingsreviews/locale');
16
+
17
+ parent::__construct();
18
+ }
19
+
20
+ public function orderData(Mage_Sales_Model_Order $order)
21
+ {
22
+ $this->initConfig($order->getStoreId());
23
+ return array(
24
+ 'purchase' => $this->_purchaseData($order),
25
+ 'products' => $this->_productsData($order)
26
+ );
27
+ }
28
+
29
+ protected function _productsData($order)
30
+ {
31
+ $orderItems = $order->getAllVisibleItems();
32
+ $productIds = array();
33
+ foreach ($orderItems as $item) {
34
+ $productIds[] = $item->getProductId();
35
+ }
36
+
37
+ $products = Mage::getModel('catalog/product')->getCollection()
38
+ ->addAttributeToFilter('entity_id', array('in' => $productIds))
39
+ ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes());
40
+
41
+ $productsData = array();
42
+ $key = 1;
43
+ foreach ($products as $product) {
44
+ // we use keys to force json encoding of array to object (php 5.2 doesn't support JSON_FORCE_OBJECT)
45
+ $productsData[$key++] = $this->_productData($product);
46
+ }
47
+
48
+ return $productsData;
49
+ }
50
+
51
+ protected function _productData($product)
52
+ {
53
+ $data = $this->productHelper->getProductData($product);
54
+ return array(
55
+ 'name' => $data['name'],
56
+ 'brand' => $data['brand'],
57
+ 'id_type' => $data['idType'],
58
+ 'id_values' => array($data['id']),
59
+ 'url' => $data['url'],
60
+ );
61
+ }
62
+
63
+ protected function _purchaseData(Mage_Sales_Model_Order $order)
64
+ {
65
+ $coupon = $this->couponHelper->generateCoupon();
66
+ $email = $this->purchaseHelper->getEmail($order);
67
+ $name = $this->purchaseHelper->getName($order);
68
+ $lang = $this->localeHelper->getLipscoreLocale();
69
+
70
+ return array(
71
+ 'buyer_email' => $email,
72
+ 'buyer_name' => $name,
73
+ 'discount_descr' => $coupon ? $this->couponHelper->getCouponDescription() : '',
74
+ 'discount_voucher' => $coupon ? $coupon->getCode() : '',
75
+ 'purchased_at' => $order->getCreatedAtDate()->get(),
76
+ 'lang' => $lang
77
+ );
78
+ }
79
+
80
+ public function initConfig($storeId)
81
+ {
82
+ $config = Mage::helper('lipscore_ratingsreviews/config')->getScoped(null, $storeId);
83
+ $this->setLipscoreConfig($config);
84
+ $this->updateHelpersConfig();
85
+ }
86
+
87
+ protected function updateHelpersConfig()
88
+ {
89
+ $this->productHelper->setLipscoreConfig($this->_lipscoreConfig);
90
+ $this->purchaseHelper->setLipscoreConfig($this->_lipscoreConfig);
91
+ $this->couponHelper->setLipscoreConfig($this->_lipscoreConfig);
92
+ $this->localeHelper->setLipscoreConfig($this->_lipscoreConfig);
93
+ }
94
+ }
app/code/community/Lipscore/RatingsReviews/Logger.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Logger
4
+ {
5
+ public static function logException(Exception $e)
6
+ {
7
+ Mage::logException($e);
8
+
9
+ $store = null;
10
+ $storeInfo = $url = $to = '';
11
+
12
+ try {
13
+ $store = Mage::app()->getStore();
14
+ } catch (Exception $e) {}
15
+
16
+ if ($store) {
17
+ $storeUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
18
+ $storeInfo = $store->getFrontendName() . ', ' . self::_url($storeUrl);
19
+ $url = $store->getCurrentUrl();
20
+ } else {
21
+ $storeInfo = 'N/A';
22
+ }
23
+
24
+ if (!$url && isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) {
25
+ $url = isset($_SERVER['HTTPS']) ? 'https' : 'http';
26
+ $url .= '://' . "{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
27
+ }
28
+
29
+ $errMsg = $e->getMessage();
30
+ $trace = $e->getTraceAsString();
31
+ $link = self::_url($url);
32
+ $version = Mage::getVersion();
33
+ $sbj = "Magento extension error: $errMsg";
34
+ $msg = "STORE: $storeInfo, $version\n\nERROR MESSAGE: $errMsg\n\nURL: $link\n\nSTACK TRACE: $trace";
35
+
36
+ try {
37
+ $config = Mage::getModel('lipscore_ratingsreviews/config_env');
38
+ $to = (string) $config->errorsEmail();
39
+ } catch (Exception $e) {}
40
+
41
+ if (!empty($to)) {
42
+ try {
43
+ self::_sendEmail($to, $sbj, $msg);
44
+ } catch (Exception $e) {}
45
+ }
46
+ }
47
+
48
+ protected static function _url($url)
49
+ {
50
+ return $url ? $url : 'N/A';
51
+ }
52
+
53
+ protected static function _sendEmail($to, $sbj, $msg)
54
+ {
55
+ $fromEmail = Mage::getStoreConfig('trans_email/ident_general/email');
56
+ $fromName = Mage::getStoreConfig('trans_email/ident_general/name');
57
+
58
+ $mail = Mage::getModel('core/email')
59
+ ->setFromEmail($fromEmail)
60
+ ->setFromName($fromName)
61
+ ->setToEmail($to)
62
+ ->setSubject($sbj)
63
+ ->setBody($msg)
64
+ ->send();
65
+ }
66
+ }
app/code/community/Lipscore/RatingsReviews/Model/Config.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Model_Config
4
+ {
5
+ protected static $_systemConfigs = array(
6
+ 'coupon' => 'lipscore_coupons/coupons/',
7
+ 'identifier' => 'lipscore_general/product_identifier/',
8
+ 'brand' => 'lipscore_general/product_brand/',
9
+ 'apiKey' => 'lipscore_general/api_key/',
10
+ 'locale' => 'lipscore_general/locale/',
11
+ );
12
+
13
+ protected $store = null;
14
+ protected $website = null;
15
+
16
+ public function __construct($params = array())
17
+ {
18
+ !empty($params['store']) and $this->store = $params['store'];
19
+ !empty($params['website']) and $this->website = $params['website'];
20
+ }
21
+
22
+ public function get($param, $type)
23
+ {
24
+ $key = self::$_systemConfigs[$type] . $param;
25
+ return $this->getMageConfig($key);
26
+ }
27
+
28
+ public function getMageConfig($key)
29
+ {
30
+ if ($this->store) {
31
+ return $this->store->getConfig($key);
32
+ }
33
+ if ($this->website) {
34
+ return $this->website->getConfig($key);
35
+ }
36
+ return Mage::getStoreConfig($key);
37
+ }
38
+
39
+ public function apiKey()
40
+ {
41
+ return $this->get('api_key', 'apiKey');
42
+ }
43
+
44
+ public function demoApiKey()
45
+ {
46
+ return $this->get('demo_api_key', 'apiKey');
47
+ }
48
+
49
+ public function locale()
50
+ {
51
+ return $this->get('locale', 'locale');
52
+ }
53
+
54
+ public function brandAttr()
55
+ {
56
+ return $this->get('attr', 'brand');
57
+ }
58
+
59
+ public function identifierType()
60
+ {
61
+ return $this->get('type', 'identifier');
62
+ }
63
+
64
+ public function identifierAttr()
65
+ {
66
+ return $this->get('attr', 'identifier');
67
+ }
68
+ }
app/code/community/Lipscore/RatingsReviews/Model/Config/Env.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Model_Config_Env extends Varien_Simplexml_Config
4
+ {
5
+ const DEV_ENV = 'development';
6
+ const PROD_ENV = 'production';
7
+
8
+ const CACHE_TAG = 'config_lipscore_env';
9
+ const CACHE_ID = 'config_lipscore_env';
10
+
11
+ public function __construct()
12
+ {
13
+ $canUserCache = Mage::app()->useCache('config');
14
+ if ($canUserCache) {
15
+ $this->setCacheId(self::CACHE_ID)
16
+ ->setCacheTags(array(self::CACHE_TAG))
17
+ ->setCacheChecksum(null)
18
+ ->setCache(Mage::app()->getCache());
19
+
20
+ if ($this->loadCache()) {
21
+ return;
22
+ }
23
+ }
24
+
25
+ $env = getenv('LIPSCORE_MAGE_ENV') == self::DEV_ENV ? self::DEV_ENV : self::PROD_ENV;
26
+ $configFile = Mage::getModuleDir('etc', 'Lipscore_RatingsReviews'). DS . 'environments' . DS . $env . '.xml';
27
+
28
+ parent::__construct($configFile);
29
+
30
+ if ($canUserCache) {
31
+ $this->saveCache();
32
+ }
33
+ }
34
+
35
+ public function apiUrl()
36
+ {
37
+ return $this->getNode('lipscore_api_url');
38
+ }
39
+
40
+ public function assetsUrl()
41
+ {
42
+ return $this->getNode('lipscore_assets_url');
43
+ }
44
+
45
+ public function errorsEmail()
46
+ {
47
+ return $this->getNode('lipscore_errors_email');
48
+ }
49
+ }
app/code/community/Lipscore/RatingsReviews/Model/Coupon/Generator.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Model_Coupon_Generator
4
+ {
5
+ public function generate($rule, $data)
6
+ {
7
+ $generator = $rule->getCouponMassGenerator();
8
+
9
+ if (!$generator->validateData($data)) {
10
+ return null;
11
+ }
12
+
13
+ $generator->setData($data);
14
+ $size = $generator->getQty();
15
+
16
+ $maxProbability = $generator->getMaxProbability() ? $generator->getMaxProbability() : $generator::MAX_PROBABILITY_OF_GUESSING;
17
+ $maxAttempts = $generator->getMaxAttempts() ? $generator->getMaxAttempts() : $generator::MAX_GENERATE_ATTEMPTS;
18
+
19
+ $coupon = Mage::getModel('salesrule/coupon');
20
+
21
+ $chars = count(Mage::helper('salesrule/coupon')->getCharset($generator->getFormat()));
22
+ $length = (int) $generator->getLength();
23
+ $maxCodes = pow($chars, $length);
24
+ $probability = $size / $maxCodes;
25
+
26
+ //increase the length of Code if probability is low
27
+ if ($probability > $maxProbability) {
28
+ do {
29
+ $length++;
30
+ $maxCodes = pow($chars, $length);
31
+ $probability = $size / $maxCodes;
32
+ } while ($probability > $maxProbability);
33
+ $generator->setLength($length);
34
+ }
35
+
36
+ $now = $generator->getResource()->formatDate(
37
+ Mage::getSingleton('core/date')->gmtTimestamp()
38
+ );
39
+
40
+ $attempt = 0;
41
+ do {
42
+ if ($attempt >= $maxAttempts) {
43
+ break;
44
+ }
45
+ $code = $generator->generateCode();
46
+ $attempt++;
47
+ } while ($generator->getResource()->exists($code));
48
+
49
+ $expirationDate = $generator->getToDate();
50
+ if ($expirationDate instanceof Zend_Date) {
51
+ $expirationDate = $expirationDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
52
+ }
53
+
54
+ $coupon->setId(null)
55
+ ->setRuleId($generator->getRuleId())
56
+ ->setUsageLimit($generator->getUsesPerCoupon())
57
+ ->setUsagePerCustomer($generator->getUsesPerCustomer())
58
+ ->setExpirationDate($expirationDate)
59
+ ->setCreatedAt($now)
60
+ ->setType(Mage_SalesRule_Helper_Coupon::COUPON_TYPE_SPECIFIC_AUTOGENERATED)
61
+ ->setCode($code)
62
+ ->save();
63
+
64
+ return $coupon;
65
+ }
66
+ }
app/code/community/Lipscore/RatingsReviews/Model/Observer.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Model_Observer
4
+ {
5
+ const REVIEW_MODULE = 'Mage_Review';
6
+ const RATING_MODULE = 'Mage_Rating';
7
+
8
+ const REVIEW_TITLE_PLACEHOLDER = 'lipscore_reviews_placeholder';
9
+
10
+ public function __call($method, $arguments) {
11
+ try {
12
+ call_user_func_array(array($this, $method), $arguments);
13
+ } catch (Exception $e) {
14
+ Lipscore_RatingsReviews_Logger::logException($e);
15
+ }
16
+ }
17
+
18
+ protected function manageMageReviewModule(Varien_Event_Observer $observer)
19
+ {
20
+ if (!Mage::helper('core/data')->isModuleEnabled(self::REVIEW_MODULE)) {
21
+ $nodePath = 'modules/' . self::REVIEW_MODULE . '/active';
22
+ Mage::getConfig()->setNode($nodePath, 'true', true);
23
+ }
24
+
25
+ $this->_disableModuleOutput(self::REVIEW_MODULE);
26
+ $this->_disableModuleOutput(self::RATING_MODULE);
27
+
28
+ $nodePath = 'global/blocks/review/rewrite/helper';
29
+ Mage::getConfig()->setNode($nodePath, 'Lipscore_RatingsReviews_Block_Review_Helper', true);
30
+
31
+ $nodePath = 'global/blocks/catalog/rewrite/product_view';
32
+ Mage::getConfig()->setNode($nodePath, 'Lipscore_RatingsReviews_Block_Catalog_Product_View', true);
33
+ }
34
+
35
+ protected function addRatings(Varien_Event_Observer $observer)
36
+ {
37
+ $collection = $observer->getEvent()->getCollection();
38
+ if ($collection->count()) {
39
+ foreach ($collection as $product) {
40
+ $product->setData('rating_summary', 1);
41
+ }
42
+ }
43
+
44
+ return $this;
45
+ }
46
+
47
+ protected function addReviewsTab(Varien_Event_Observer $observer)
48
+ {
49
+ $layout = $observer->getEvent()->getLayout();
50
+
51
+ if (!$layout) {
52
+ return;
53
+ }
54
+
55
+ $tabs = $layout->getBlock('product.info.tabs');
56
+ if ($tabs) {
57
+ $tabs->addTab(
58
+ 'lipscore.reviews', self::REVIEW_TITLE_PLACEHOLDER, 'core/template', 'lipscore/reviews/view.phtml'
59
+ );
60
+ }
61
+ }
62
+
63
+ public function addReviewsFeatures(Varien_Event_Observer $observer)
64
+ {
65
+ $block = $observer->getBlock();
66
+ $layout = $block->getLayout();
67
+
68
+ if (!$layout) {
69
+ return;
70
+ }
71
+
72
+ $layoutHandles = $layout->getUpdate()->getHandles();
73
+ $properLayout = in_array('catalog_product_view', $layoutHandles);
74
+ $properBlock = $block->getNameInLayout() == 'product.info';
75
+
76
+ if ($properLayout && $properBlock) {
77
+ $transport = $observer->getTransport();
78
+ $html = $transport->getHtml();
79
+
80
+ // set review title
81
+ $titleBlock = $block->getLayout()->createBlock('lipscore_ratingsreviews/review_tabTitle');
82
+ $html = str_replace(self::REVIEW_TITLE_PLACEHOLDER, $titleBlock->toHtml(), $html);
83
+
84
+ // ensure that reviews block exists on a page
85
+ $pos = strripos($html, 'lipscore-review-list');
86
+ if ($pos === false) {
87
+ $reviewsBlock = $block->getLayout()->createBlock('core/template', '', array('template' => 'lipscore/reviews/view.phtml'));
88
+ $html .= $reviewsBlock->toHtml();
89
+ }
90
+
91
+ $transport->setHtml($html);
92
+ }
93
+ }
94
+
95
+ protected function _disableModuleOutput($moduleName)
96
+ {
97
+ $outputPath = 'advanced/modules_disable_output/' . $moduleName;
98
+ if (!Mage::getStoreConfig($outputPath)) {
99
+ Mage::app()->getStore()->setConfig($outputPath, true);
100
+ }
101
+ }
102
+ }
app/code/community/Lipscore/RatingsReviews/Model/Purchase/Reminder.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Model_Purchase_Reminder
4
+ {
5
+ protected $lipscoreConfig = null;
6
+ protected $response = null;
7
+
8
+ const LOG_FILE = 'lipscore_reminder.log';
9
+
10
+ public function __construct($params)
11
+ {
12
+ $websiteCode = isset($params['websiteCode']) ? $params['websiteCode'] : null;
13
+ $storeCode = isset($params['storeCode']) ? $params['storeCode'] : null;
14
+
15
+ $this->lipscoreConfig = Mage::helper('lipscore_ratingsreviews/config')->getScoped($websiteCode, $storeCode);
16
+ }
17
+
18
+ public function send($orders)
19
+ {
20
+ $data = array();
21
+ $dataHelper = Mage::helper('lipscore_ratingsreviews/reminder');
22
+
23
+ foreach ($orders as $order) {
24
+ $data[] = $dataHelper->orderData($order);
25
+ }
26
+
27
+ return $this->sendRequest(array('purchases' => $data));
28
+ }
29
+
30
+ public function getResponseMsg()
31
+ {
32
+ return $this->response ? $this->response->__toString() : '';
33
+ }
34
+
35
+ protected function sendRequest($data)
36
+ {
37
+ $apiKey = $this->lipscoreConfig->apiKey();
38
+ $apiUrl = Mage::getModel('lipscore_ratingsreviews/config_env')->apiUrl();
39
+
40
+ $client = new Zend_Http_Client("http://$apiUrl/purchases?api_key=$apiKey", array(
41
+ 'timeout' => 300
42
+ ));
43
+ $client->setRawData(json_encode($data), 'application/json')
44
+ ->setMethod(Zend_Http_Client::POST);
45
+
46
+ $this->response = $client->request();
47
+ $result = $this->response->isSuccessful();
48
+
49
+ $this->log($result);
50
+
51
+ return $result;
52
+ }
53
+
54
+ protected function log($isSuccessful)
55
+ {
56
+ $result = $isSuccessful ? 'Reminders were created: ' : 'Reminders weren\'t created: ';
57
+ Mage::log($result . $this->getResponseMsg(), Zend_Log::INFO, self::LOG_FILE);
58
+ }
59
+ }
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Identifiertype.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Model_System_Config_Source_Identifiertype
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => 'ean', 'label' => Mage::helper('adminhtml')->__('EAN')),
9
+ array('value' => 'isbn', 'label' => Mage::helper('adminhtml')->__('ISBN')),
10
+ array('value' => 'mbid', 'label' => Mage::helper('adminhtml')->__('MBID')),
11
+ array('value' => 'mpn', 'label' => Mage::helper('adminhtml')->__('MPN')),
12
+ array('value' => 'sku', 'label' => Mage::helper('adminhtml')->__('SKU')),
13
+ array('value' => 'upc', 'label' => Mage::helper('adminhtml')->__('UPC')),
14
+ );
15
+ }
16
+ }
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Locale.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Model_System_Config_Source_Locale
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => 'auto', 'label' => Mage::helper('adminhtml')->__('Auto')),
9
+ array('value' => 'en', 'label' => Mage::helper('adminhtml')->__('English')),
10
+ array('value' => 'it', 'label' => Mage::helper('adminhtml')->__('Italian')),
11
+ array('value' => 'no', 'label' => Mage::helper('adminhtml')->__('Norwegian')),
12
+ array('value' => 'br', 'label' => Mage::helper('adminhtml')->__('Portuguese (Brazil)')),
13
+ array('value' => 'ru', 'label' => Mage::helper('adminhtml')->__('Russian')),
14
+ array('value' => 'es', 'label' => Mage::helper('adminhtml')->__('Spanish')),
15
+ array('value' => 'se', 'label' => Mage::helper('adminhtml')->__('Swedish')),
16
+ );
17
+ }
18
+ }
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Pricerule.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Model_System_Config_Source_Pricerule
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $attrs = array(
8
+ array('value' => '', 'label' => Mage::helper('adminhtml')->__('--Please Select--'))
9
+ );
10
+
11
+ try {
12
+ $attrs = array_merge($attrs, $this->_findAttrs());
13
+ } catch (Exception $e) {
14
+ Lipscore_RatingsReviews_Logger::logException($e);
15
+ }
16
+
17
+ return $attrs;
18
+ }
19
+
20
+ protected function _findAttrs()
21
+ {
22
+ $attrs = array();
23
+
24
+ if (!Mage::helper('lipscore_ratingsreviews/coupon')->isAutoGenerationSupported()) {
25
+ // magento doesn't support auto generation
26
+ return $attrs;
27
+ }
28
+
29
+ $collection = Mage::getModel('salesrule/rule')
30
+ ->getResourceCollection()
31
+ ->addFieldToFilter('coupon_type', Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC)
32
+ ->addFieldToFilter('use_auto_generation', '1');
33
+
34
+ if ($collection->getSize() > 0) {
35
+ foreach ($collection->getItems() as $rule) {
36
+ $attrs[] = array(
37
+ 'value' => $rule->getRuleId(),
38
+ 'label' => $rule->getName()
39
+ );
40
+ }
41
+ }
42
+
43
+ return $attrs;
44
+ }
45
+ }
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Productattr/Brand.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Model_System_Config_Source_Productattr_Brand
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $attrs = array(
8
+ array('value' =>'', 'label' => Mage::helper('adminhtml')->__('--Please Select--'))
9
+ );
10
+
11
+ try {
12
+ $attrs = array_merge($attrs, $this->_findAttrs());
13
+ } catch (Exception $e) {
14
+ Lipscore_RatingsReviews_Logger::logException($e);
15
+ }
16
+
17
+ return $attrs;
18
+ }
19
+
20
+ protected function _findAttrs()
21
+ {
22
+ $attrs = array();
23
+
24
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection')
25
+ ->addStoreLabel(Mage::app()->getStore()->getId())
26
+ ->addFieldToFilter('frontend_input', array('in' => array('text', 'select')))
27
+ ->addVisibleFilter();
28
+
29
+ if ($collection->getSize() > 0) {
30
+ foreach ($collection->getItems() as $attr) {
31
+ $attrs[] = array(
32
+ 'value' => $attr->getAttributeCode(),
33
+ 'label' => $attr->getStoreLabel()
34
+ );
35
+ }
36
+ }
37
+
38
+ return $attrs;
39
+ }
40
+ }
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Productattr/Identifier.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Model_System_Config_Source_Productattr_Identifier
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $attrs = array();
8
+
9
+ try {
10
+ $attrs = $this->_findAttrs();
11
+ } catch (Exception $e) {
12
+ Lipscore_RatingsReviews_Logger::logException($e);
13
+ }
14
+
15
+ return $attrs;
16
+ }
17
+
18
+ protected function _findAttrs()
19
+ {
20
+ $attrs = array();
21
+
22
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection')
23
+ ->addStoreLabel(Mage::app()->getStore()->getId())
24
+ ->addFieldToFilter('frontend_input', array('in' => array('text', 'select')))
25
+ ->addVisibleFilter();
26
+
27
+ if ($collection->getSize() > 0) {
28
+ foreach ($collection->getItems() as $attr) {
29
+ $attrs[] = array(
30
+ 'value' => $attr->getAttributeCode(),
31
+ 'label' => $attr->getStoreLabel()
32
+ );
33
+ }
34
+ }
35
+
36
+ return $attrs;
37
+ }
38
+ }
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Reminderperiod.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Lipscore_RatingsReviews_Model_System_Config_Source_Reminderperiod
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value' =>'', 'label' => Mage::helper('adminhtml')->__('--Please Select--')),
8
+ array('value' => '1 week', 'label' => Mage::helper('adminhtml')->__('1 week')),
9
+ array('value' => '1 month', 'label' => Mage::helper('adminhtml')->__('1 month')),
10
+ array('value' => '3 months', 'label' => Mage::helper('adminhtml')->__('3 months')),
11
+ );
12
+ }
13
+ }
app/code/community/Lipscore/RatingsReviews/controllers/Purchases/RemindersController.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lipscore_RatingsReviews_Purchases_RemindersController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected $lipscoreConfig = null;
6
+
7
+ public function preDispatch()
8
+ {
9
+ Mage::setIsDeveloperMode(true);
10
+ parent::preDispatch();
11
+ }
12
+
13
+ public function sendAction()
14
+ {
15
+ if (!$this->getRequest()->isAjax()) {
16
+ Lipscore_RatingsReviews_Logger::logException(new Exception('Non-ajax request to sending reminders action'));
17
+ $this->_forward('noRoute');
18
+ return;
19
+ }
20
+
21
+ try {
22
+ $this->_send();
23
+ } catch (Exception $e) {
24
+ Lipscore_RatingsReviews_Logger::logException($e);
25
+ $this->_response(false, $e->getMessage() . '\n' . $e->getTraceAsString());
26
+ }
27
+ }
28
+
29
+ protected function _send()
30
+ {
31
+ $this->_checkKey();
32
+
33
+ $start = $this->_getStartDate();
34
+ $orders = Mage::getModel('sales/order')->getCollection()
35
+ ->addAttributeToFilter('created_at', array('from' => $start))
36
+ ->addAttributeToFilter('status', array('eq' => Mage_Sales_Model_Order::STATE_COMPLETE));
37
+
38
+ $store = $this->getStore();
39
+ if ($store) {
40
+ $orders->addAttributeToFilter('store_id', array('eq' => $store->getId()));
41
+ }
42
+
43
+ if (!count($orders)) {
44
+ $this->_response(false, 'No completed orders found for a selected period.');
45
+ }
46
+
47
+ $sender = Mage::getModel('lipscore_ratingsreviews/purchase_reminder', array(
48
+ 'websiteCode' => $this->getWebsiteCode(),
49
+ 'storeCode' => $this->getStoreCode()
50
+ ));
51
+ $result = $sender->send($orders);
52
+ if ($result) {
53
+ $this->_response(true, "Emails were scheduled successfully.");
54
+ } else {
55
+ $this->_response(false, $sender->getResponseMsg());
56
+ }
57
+ }
58
+
59
+ protected function _checkKey()
60
+ {
61
+ $apiKey = $this->getLipscoreConfig()->apiKey();
62
+ if (!$apiKey) {
63
+ $this->_response(false, 'You should provide your Api Key and save config.');
64
+ }
65
+ }
66
+
67
+ protected function _getStartDate()
68
+ {
69
+ $data = $this->getRequest()->getParams();
70
+
71
+ $startDate = empty($data['period']) ? false : strtotime('-' . $data['period']);
72
+ if (!$startDate) {
73
+ $this->_response(false, 'Please select a correct period.');
74
+ }
75
+
76
+ return date('Y-m-d H:i:s', $startDate);
77
+ }
78
+
79
+ protected function _response($result, $response)
80
+ {
81
+ $body = Zend_Json::encode(array('message' => $response));
82
+ $this->getResponse()
83
+ ->setHeader('Content-Type', 'application/json')
84
+ ->setBody($body);
85
+
86
+ if (!$result) {
87
+ $this->getResponse()->setHttpResponseCode(422);
88
+ }
89
+
90
+ $this->getResponse()->sendResponse();
91
+
92
+ exit(0);
93
+ }
94
+
95
+ protected function getLipscoreConfig()
96
+ {
97
+ if (!$this->lipscoreConfig) {
98
+ $websiteCode = $this->getWebsiteCode();
99
+ $storeCode = $this->getStoreCode();
100
+
101
+ $this->lipscoreConfig = Mage::helper('lipscore_ratingsreviews/config')->getScoped($websiteCode, $storeCode);
102
+ }
103
+ return $this->lipscoreConfig;
104
+ }
105
+
106
+ protected function getStore()
107
+ {
108
+ $code = $this->getStoreCode();
109
+ if ($code) {
110
+ return Mage::getModel('core/store')->load($code);
111
+ }
112
+ }
113
+
114
+ protected function getWebsiteCode()
115
+ {
116
+ return $this->getRequest()->getParam('website');
117
+ }
118
+
119
+ protected function getStoreCode()
120
+ {
121
+ return $this->getRequest()->getParam('store');
122
+ }
123
+ }
app/code/community/Lipscore/RatingsReviews/etc/adminhtml.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <config>
4
+ <acl>
5
+ <resources>
6
+ <admin>
7
+ <children>
8
+ <system>
9
+ <children>
10
+ <config>
11
+ <children>
12
+ <lipscore_general translate="title">
13
+ <title>General</title>
14
+ </lipscore_general>
15
+ <lipscore_coupons translate="title">
16
+ <title>Coupons</title>
17
+ </lipscore_coupons>
18
+ </children>
19
+ </config>
20
+ </children>
21
+ </system>
22
+ </children>
23
+ </admin>
24
+ </resources>
25
+ </acl>
26
+ </config>
app/code/community/Lipscore/RatingsReviews/etc/config.xml ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <!--
4
+ /**
5
+ * Module configuration
6
+ *
7
+ * @author oivanova
8
+ */
9
+ -->
10
+
11
+ <config>
12
+ <modules>
13
+ <Lipscore_RatingsReviews>
14
+ <version>1.1.0.0</version>
15
+ </Lipscore_RatingsReviews>
16
+ </modules>
17
+
18
+ <global>
19
+ <cache>
20
+ <types>
21
+ <config_api translate="label,description" module="lipscore_ratingsreviews">
22
+ <label>Lipscore Extension Configuration</label>
23
+ <description>Environment configuration files.</description>
24
+ <tags>CONFIG_LIPSCORE_ENV</tags>
25
+ </config_api>
26
+ </types>
27
+ </cache>
28
+
29
+ <blocks>
30
+ <lipscore_ratingsreviews>
31
+ <class>Lipscore_RatingsReviews_Block</class>
32
+ </lipscore_ratingsreviews>
33
+ <review>
34
+ <rewrite>
35
+ <helper>Lipscore_RatingsReviews_Block_Review_Helper</helper>
36
+ </rewrite>
37
+ </review>
38
+ <catalog>
39
+ <rewrite>
40
+ <product_view>Lipscore_RatingsReviews_Block_Catalog_Product_View</product_view>
41
+ </rewrite>
42
+ </catalog>
43
+ </blocks>
44
+
45
+ <models>
46
+ <lipscore_ratingsreviews>
47
+ <class>Lipscore_RatingsReviews_Model</class>
48
+ </lipscore_ratingsreviews>
49
+ </models>
50
+
51
+ <helpers>
52
+ <lipscore_ratingsreviews>
53
+ <class>Lipscore_RatingsReviews_Helper</class>
54
+ </lipscore_ratingsreviews>
55
+ </helpers>
56
+
57
+ <events>
58
+ <controller_action_layout_load_before>
59
+ <observers>
60
+ <lipscore_ratingsreviews>
61
+ <class>lipscore_ratingsreviews/observer</class>
62
+ <method>manageMageReviewModule</method>
63
+ </lipscore_ratingsreviews>
64
+ </observers>
65
+ </controller_action_layout_load_before>
66
+ <catalog_product_collection_load_after>
67
+ <observers>
68
+ <lipscore_ratingsreviews>
69
+ <class>lipscore_ratingsreviews/observer</class>
70
+ <method>addRatings</method>
71
+ </lipscore_ratingsreviews>
72
+ </observers>
73
+ </catalog_product_collection_load_after>
74
+ <controller_action_layout_generate_blocks_after>
75
+ <observers>
76
+ <lipscore_ratingsreviews>
77
+ <class>lipscore_ratingsreviews/observer</class>
78
+ <method>addReviewsTab</method>
79
+ </lipscore_ratingsreviews>
80
+ </observers>
81
+ </controller_action_layout_generate_blocks_after>
82
+ <core_block_abstract_to_html_after>
83
+ <observers>
84
+ <lipscore_ratingsreviews>
85
+ <class>lipscore_ratingsreviews/observer</class>
86
+ <method>addReviewsFeatures</method>
87
+ </lipscore_ratingsreviews>
88
+ </observers>
89
+ </core_block_abstract_to_html_after>
90
+ </events>
91
+ </global>
92
+
93
+ <admin>
94
+ <routers>
95
+ <adminhtml>
96
+ <args>
97
+ <modules>
98
+ <lipscore_ratingsreviews after="Mage_Adminhtml">Lipscore_RatingsReviews</lipscore_ratingsreviews>
99
+ </modules>
100
+ <frontName>lipscore</frontName>
101
+ </args>
102
+ </adminhtml>
103
+ </routers>
104
+ </admin>
105
+
106
+ <frontend>
107
+ <layout>
108
+ <updates>
109
+ <lipscore_ratingsreviews>
110
+ <file>lipscore_ratingsreviews.xml</file>
111
+ </lipscore_ratingsreviews>
112
+ </updates>
113
+ </layout>
114
+ </frontend>
115
+
116
+ <adminhtml>
117
+ <layout>
118
+ <updates>
119
+ <lipscore_ratingsreviews>
120
+ <file>lipscore_ratingsreviews.xml</file>
121
+ </lipscore_ratingsreviews>
122
+ </updates>
123
+ </layout>
124
+ </adminhtml>
125
+
126
+ <default>
127
+ <lipscore_general>
128
+ <api_key>
129
+ <api_key>889c3f3e4b6ac67269261324</api_key>
130
+ <demo_api_key>889c3f3e4b6ac67269261324</demo_api_key>
131
+ </api_key>
132
+ <product_identifier>
133
+ <type>sku</type>
134
+ <attr>sku</attr>
135
+ <brand>brand</brand>
136
+ </product_identifier>
137
+ <product_brand>
138
+ <attr>brand</attr>
139
+ </product_brand>
140
+ <locale>
141
+ <locale>auto</locale>
142
+ </locale>
143
+ </lipscore_general>
144
+ <lipscore_coupons>
145
+ <coupons>
146
+ <length>12</length>
147
+ </coupons>
148
+ </lipscore_coupons>
149
+ </default>
150
+ </config>
app/code/community/Lipscore/RatingsReviews/etc/environments/production.xml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <config>
2
+ <lipscore_api_url>api.lipscore.com</lipscore_api_url>
3
+ <lipscore_assets_url>static.lipscore.com/assets</lipscore_assets_url>
4
+ <lipscore_errors_email>server_error@lipscore.com</lipscore_errors_email>
5
+ </config>
app/code/community/Lipscore/RatingsReviews/etc/system.xml ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <config>
4
+ <tabs>
5
+ <lipscore translate="label" module="lipscore_ratingsreviews">
6
+ <label>Lipscore</label>
7
+ <sort_order>500</sort_order>
8
+ </lipscore>
9
+ </tabs>
10
+ <sections>
11
+ <lipscore_general translate="label">
12
+ <label>General</label>
13
+ <tab>lipscore</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>100</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+
20
+ <groups>
21
+ <api_key translate="label">
22
+ <label>Api Key</label>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>100</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ <expanded>1</expanded>
29
+
30
+ <fields>
31
+ <api_key translate="label comment">
32
+ <label>Api Key</label>
33
+ <frontend_model>lipscore_ratingsreviews/system_config_form_field_apikey</frontend_model>
34
+ <frontend_type>text</frontend_type>
35
+ <validate>required-entry</validate>
36
+ <sort_order>10</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>1</show_in_store>
40
+ </api_key>
41
+ </fields>
42
+ </api_key>
43
+
44
+ <product_identifier translate="label">
45
+ <label>Product Identifier</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>200</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ <expanded>1</expanded>
52
+
53
+ <fields>
54
+ <type translate="label comment">
55
+ <label>Identifier Type</label>
56
+ <frontend_type>select</frontend_type>
57
+ <validate>required-entry</validate>
58
+ <source_model>
59
+ lipscore_ratingsreviews/system_config_source_identifiertype
60
+ </source_model>
61
+ <sort_order>10</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ </type>
66
+ <attr translate="label comment">
67
+ <label>Identifier Attribute</label>
68
+ <frontend_type>select</frontend_type>
69
+ <validate>required-entry</validate>
70
+ <source_model>
71
+ lipscore_ratingsreviews/system_config_source_productattr_identifier
72
+ </source_model>
73
+ <sort_order>20</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ </attr>
78
+ </fields>
79
+ </product_identifier>
80
+
81
+ <product_brand translate="label">
82
+ <label>Product Brand</label>
83
+ <frontend_type>text</frontend_type>
84
+ <sort_order>300</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ <expanded>1</expanded>
89
+ <fields>
90
+ <attr translate="label comment">
91
+ <label>Brand Attribute</label>
92
+ <comment>Optional, but strongly recommended to increase accuracy of product identification.</comment>
93
+ <frontend_type>select</frontend_type>
94
+ <source_model>
95
+ lipscore_ratingsreviews/system_config_source_productattr_brand
96
+ </source_model>
97
+ <sort_order>30</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>1</show_in_store>
101
+ </attr>
102
+ </fields>
103
+ </product_brand>
104
+
105
+ <locale translate="label">
106
+ <label>Interface Locale</label>
107
+ <frontend_type>text</frontend_type>
108
+ <sort_order>400</sort_order>
109
+ <show_in_default>1</show_in_default>
110
+ <show_in_website>1</show_in_website>
111
+ <show_in_store>1</show_in_store>
112
+ <expanded>1</expanded>
113
+ <fields>
114
+ <locale translate="label comment">
115
+ <label>Locale</label>
116
+ <comment>If 'Auto' is selected, the store locale will be used.</comment>
117
+ <frontend_type>select</frontend_type>
118
+ <source_model>
119
+ lipscore_ratingsreviews/system_config_source_locale
120
+ </source_model>
121
+ <sort_order>30</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>1</show_in_website>
124
+ <show_in_store>1</show_in_store>
125
+ </locale>
126
+ </fields>
127
+ </locale>
128
+
129
+ <reminder translate="label">
130
+ <label>Reminders</label>
131
+ <frontend_type>text</frontend_type>
132
+ <sort_order>500</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>1</show_in_store>
136
+ <expanded>1</expanded>
137
+ <fields>
138
+ <period translate="label comment">
139
+ <label>Period</label>
140
+ <frontend_model>lipscore_ratingsreviews/system_config_form_field_reminderperiod</frontend_model>
141
+ <frontend_type>text</frontend_type>
142
+ <sort_order>10</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>1</show_in_store>
146
+ </period>
147
+ </fields>
148
+ </reminder>
149
+
150
+ <dashboard_link translate="label">
151
+ <label>Advanced settings</label>
152
+ <frontend_model>lipscore_ratingsreviews/system_config_form_fieldset_dashboardlink</frontend_model>
153
+ <frontend_type>text</frontend_type>
154
+ <sort_order>600</sort_order>
155
+ <show_in_default>1</show_in_default>
156
+ <show_in_website>1</show_in_website>
157
+ <show_in_store>1</show_in_store>
158
+ <expanded>1</expanded>
159
+ </dashboard_link>
160
+ </groups>
161
+ </lipscore_general>
162
+
163
+ <lipscore_coupons>
164
+ <label>Coupons</label>
165
+ <tab>lipscore</tab>
166
+ <frontend_type>text</frontend_type>
167
+ <frontend_model>lipscore_ratingsreviews/system_config_form_coupons</frontend_model>
168
+ <sort_order>200</sort_order>
169
+ <show_in_default>1</show_in_default>
170
+ <show_in_website>1</show_in_website>
171
+ <show_in_store>1</show_in_store>
172
+
173
+ <groups>
174
+ <coupons translate="label">
175
+ <label>Coupons</label>
176
+ <frontend_type>text</frontend_type>
177
+ <sort_order>100</sort_order>
178
+ <show_in_default>1</show_in_default>
179
+ <show_in_website>1</show_in_website>
180
+ <show_in_store>1</show_in_store>
181
+ <expanded>1</expanded>
182
+
183
+ <fields>
184
+ <rule_id translate="label comment">
185
+ <label>Price Rule</label>
186
+ <comment>Price rule has to use auto generation to generate multiple coupon codes. Price rule's description will be used as a coupon description.</comment>
187
+ <frontend_type>select</frontend_type>
188
+ <source_model>
189
+ lipscore_ratingsreviews/system_config_source_pricerule
190
+ </source_model>
191
+ <sort_order>10</sort_order>
192
+ <show_in_default>1</show_in_default>
193
+ <show_in_website>1</show_in_website>
194
+ <show_in_store>1</show_in_store>
195
+ </rule_id>
196
+ <length translate="label comment">
197
+ <label>Code Length</label>
198
+ <comment>Excluding prefix, suffix and separators.</comment>
199
+ <frontend_type>text</frontend_type>
200
+ <validate>validate-digits validate-greater-than-zero</validate>
201
+ <sort_order>20</sort_order>
202
+ <show_in_default>1</show_in_default>
203
+ <show_in_website>1</show_in_website>
204
+ <show_in_store>1</show_in_store>
205
+ </length>
206
+ <format translate="label comment">
207
+ <label>Code Format</label>
208
+ <frontend_type>select</frontend_type>
209
+ <source_model>
210
+ salesrule/system_config_source_coupon_format
211
+ </source_model>
212
+ <sort_order>30</sort_order>
213
+ <show_in_default>1</show_in_default>
214
+ <show_in_website>1</show_in_website>
215
+ <show_in_store>1</show_in_store>
216
+ </format>
217
+ <prefix translate="label comment">
218
+ <label>Code Prefix</label>
219
+ <frontend_type>text</frontend_type>
220
+ <sort_order>40</sort_order>
221
+ <show_in_default>1</show_in_default>
222
+ <show_in_website>1</show_in_website>
223
+ <show_in_store>1</show_in_store>
224
+ </prefix>
225
+ <suffix translate="label comment">
226
+ <label>Code Suffix</label>
227
+ <frontend_type>text</frontend_type>
228
+ <sort_order>50</sort_order>
229
+ <show_in_default>1</show_in_default>
230
+ <show_in_website>1</show_in_website>
231
+ <show_in_store>1</show_in_store>
232
+ </suffix>
233
+ <dash translate="label comment">
234
+ <label>Dash Every X Characters</label>
235
+ <comment>If empty no separation.</comment>
236
+ <frontend_type>text</frontend_type>
237
+ <validate>validate-digits</validate>
238
+ <sort_order>60</sort_order>
239
+ <show_in_default>1</show_in_default>
240
+ <show_in_website>1</show_in_website>
241
+ <show_in_store>1</show_in_store>
242
+ </dash>
243
+ </fields>
244
+ </coupons>
245
+ <coupons_warning translate="label">
246
+ <label>Coupons</label>
247
+ <frontend_model>lipscore_ratingsreviews/system_config_form_fieldset_coupons</frontend_model>
248
+ <frontend_type>text</frontend_type>
249
+ <sort_order>100</sort_order>
250
+ <show_in_default>1</show_in_default>
251
+ <show_in_website>1</show_in_website>
252
+ <show_in_store>1</show_in_store>
253
+ <expanded>1</expanded>
254
+ </coupons_warning>
255
+ </groups>
256
+ </lipscore_coupons>
257
+ </sections>
258
+ </config>
app/design/adminhtml/default/default/layout/lipscore_ratingsreviews.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <layout>
4
+ <adminhtml_system_config_edit>
5
+ <reference name="head">
6
+ <action method="addItem"><type>skin_css</type><file>lipscore.css</file></action>
7
+ <action method="addItem"><type>skin_js</type><file>js/lipscore.js</file></action>
8
+ </reference>
9
+ </adminhtml_system_config_edit>
10
+ </layout>
app/design/frontend/base/default/layout/lipscore_ratingsreviews.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <layout>
4
+ <default>
5
+ <update handle="lipscore_common_head" />
6
+ </default>
7
+
8
+ <catalog_product_view>
9
+ <reference name="product.info">
10
+ <block type="core/template" name="lipscore.reviews" as="lipscore-reviews" template="lipscore/reviews/view.phtml">
11
+ <action method="addToParentGroup"><group>detailed_info</group></action>
12
+ <action method="setTitle"><value>lipscore_reviews_placeholder</value></action>
13
+ </block>
14
+ </reference>
15
+ </catalog_product_view>
16
+
17
+ <checkout_onepage_success>
18
+ <update handle="lipscore_common_head" />
19
+ <reference name="before_body_end">
20
+ <block type="lipscore_ratingsreviews/purchase_onepage" name="purchase.onepage" template="lipscore/purchase/view.phtml" />
21
+ </reference>
22
+ </checkout_onepage_success>
23
+
24
+ <checkout_multishipping_success>
25
+ <update handle="lipscore_common_head" />
26
+ <reference name="before_body_end">
27
+ <block type="lipscore_ratingsreviews/purchase_multishipping" name="purchase.multishipping" template="lipscore/purchase/view.phtml" />
28
+ </reference>
29
+ </checkout_multishipping_success>
30
+
31
+ <lipscore_common_head>
32
+ <reference name="head">
33
+ <block type="lipscore_ratingsreviews/init" name="lipscore.init" template="lipscore/init.phtml" />
34
+ <action method="addItem"><type>skin_css</type><file>css/lipscore.css</file></action>
35
+ <action method="addItem"><type>skin_js</type><file>js/lipscore.js</file></action>
36
+ </reference>
37
+ </lipscore_common_head>
38
+ </layout>
app/design/frontend/base/default/template/lipscore/init.phtml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * JS block for lipscore initialization
4
+ *
5
+ * @see Mage_Core_Block_Template
6
+ */
7
+ ?>
8
+
9
+ <script src="//<?php echo $this->assetsUrl ?>/<?php echo $this->getLipscoreLocale() ?>lipscore-v1.js" charset="utf-8"></script>
10
+ <link href="//<?php echo $this->assetsUrl ?>/lipscore-v1.css" rel="stylesheet" type="text/css">
11
+
12
+ <?php if ($this->lipscoreApiKey) { ?>
13
+ <script type="text/javascript">
14
+ //<![CDATA[
15
+ window.lipscoreInit = function() {
16
+ lipscore.init({
17
+ apiKey: "<?php echo $this->lipscoreApiKey ?>"
18
+ });
19
+ };
20
+ //]]>
21
+ </script>
22
+ <?php } ?>
app/design/frontend/base/default/template/lipscore/purchase/view.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $productsData = $this->getProductsData() ?>
2
+
3
+ <?php if ($productsData) { ?>
4
+ <?php foreach ($productsData as $data) { ?>
5
+ <div class="lipscore-purchase"
6
+ ls-email="<?php echo $this->getCustomerEmail() ?>"
7
+ ls-name="<?php echo $this->getCustomerName() ?>"
8
+ ls-product-name="<?php echo $data['name'] ?>"
9
+ ls-brand="<?php echo $data['brand'] ?>"
10
+ ls-id-type="<?php echo $data['idType'] ?>"
11
+ ls-id="<?php echo $data['id'] ?>"
12
+ ls-product-url="<?php echo $data['url'] ?>"
13
+ ls-voucher-code="<?php echo $this->getCouponCode() ?>"
14
+ ls-voucher-descr="<?php echo $this->getCouponDescription() ?>">
15
+ </div>
16
+ <?php } ?>
17
+ <?php } ?>
app/design/frontend/base/default/template/lipscore/rating/view.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_data = $this->helper('lipscore_ratingsreviews/product')->getProductData($this->getProduct()) ?>
2
+ <?php if ($_data) { ?>
3
+ <div class="ratings mg-lipscore-rating-wrapper">
4
+ <div <?php echo $this->getRatingType() ?>
5
+ ls-product-name="<?php echo $_data['name'] ?>"
6
+ ls-brand="<?php echo $_data['brand'] ?>"
7
+ ls-id-type="<?php echo $_data['idType'] ?>"
8
+ ls-id="<?php echo $_data['id'] ?>">
9
+ </div>
10
+ </div>
11
+ <?php } else { ?>
12
+ <div style="display: none !important;">Lipscore: empty product data</div>
13
+ <?php } ?>
app/design/frontend/base/default/template/lipscore/reviews/tab_title.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <span class='lipscore-reviews-tab'>
2
+ <?php echo $this->__('Reviews') ?><span class='lipscore-reviews-tab-count' style='display: none;'>&nbsp;(<span class='lipscore-review-count'></span>)</span>
3
+ </span>
app/design/frontend/base/default/template/lipscore/reviews/view.phtml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div style="display: none !important;">Reviews</div>
2
+ <?php $_data = $this->helper('lipscore_ratingsreviews/product')->getProductData($this->getProduct()) ?>
3
+ <?php if ($_data) { ?>
4
+ <div id="lipscore-review-post"
5
+ ls-product-name="<?php echo $_data['name'] ?>"
6
+ ls-brand="<?php echo $_data['brand'] ?>"
7
+ ls-id-type="<?php echo $_data['idType'] ?>"
8
+ ls-id="<?php echo $_data['id'] ?>">
9
+ </div>
10
+ <div id="lipscore-review-list"
11
+ ls-product-name="<?php echo $_data['name'] ?>"
12
+ ls-brand="<?php echo $_data['brand'] ?>"
13
+ ls-id-type="<?php echo $_data['idType'] ?>"
14
+ ls-id="<?php echo $_data['id'] ?>">
15
+ </div>
16
+ <?php } else { ?>
17
+ <div style="display: none !important;">Lipscore: empty product data</div>
18
+ <?php } ?>
app/design/frontend/base/default/template/lipscore/richsnippet.phtml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <div id="lipscore-richsnippet"
2
+ ls-rs-name=""
3
+ ls-rs-description=""
4
+ ls-rs-image=""
5
+ ls-rs-product-id=""
6
+ ls-rs-offer-price=""
7
+ ls-rs-offer-currency=""
8
+ ls-rs-offer-avaialbility=""
9
+ ><div>
app/etc/modules/Lipscore_RatingsReviews.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <!--
4
+ /**
5
+ * Module initial config
6
+ *
7
+ * @author @oivanova
8
+ */
9
+ -->
10
+
11
+ <config>
12
+ <modules>
13
+ <Lipscore_RatingsReviews>
14
+ <active>true</active>
15
+ <codePool>community</codePool>
16
+ </Lipscore_RatingsReviews>
17
+ </modules>
18
+ </config>
package.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>lipscore</name>
4
+ <version>1.2.17</version>
5
+ <stability>stable</stability>
6
+ <license uri="https://lipscore.com/signup">Terms of use</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The best new ratings and reviews extension. </summary>
10
+ <description>The best new ratings and reviews extension which replaces basic magento ratings and reviews functionality.&#xD;
11
+ Lipscore has a range of great features that will&#xD;
12
+ take all the hassle out of collecting product reviews, and help convert more&#xD;
13
+ visitors in to profitable customers.</description>
14
+ <notes>Minor fix: demo API key is checked considering current configuration scope.</notes>
15
+ <authors><author><name>Henning Frettem</name><user>Lipscore</user><email>henning@lipscore.com</email></author><author><name>Olga Ivanova</name><user>oivanova</user><email>o.ivanova@datacrafts.io</email></author></authors>
16
+ <date>2015-05-07</date>
17
+ <time>14:03:14</time>
18
+ <contents><target name="magecommunity"><dir name="Lipscore"><dir name="RatingsReviews"><dir name="Block"><dir name="Catalog"><dir name="Product"><file name="View.php" hash="c88cf05f967d7bdebe16ad4c8cb1864f"/></dir></dir><file name="Init.php" hash="54aa73f8964025643d200ef83d79a21f"/><dir name="Purchase"><file name="Abstract.php" hash="aaaabff2ee4366393c66b3a4469f8957"/><file name="Multishipping.php" hash="5b32395d9054b0a242a59e4f9f38988e"/><file name="Onepage.php" hash="ff7faab280d62e4bb906ebdd45521d65"/></dir><dir name="Review"><file name="Helper.php" hash="ca5340736a6b7ecc41f1635b255ff4fc"/><file name="TabTitle.php" hash="4b823e24b4f497554283791a70c68b09"/></dir><dir name="System"><dir name="Config"><dir name="Form"><file name="Coupons.php" hash="359eeb7d3913a2b52e7a704afd978464"/><dir name="Field"><file name="Abstract.php" hash="0e8b5385e58dfe4f1f92ddf6063b6376"/><file name="Apikey.php" hash="4012af99141381375a0a4d294bc60f88"/><file name="Reminderperiod.php" hash="e4eb8cb0acfa37dbe529ac7d657a2d04"/></dir><dir name="Fieldset"><file name="Coupons.php" hash="08b73ed814a47b46c05cf14889bb4ead"/><file name="Dashboardlink.php" hash="361363cd3bd1be3767d1c0e3ed601678"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Abstract.php" hash="65d8d9da169b1b1c4477d7d83c985c84"/><file name="Config.php" hash="10a7f292094fa16515975769bf675d13"/><file name="Coupon.php" hash="748ea1f72a63f22efdd9bffc4db27ce3"/><file name="Data.php" hash="6ae3c816d5d899f6f8050c213860ecf0"/><file name="Locale.php" hash="7b3f82b972fd8f8640dc69057682113d"/><file name="Product.php" hash="dfc10efaa05c064f956e742877e831fc"/><file name="Purchase.php" hash="c0fe0f8db92e449f420f0346a763519c"/><file name="Reminder.php" hash="190dcd087e406fba5254adb58ded959c"/></dir><file name="Logger.php" hash="b9d3b2df0bb8c2a8191763202ad272f8"/><dir name="Model"><dir name="Config"><file name="Env.php" hash="06610d75a570d1f6dbb75969ca11be82"/></dir><file name="Config.php" hash="75760dba8101023e77a5bad971bad009"/><dir name="Coupon"><file name="Generator.php" hash="d3164b63b6535e712888ce0c25900e12"/></dir><file name="Observer.php" hash="a5bbd3efe6de89d93a2facd4bf53d67f"/><dir name="Purchase"><file name="Reminder.php" hash="c96f31585b66afe111b1e5b833c9c0c7"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Identifiertype.php" hash="6b6f48d72b35eb5c30389ce2cbd306f3"/><file name="Locale.php" hash="deccbe6c50eb273fe6be8cbe640390f7"/><file name="Pricerule.php" hash="b100a5b624e5188691fa3f7c0dbed275"/><dir name="Productattr"><file name="Brand.php" hash="0bcb5b3ce8f0fefca0d52108e3b9807c"/><file name="Identifier.php" hash="15af8ee20f4fa40c2a702b90d7f45840"/></dir><file name="Reminderperiod.php" hash="674ad0760ba520655f1f4cabb4340b55"/></dir></dir></dir></dir><dir name="controllers"><dir name="Purchases"><file name="RemindersController.php" hash="7decc9845fd7e1702cadfd1bdbb55bfa"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="5edee417a954579c97186a8ebfdf3fbc"/><file name="config.xml" hash="a5d47bd5db3a80a4714b5bfe20bfd663"/><dir name="environments"><file name="production.xml" hash="bb3749dea14df3f07007dc9c24658eff"/></dir><file name="system.xml" hash="7d32fd473a4dbad0197101a06fc8c3b2"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="lipscore"><file name="init.phtml" hash="45db33eec713376d9243f1d690e43e59"/><dir name="purchase"><file name="view.phtml" hash="c2b3c47fdd77a17b2c77d787fef9def4"/></dir><dir name="rating"><file name="view.phtml" hash="50c74a4dc0bda1ebde342a4ff0f4d267"/></dir><dir name="reviews"><file name="tab_title.phtml" hash="cee27e2ae8b71c9705097584e9c0c3cc"/><file name="view.phtml" hash="9d5c3ae48fdbe603b5fbce1d895b9813"/></dir><file name="richsnippet.phtml" hash="692dbf43736e27c7027dc3483ba0cb27"/></dir></dir><dir name="layout"><file name="lipscore_ratingsreviews.xml" hash="1338423489c12d8f6a86bb644a887b4d"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="lipscore_ratingsreviews.xml" hash="73e5f3cd2b25005bb0456f28c4a40c51"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Lipscore_RatingsReviews.xml" hash="a5bea23f8ccc23ae46ee206b4b827939"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="lipscore.css" hash="ff29f27edd404707ac381e5a29ebcc27"/></dir><dir name="js"><file name="lipscore.js" hash="00726b0be0c2485063adc1b3367dd755"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><file name="lipscore.css" hash="3157f12c08a6957c33b5e8314cb14ea5"/><dir name="js"><file name="lipscore.js" hash="64b96d4ea835d24edd8bd7601e1ef651"/></dir></dir></dir></dir></target></contents>
19
+ <compatible/>
20
+ <dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
21
+ </package>
skin/adminhtml/default/default/js/lipscore.js ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function sendLipscoreReminder(url, periodElementId) {
2
+ $periodEl = $(periodElementId);
3
+ new Ajax.Request(url, {
4
+ method: 'post',
5
+ parameters: {period: $periodEl.getValue()},
6
+ onSuccess: function(response) {
7
+ showReminderMessage(response);
8
+ $periodEl.setValue('');
9
+ },
10
+ onFailure: function(response) {
11
+ showReminderMessage(response);
12
+ }
13
+ });
14
+ };
15
+
16
+ function showReminderMessage(response) {
17
+ var txt = '';
18
+ var type = 'error';
19
+ var commonErr = "We're sorry, but something went wrong with reminders, please try again or contact support.<br/><br/>";
20
+
21
+ var errMessage = function(response) {
22
+ return commonErr + response.status + ': ' + response.request.url + '.<br/> Params: ' +
23
+ response.request.body + '.<br/> Text: ' + response.responseText;
24
+ };
25
+
26
+ switch(response.status) {
27
+ case 200:
28
+ if (response.responseJSON && 'message' in response.responseJSON) {
29
+ txt = response.responseJSON.message;
30
+ type = 'success';
31
+ } else {
32
+ txt = errMessage(response);
33
+ }
34
+ break;
35
+ case 403:
36
+ txt = '403 Forbidden';
37
+ break;
38
+ case 404:
39
+ txt = commonErr + '404 Not Found: ' + response.request.url;
40
+ break;
41
+ case 422:
42
+ txt = response.responseJSON.message;
43
+ break;
44
+ case 408:
45
+ txt = 'The server timed out waiting for the request.';
46
+ break;
47
+ default:
48
+ txt = errMessage(response);
49
+ break;
50
+ }
51
+
52
+ var html = '<ul class="messages"><li class="' + type + '-msg"><ul><li>' + txt + '</li></ul></li></ul>';
53
+ $('messages').update(html);
54
+ }
skin/adminhtml/default/default/lipscore.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+ #reminder_period { margin: 0 20px; width: 180px; }
2
+ .lipscore-notice-msg { background: url(images/warning_msg_icon.gif) no-repeat; padding: 2px 0 0 20px; }
skin/frontend/base/default/css/lipscore.css ADDED
@@ -0,0 +1 @@
 
1
+ img.lipscore-rating-small-image { display: inline; }
skin/frontend/base/default/js/lipscore.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.observe("dom:loaded", function() {
2
+ if (typeof lipscore !== 'undefined') {
3
+ tabSelector = '.lipscore-reviews-tab';
4
+ if ($$(tabSelector)) {
5
+ // show review count
6
+ lipscore.on('review-count-set', function(data) {
7
+ if (data.value > 0) {
8
+ $$('.lipscore-reviews-tab-count').invoke('show');
9
+ }
10
+ });
11
+
12
+ // open reviews tab if reviews link clicked
13
+ lipscore.on('review-count-link-clicked', function(data) {
14
+ $$(tabSelector)[0].up().click();
15
+ });
16
+ }
17
+ }
18
+ });