Yireo_EmailOverride - Version 0.2.6

Version Notes

No notes

Download this release

Release Info

Developer Yireo
Extension Yireo_EmailOverride
Version 0.2.6
Comparing to
See all releases


Code changes from version 0.2.1 to 0.2.6

app/code/community/Yireo/EmailOverride/Helper/Data.php CHANGED
@@ -13,6 +13,13 @@
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);
@@ -22,8 +29,15 @@ class Yireo_EmailOverride_Helper_Data extends Mage_Core_Helper_Abstract
22
  return $filePath;
23
  }
24
  }
 
 
25
  }
26
 
 
 
 
 
 
27
  public function getLocalePaths($store = null)
28
  {
29
  $paths = array();
@@ -31,11 +45,15 @@ class Yireo_EmailOverride_Helper_Data extends Mage_Core_Helper_Abstract
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
 
@@ -47,6 +65,11 @@ class Yireo_EmailOverride_Helper_Data extends Mage_Core_Helper_Abstract
47
  return $paths;
48
  }
49
 
 
 
 
 
 
50
  public function getDesign($store = null)
51
  {
52
  if(empty($store)) {
@@ -73,6 +96,10 @@ class Yireo_EmailOverride_Helper_Data extends Mage_Core_Helper_Abstract
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);
13
  */
14
  class Yireo_EmailOverride_Helper_Data extends Mage_Core_Helper_Abstract
15
  {
16
+ /**
17
+ * @param string $localeCode
18
+ * @param string $fileName
19
+ * @param string|integer|Mage_Core_Model_Store $store (optional)
20
+ *
21
+ * @return string|null
22
+ */
23
  public function getLocaleOverrideFile($localeCode, $fileName, $store = null)
24
  {
25
  $paths = $this->getLocalePaths($store);
29
  return $filePath;
30
  }
31
  }
32
+
33
+ return null;
34
  }
35
 
36
+ /**
37
+ * @param string|integer|Mage_Core_Model_Store $store (optional)
38
+ *
39
+ * @return array
40
+ */
41
  public function getLocalePaths($store = null)
42
  {
43
  $paths = array();
45
  $design = $this->getDesign($store);
46
  $paths[] = Mage::getBaseDir('design').DS.'frontend'.DS.$design['package'].DS.$design['theme'].DS.'locale';
47
 
48
+ // Check for fallback support
49
+ $fallbackModel = Mage::getModel('core/design_fallback');
50
+ if(!empty($fallbackModel)) {
51
+ $fallbackSchemes = $fallbackModel->getFallbackScheme('frontend', $design['package'], $design['theme']);
52
+ if(!empty($fallbackSchemes)) {
53
+ foreach($fallbackSchemes as $scheme) {
54
+ if(!isset($scheme['_package']) || !isset($scheme['_theme'])) continue;
55
+ $paths[] = Mage::getBaseDir('design').DS.'frontend'.DS.$scheme['_package'].DS.$scheme['_theme'].DS.'locale';
56
+ }
57
  }
58
  }
59
 
65
  return $paths;
66
  }
67
 
68
+ /**
69
+ * @param string|integer|Mage_Core_Model_Store $store (optional)
70
+ *
71
+ * @return array
72
+ */
73
  public function getDesign($store = null)
74
  {
75
  if(empty($store)) {
96
  if(empty($packageName) || in_array($theme, array('base', 'default'))) {
97
  $packageName = Mage::getStoreConfig('design/package/name', $store);
98
  }
99
+
100
+ if(empty($theme)) {
101
+ $theme = Mage::getStoreConfig('design/theme/default', $store);
102
+ }
103
 
104
  if(empty($theme) || in_array($theme, array('default'))) {
105
  $theme = Mage::getStoreConfig('design/theme/locale', $store);
app/code/community/Yireo/EmailOverride/Model/Email/Template.php CHANGED
@@ -8,10 +8,19 @@
8
  * @license Open Source License (OSL v3)
9
  */
10
 
 
 
 
 
 
 
 
 
 
11
  /**
12
  * EmailOverride Core model
13
  */
14
- class Yireo_EmailOverride_Model_Email_Template extends Mage_Core_Model_Email_Template
15
  {
16
  public function setDesignConfig(array $config)
17
  {
8
  * @license Open Source License (OSL v3)
9
  */
10
 
11
+ // Allow for an override of Aschroder_SMTPPro_Model_Email_Template
12
+ if (Mage::helper('core')->isModuleEnabled('Aschroder_SMTPPro') && class_exists('Aschroder_SMTPPro_Model_Email_Template')) {
13
+ class Yireo_EmailOverride_Model_Email_Template_Wrapper extends Aschroder_SMTPPro_Model_Email_Template {}
14
+ }elseif (Mage::helper('core')->isModuleEnabled('Ebizmarts_Mandrill') && class_exists('Ebizmarts_Mandrill_Model_Email_Template')) {
15
+ class Yireo_EmailOverride_Model_Email_Template_Wrapper extends Ebizmarts_Mandrill_Model_Email_Template {}
16
+ } else {
17
+ class Yireo_EmailOverride_Model_Email_Template_Wrapper extends Mage_Core_Model_Email_Template {}
18
+ }
19
+
20
  /**
21
  * EmailOverride Core model
22
  */
23
+ class Yireo_EmailOverride_Model_Email_Template extends Yireo_EmailOverride_Model_Email_Template_Wrapper
24
  {
25
  public function setDesignConfig(array $config)
26
  {
app/code/community/Yireo/EmailOverride/Model/Translate.php CHANGED
@@ -16,8 +16,10 @@ class Yireo_EmailOverride_Model_Translate extends Mage_Core_Model_Translate
16
  /**
17
  * Retrieve translation file for module
18
  *
19
- * @param string $module
20
- * @return string
 
 
21
  */
22
  protected function _getModuleFilePath($module, $fileName)
23
  {
@@ -54,7 +56,7 @@ class Yireo_EmailOverride_Model_Translate extends Mage_Core_Model_Translate
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
  }
60
 
@@ -67,7 +69,9 @@ class Yireo_EmailOverride_Model_Translate extends Mage_Core_Model_Translate
67
  /**
68
  * Custom function to return override folder for locales
69
  *
70
- * @param null
 
 
71
  * @return string
72
  */
73
  protected function getLocaleOverrideFile($localeCode, $fileName)
@@ -77,17 +81,20 @@ class Yireo_EmailOverride_Model_Translate extends Mage_Core_Model_Translate
77
  $store = $this->_config['store'];
78
  }
79
 
 
80
  return Mage::helper('emailoverride')->getLocaleOverrideFile($localeCode, $fileName, $store);
81
  }
82
 
83
  /**
84
  * Loading data from module translation files
85
  *
86
- * @param string $moduleName
87
- * @param string $files
88
- * @return Mage_Core_Model_Translate
 
 
89
  */
90
- protected function _loadModuleTranslation($moduleName, $files, $forceReload=false)
91
  {
92
  foreach ($files as $file) {
93
  $file = $this->_getModuleFilePath($moduleName, $file);
@@ -100,4 +107,36 @@ class Yireo_EmailOverride_Model_Translate extends Mage_Core_Model_Translate
100
  }
101
  return $this;
102
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  }
16
  /**
17
  * Retrieve translation file for module
18
  *
19
+ * @param string $module
20
+ * @param string $fileName
21
+ *
22
+ * @return string
23
  */
24
  protected function _getModuleFilePath($module, $fileName)
25
  {
56
  }
57
 
58
  $filePath = $this->getLocaleOverrideFile($localeCode, 'template'.DS.$type.DS.$file);
59
+ if (empty($filePath) || !file_exists($filePath)) {
60
  return parent::getTemplateFile($file, $type, $localeCode);
61
  }
62
 
69
  /**
70
  * Custom function to return override folder for locales
71
  *
72
+ * @param string $localeCode
73
+ * @param string $fileName
74
+ *
75
  * @return string
76
  */
77
  protected function getLocaleOverrideFile($localeCode, $fileName)
81
  $store = $this->_config['store'];
82
  }
83
 
84
+ /** @see Yireo_EmailOverride_Helper_Data::getLocalOverrideFile */
85
  return Mage::helper('emailoverride')->getLocaleOverrideFile($localeCode, $fileName, $store);
86
  }
87
 
88
  /**
89
  * Loading data from module translation files
90
  *
91
+ * @param string $moduleName
92
+ * @param string $files
93
+ * @param bool $forceReload (optional)
94
+ *
95
+ * @return Mage_Core_Model_Translate
96
  */
97
+ protected function _loadModuleTranslation($moduleName, $files, $forceReload = false)
98
  {
99
  foreach ($files as $file) {
100
  $file = $this->_getModuleFilePath($moduleName, $file);
107
  }
108
  return $this;
109
  }
110
+
111
+ /**
112
+ * Loading current theme translation
113
+ *
114
+ * @param bool $forceReload (optional)
115
+ *
116
+ * @return Mage_Core_Model_Translate
117
+ */
118
+ protected function _loadThemeTranslation($forceReload = false)
119
+ {
120
+ // Check for fallback support
121
+ $fallbackModel = Mage::getModel('core/design_fallback');
122
+ if(empty($fallbackModel)) {
123
+ return parent::_loadThemeTranslation($forceReload);
124
+ }
125
+
126
+ // First add fallback package translate.csv files
127
+ $designPackage = Mage::getSingleton('core/design_package');
128
+ $fallbacks = $fallbackModel->getFallbackScheme($designPackage->getArea(), $designPackage->getPackageName(), $designPackage->getTheme('layout'));
129
+
130
+ foreach ($fallbacks as $fallback)
131
+ {
132
+ if(!isset($fallback['_package']) || !isset($fallback['_theme'])) continue; // first one is empty for some reason
133
+ $fallbackFile = $designPackage->getLocaleFileName('translate.csv', array('_package' => $fallback['_package']));
134
+ $this->_addData($this->_getFileData($fallbackFile), false, $forceReload);
135
+ }
136
+
137
+ // Now add current package translate.csv
138
+ $file = Mage::getDesign()->getLocaleFileName('translate.csv');
139
+ $this->_addData($this->_getFileData($file), false, $forceReload);
140
+ return $this;
141
+ }
142
  }
app/code/community/Yireo/EmailOverride/etc/config.xml CHANGED
@@ -13,7 +13,7 @@
13
 
14
  <modules>
15
  <Yireo_EmailOverride>
16
- <version>0.2.1</version>
17
  </Yireo_EmailOverride>
18
  </modules>
19
 
13
 
14
  <modules>
15
  <Yireo_EmailOverride>
16
+ <version>0.2.6</version>
17
  </Yireo_EmailOverride>
18
  </modules>
19
 
package.xml CHANGED
@@ -1,2 +1,2 @@
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>
1
  <?xml version="1.0"?>
2
+ <package><name>Yireo_EmailOverride</name><version>0.2.6</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-05-07</date><time>0:11:23</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="4a74ba00765dfe9f4fe3899bfdff4823"/></dir><dir name="Model"><file name="Translate.php" hash="9cc0cc71596d3ddc06ca5b9c7df1ba6a"/><dir name="Email"><file name="Template.php" hash="7a4b950edadb943ff644a6383d224150"/></dir></dir><dir name="Helper"><file name="Data.php" hash="28767abdaaf1ae5c6e8b672b020ec289"/></dir></dir></dir></dir></dir></dir></target></contents></package>