Grinet_TcmbDoviz - Version 0.1.1

Version Notes

No notes at this time

Download this release

Release Info

Developer Magento Core Team
Extension Grinet_TcmbDoviz
Version 0.1.1
Comparing to
See all releases


Version 0.1.1

app/code/community/Grinet/TcmbDoviz/Model/Currency/Import/Tcmb.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Directory
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Currency rate import model (From www.tcmb.gov.tr)
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Directory
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Grinet_TcmbDoviz_Model_Currency_Import_Tcmb extends Mage_Directory_Model_Currency_Import_Abstract
35
+ {
36
+ protected $_url = 'http://www.grinet.com.tr/doviz_tcmb.php?FromCurrency={{CURRENCY_FROM}}&ToCurrency={{CURRENCY_TO}}&format=XML';
37
+ protected $_messages = array();
38
+
39
+ /**
40
+ * HTTP client
41
+ *
42
+ * @var Varien_Http_Client
43
+ */
44
+ protected $_httpClient;
45
+
46
+ public function __construct()
47
+ {
48
+ $this->_httpClient = new Varien_Http_Client();
49
+ }
50
+
51
+ protected function _convert($currencyFrom, $currencyTo, $retry=0)
52
+ {
53
+ $url = str_replace('{{CURRENCY_FROM}}', $currencyFrom, $this->_url);
54
+ $url = str_replace('{{CURRENCY_TO}}', $currencyTo, $url);
55
+
56
+ try {
57
+ $response = $this->_httpClient
58
+ ->setUri($url)
59
+ ->setConfig(array('timeout' => Mage::getStoreConfig('currency/tcmb/timeout')))
60
+ ->request('GET')
61
+ ->getBody();
62
+
63
+ $xml = simplexml_load_string($response, null, LIBXML_NOERROR);
64
+ if( !$xml ) {
65
+ $this->_messages[] = Mage::helper('directory')->__('Cannot retrieve rate from %s.', $url);
66
+ return null;
67
+ }
68
+ return (float) $xml;
69
+ }
70
+ catch (Exception $e) {
71
+ if( $retry == 0 ) {
72
+ $this->_convert($currencyFrom, $currencyTo, 1);
73
+ } else {
74
+ $this->_messages[] = Mage::helper('directory')->__('Cannot retrieve rate from %s.', $url);
75
+ }
76
+ }
77
+ }
78
+ }
app/code/community/Grinet/TcmbDoviz/etc/config.xml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category Mage
23
+ * @package Mage_Directory
24
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+ -->
28
+ <config>
29
+ <modules>
30
+ <Grinet_TcmbDoviz>
31
+ <version>0.1.1</version>
32
+ </Grinet_TcmbDoviz>
33
+ </modules>
34
+ <global>
35
+ <currency>
36
+ <import>
37
+ <services>
38
+ <tcmb>
39
+ <name>T.C. Merkez Bankasi</name>
40
+ <model>Grinet_TcmbDoviz_Model_Currency_Import_Tcmb</model>
41
+ </tcmb>
42
+ </services>
43
+ </import>
44
+ </currency>
45
+ </global>
46
+ <default>
47
+ <currency>
48
+ <tcmb>
49
+ <timeout>100</timeout>
50
+ </tcmb>
51
+ </currency>
52
+ </default>
53
+ </config>
app/code/community/Grinet/TcmbDoviz/etc/system.xml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category Mage
23
+ * @package Mage_Directory
24
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+ -->
28
+ <config>
29
+ <sections>
30
+ <currency translate="label" module="directory">
31
+ <label>Currency Setup</label>
32
+ <tab>general</tab>
33
+ <sort_order>60</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ <groups>
38
+ <tcmb translate="label">
39
+ <label>T.C. Merkez Bankasi</label>
40
+ <sort_order>40</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>0</show_in_website>
43
+ <show_in_store>0</show_in_store>
44
+ <fields>
45
+ <timeout translate="label">
46
+ <label>Connection Timeout in Seconds</label>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>0</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>0</show_in_website>
51
+ <show_in_store>0</show_in_store>
52
+ </timeout>
53
+ </fields>
54
+ </tcmb>
55
+ </groups>
56
+ </currency>
57
+ </sections>
58
+ </config>
app/etc/modules/Grinet_TcmbDoviz.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Grinet_TcmbDoviz>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Grinet_TcmbDoviz>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Grinet_TcmbDoviz</name>
4
+ <version>0.1.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Adds Turkish Central Bank to Currency Conversion services</summary>
10
+ <description>- Adds Turkish Central Bank to Currency Conversion services
11
+
12
+ - D&#xF6;viz &#xE7;evrimi i&#xE7;in TC Merkez Bankas&#x131; kurlar&#x131;n&#x131; kullanabilmenizi sa&#x11F;lar</description>
13
+ <notes>No notes at this time</notes>
14
+ <authors><author><name>Hidayet Ok</name><user>auto-converted</user><email>hidonet@grinet.com.tr</email></author></authors>
15
+ <date>2011-02-15</date>
16
+ <time>10:40:03</time>
17
+ <contents><target name="magecommunity"><dir name="Grinet"><dir name="TcmbDoviz"><dir name="etc"><file name="config.xml" hash="32ad82fb25c4a2d39a0c7d5b53c76e4c"/><file name="system.xml" hash="13a4fca93b6fbbd8464001b327672e7f"/></dir><dir name="Model"><dir name="Currency"><dir name="Import"><file name="Tcmb.php" hash="4fdadd040a592a53f93bd0a7b9a268f9"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Grinet_TcmbDoviz.xml" hash="3f103dbf0f30988e7f6674a318ec4625"/></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies/>
20
+ </package>