admin 19 Posted October 15, 2011 Report Share Posted October 15, 2011 Narodowy Bank PolskiВ папке models создать файл nbp.class.php (Create a file nbp.class.php in the folder models.)<?php/*** @author stankiewiczpl.opole at gmail.com 12-Oct-2011*/// no direct accessdefined('_JEXEC') or die('Restricted access');/*** Euro foreign exchange reference rates by the National Bank of Poland*/class currency_data_nbp extends currency_data{ function __construct() { parent::__construct(); // $this->before_flag = FALSE; // differences b/w rates are taken from the same XML source $this->url = "http://www.nbp.pl/kursy/xml/LastA.xml"; // last day rates $this->bank_name = "Narodowy Bank Polski"; $this->bank_url = "http://www.nbp.pl/"; $this->currency_name = "PLN"; } function get_array($xml, $day = '', $replace_currency_array) { // Handle no data received error if (!isset ($xml->document->pozycja)) { $error ['error'] = 1; return $error; } // Save currencies' rates in an associative array indexed by currency 3 char code $rates = array(); // array to store currencies exchange rates $data = $xml->document->pozycja; $rates ['date'] = $xml->document->data_publikacji [0]->data(); foreach ($data as $dt) { $code = $dt->kod_waluty [0]->data(); // Store data for selected by user currencies only, if they are set if (empty ($this->currencies) || in_array($code, $this->currencies)) { $rates ['currency'] [$code] ['scale'] = $dt->przelicznik [0]->data(); // units $rates ['currency'] [$code] ['name'] = parent::replace_currency_name($dt->nazwa_waluty [0]->data(), $code, $replace_currency_array); $rates ['currency'] [$code] ['rate'] = str_replace(',', '.', $dt->kurs_sredni [0]->data()); } } // Save additional info (only one time) if ($day == 'today' || $this->before_flag == FALSE) { $rates['info'] = array( "bank_name" => $this->bank_name, "bank_url" => $this->bank_url, "currency_name" => $this->currency_name); } return $rates; } public function getUrl($date = "") { if (strlen($date) > 1) { $file = file_get_contents('http://nbp.pl/Kursy/xml/dir.txt'); //list filenames of last days rates preg_match_all('/^(a.+)/mi', $file, $pregs); $count = count($pregs[1]) - 2; $filename = $pregs[1][$count]; $xml_source = substr($filename, 0, -1); $url = 'http://nbp.pl/Kursy/xml/' . $xml_source . '.xml'; //before last day rates } else { $url = $this->url; } return $url; }} в mod_jextcurrency.xml в секцию source_class добавить (add code to section source_class in mod_jextcurrency.xml)<option value="nbp">MOD_JEXTCURRENCY_SOURCE_OPTION_NBP</option> Quote Link to post Share on other sites
Misiek 0 Posted October 30, 2013 Report Share Posted October 30, 2013 Hi Admin!First of all thank you very much for your module, it is amazing! I was using it on Joomla 2.5 and was very impressed, every thing was working absolutely fine. I changed my joomla to 3.x and found on forum module working with this version of Joomla but unfortunatelly code above doesn't work with J3.x.I tried to contact author but mailbox doesn't exists.Is there any chance to get your extension working with polish bank stated above? Can you please have a look on code above and make changes to make it work?Pretty please ! Kind regards, Emil. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.