Reviews_Sidebar - Version 1.0.4

Version Notes

None

Download this release

Release Info

Developer Magento Core Team
Extension Reviews_Sidebar
Version 1.0.4
Comparing to
See all releases


Version 1.0.4

app/code/community/Amasty/Review/Block/Sidebar.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Amasty.
4
+ */
5
+ class Amasty_Review_Block_Sidebar extends Mage_Core_Block_Template
6
+ {
7
+ protected function _prepareLayout()
8
+ {
9
+ if (!Mage::getStoreConfig('amreview/sidebar/active'))
10
+ return parent::_prepareLayout();
11
+
12
+ $count = Mage::getStoreConfig('amreview/sidebar/count');
13
+ if (!$count)
14
+ return parent::_prepareLayout();
15
+
16
+ $collection = Mage::getResourceModel('amreview/collection')
17
+ ->addVisiblityFilter()
18
+ ->setPageSize($count);
19
+ if (Mage::getStoreConfig('amreview/sidebar/show_stars'))
20
+ $collection->addRatingData();
21
+
22
+ if (Mage::getStoreConfig('amreview/sidebar/by_date'))
23
+ $collection->setDateOrder();
24
+ else
25
+ $collection->getSelect()->order('rand()');
26
+
27
+ $collection->load();
28
+
29
+
30
+ $baseUrl = Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
31
+ foreach ($collection->getItems() as $product){
32
+ $url = Mage::getUrl('catalog/product/view', array('id'=>$product->getId()));
33
+ if ($product->getUrl())
34
+ $url = $baseUrl . $product->getUrl();
35
+ $product->setUrl($url);
36
+
37
+ $product->setDetail($this->_trim($product->getDetail()));
38
+
39
+ if (Mage::getStoreConfig('amreview/sidebar/show_stars')){
40
+ $vote = new Varien_Object();
41
+ $vote->setPercent($product->getAvRating());
42
+ $vote->setRatingCode(Mage::helper('amreview')->__('Rating'));
43
+ $product->setRatingVotes(array($vote));
44
+ }
45
+ }
46
+
47
+ $this->setReviews($collection);
48
+ }
49
+
50
+
51
+ protected function _trim($str)
52
+ {
53
+ $max = Mage::getStoreConfig('amreview/sidebar/max_words');
54
+ if ($max > 0){
55
+ $str = implode(' ', array_slice(preg_split('/\s+/', $str), 0, $max));
56
+ }
57
+ return $str;
58
+ }
59
+ }
app/code/community/Amasty/Review/Helper/Data.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Amasty.
4
+ */
5
+ class Amasty_Review_Helper_Data extends Mage_Core_Helper_Abstract
6
+ {
7
+ }
app/code/community/Amasty/Review/Model/Mysql4/Collection.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Amasty.
4
+ */
5
+ class Amasty_Review_Model_Mysql4_Collection extends Mage_Review_Model_Mysql4_Review_Product_Collection
6
+ {
7
+ // approved reviews plus visible in catalog products plus url revrites data
8
+ public function addVisiblityFilter()
9
+ {
10
+ $store = Mage::app()->getStore();
11
+
12
+ $this->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
13
+ ->addStoreFilter($store->getId())
14
+ ->addAttributeToSelect(array('name','visibility'), 'inner');
15
+
16
+ Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this);
17
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this);
18
+
19
+ $urCondions = array(
20
+ 'e.entity_id=ur.product_id',
21
+ 'ur.category_id IS NULL',
22
+ 'ur.store_id='.intVal($store->getId()),
23
+ 'ur.is_system=1'
24
+ );
25
+
26
+ $this->getSelect()->joinLeft(
27
+ array('ur' => $this->getTable('core/url_rewrite')),
28
+ join(' AND ', $urCondions),
29
+ array('url' => 'request_path')
30
+ );
31
+
32
+ return $this;
33
+ }
34
+
35
+ public function addRatingData()
36
+ {
37
+ $ratingTable = Mage::getSingleton('core/resource')->getTableName('rating/rating_option_vote');
38
+ $this->getSelect()
39
+ ->joinLeft(array('rat' => $ratingTable),
40
+ 'rat.review_id = rt.review_id',
41
+ array('av_rating' => new Zend_Db_Expr('AVG(rat.percent)')))
42
+ ->group('rt.review_id');
43
+
44
+ return $this;
45
+ }
46
+
47
+ }
app/code/community/Amasty/Review/etc/adminhtml.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
7
+ </all>
8
+ <admin>
9
+ <children>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <amreview translate="title" module="amreview">
15
+ <title>Reviews Sidebar</title>
16
+ </amreview>
17
+ </children>
18
+ </config>
19
+ </children>
20
+ </system>
21
+ </children>
22
+ </admin>
23
+ </resources>
24
+ </acl>
25
+ <translate>
26
+ <modules>
27
+ <Amasty_Review>
28
+ <files>
29
+ <default>Amasty_Review.csv</default>
30
+ </files>
31
+ </Amasty_Review>
32
+ </modules>
33
+ </translate>
34
+ </config>
app/code/community/Amasty/Review/etc/config.xml ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Amasty_Review>
5
+ <version>1.0.1</version>
6
+ </Amasty_Review>
7
+ </modules>
8
+ <adminhtml>
9
+ <acl>
10
+ <resources>
11
+ <all>
12
+ <title>Allow Everything</title>
13
+ </all>
14
+ <admin>
15
+ <children>
16
+ <system>
17
+ <children>
18
+ <config>
19
+ <children>
20
+ <amreview translate="title" module="amreview">
21
+ <title>Reviews Sidebar</title>
22
+ </amreview>
23
+ </children>
24
+ </config>
25
+ </children>
26
+ </system>
27
+ </children>
28
+ </admin>
29
+ </resources>
30
+ </acl>
31
+ <translate>
32
+ <modules>
33
+ <Amasty_Review>
34
+ <files>
35
+ <default>Amasty_Review.csv</default>
36
+ </files>
37
+ </Amasty_Review>
38
+ </modules>
39
+ </translate>
40
+ </adminhtml>
41
+ <frontend>
42
+ <translate>
43
+ <modules>
44
+ <Amasty_Review>
45
+ <files>
46
+ <default>Amasty_Review.csv</default>
47
+ </files>
48
+ </Amasty_Review>
49
+ </modules>
50
+ </translate>
51
+ <layout>
52
+ <updates>
53
+ <amreview>
54
+ <file>amreview.xml</file>
55
+ </amreview>
56
+ </updates>
57
+ </layout>
58
+ </frontend>
59
+ <global>
60
+ <models>
61
+ <amreview>
62
+ <class>Amasty_Review_Model</class>
63
+ <resourceModel>amreview_mysql4</resourceModel>
64
+ </amreview>
65
+ <amreview_mysql4>
66
+ <class>Amasty_Review_Model_Mysql4</class>
67
+ </amreview_mysql4>
68
+ </models>
69
+ <resources>
70
+ <amreview_setup>
71
+ <setup>
72
+ <module>Amasty_Review</module>
73
+ </setup>
74
+ <connection>
75
+ <use>core_setup</use>
76
+ </connection>
77
+ </amreview_setup>
78
+ <amreview_write>
79
+ <connection>
80
+ <use>core_write</use>
81
+ </connection>
82
+ </amreview_write>
83
+ <amreview_read>
84
+ <connection>
85
+ <use>core_read</use>
86
+ </connection>
87
+ </amreview_read>
88
+ </resources>
89
+ <blocks>
90
+ <amreview>
91
+ <class>Amasty_Review_Block</class>
92
+ </amreview>
93
+ </blocks>
94
+ <helpers>
95
+ <amreview>
96
+ <class>Amasty_Review_Helper</class>
97
+ </amreview>
98
+ </helpers>
99
+ </global>
100
+
101
+ <default>
102
+ <amreview>
103
+ <sidebar>
104
+ <active>1</active>
105
+ <by_date>1</by_date>
106
+ <count>5</count>
107
+ <max_words>30</max_words>
108
+ <show_stars>1</show_stars>
109
+ </sidebar>
110
+ </amreview>
111
+ </default>
112
+ </config>
app/code/community/Amasty/Review/etc/system.xml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <amreview translate="label" module="amreview">
5
+ <label>Reviews Sidebar</label>
6
+ <tab>amasty</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>888</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <sidebar translate="label">
14
+ <label>Reviews Sidebar</label>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>300</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <fields>
21
+ <active translate="label">
22
+ <label>Enabled</label>
23
+ <frontend_type>select</frontend_type>
24
+ <source_model>adminhtml/system_config_source_yesno</source_model>
25
+ <sort_order>10</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ </active>
30
+ <by_date translate="label">
31
+ <label>Order By Date</label>
32
+ <frontend_type>select</frontend_type>
33
+ <source_model>adminhtml/system_config_source_yesno</source_model>
34
+ <sort_order>20</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </by_date>
39
+ <count translate="label">
40
+ <label>Reviews Count</label>
41
+ <frontend_type>text</frontend_type>
42
+ <sort_order>30</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ </count>
47
+ <max_words translate="label">
48
+ <label>Words Count</label>
49
+ <frontend_type>text</frontend_type>
50
+ <sort_order>40</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ <comment><![CDATA[Set to zero to show full review text.]]></comment>
55
+ </max_words>
56
+ <show_stars translate="label">
57
+ <label>Display Rating Stars</label>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>adminhtml/system_config_source_yesno</source_model>
60
+ <sort_order>50</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>1</show_in_store>
64
+ </show_stars>
65
+ </fields>
66
+ </sidebar>
67
+ </groups>
68
+ </amreview>
69
+ </sections>
70
+ </config>
app/code/local/Amasty/Base/Block/Extensions.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2010 Amasty
4
+ */
5
+ class Amasty_Base_Block_Extensions extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
6
+ {
7
+ protected $_dummyElement;
8
+ protected $_fieldRenderer;
9
+ protected $_values;
10
+
11
+ public function render(Varien_Data_Form_Element_Abstract $element)
12
+ {
13
+ $html = $this->_getHeaderHtml($element);
14
+ $modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
15
+ sort($modules);
16
+
17
+ foreach ($modules as $moduleName) {
18
+ if (strstr($moduleName, 'Amasty_') === false) {
19
+ continue;
20
+ }
21
+
22
+ if ($moduleName == 'Amasty_Base'){
23
+ continue;
24
+ }
25
+
26
+ $html.= $this->_getFieldHtml($element, $moduleName);
27
+ }
28
+ $html .= $this->_getFooterHtml($element);
29
+
30
+ return $html;
31
+ }
32
+
33
+ protected function _getFieldRenderer()
34
+ {
35
+ if (empty($this->_fieldRenderer)) {
36
+ $this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
37
+ }
38
+ return $this->_fieldRenderer;
39
+ }
40
+
41
+ protected function _getFieldHtml($fieldset, $moduleCode)
42
+ {
43
+ $currentVer = Mage::getConfig()->getModuleConfig($moduleCode)->version;
44
+ if (!$currentVer)
45
+ return '';
46
+
47
+ $moduleName = substr($moduleCode, strpos($moduleCode, '_') + 1); // in case we have no data in the RSS
48
+
49
+ $allExtensions = unserialize(Mage::app()->loadCache('ambase_extensions'));
50
+
51
+ $status = '<a target="_blank"><img src="'.$this->getSkinUrl('images/ambase/ok.gif').'" title="'.$this->__("Installed").'"/></a>';
52
+
53
+ if ($allExtensions && isset($allExtensions[$moduleCode])){
54
+ $ext = $allExtensions[$moduleCode];
55
+
56
+ $url = $ext['url'];
57
+ $name = $ext['name'];
58
+ $lastVer = $ext['version'];
59
+
60
+ $moduleName = '<a href="'.$url.'" target="_blank" title="'.$name.'">'.$name."</a>";
61
+
62
+ if ($this->_convertVersion($currentVer) < $this->_convertVersion($lastVer)){
63
+ $status = '<a href="'.$url.'" target="_blank"><img src="'.$this->getSkinUrl('images/ambase/update.gif').'" alt="'.$this->__("Update available").'" title="'.$this->__("Update available").'"/></a>';
64
+ }
65
+ }
66
+
67
+ //TODO check if module output disabled in future
68
+
69
+ $moduleName = $status . ' ' . $moduleName;
70
+
71
+ $field = $fieldset->addField($moduleCode, 'label', array(
72
+ 'name' => 'dummy',
73
+ 'label' => $moduleName,
74
+ 'value' => $currentVer,
75
+ ))->setRenderer($this->_getFieldRenderer());
76
+
77
+ return $field->toHtml();
78
+ }
79
+
80
+ protected function _convertVersion($v)
81
+ {
82
+ $digits = @explode(".", $v);
83
+ $version = 0;
84
+ if (is_array($digits)){
85
+ foreach ($digits as $k=>$v){
86
+ $version += ($v * pow(10, max(0, (3-$k))));
87
+ }
88
+
89
+ }
90
+ return $version;
91
+ }
92
+ }
app/code/local/Amasty/Base/Helper/Data.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2010 Amasty (http://www.amasty.com)
4
+ */
5
+ class Amasty_Base_Helper_Data extends Mage_Core_Helper_Abstract
6
+ {
7
+ }
app/code/local/Amasty/Base/Model/Feed.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2010 Amasty (http://www.amasty.com)
4
+ */
5
+ class Amasty_Base_Model_Feed extends Mage_AdminNotification_Model_Feed
6
+ {
7
+ const XML_FREQUENCY_PATH = 'ambase/feed/check_frequency';
8
+ const XML_LAST_UPDATE_PATH = 'ambase/feed/last_update';
9
+ const XML_ITERESTS = 'ambase/feed/interests';
10
+
11
+ const URL_EXTENSIONS = 'http://amasty.com/feed-extensions.xml';
12
+ const URL_NEWS = 'http://amasty.com/feed-news.xml';
13
+
14
+
15
+ public static function check()
16
+ {
17
+ return Mage::getModel('ambase/feed')->checkUpdate();
18
+ }
19
+
20
+ public function checkUpdate()
21
+ {
22
+ if (($this->getFrequency() + $this->getLastUpdate()) > time()) {
23
+ return $this;
24
+ }
25
+ $this->setLastUpdate();
26
+
27
+ if (!extension_loaded('curl')) {
28
+ return $this;
29
+ }
30
+
31
+ // load all new and relevant updates into inbox
32
+ $feedData = array();
33
+ $feedXml = $this->getFeedData();
34
+ $wasInstalled = gmdate('Y-m-d H:i:s', Mage::getStoreConfig('ambase/feed/installed'));
35
+
36
+ if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
37
+ foreach ($feedXml->channel->item as $item) {
38
+ $date = $this->getDate((string)$item->pubDate);
39
+ // compare strings, but they are well-formmatted
40
+ if ($date < $wasInstalled)
41
+ continue;
42
+ if (!$this->isInteresting($item))
43
+ continue;
44
+
45
+ $feedData[] = array(
46
+ 'severity' => 3,
47
+ 'date_added' => $this->getDate($date),
48
+ 'title' => (string)$item->title,
49
+ 'description' => (string)$item->description,
50
+ 'url' => (string)$item->link,
51
+ );
52
+ }
53
+ if ($feedData) {
54
+ Mage::getModel('adminnotification/inbox')->parse($feedData);
55
+ }
56
+ }
57
+
58
+ //load all available extensions in the cache
59
+ $this->_feedUrl = self::URL_EXTENSIONS;
60
+ $feedData = array();
61
+ $feedXml = $this->getFeedData();
62
+ if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
63
+ foreach ($feedXml->channel->item as $item) {
64
+ $feedData[(string)$item->code] = array(
65
+ 'name' => (string)$item->title,
66
+ 'url' => (string)$item->link,
67
+ 'version' => (string)$item->version,
68
+ );
69
+ }
70
+ if ($feedData) {
71
+ Mage::app()->saveCache(serialize($feedData), 'ambase_extensions');
72
+ }
73
+ }
74
+
75
+ return $this;
76
+ }
77
+
78
+ public function getFrequency()
79
+ {
80
+ return Mage::getStoreConfig(self::XML_FREQUENCY_PATH);
81
+ }
82
+
83
+ public function getLastUpdate()
84
+ {
85
+ return Mage::app()->loadCache('ambase_notifications_lastcheck');
86
+ }
87
+
88
+ public function setLastUpdate()
89
+ {
90
+ Mage::app()->saveCache(time(), 'ambase_notifications_lastcheck');
91
+ return $this;
92
+ }
93
+
94
+ public function getFeedUrl()
95
+ {
96
+ if (is_null($this->_feedUrl)) {
97
+ $this->_feedUrl = self::URL_NEWS;
98
+ }
99
+ return $this->_feedUrl;
100
+ }
101
+
102
+ protected function getInterests()
103
+ {
104
+ return Mage::getStoreConfig(self::XML_FREQUENCY_PATH);
105
+ }
106
+
107
+ protected function isInteresting($item)
108
+ {
109
+ $interests = @explode(',', $this->getInterests());
110
+ $types = @explode(':', (string)$item->types);
111
+ $extenion = (string)$item->extension;
112
+
113
+ $selfUpgrades = array_search(Amasty_Base_Model_Source_Updates_Type::TYPE_INSTALLED_UPDATE, $types);
114
+
115
+ foreach ($types as $type){
116
+ if (array_search($type, $interests) !== false){
117
+ return true;
118
+ }
119
+
120
+ if ($extenion && ($type == Amasty_Base_Model_Source_Updates_Type::TYPE_UPDATE_RELEASE) && $selfUpgrades){
121
+ if ($this->isExtensionInstalled($extenion)){
122
+ return true;
123
+ }
124
+ }
125
+ }
126
+
127
+ return false;
128
+ }
129
+
130
+ protected function isExtensionInstalled($code)
131
+ {
132
+ $modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
133
+ foreach ($modules as $moduleName) {
134
+ if ($moduleName == $code){
135
+ return true;
136
+ }
137
+ }
138
+
139
+ return false;
140
+ }
141
+
142
+ }
app/code/local/Amasty/Base/Model/Source/Updates/Type.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2010 Amasty (http://www.amasty.com)
4
+ */
5
+ class Amasty_Base_Model_Source_Updates_Type extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
6
+ {
7
+ const TYPE_PROMO = 'PROMO';
8
+ const TYPE_NEW_RELEASE = 'NEW_RELEASE';
9
+ const TYPE_UPDATE_RELEASE = 'UPDATE_RELEASE';
10
+ const TYPE_INFO = 'INFO';
11
+ const TYPE_INSTALLED_UPDATE = 'INSTALLED_UPDATE';
12
+
13
+
14
+ public function toOptionArray()
15
+ {
16
+ $hlp = Mage::helper('ambase');
17
+ return array(
18
+ array('value' => self::TYPE_INSTALLED_UPDATE, 'label' => $hlp->__('My extensions updates')),
19
+ array('value' => self::TYPE_UPDATE_RELEASE, 'label' => $hlp->__('All extensions updates')),
20
+ array('value' => self::TYPE_NEW_RELEASE, 'label' => $hlp->__('New Releases')),
21
+ array('value' => self::TYPE_PROMO, 'label' => $hlp->__('Promotions/Discounts')),
22
+ array('value' => self::TYPE_INFO, 'label' => $hlp->__('Other information'))
23
+ );
24
+ }
25
+
26
+ /**
27
+ * Retrive all attribute options
28
+ *
29
+ * @return array
30
+ */
31
+ public function getAllOptions()
32
+ {
33
+ return $this->toOptionArray();
34
+ }
35
+
36
+
37
+ /**
38
+ * Returns label for value
39
+ * @param string $value
40
+ * @return string
41
+ */
42
+ public function getLabel($value)
43
+ {
44
+ $options = $this->toOptionArray();
45
+ foreach($options as $v){
46
+ if($v['value'] == $value){
47
+ return $v['label'];
48
+ }
49
+ }
50
+ return '';
51
+ }
52
+
53
+ /**
54
+ * Returns array ready for use by grid
55
+ * @return array
56
+ */
57
+ public function getGridOptions()
58
+ {
59
+ $items = $this->getAllOptions();
60
+ $out = array();
61
+ foreach($items as $item){
62
+ $out[$item['value']] = $item['label'];
63
+ }
64
+ return $out;
65
+ }
66
+ }
app/code/local/Amasty/Base/etc/adminhtml.xml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
7
+ </all>
8
+ <admin>
9
+ <children>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <ambase>
15
+ <title>Amasty - Extensions Information</title>
16
+ </ambase>
17
+ </children>
18
+ </config>
19
+ </children>
20
+ </system>
21
+ </children>
22
+ </admin>
23
+ </resources>
24
+ </acl>
25
+ <events>
26
+ <controller_action_predispatch>
27
+ <observers>
28
+ <ambase_upds>
29
+ <type>singleton</type>
30
+ <class>ambase/feed</class>
31
+ <method>check</method>
32
+ </ambase_upds>
33
+ </observers>
34
+ </controller_action_predispatch>
35
+ </events>
36
+ </config>
app/code/local/Amasty/Base/etc/config.xml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Amasty_Base>
5
+ <version>1.0.1</version>
6
+ <platform>ee</platform>
7
+ </Amasty_Base>
8
+ </modules>
9
+
10
+ <global>
11
+ <blocks>
12
+ <ambase>
13
+ <class>Amasty_Base_Block</class>
14
+ </ambase>
15
+ </blocks>
16
+ <resources>
17
+ <ambase_setup>
18
+ <setup>
19
+ <module>Amasty_Base</module>
20
+ </setup>
21
+ <connection>
22
+ <use>core_setup</use>
23
+ </connection>
24
+ </ambase_setup>
25
+ <ambase_write>
26
+ <connection>
27
+ <use>core_write</use>
28
+ </connection>
29
+ </ambase_write>
30
+ <ambase_read>
31
+ <connection>
32
+ <use>core_read</use>
33
+ </connection>
34
+ </ambase_read>
35
+ </resources>
36
+ <models>
37
+ <ambase>
38
+ <class>Amasty_Base_Model</class>
39
+ </ambase>
40
+ </models>
41
+ <helpers>
42
+ <ambase>
43
+ <class>Amasty_Base_Helper</class>
44
+ </ambase>
45
+ </helpers>
46
+ </global>
47
+
48
+ <adminhtml>
49
+ <acl>
50
+ <resources>
51
+ <all>
52
+ <title>Allow Everything</title>
53
+ </all>
54
+ <admin>
55
+ <children>
56
+ <system>
57
+ <children>
58
+ <config>
59
+ <children>
60
+ <ambase>
61
+ <title>Amasty - Extensions Information</title>
62
+ </ambase>
63
+ </children>
64
+ </config>
65
+ </children>
66
+ </system>
67
+ </children>
68
+ </admin>
69
+ </resources>
70
+ </acl>
71
+ <events>
72
+ <controller_action_predispatch>
73
+ <observers>
74
+ <ambase_upds>
75
+ <type>singleton</type>
76
+ <class>ambase/feed</class>
77
+ <method>check</method>
78
+ </ambase_upds>
79
+ </observers>
80
+ </controller_action_predispatch>
81
+ </events>
82
+ </adminhtml>
83
+ <default>
84
+ <ambase>
85
+ <feed>
86
+ <url>amasty.com/feed.xml</url>
87
+ <use_https>0</use_https>
88
+ <check_frequency>86400</check_frequency>
89
+ <enabled>1</enabled>
90
+ <interests>INFO,PROMO,UPDATE_RELEASE,NEW_RELEASE,INSTALLED_UPDATE</interests>
91
+ </feed>
92
+ </ambase>
93
+ </default>
94
+ </config>
app/code/local/Amasty/Base/etc/system.xml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <amasty translate="label" module="ambase">
5
+ <label>Amasty Extensions</label>
6
+ <sort_order>400</sort_order>
7
+ </amasty>
8
+ </tabs>
9
+ <sections>
10
+ <ambase translate="label" module="ambase">
11
+ <label>General</label>
12
+ <tab>amasty</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>777</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <extensions translate="label">
20
+ <label>Installed Extensions</label>
21
+ <frontend_type>text</frontend_type>
22
+ <frontend_model>ambase/extensions</frontend_model>
23
+ <sort_order>2</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ </extensions>
28
+ <feed>
29
+ <label>Notifications</label>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>90</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ <fields>
36
+ <interests translate="label">
37
+ <label>I'd like to be informed by Amasty about:</label>
38
+ <comment></comment>
39
+ <frontend_type>multiselect</frontend_type>
40
+ <sort_order>100</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ <can_be_empty>1</can_be_empty>
45
+ <source_model>ambase/source_updates_type</source_model>
46
+ </interests>
47
+ </fields>
48
+ </feed>
49
+ </groups>
50
+ </ambase>
51
+ </sections>
52
+ </config>
app/code/local/Amasty/Base/sql/ambase_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ $this->startSetup();
3
+ $this->endSetup();
app/code/local/Amasty/Base/sql/ambase_setup/mysql4-upgrade-1.0.0-1.0.1.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $this->startSetup();
3
+
4
+ Mage::getModel('core/config_data')
5
+ ->setScope('default')
6
+ ->setPath('ambase/feed/installed')
7
+ ->setValue(time())
8
+ ->save();
9
+
10
+ $feedData = array();
11
+ $feedData[] = array(
12
+ 'severity' => 3,
13
+ 'date_added' => gmdate('Y-m-d H:i:s', time()); ,
14
+ 'title' => 'Amasty\'s extension has been installed.',
15
+ 'description' => 'You can see versions of the installed extensions right in the admin, as well as configure notifications about major updates.',
16
+ 'url' => '#', // getModel('admin/url')->getUrl('config/ambase'),
17
+ );
18
+
19
+ Mage::getModel('adminnotification/inbox')->parse(($feedData));
20
+
21
+ $this->endSetup();
app/design/frontend/default/default/layout/amreview.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="right">
5
+ <block type="amreview/sidebar" name="amreview_sidebar"
6
+ template="amreview/sidebar.phtml"/>
7
+ </reference>
8
+ <!-- begin: comment this block if you use 3colunms template -->
9
+ <reference name="left">
10
+ <block type="amreview/sidebar" name="amreview_sidebar"
11
+ template="amreview/sidebar.phtml" />
12
+ </reference>
13
+ <!-- end -->
14
+ </default>
15
+ </layout>
app/design/frontend/default/default/template/amreview/sidebar.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $reviews = $this->getReviews() ?>
2
+ <?php if ($reviews && $reviews->count() > 0) : ?>
3
+ <div class="block block-review">
4
+ <div class="block-title">
5
+ <strong><span><?php echo $this->__("Product's Reviews") ?></span></strong>
6
+ </div>
7
+ <div class="block-content">
8
+ <?php foreach ($reviews as $review): ?>
9
+ <h5><a href="<?php echo $review->getUrl()?>"><?php echo $this->htmlEscape($review->getName())?></a></h5>
10
+ <?php echo $this->__('Review by %s', $this->htmlEscape($review->getNickname()))?>
11
+ <?php if (count($review->getRatingVotes())): ?>
12
+ <table class="ratings-list" cellspacing="0">
13
+ <tbody>
14
+ <?php foreach ($review->getRatingVotes() as $_vote): ?>
15
+ <tr>
16
+ <td class="label"><strong><?php echo $_vote->getRatingCode() ?></strong>:</td>
17
+ <td>
18
+ <div class="rating-box">
19
+ <div class="rating" style="width: <?php echo $_vote->getPercent() ?>%;"></div>
20
+ </div>
21
+ </td>
22
+ </tr>
23
+ <?php endforeach ?>
24
+ </tbody>
25
+ </table>
26
+ <?php else: ?>
27
+ <br />
28
+ <?php endif;?>
29
+ <strong><?php echo $this->htmlEscape($review->getTitle())?></strong>.<br/>
30
+ <?php echo $this->htmlEscape($review->getDetail())?>
31
+ <br />
32
+ <br />
33
+ <?php endforeach ?>
34
+ </div>
35
+ </div>
36
+ <?php endif ?>
app/etc/modules/Amasty_Base.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Amasty_Base>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Amasty_Base>
8
+ </modules>
9
+ </config>
app/etc/modules/Amasty_Review.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Amasty_Review>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Amasty_Review>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Reviews_Sidebar</name>
4
+ <version>1.0.4</version>
5
+ <stability>stable</stability>
6
+ <license>AFL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Reviews sidebar block</summary>
10
+ <description>Reviews sidebar block</description>
11
+ <notes>None</notes>
12
+ <authors><author><name>Amasty Team</name><user>auto-converted</user><email>amastysupport@gmail.com</email></author></authors>
13
+ <date>2011-03-04</date>
14
+ <time>14:21:19</time>
15
+ <contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="ambase"><file name="bad.gif" hash="b8379f1ba7ab552ca46b9d5fd0452345"/><file name="ok.gif" hash="a38bc2ee6e116e39c6e2e3013ee50f5e"/><file name="update.gif" hash="8342e11f7739fcfa25134707f0536ed6"/></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="Amasty"><dir name="Base"><dir name="Block"><file name="Extensions.php" hash="e0f76a6c0e9d3db6f634562cbb0266bc"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2134fcecc3d5cb639a2446dded0032d5"/><file name="config.xml" hash="aca36e496aac596ef0e5266961b71f16"/><file name="system.xml" hash="d7e5cda7d0b09152931039fdf1d4b2bc"/></dir><dir name="Helper"><file name="Data.php" hash="dd3a5d1f14acb20f3a86c43d50fe0dd4"/></dir><dir name="Model"><file name="Feed.php" hash="983c85338cd4e79c154c3672f1f6cfb7"/><dir name="Source"><dir name="Updates"><file name="Type.php" hash="dbb958c4aa01c61578cfb22a1c88a482"/></dir></dir></dir><dir name="sql"><dir name="ambase_setup"><file name="mysql4-install-1.0.0.php" hash="ba30c778afd0f4a959ec9f86d439ea0a"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="2c6e57b799da65393e07e8f9fe77f21b"/></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Amasty"><dir name="Review"><dir name="Block"><file name="Sidebar.php" hash="728917213d55a4e0878a1adf7560beda"/></dir><dir name="etc"><file name="adminhtml.xml" hash="95bdba467b5adbf7920b239fc0e1a003"/><file name="config.xml" hash="36092860f0272d1b84ad25a58e6f441e"/><file name="system.xml" hash="9416b00448bcd2e251196088b3175e4e"/></dir><dir name="Helper"><file name="Data.php" hash="e21dbd2eb8bbbb330f01d9f1c0c6785a"/></dir><dir name="Model"><dir name="Mysql4"><file name="Collection.php" hash="92d8ff7b807bf3fc9aa23be784dc7414"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="amreview.xml" hash="bb51db7e5319681cbcdb30818cafb9d1"/></dir><dir name="template"><dir name="amreview"><file name="sidebar.phtml" hash="59fa56389faa85d68468caa7351f7cf8"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Amasty_Base.xml" hash="651f99cee7568ab645fdef118f7933ca"/><file name="Amasty_Review.xml" hash="84f047ff01bce56c789217157cdcfd53"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>
skin/adminhtml/default/default/images/ambase/bad.gif ADDED
Binary file
skin/adminhtml/default/default/images/ambase/ok.gif ADDED
Binary file
skin/adminhtml/default/default/images/ambase/update.gif ADDED
Binary file