В папке 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 access
defined('_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>










