Version Notes
No notes
Download this release
Release Info
Developer | Yireo |
Extension | Yireo_EmailOverride |
Version | 0.1.5 |
Comparing to | |
See all releases |
Version 0.1.5
- app/code/community/Yireo/EmailOverride/Helper/Data.php +16 -0
- app/code/community/Yireo/EmailOverride/Model/Email/Template.php +23 -0
- app/code/community/Yireo/EmailOverride/Model/Translate.php +132 -0
- app/code/community/Yireo/EmailOverride/etc/config.xml +41 -0
- app/etc/modules/Yireo_EmailOverride.xml +22 -0
- package.xml +2 -0
app/code/community/Yireo/EmailOverride/Helper/Data.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Yireo EmailOverride for Magento
|
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 |
+
|
11 |
+
/**
|
12 |
+
* EmailOverride helper
|
13 |
+
*/
|
14 |
+
class Yireo_EmailOverride_Helper_Data extends Mage_Core_Helper_Abstract
|
15 |
+
{
|
16 |
+
}
|
app/code/community/Yireo/EmailOverride/Model/Email/Template.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Yireo EmailOverride for Magento
|
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 |
+
|
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 |
+
{
|
18 |
+
if(isset($config['store'])) {
|
19 |
+
Mage::register('emailoverride.store', $config['store'], true);
|
20 |
+
}
|
21 |
+
return parent::setDesignConfig($config);
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Yireo/EmailOverride/Model/Translate.php
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Yireo EmailOverride for Magento
|
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 |
+
|
11 |
+
/**
|
12 |
+
* EmailOverride Core model
|
13 |
+
*/
|
14 |
+
class Yireo_EmailOverride_Model_Translate extends Mage_Core_Model_Translate
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Retrieve translation file for module
|
18 |
+
*
|
19 |
+
* @param string $module
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
protected function _getModuleFilePath($module, $fileName)
|
23 |
+
{
|
24 |
+
if (Mage::app()->getStore()->isAdmin() == true) {
|
25 |
+
return parent::_getModuleFilePath($module, $fileName);
|
26 |
+
}
|
27 |
+
|
28 |
+
$localeCode = $this->getLocale();
|
29 |
+
if (empty($localeCode)) {
|
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 |
+
}
|
37 |
+
|
38 |
+
return parent::_getModuleFilePath($module, $fileName);
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Retrieve translated template file
|
43 |
+
* Try current design package first
|
44 |
+
*
|
45 |
+
* @param string $file
|
46 |
+
* @param string $type
|
47 |
+
* @param string $localeCode
|
48 |
+
* @return string
|
49 |
+
*/
|
50 |
+
public function getTemplateFile($file, $type, $localeCode=null)
|
51 |
+
{
|
52 |
+
if (is_null($localeCode) || preg_match('/[^a-zA-Z_]/', $localeCode)) {
|
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 |
+
}
|
60 |
+
|
61 |
+
$ioAdapter = new Varien_Io_File();
|
62 |
+
$ioAdapter->open(array('path' => Mage::getBaseDir('locale')));
|
63 |
+
|
64 |
+
return (string) $ioAdapter->read($filePath);
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Custom function to return override folder for locales
|
69 |
+
*
|
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 |
+
/**
|
113 |
+
* Loading data from module translation files
|
114 |
+
*
|
115 |
+
* @param string $moduleName
|
116 |
+
* @param string $files
|
117 |
+
* @return Mage_Core_Model_Translate
|
118 |
+
*/
|
119 |
+
protected function _loadModuleTranslation($moduleName, $files, $forceReload=false)
|
120 |
+
{
|
121 |
+
foreach ($files as $file) {
|
122 |
+
$file = $this->_getModuleFilePath($moduleName, $file);
|
123 |
+
$baseFile = basename($file);
|
124 |
+
$overrideFile = Mage::getDesign()->getLocaleFileName($baseFile);
|
125 |
+
if(file_exists($overrideFile)) {
|
126 |
+
$file = $overrideFile;
|
127 |
+
}
|
128 |
+
$this->_addData($this->_getFileData($file), $moduleName, $forceReload);
|
129 |
+
}
|
130 |
+
return $this;
|
131 |
+
}
|
132 |
+
}
|
app/code/community/Yireo/EmailOverride/etc/config.xml
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Yireo EmailOverride for Magento
|
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 |
+
-->
|
12 |
+
<config>
|
13 |
+
|
14 |
+
<modules>
|
15 |
+
<Yireo_EmailOverride>
|
16 |
+
<version>0.1.5</version>
|
17 |
+
</Yireo_EmailOverride>
|
18 |
+
</modules>
|
19 |
+
|
20 |
+
<global>
|
21 |
+
<helpers>
|
22 |
+
<emailoverride>
|
23 |
+
<class>Yireo_EmailOverride_Helper</class>
|
24 |
+
</emailoverride>
|
25 |
+
</helpers>
|
26 |
+
|
27 |
+
<models>
|
28 |
+
<emailoverride>
|
29 |
+
<class>Yireo_EmailOverride_Model</class>
|
30 |
+
</emailoverride>
|
31 |
+
<core>
|
32 |
+
<rewrite>
|
33 |
+
<translate>Yireo_EmailOverride_Model_Translate</translate>
|
34 |
+
</rewrite>
|
35 |
+
<rewrite>
|
36 |
+
<email_template>Yireo_EmailOverride_Model_Email_Template</email_template>
|
37 |
+
</rewrite>
|
38 |
+
</core>
|
39 |
+
</models>
|
40 |
+
</global>
|
41 |
+
</config>
|
app/etc/modules/Yireo_EmailOverride.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Yireo EmailOverride-module for Magento
|
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 |
+
-->
|
12 |
+
<config>
|
13 |
+
<modules>
|
14 |
+
<Yireo_EmailOverride>
|
15 |
+
<active>true</active>
|
16 |
+
<codePool>community</codePool>
|
17 |
+
<depends>
|
18 |
+
<Mage_Core />
|
19 |
+
</depends>
|
20 |
+
</Yireo_EmailOverride>
|
21 |
+
</modules>
|
22 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +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>
|