Yireo_EmailOverride - Version 0.2.1

Version Notes

No notes

Download this release

Release Info

Developer Yireo
Extension Yireo_EmailOverride
Version 0.2.1
Comparing to
See all releases


Code changes from version 0.1.5 to 0.2.1

app/code/community/Yireo/EmailOverride/Helper/Data.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @package Yireo_EmailOverride
6
  * @author Yireo (http://www.yireo.com/)
7
- * @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
@@ -13,4 +13,77 @@
13
  */
14
  class Yireo_EmailOverride_Helper_Data extends Mage_Core_Helper_Abstract
15
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  }
4
  *
5
  * @package Yireo_EmailOverride
6
  * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
13
  */
14
  class Yireo_EmailOverride_Helper_Data extends Mage_Core_Helper_Abstract
15
  {
16
+ public function getLocaleOverrideFile($localeCode, $fileName, $store = null)
17
+ {
18
+ $paths = $this->getLocalePaths($store);
19
+ foreach($paths as $path) {
20
+ $filePath = $path.DS.$localeCode.DS.$fileName;
21
+ if (!empty($filePath) && file_exists($filePath)) {
22
+ return $filePath;
23
+ }
24
+ }
25
+ }
26
+
27
+ public function getLocalePaths($store = null)
28
+ {
29
+ $paths = array();
30
+
31
+ $design = $this->getDesign($store);
32
+ $paths[] = Mage::getBaseDir('design').DS.'frontend'.DS.$design['package'].DS.$design['theme'].DS.'locale';
33
+
34
+ $fallbackSchemes = Mage::getModel('core/design_fallback')->getFallbackScheme('frontend', $design['package'], $design['theme']);
35
+ if(!empty($fallbackSchemes)) {
36
+ foreach($fallbackSchemes as $scheme) {
37
+ if(!isset($scheme['_package']) || !isset($scheme['_theme'])) continue;
38
+ $paths[] = Mage::getBaseDir('design').DS.'frontend'.DS.$scheme['_package'].DS.$scheme['_theme'].DS.'locale';
39
+ }
40
+ }
41
+
42
+ $paths[] = Mage::getBaseDir('design').DS.'frontend'.DS.$design['package'].DS.'default'.DS.'locale';
43
+ $paths[] = Mage::getBaseDir('design').DS.'frontend'.DS.'default'.DS.'default'.DS.'locale';
44
+ $paths[] = Mage::getBaseDir('design').DS.'frontend'.DS.'base'.DS.'default'.DS.'locale';
45
+ $paths[] = Mage::getBaseDir('locale');
46
+
47
+ return $paths;
48
+ }
49
+
50
+ public function getDesign($store = null)
51
+ {
52
+ if(empty($store)) {
53
+ $store = Mage::registry('emailoverride.store');
54
+ }
55
+
56
+ $packageName = null;
57
+ $theme = null;
58
+
59
+ if (Mage::app()->getStore()->isAdmin() == false) {
60
+ $package = Mage::getSingleton('core/design_package');
61
+ $originalArea = $package->getArea();
62
+ $originalStore = $package->getStore();
63
+
64
+ if(!empty($store)) $package->setStore($store);
65
+ $package->setArea('frontend');
66
+ $packageName = $package->getPackageName();
67
+ $theme = $package->getTheme('default');
68
+
69
+ $package->setArea($originalArea);
70
+ $package->setStore($originalStore);
71
+ }
72
+
73
+ if(empty($packageName) || in_array($theme, array('base', 'default'))) {
74
+ $packageName = Mage::getStoreConfig('design/package/name', $store);
75
+ }
76
+
77
+ if(empty($theme) || in_array($theme, array('default'))) {
78
+ $theme = Mage::getStoreConfig('design/theme/locale', $store);
79
+ }
80
+
81
+ if(empty($packageName)) $packageName = 'default';
82
+ if(empty($theme)) $theme = 'default';
83
+
84
+ return array(
85
+ 'package' => $packageName,
86
+ 'theme' => $theme,
87
+ );
88
+ }
89
  }
app/code/community/Yireo/EmailOverride/Model/Email/Template.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @package Yireo_EmailOverride
6
  * @author Yireo (http://www.yireo.com/)
7
- * @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
@@ -16,7 +16,10 @@ class Yireo_EmailOverride_Model_Email_Template extends Mage_Core_Model_Email_Tem
16
  public function setDesignConfig(array $config)
17
  {
18
  if(isset($config['store'])) {
19
- Mage::register('emailoverride.store', $config['store'], true);
 
 
 
20
  }
21
  return parent::setDesignConfig($config);
22
  }
4
  *
5
  * @package Yireo_EmailOverride
6
  * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
16
  public function setDesignConfig(array $config)
17
  {
18
  if(isset($config['store'])) {
19
+ $store = Mage::registry('emailoverride.store');
20
+ if(empty($store)) {
21
+ Mage::register('emailoverride.store', $config['store'], true);
22
+ }
23
  }
24
  return parent::setDesignConfig($config);
25
  }
app/code/community/Yireo/EmailOverride/Model/Translate.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @package Yireo_EmailOverride
6
  * @author Yireo (http://www.yireo.com/)
7
- * @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
@@ -30,7 +30,7 @@ class Yireo_EmailOverride_Model_Translate extends Mage_Core_Model_Translate
30
  return parent::_getModuleFilePath($module, $fileName);
31
  }
32
 
33
- $filePath = $this->getLocaleOverrideFolder().DS.$localeCode.DS.$fileName;
34
  if (!empty($filePath) && file_exists($filePath)) {
35
  return $filePath;
36
  }
@@ -53,7 +53,7 @@ class Yireo_EmailOverride_Model_Translate extends Mage_Core_Model_Translate
53
  $localeCode = $this->getLocale();
54
  }
55
 
56
- $filePath = $this->getLocaleOverrideFolder().DS.$localeCode.DS.'template'.DS.$type.DS.$file;
57
  if (!empty($filePath) && !file_exists($filePath)) {
58
  return parent::getTemplateFile($file, $type, $localeCode);
59
  }
@@ -70,43 +70,14 @@ class Yireo_EmailOverride_Model_Translate extends Mage_Core_Model_Translate
70
  * @param null
71
  * @return string
72
  */
73
- protected function getLocaleOverrideFolder()
74
  {
75
- $store = $store = Mage::registry('emailoverride.store');
76
  if(!empty($this->_config['store'])) {
77
  $store = $this->_config['store'];
78
  }
79
 
80
- $packageName = null;
81
- $theme = null;
82
-
83
- if (Mage::app()->getStore()->isAdmin() == false) {
84
- $package = Mage::getSingleton('core/design_package');
85
- $originalArea = $package->getArea();
86
- $originalStore = $package->getStore();
87
-
88
- if(!empty($store)) $package->setStore($store);
89
- $package->setArea('frontend');
90
- $packageName = $package->getPackageName();
91
- $theme = $package->getTheme('default');
92
-
93
- $package->setArea($originalArea);
94
- $package->setStore($originalStore);
95
- }
96
-
97
- if(empty($packageName) || in_array($theme, array('base', 'default'))) {
98
- $packageName = Mage::getStoreConfig('design/package/name', $store);
99
- }
100
-
101
- if(empty($theme) || in_array($theme, array('default'))) {
102
- $theme = Mage::getStoreConfig('design/theme/locale', $store);
103
- }
104
-
105
- if(empty($packageName)) $packageName = 'default';
106
- if(empty($theme)) $theme = 'default';
107
-
108
- $folder = Mage::getBaseDir('design').DS.'frontend'.DS.$packageName.DS.$theme.DS.'locale';
109
- return $folder;
110
  }
111
 
112
  /**
4
  *
5
  * @package Yireo_EmailOverride
6
  * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
30
  return parent::_getModuleFilePath($module, $fileName);
31
  }
32
 
33
+ $filePath = $this->getLocaleOverrideFile($localeCode, $fileName);
34
  if (!empty($filePath) && file_exists($filePath)) {
35
  return $filePath;
36
  }
53
  $localeCode = $this->getLocale();
54
  }
55
 
56
+ $filePath = $this->getLocaleOverrideFile($localeCode, 'template'.DS.$type.DS.$file);
57
  if (!empty($filePath) && !file_exists($filePath)) {
58
  return parent::getTemplateFile($file, $type, $localeCode);
59
  }
70
  * @param null
71
  * @return string
72
  */
73
+ protected function getLocaleOverrideFile($localeCode, $fileName)
74
  {
75
+ $store = null;
76
  if(!empty($this->_config['store'])) {
77
  $store = $this->_config['store'];
78
  }
79
 
80
+ return Mage::helper('emailoverride')->getLocaleOverrideFile($localeCode, $fileName, $store);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  }
82
 
83
  /**
app/code/community/Yireo/EmailOverride/etc/config.xml CHANGED
@@ -5,7 +5,7 @@
5
  *
6
  * @package Yireo_EmailOverride
7
  * @author Yireo (http://www.yireo.com/)
8
- * @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
9
  * @license Open Source License (OSL v3)
10
  */
11
  -->
@@ -13,7 +13,7 @@
13
 
14
  <modules>
15
  <Yireo_EmailOverride>
16
- <version>0.1.5</version>
17
  </Yireo_EmailOverride>
18
  </modules>
19
 
5
  *
6
  * @package Yireo_EmailOverride
7
  * @author Yireo (http://www.yireo.com/)
8
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
9
  * @license Open Source License (OSL v3)
10
  */
11
  -->
13
 
14
  <modules>
15
  <Yireo_EmailOverride>
16
+ <version>0.2.1</version>
17
  </Yireo_EmailOverride>
18
  </modules>
19
 
app/etc/modules/Yireo_EmailOverride.xml CHANGED
@@ -5,7 +5,7 @@
5
  *
6
  * @package Yireo_EmailOverride
7
  * @author Yireo (http://www.yireo.com/)
8
- * @copyright Copyright (c) 2014 Yireo (http://www.yireo.com/)
9
  * @license Open Software License
10
  */
11
  -->
5
  *
6
  * @package Yireo_EmailOverride
7
  * @author Yireo (http://www.yireo.com/)
8
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
9
  * @license Open Software License
10
  */
11
  -->
package.xml CHANGED
@@ -1,2 +1,2 @@
1
  <?xml version="1.0"?>
2
- <package><name>Yireo_EmailOverride</name><version>0.1.5</version><stability>stable</stability><license>Open Source License</license><channel>community</channel><extends></extends><summary>No summary</summary><description>No description</description><notes>No notes</notes><authors><author><name>Yireo</name><user>yireo</user><email>info@yireo.com</email></author></authors><date>2014-10-03</date><time>0:15:00</time><compatible></compatible><dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Yireo_EmailOverride.xml" hash="f45e6e7848fb03cc0e0a4daacf143730"/></dir></dir><dir name="code"><dir name="community"><dir name="Yireo"><dir name="EmailOverride"><dir name="etc"><file name="config.xml" hash="b04bab533360c57eda5adb9bdb2b1b9b"/></dir><dir name="Model"><file name="Translate.php" hash="07367a58ba54c3ef860bffc23fcde917"/><dir name="Email"><file name="Template.php" hash="112e7303d1036465068a5addc0c0d742"/></dir></dir><dir name="Helper"><file name="Data.php" hash="ccacf536debc24d770ca559ab2b62a14"/></dir></dir></dir></dir></dir></dir></target></contents></package>
1
  <?xml version="1.0"?>
2
+ <package><name>Yireo_EmailOverride</name><version>0.2.1</version><stability>stable</stability><license>Open Source License</license><channel>community</channel><extends></extends><summary>No summary</summary><description>No description</description><notes>No notes</notes><authors><author><name>Yireo</name><user>yireo</user><email>info@yireo.com</email></author></authors><date>2015-01-16</date><time>0:13:27</time><compatible></compatible><dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Yireo_EmailOverride.xml" hash="fe22ada4c2be9373c3b0dc15cf2f805b"/></dir></dir><dir name="code"><dir name="community"><dir name="Yireo"><dir name="EmailOverride"><dir name="etc"><file name="config.xml" hash="7ecd3f2af66c045367631d09b0a84e35"/></dir><dir name="Model"><file name="Translate.php" hash="ef268156a6bc135efb63b47a57024503"/><dir name="Email"><file name="Template.php" hash="6a575d99032c050df39ee24c6e408614"/></dir></dir><dir name="Helper"><file name="Data.php" hash="9674be75f6d2b9b0d7541dd9c1c1a773"/></dir></dir></dir></dir></dir></dir></target></contents></package>