ET_CurrencyManager - Version 0.1.2

Version Notes

stable release

Download this release

Release Info

Developer Magento Core Team
Extension ET_CurrencyManager
Version 0.1.2
Comparing to
See all releases


Code changes from version 0.1.1 to 0.1.2

app/code/community/ET/CurrencyManager/Helper/Data.php CHANGED
@@ -20,5 +20,73 @@
20
 
21
  class ET_CurrencyManager_Helper_Data extends Mage_Core_Helper_Abstract
22
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  }
20
 
21
  class ET_CurrencyManager_Helper_Data extends Mage_Core_Helper_Abstract
22
  {
23
+ /**
24
+ * ZEND constants avalable in /lib/Zend/Currency.php
25
+ *
26
+ * NOTICE
27
+ *
28
+ * Magento ver 1.3.x - display - USE_SHORTNAME(3) by default
29
+ * Magento ver 1.4.x - display - USE_SYMBOL(2) by default
30
+ *
31
+ * position: 8 - standart; 16 - right; 32 - left
32
+ *
33
+ */
34
+
35
+ protected $_options=array();
36
+
37
+ public function getOptions($options=array())
38
+ {
39
+ $storeId=Mage::app()->getStore()->getStoreId();
40
+ if (!isset($this->_options[$storeId])) {
41
+ $this->setOptions();
42
+ }
43
+ if (count($options) > 0)
44
+ return $this->_options[$storeId] + $options;
45
+ else
46
+ return $this->_options[$storeId];
47
+ }
48
+
49
+
50
+
51
+ public function setOptions()
52
+ {
53
+ // TODO ?
54
+ // IF i become not empty options array What to do?
55
+
56
+ $config = Mage::getStoreConfig('currencymanager/general');
57
+ $options=array();
58
+ $storeId=Mage::app()->getStore()->getStoreId();
59
+ if ((($config['enabled'])&&($storeId>0))
60
+ ||(($config['enabledadm'])&&($storeId==0))){
61
+
62
+ if (isset($config['precision'])) // precision must be in range -1 .. 30
63
+ $options['precision'] = min(30, max(-1, (int)$config['precision']));
64
+
65
+ if (isset($config['position']))$options['position'] = (int)$config['position'];
66
+ if (isset($config['display']))$options['display'] = (int)$config['display'];
67
+
68
+ // formating symbols from admin, preparing to use. Maybe can better :)
69
+ // ���� � ������� ����� ������� ��������� �������� ��� ����� ������, �� �������������� ����� ������ ����
70
+ if(isset($config['symbolreplace'])){
71
+ $symbolreplace = unserialize($config['symbolreplace']);
72
+ foreach($symbolreplace['currency'] as $symbolreplaceKey=>$symbolreplaceValue)
73
+ if(strlen(trim($symbolreplace['currency'][$symbolreplaceKey]))==0){
74
+ unset($symbolreplace['currency'][$symbolreplaceKey]);
75
+ unset($symbolreplace['symbol'][$symbolreplaceKey]);
76
+ }
77
+
78
+ if(count($symbolreplace['currency'])>0){
79
+ $symbols = array_combine($symbolreplace['currency'], $symbolreplace['symbol']);
80
+
81
+ $displayCurrencyCode = Mage::app()->getStore()-> getCurrentCurrencyCode(); //geting current display currency
82
+ if (array_key_exists($displayCurrencyCode, $symbols))
83
+ $options['symbol'] = $symbols[$displayCurrencyCode];
84
+ }
85
+ }
86
+ } // end NOT ENABLED
87
+
88
+ $this->_options[$storeId] = $options;
89
+ return $this;
90
+ }
91
 
92
  }
app/code/community/ET/CurrencyManager/Model/Currency.php CHANGED
@@ -20,59 +20,30 @@
20
 
21
  class ET_CurrencyManager_Model_Currency extends Mage_Directory_Model_Currency
22
  {
23
- /**
24
- * Rewrites original Magento function
25
- *
26
- * Format price to currency format
27
- *
28
- * @param double $price
29
- * @param bool $includeContainer
30
- * @return string
31
- */
32
- /**
33
- * ZEND constants avalable in /lib/Zend/Currency.php
34
- *
35
- * NOTICE
36
- *
37
- * Magento ver 1.3.x - display - USE_SHORTNAME(3) by default
38
- * Magento ver 1.4.x - display - USE_SYMBOL(2) by default
39
- *
40
- * position: 8 - standart; 16 - right; 32 - left
41
- *
42
- */
43
- public function format($price, $options=array(), $includeContainer = true, $addBrackets = false)
44
- {
45
 
 
 
 
46
  $config = Mage::getStoreConfig('currencymanager/general');
 
47
 
 
 
48
 
49
- if ($config['enabled'])
50
- {
51
- if (isset($config['precision'])) // precision must be in range -1 .. 30
52
- $options['precision'] = min(30, max(-1, (int)$config['precision']));
53
-
54
- if (isset($config['position']))$options['position'] = (int)$config['position'];
55
- if (isset($config['display']))$options['display'] = (int)$config['display'];
56
-
57
- // formating symbols from admin, preparing to use. Maybe can better :)
58
- // ���� � ������� ����� ������� ��������� �������� ��� ����� ������, �� �������������� ����� ������ ����
59
- if(isset($config['symbolreplace'])){
60
- $symbolreplace = unserialize($config['symbolreplace']);
61
- foreach($symbolreplace['currency'] as $symbolreplaceKey=>$symbolreplaceValue)
62
- if(strlen(trim($symbolreplace['currency'][$symbolreplaceKey]))==0){
63
- unset($symbolreplace['currency'][$symbolreplaceKey]);
64
- unset($symbolreplace['symbol'][$symbolreplaceKey]);
65
- }
66
-
67
- if(count($symbolreplace['currency'])>0){
68
- $symbols = array_combine($symbolreplace['currency'], $symbolreplace['symbol']);
69
-
70
- $displayCurrencyCode = Mage::app()->getStore()-> getCurrentCurrencyCode(); //geting current display currency
71
- if (array_key_exists($displayCurrencyCode, $symbols))
72
- $options['symbol'] = $symbols[$displayCurrencyCode];
73
- }
74
- }
75
- }
76
  return parent::format($price, $options, $includeContainer, $addBrackets);
77
  }
 
 
 
 
 
 
 
 
 
 
 
78
  }
20
 
21
  class ET_CurrencyManager_Model_Currency extends Mage_Directory_Model_Currency
22
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
+ /*
25
+ public function format($price, $options=array(), $includeContainer = true, $addBrackets = false)
26
+ {
27
  $config = Mage::getStoreConfig('currencymanager/general');
28
+ $store = Mage::app()->getStore()->getStoreId();
29
 
30
+ if (($config['enabledadm'])and($store=0))
31
+ $options = Mage::helper('currencymanager')->getOptions($options);
32
 
33
+ if (($config['enabled'])and($store>0))
34
+ $options = Mage::helper('currencymanager')->getOptions($options);
35
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  return parent::format($price, $options, $includeContainer, $addBrackets);
37
  }
38
+ */
39
+
40
+ public function formatTxt($price, $options=array())
41
+ {
42
+ $config = Mage::getStoreConfig('currencymanager/general');
43
+ $store = Mage::app()->getStore()->getStoreId();
44
+ $options = Mage::helper('currencymanager')->getOptions($options);
45
+
46
+ return parent::formatTxt($price, $options);
47
+ }
48
+
49
  }
app/code/community/ET/CurrencyManager/Model/Locale.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ET Web Solutions
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade to newer
12
+ * versions in the future.
13
+ *
14
+ * @category ET
15
+ * @package ET_CurrencyManager
16
+ * @copyright Copyright (c) 2010 ET Web Solutions (http://etwebsolutions.com)
17
+ * @contacts support@etwebsolutions.com
18
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
19
+ */
20
+
21
+
22
+ class ET_CurrencyManager_Model_Locale extends Mage_Core_Model_Locale
23
+ {
24
+ public function currency($ccode)
25
+ {
26
+ $admcurrency = parent::currency($ccode);
27
+ $options = Mage::helper('currencymanager')->getOptions();
28
+ $admcurrency->setFormat($options);
29
+
30
+ return $admcurrency;
31
+ }
32
+
33
+ }
app/code/community/ET/CurrencyManager/etc/config.xml CHANGED
@@ -22,7 +22,7 @@
22
  <config>
23
  <modules>
24
  <ET_CurrencyManager>
25
- <version>0.1.1</version>
26
  <descr>
27
  <ru_RU>
28
  Позволяет управлять значениями локализации для валюты. Например: кол-во знаков после запятой для цены или символ валюты.
@@ -46,6 +46,13 @@
46
  <currency>ET_CurrencyManager_Model_Currency</currency>
47
  </rewrite>
48
  </directory>
 
 
 
 
 
 
 
49
  <currencymanager>
50
  <class>ET_CurrencyManager_Model</class>
51
  </currencymanager>
@@ -81,6 +88,7 @@
81
  <currencymanager>
82
  <general>
83
  <enabled>1</enabled>
 
84
  <precision>0</precision>
85
  <position>8</position>
86
  <display>2</display>
22
  <config>
23
  <modules>
24
  <ET_CurrencyManager>
25
+ <version>0.1.2</version>
26
  <descr>
27
  <ru_RU>
28
  Позволяет управлять значениями локализации для валюты. Например: кол-во знаков после запятой для цены или символ валюты.
46
  <currency>ET_CurrencyManager_Model_Currency</currency>
47
  </rewrite>
48
  </directory>
49
+
50
+ <core>
51
+ <rewrite>
52
+ <locale>ET_CurrencyManager_Model_Locale</locale>
53
+ </rewrite>
54
+ </core>
55
+
56
  <currencymanager>
57
  <class>ET_CurrencyManager_Model</class>
58
  </currencymanager>
88
  <currencymanager>
89
  <general>
90
  <enabled>1</enabled>
91
+ <enabledadm>0</enabledadm>
92
  <precision>0</precision>
93
  <position>8</position>
94
  <display>2</display>
app/code/community/ET/CurrencyManager/etc/system.xml CHANGED
@@ -54,7 +54,16 @@
54
  <show_in_website>1</show_in_website>
55
  <show_in_store>1</show_in_store>
56
  </enabled>
57
- <precision translate="label comment">
 
 
 
 
 
 
 
 
 
58
  <label>Precision</label>
59
  <comment>Number of decimal (e.g. 0, 1, 2). Default: 0</comment>
60
  <frontend_type>text</frontend_type>
54
  <show_in_website>1</show_in_website>
55
  <show_in_store>1</show_in_store>
56
  </enabled>
57
+ <enabledadm translate="label">
58
+ <label>Enabled for Admin</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_yesno</source_model>
61
+ <sort_order>2</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ </enabledadm>
66
+ <precision translate="label comment">
67
  <label>Precision</label>
68
  <comment>Number of decimal (e.g. 0, 1, 2). Default: 0</comment>
69
  <frontend_type>text</frontend_type>
app/code/community/ET/ET_CurrencyManager_ChangeLog.txt CHANGED
@@ -8,14 +8,17 @@ Legend:
8
 
9
  =====================================
10
  TODO:
11
- + �������� ����������� ������/Add the ability to change:
12
- group symbol (����������� �����/thousands separator)
13
  decimal separator (, or .)
14
- ��� ��� ���� ������� ��� �� �����������, �� ������� ������ �� ������ ����� /lib/Zend/Locale/Data/
15
  Since it is not implemented in the Magento core, it will have to write directly to files in /lib/Zend/Locale/Data/
16
 
17
 
18
  =====================================
 
 
 
19
 
20
  ver. 0.1.1
21
  * repacking for Magento Connect
8
 
9
  =====================================
10
  TODO:
11
+ + Добавить возможность менять/Add the ability to change:
12
+ group symbol (разделитель тысяч/thousands separator)
13
  decimal separator (, or .)
14
+ Так как в ядре Магенто это не реализовано, то придётся писать на прямую в файлы /lib/Zend/Locale/Data/
15
  Since it is not implemented in the Magento core, it will have to write directly to files in /lib/Zend/Locale/Data/
16
 
17
 
18
  =====================================
19
+ ver. 0.1.2
20
+ * Added separate configurations for enable/disable module for frontend and admin.
21
+
22
 
23
  ver. 0.1.1
24
  * repacking for Magento Connect
app/code/community/ET/ET_CurrencyManager_Description.txt CHANGED
@@ -10,6 +10,13 @@ RU:
10
  * что использовать в качестве символа валюты (не использовать, использовать код, использовать символ, использовать название)
11
  * позиция символа валюты (перед ценой, после цены)
12
 
 
 
 
 
 
 
 
13
  EN:
14
  This extension lets you manage currency localization. By default values are taken from Zend Framework configuration. Of course, you can edit those values directly there, but in that case you'll most likely lose these changes when Magento decides to upgrade Zend Framework.
15
 
@@ -19,6 +26,13 @@ Things you can manage with this extension:
19
  * use what as currency symbol (use nothing, currency code, currency symbol, currency name)
20
  * symbol position (before price, after price)
21
 
 
 
 
 
 
 
 
22
 
23
  ====Features / Особенности модуля====
24
 
10
  * что использовать в качестве символа валюты (не использовать, использовать код, использовать символ, использовать название)
11
  * позиция символа валюты (перед ценой, после цены)
12
 
13
+ ВАЖНО: Этот модуль меняет ТОЛЬКО ОТОБРАЖЕНИЕ валюты, но не влияет на хранение сумм.
14
+ Пример: Товар стоит 149.99 денег. Если модуль включен, то
15
+ * клиент увидит цену 150.
16
+ * Администратор в зависимости от настроек 150 или 149.99
17
+ * При оплате онлайн с клиента будет списано 149.99, так как товар столько стоит.
18
+
19
+
20
  EN:
21
  This extension lets you manage currency localization. By default values are taken from Zend Framework configuration. Of course, you can edit those values directly there, but in that case you'll most likely lose these changes when Magento decides to upgrade Zend Framework.
22
 
26
  * use what as currency symbol (use nothing, currency code, currency symbol, currency name)
27
  * symbol position (before price, after price)
28
 
29
+ IMPORTANT NOTE: This extension changes ONLY DISPLAY of currency, but it doesn't change storing of prices and sums inside Magento.
30
+ Example: Product price is 149.99 of money. If extension is enabled:
31
+ * Customer will see price as 150.
32
+ * Admin - depending on settings - 150 or 149.99
33
+ * When paying online client will be charged 149.99 because it is this product's real price.
34
+
35
+
36
 
37
  ====Features / Особенности модуля====
38
 
app/locale/en_US/ET_Currencymanager.csv CHANGED
@@ -4,7 +4,8 @@
4
  "* Select currency","* Select currency"
5
  "Remove","Remove"
6
  "Currency Options","Currency Options"
7
- "Enabled","Enabled"
 
8
  "Precision","Precision"
9
  "Number of decimal (e.g. 0, 1, 2). Default: 0","Number of decimal (e.g. 0, 1, 2). Default: 0"
10
  "Symbol position","Symbol position"
4
  "* Select currency","* Select currency"
5
  "Remove","Remove"
6
  "Currency Options","Currency Options"
7
+ "Enabled","Enabled for Frontend"
8
+ "Enabled for Admin","Enabled for Admin"
9
  "Precision","Precision"
10
  "Number of decimal (e.g. 0, 1, 2). Default: 0","Number of decimal (e.g. 0, 1, 2). Default: 0"
11
  "Symbol position","Symbol position"
app/locale/ru_RU/ET_Currencymanager.csv CHANGED
@@ -4,7 +4,8 @@
4
  "* Select currency","* Выберите валюту"
5
  "Remove","Удалить"
6
  "Currency Options","Параметры валюты"
7
- "Enabled","Включено"
 
8
  "Precision","Точность"
9
  "Number of decimal (e.g. 0, 1, 2). Default: 0","Кол-во знаков после запятой (например: 0, 1, 2). По умолчанию: 0"
10
  "Symbol position","Позиция символа"
4
  "* Select currency","* Выберите валюту"
5
  "Remove","Удалить"
6
  "Currency Options","Параметры валюты"
7
+ "Enabled","Включено для пользователей"
8
+ "Enabled for Admin","Включено для администраторов"
9
  "Precision","Точность"
10
  "Number of decimal (e.g. 0, 1, 2). Default: 0","Кол-во знаков после запятой (например: 0, 1, 2). По умолчанию: 0"
11
  "Symbol position","Позиция символа"
package.xml CHANGED
@@ -1,12 +1,13 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ET_CurrencyManager</name>
4
- <version>0.1.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/afl-3.0.php">AFL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Currency Manager module allow to change in admin currency's display parametrs.</summary>
 
10
  <description>Currency Manager module allow to change in admin currency's display parametrs:
11
  * symbol
12
  * precision
@@ -14,9 +15,9 @@
14
  * symbol type (name, short name/code, symbol)</description>
15
  <notes>stable release</notes>
16
  <authors><author><name>Jurij</name><user>auto-converted</user><email>support@etwebsolutions.com</email></author></authors>
17
- <date>2011-02-25</date>
18
- <time>08:53:05</time>
19
- <contents><target name="magelocale"><dir name="en_US"><file name="ET_Currencymanager.csv" hash="262ae57e18307a22a25f7918221918a8"/></dir><dir name="ru_RU"><file name="ET_Currencymanager.csv" hash="895eadb455c55163f1be91e51f565992"/></dir></target><target name="magecommunity"><dir name="ET"><dir name="CurrencyManager"><dir name="Block"><dir name="Adminhtml"><file name="Symbolreplace.php" hash="675718a8640ede89e87edb3b6652f85d"/></dir></dir><dir name="etc"><file name="config.xml" hash="6b2a97956a0ee41278b96da10e55048f"/><file name="system.xml" hash="3905d76400a09b3ddc4ed1630994f888"/></dir><dir name="Helper"><file name="Data.php" hash="e62c5d7dfcd9b1bd7a59f967d671a975"/></dir><dir name="Model"><file name="Currency.php" hash="a0779a0b978ae86ab45e4ab91bbbe1c5"/><file name="Typeposition.php" hash="3c8655f73d39f74d0a0dc0efa4cf0be3"/><file name="Typesymboluse.php" hash="973fa7feb75aa4cf846ffb3cd21d8fa4"/></dir></dir><file name="ET_CurrencyManager_ChangeLog.txt" hash="0ee635b3824bce283707ec6ae1dfc197"/><file name="ET_CurrencyManager_Description.txt" hash="0e521fe493b7e72b1bbad116da69b532"/><file name="ET_CurrencyManager_LICENSE.txt" hash="b799504264c23c11a941473d7a3e3ab7"/></dir></target><target name="mageetc"><dir name="modules"><file name="ET_CurrencyManager.xml" hash="e2631245590a94c04438246a5827625f"/></dir></target></contents>
20
  <compatible/>
21
  <dependencies/>
22
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ET_CurrencyManager</name>
4
+ <version>0.1.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/afl-3.0.php">AFL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Changes:
10
+ Added separate configurations for enable/disable module for frontend and admin.</summary>
11
  <description>Currency Manager module allow to change in admin currency's display parametrs:
12
  * symbol
13
  * precision
15
  * symbol type (name, short name/code, symbol)</description>
16
  <notes>stable release</notes>
17
  <authors><author><name>Jurij</name><user>auto-converted</user><email>support@etwebsolutions.com</email></author></authors>
18
+ <date>2011-03-04</date>
19
+ <time>13:08:02</time>
20
+ <contents><target name="magelocale"><dir name="en_US"><file name="ET_Currencymanager.csv" hash="c41fcaff10fe6023a2696341bb147c25"/></dir><dir name="ru_RU"><file name="ET_Currencymanager.csv" hash="a7b43d416473671fac03692bdb4797cc"/></dir></target><target name="magecommunity"><dir name="ET"><dir name="CurrencyManager"><dir name="Block"><dir name="Adminhtml"><file name="Symbolreplace.php" hash="675718a8640ede89e87edb3b6652f85d"/></dir></dir><dir name="etc"><file name="config.xml" hash="6b9a02876f97ecd59f88bfa068980dd1"/><file name="system.xml" hash="70021f48efb3a3290bfd3e60e1c641d3"/></dir><dir name="Helper"><file name="Data.php" hash="b900d8f61891ad99bd409d0118a266c7"/></dir><dir name="Model"><file name="Currency.php" hash="36e1836c0c3e5fd49dd80f8c8fe734d5"/><file name="Locale.php" hash="74ba11dfdb66b39feb242ef330819f8c"/><file name="Typeposition.php" hash="3c8655f73d39f74d0a0dc0efa4cf0be3"/><file name="Typesymboluse.php" hash="973fa7feb75aa4cf846ffb3cd21d8fa4"/></dir></dir><file name="ET_CurrencyManager_ChangeLog.txt" hash="b35eabffc91ae970dec4f4d94229abcd"/><file name="ET_CurrencyManager_Description.txt" hash="58eb12ef28d5a34916935799f0a5b983"/><file name="ET_CurrencyManager_LICENSE.txt" hash="b799504264c23c11a941473d7a3e3ab7"/></dir></target><target name="mageetc"><dir name="modules"><file name="ET_CurrencyManager.xml" hash="e2631245590a94c04438246a5827625f"/></dir></target></contents>
21
  <compatible/>
22
  <dependencies/>
23
  </package>