celtic_gauniversal - Version 1.0.1

Version Notes

1.0.1 : add unpackaged file
1.0.0 : first release

Download this release

Release Info

Developer Hirokazu Nishi
Extension celtic_gauniversal
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/code/community/Celtic/Gauniversal/Model/Observer.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Celtic_Gauniversal_Model_Observer
3
+ {
4
+ public function onCheckoutSuccess(Varien_Event_Observer $ob)
5
+ {
6
+ $orderIds = $ob->getEvent()->getData('order_ids');
7
+
8
+ if ($orderIds) {
9
+ /* @var $layout Mage_Core_Model_Layout */
10
+ $layout = Mage::getSingleton('core/layout');
11
+ $tagBlock = $layout->getBlock('celticga_ecommerce');
12
+ if ($tagBlock) {
13
+ $tagBlock->setOrderIds($orderIds);
14
+ }
15
+ }
16
+ }
17
+
18
+ public function generateFile(Varien_Event_Observer $observer){
19
+ $file = $observer->getEvent()->getFile();
20
+ $fileNames = $this->_getFilePath($file);
21
+
22
+ foreach($fileNames as $_file) {
23
+ if(!file_exists(dirname($_file))) {
24
+ mkdir(dirname($_file), 0777, true);
25
+ }
26
+
27
+ if(!$file->getIsActive()) {
28
+ //remove file if the file is inactivated.
29
+ $this->removeFile($observer);
30
+ } else {
31
+ if($fp = fopen($_file, "w")) {
32
+ fwrite($fp, $file->getContents());
33
+ fclose($fp);
34
+ }
35
+ }
36
+ }
37
+
38
+ return $this;
39
+ }
40
+
41
+ public function removeFile(Varien_Event_Observer $observer){
42
+ $file = $observer->getEvent()->getFile();
43
+ $fileNames = $this->_getFilePath($file);
44
+
45
+ foreach($fileNames as $_file) {
46
+ if(file_exists($_file)) {
47
+ unlink($_file);
48
+ }
49
+ }
50
+ return $this;
51
+ }
52
+
53
+ /**
54
+ * Remove old file if the file name and store view were changed.
55
+ *
56
+ * @param $observer
57
+ * @return $this
58
+ */
59
+ public function removeOldFile($observer)
60
+ {
61
+ $curFile = $observer->getEvent()->getFile();
62
+ $oldFile = Mage::getModel('csseditor/css')->load($curFile->getId());
63
+
64
+ if(!$oldFile->getId())
65
+ {
66
+ return;
67
+ }
68
+
69
+ if(($oldFile->getFileName . $oldFile->getFileType()) != ($curFile->getFileName . $curFile->getFileType())) {
70
+ $this->_removeOldNameFile($oldFile);
71
+ }
72
+
73
+ $oldStores = explode(',', $oldFile->getStoreIds());
74
+ $curStores = explode(',', $curFile->getStoreIds());
75
+
76
+ foreach($oldStores as $old) {
77
+ if(!in_array($old, $curStores)) {
78
+ $this->_removeUnselectedStoreViewFile($oldFile, $old);
79
+ }
80
+ }
81
+
82
+ return $this;
83
+ }
84
+
85
+ protected function _removeOldNameFile($file)
86
+ {
87
+ $fileNames = $this->_getFilePath($file);
88
+
89
+ foreach ($fileNames as $_file) {
90
+ if(file_exists($_file)) {
91
+ unlink($_file);
92
+ }
93
+ }
94
+ }
95
+
96
+ protected function _removeUnselectedStoreViewFile($oldFile, $diff)
97
+ {
98
+ //foreach($diffs as $_diff) {
99
+ $_file = $this->_getFilePath($oldFile, $diff);
100
+
101
+ if(file_exists($_file)) {
102
+ $res = unlink($_file);
103
+ }
104
+ //}
105
+ }
106
+
107
+ protected function _getFilePath($file, $storeId=null)
108
+ {
109
+ if($storeId != null) {
110
+ return Mage::getBaseDir('media') . DS . "celticga" . DS . $file->getPackageTheme() . DS . $storeId . DS . $file->getFileName() . $file->getFileType();
111
+ } else {
112
+ $_files = array();
113
+ $_stores = explode(',', $file->getStoreIds());
114
+ foreach ($_stores as $_store) {
115
+ $_files[] = Mage::getBaseDir('media') . DS . "celticga" . DS . $file->getPackageTheme() . DS . $_store . DS . $file->getFileName() . $file->getFileType();
116
+ }
117
+ return $_files;
118
+ }
119
+ }
120
+ }
app/code/community/Celtic/Gauniversal/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Celtic_Gauniversal>
5
- <version>1.0.0</version>
6
  </Celtic_Gauniversal>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <Celtic_Gauniversal>
5
+ <version>1.0.1</version>
6
  </Celtic_Gauniversal>
7
  </modules>
8
  <global>
package.xml CHANGED
@@ -1,18 +1,19 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>celtic_gauniversal</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license>OSL V3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Insert Google Universal Analytics tracking codes into your Magento</summary>
10
  <description>Insert Google Universal Analytics tracking codes into your Magento</description>
11
- <notes>1.0.0 : first release</notes>
 
12
  <authors><author><name>Hirokazu Nishi</name><user>hirokazu_n</user><email>nishi@principle-works.jp</email></author></authors>
13
- <date>2014-03-06</date>
14
- <time>04:54:06</time>
15
- <contents><target name="magecommunity"><dir name="Celtic"><dir name="Gauniversal"><dir name="Block"><file name="Ecommerce.php" hash="911e7973f46f1a65dd092f7a57a56ef4"/><file name="Tag.php" hash="c835727cd006103bc17d364686b93b4e"/></dir><dir name="Helper"><file name="Data.php" hash="bb5efc36937fcbaf07f20df7da38a3a4"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f4c2465ba095f4dad3b1d45160a7bb4b"/><file name="config.xml" hash="3b22e0dd25bed3f2e519a87d192ed471"/><file name="system.xml" hash="b93ad4e67ac2c31e5ca9b9f56d0a5982"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="celtic_gauniversal.xml" hash="84b11a6dd633719e7515644323c6e709"/></dir><dir name="template"><dir name="celtic_gauniversal"><file name="ecommerce.phtml" hash="de44f56d6f5040b4cd2dbf5bb6387017"/><file name="tag.phtml" hash="123a9b7f11f05bc93e21662baa9d0d8b"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="ja_JP"><file name="Celtic_Gauniversal.csv" hash="00d07d45067f7abef43a72745d470754"/></dir></target><target name="mageetc"><dir name="modules"><file name="Celtic_Gauniversal.xml" hash="3e9b9db09f64cc403666852c98b14714"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>5.5.99</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>celtic_gauniversal</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license>OSL V3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Insert Google Universal Analytics tracking codes into your Magento</summary>
10
  <description>Insert Google Universal Analytics tracking codes into your Magento</description>
11
+ <notes>1.0.1 : add unpackaged file&#xD;
12
+ 1.0.0 : first release</notes>
13
  <authors><author><name>Hirokazu Nishi</name><user>hirokazu_n</user><email>nishi@principle-works.jp</email></author></authors>
14
+ <date>2014-03-11</date>
15
+ <time>08:52:36</time>
16
+ <contents><target name="magecommunity"><dir name="Celtic"><dir name="Gauniversal"><dir name="Block"><file name="Ecommerce.php" hash="911e7973f46f1a65dd092f7a57a56ef4"/><file name="Tag.php" hash="c835727cd006103bc17d364686b93b4e"/></dir><dir name="Helper"><file name="Data.php" hash="bb5efc36937fcbaf07f20df7da38a3a4"/></dir><dir name="Model"><file name="Observer.php" hash="2bf4b3a349eafb7333cc94383bfc8148"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f4c2465ba095f4dad3b1d45160a7bb4b"/><file name="config.xml" hash="76a3ae41398a55d6362f84e228ed0bb8"/><file name="system.xml" hash="b93ad4e67ac2c31e5ca9b9f56d0a5982"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="celtic_gauniversal.xml" hash="84b11a6dd633719e7515644323c6e709"/></dir><dir name="template"><dir name="celtic_gauniversal"><file name="ecommerce.phtml" hash="de44f56d6f5040b4cd2dbf5bb6387017"/><file name="tag.phtml" hash="123a9b7f11f05bc93e21662baa9d0d8b"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="ja_JP"><file name="Celtic_Gauniversal.csv" hash="00d07d45067f7abef43a72745d470754"/></dir></target><target name="mageetc"><dir name="modules"><file name="Celtic_Gauniversal.xml" hash="3e9b9db09f64cc403666852c98b14714"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.2.0</min><max>5.5.99</max></php></required></dependencies>
19
  </package>