Eadesigndev_Shipestimation - Version 1.0.3

Version Notes

Added the EaCore System for the module.

Download this release

Release Info

Developer EaDesign
Extension Eadesigndev_Shipestimation
Version 1.0.3
Comparing to
See all releases


Code changes from version 1.0.2 to 1.0.3

app/code/local/Eadesigndev/Shipestimation/Model/Eacore/Feed.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ Class Eadesigndev_Shipestimation_Model_Eacore_Feed extends Mage_AdminNotification_Model_Feed
4
+ {
5
+
6
+ protected $eadesignUrl;
7
+
8
+ public function checkUpdate()
9
+ {
10
+
11
+ if (($this->getFrequency() + $this->getLastUpdate()) > time()) {
12
+ return $this;
13
+ }
14
+
15
+ $this->getClientData();
16
+ $feedData = array();
17
+
18
+ $feedXml = $this->getFeedData();
19
+
20
+ if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
21
+ foreach ($feedXml->channel->item as $item) {
22
+ $feedData[] = array(
23
+ 'severity' => (int)$item->severity,
24
+ 'date_added' => $this->getDate((string)$item->pubDate),
25
+ 'title' => (string)$item->title,
26
+ 'description' => (string)$item->description,
27
+ 'url' => (string)$item->link,
28
+ );
29
+ }
30
+
31
+
32
+ if ($feedData) {
33
+ Mage::getModel('adminnotification/inbox')->parse(array_reverse($feedData));
34
+ }
35
+
36
+ }
37
+
38
+ $this->setLastUpdate();
39
+
40
+ return $this;
41
+ }
42
+
43
+
44
+ /**
45
+ * Retrieve Last update time
46
+ *
47
+ * @return int
48
+ */
49
+ public function getLastUpdate()
50
+ {
51
+ return Mage::app()->loadCache('eadesign_lastcheck');
52
+ }
53
+
54
+ /**
55
+ * Set last update time (now)
56
+ *
57
+ * @return Mage_AdminNotification_Model_Feed
58
+ */
59
+ public function setLastUpdate()
60
+ {
61
+ Mage::app()->saveCache(time(), 'eadesign_lastcheck');
62
+ return $this;
63
+ }
64
+
65
+ public function getFeedUrl()
66
+ {
67
+ if (is_null($this->eadesignUrl)) {
68
+ $this->eadesignUrl = 'https://www.eadesign.ro/notifications.rss';
69
+ }
70
+ return $this->eadesignUrl;
71
+ }
72
+
73
+
74
+ public function getFeedData()
75
+ {
76
+ $curl = new Varien_Http_Adapter_Curl();
77
+ $curl->setConfig(array(
78
+ 'timeout' => 3
79
+ ));
80
+
81
+ $curl->write(Zend_Http_Client::GET, $this->getFeedUrl(), '1.0');
82
+ $data = $curl->read();
83
+ if ($data === false) {
84
+ return false;
85
+ }
86
+ $data = preg_split('/^\r?$/m', $data, 2);
87
+ $data = trim($data[1]);
88
+ $curl->close();
89
+
90
+ try {
91
+ $xml = new SimpleXMLElement($data);
92
+ } catch (Exception $e) {
93
+ return false;
94
+ }
95
+
96
+ return $xml;
97
+ }
98
+
99
+ public function getClientData()
100
+ {
101
+ $eadesignUrl = 'https://www.eadesign.ro/';
102
+
103
+ $extension = 'Eadesigndev_Shipestimation';
104
+
105
+ $moduleVersion = Mage::getConfig()->getModuleConfig($extension)->version;
106
+
107
+ $baseUrl = 'track/index/update?url=' . Mage::getBaseUrl();
108
+ $version = '&version=' . $moduleVersion;
109
+ $moduleExtension = '&extension='.$extension;
110
+
111
+ $url = $eadesignUrl.$baseUrl.$version.$moduleExtension;
112
+
113
+ $curl = new Varien_Http_Adapter_Curl();
114
+ $curl->setConfig(array(
115
+ 'timeout' => 3
116
+ ));
117
+
118
+ $curl->write(Zend_Http_Client::GET, $url, '1.0');
119
+ $curl->read();
120
+ $curl->close();
121
+ }
122
+
123
+ }
app/code/local/Eadesigndev/Shipestimation/Model/Eacore/Observer.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Eadesigndev_Shipestimation_Model_Eacore_Observer
3
+ {
4
+ public function preDispatch(Varien_Event_Observer $observer)
5
+ {
6
+ if (Mage::getSingleton('admin/session')->isLoggedIn()) {
7
+
8
+ $feedModel = Mage::getModel('shipestimation/eacore_feed');
9
+
10
+ $feedModel->checkUpdate();
11
+ }
12
+ }
13
+ }
app/code/local/Eadesigndev/Shipestimation/etc/config.xml CHANGED
@@ -22,7 +22,7 @@
22
  <config>
23
  <modules>
24
  <Eadesigndev_Shipestimation>
25
- <version>1.0.2</version>
26
  </Eadesigndev_Shipestimation>
27
  </modules>
28
  <global>
@@ -62,6 +62,16 @@
62
  </admin>
63
  </resources>
64
  </acl>
 
 
 
 
 
 
 
 
 
 
65
  </adminhtml>
66
  <frontend>
67
  <layout>
22
  <config>
23
  <modules>
24
  <Eadesigndev_Shipestimation>
25
+ <version>1.0.3</version>
26
  </Eadesigndev_Shipestimation>
27
  </modules>
28
  <global>
62
  </admin>
63
  </resources>
64
  </acl>
65
+ <events>
66
+ <controller_action_predispatch>
67
+ <observers>
68
+ <eadesigndev_shipestimation>
69
+ <class>shipestimation/eacore_observer</class>
70
+ <method>preDispatch</method>
71
+ </eadesigndev_shipestimation>
72
+ </observers>
73
+ </controller_action_predispatch>
74
+ </events>
75
  </adminhtml>
76
  <frontend>
77
  <layout>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Eadesigndev_Shipestimation</name>
4
- <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Extension license name (OSL v3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Estimate shipping</summary>
10
  <description>The extension get the estimated cost for shipping for country, regions and postal code.</description>
11
- <notes>Add city input</notes>
12
  <authors><author><name>EaDesign</name><user>eadesign</user><email>office@eadesign.ro</email></author></authors>
13
- <date>2015-10-14</date>
14
- <time>13:15:34</time>
15
- <contents><target name="magelocal"><dir name="Eadesigndev"><dir name="Shipestimation"><dir name="Helper"><file name="Data.php" hash="5dae9c8cd88a46cb9d35f72661426df8"/></dir><dir name="controllers"><file name="IndexController.php" hash="49a3a38ac55e51b3f74336fb034d2425"/></dir><dir name="etc"><file name="config.xml" hash="bffdda65bae5a07a90b4f4c1132b2547"/><file name="system.xml" hash="21a5b1618a36b44d9401b6cd4927adc9"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="eadesigndev"><dir name="shipestimation"><dir name="catalog"><dir name="product"><dir name="view"><file name="estimate.phtml" hash="f5670c33b963e0e62f79d15af2901a96"/></dir></dir></dir><file name="shipestimation.phtml" hash="814331439e53749ddb2105bcfd4dde0a"/></dir></dir></dir><dir name="layout"><dir name="eadesigndev"><file name="shipestimation.xml" hash="9a77c641f4c4fe5d925ee5cbb777ce9a"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="layout"><dir name="eadesigndev"><file name="shipestimation.xml" hash="9a77c641f4c4fe5d925ee5cbb777ce9a"/></dir></dir><dir name="template"><dir name="eadesigndev"><dir name="shipestimation"><dir name="catalog"><dir name="product"><dir name="view"><file name="estimate.phtml" hash="f5670c33b963e0e62f79d15af2901a96"/></dir></dir></dir><file name="shipestimation.phtml" hash="814331439e53749ddb2105bcfd4dde0a"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="eadesigndev"><dir name="shipestimation"><file name="71222.png" hash="f596a4fd67aa4a6eccc019c1722fa3cb"/><file name="bkg_main2.gif" hash="cf18ba9f7c7e6b058b439cde1a897e9c"/><dir name="css"><file name="default.css" hash="ab3bb2025895a50924d6b924cf2240c4"/></dir></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="eadesigndev"><dir name="shipestimation"><file name="71222.png" hash="f596a4fd67aa4a6eccc019c1722fa3cb"/><file name="bkg_main2.gif" hash="cf18ba9f7c7e6b058b439cde1a897e9c"/><dir name="css"><file name="default.css" hash="15fe12fc16d486c9f26096fb644d1d73"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Eadesigndev_Shipestimation.xml" hash="e9c7ced8afd9a27b5917d269c354726a"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>5.6.3</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Eadesigndev_Shipestimation</name>
4
+ <version>1.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Extension license name (OSL v3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Estimate shipping</summary>
10
  <description>The extension get the estimated cost for shipping for country, regions and postal code.</description>
11
+ <notes>Added the EaCore System for the module.</notes>
12
  <authors><author><name>EaDesign</name><user>eadesign</user><email>office@eadesign.ro</email></author></authors>
13
+ <date>2015-10-19</date>
14
+ <time>09:14:45</time>
15
+ <contents><target name="magelocal"><dir name="Eadesigndev"><dir name="Shipestimation"><dir name="Helper"><file name="Data.php" hash="5dae9c8cd88a46cb9d35f72661426df8"/></dir><dir name="Model"><dir name="Eacore"><file name="Feed.php" hash="f4be52365e1173668ab4f2564cb12b17"/><file name="Observer.php" hash="9866c8c8344a83f5c32066d41aec6e03"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="49a3a38ac55e51b3f74336fb034d2425"/></dir><dir name="etc"><file name="config.xml" hash="65941125e76022df743c5d9fc6b76b57"/><file name="system.xml" hash="21a5b1618a36b44d9401b6cd4927adc9"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="eadesigndev"><dir name="shipestimation"><dir name="catalog"><dir name="product"><dir name="view"><file name="estimate.phtml" hash="f5670c33b963e0e62f79d15af2901a96"/></dir></dir></dir><file name="shipestimation.phtml" hash="814331439e53749ddb2105bcfd4dde0a"/></dir></dir></dir><dir name="layout"><dir name="eadesigndev"><file name="shipestimation.xml" hash="9a77c641f4c4fe5d925ee5cbb777ce9a"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="layout"><dir name="eadesigndev"><file name="shipestimation.xml" hash="9a77c641f4c4fe5d925ee5cbb777ce9a"/></dir></dir><dir name="template"><dir name="eadesigndev"><dir name="shipestimation"><dir name="catalog"><dir name="product"><dir name="view"><file name="estimate.phtml" hash="f5670c33b963e0e62f79d15af2901a96"/></dir></dir></dir><file name="shipestimation.phtml" hash="814331439e53749ddb2105bcfd4dde0a"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="eadesigndev"><dir name="shipestimation"><file name="71222.png" hash="f596a4fd67aa4a6eccc019c1722fa3cb"/><file name="bkg_main2.gif" hash="cf18ba9f7c7e6b058b439cde1a897e9c"/><dir name="css"><file name="default.css" hash="ab3bb2025895a50924d6b924cf2240c4"/></dir></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="eadesigndev"><dir name="shipestimation"><file name="71222.png" hash="f596a4fd67aa4a6eccc019c1722fa3cb"/><file name="bkg_main2.gif" hash="cf18ba9f7c7e6b058b439cde1a897e9c"/><dir name="css"><file name="default.css" hash="15fe12fc16d486c9f26096fb644d1d73"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Eadesigndev_Shipestimation.xml" hash="e9c7ced8afd9a27b5917d269c354726a"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>5.6.3</max></php></required></dependencies>
18
  </package>