Jump to content
UTM.SPACE community
Sign in to follow this  
dozent

National Bank Of Tajikistan

Recommended Posts

Доброго времени суток,

Решил добавить в модуль JextCurrency курсы Национального банка Таджикистана (НБТ), изменил код см.ниже:

НБТ: http://nbt.tj/ru/kurs/?c=4&id=28&lg=ru&d=17-06-2011&export=xmlout

Далее добавил в mod_jextcurrency.xml след. строку: <option value="nbt">PLG_JEXTCURRENCY_SOURCE_OPTION_NBT</option>

Результат: Пишет невозможно получить данные.

Что не так сделано?

Share this post


Link to post
Share on other sites
<?php
/**
* @author Darang
* @date 24-June-2011
* @copyright (c)2010-2011 JExt.biz
*/

// no direct access
defined ( '_JEXEC' ) or die ( 'Restricted access' );

/**
* Official exchange rates of the National bank of Tajikistan
*/
class currency_data_nbt extends currency_data {

function __construct() {
parent::__construct ();
$this->url = "http://nbt.tj/ru/kurs/?c=4&id=28&lg=ru&export=xmlout";
$this->bank_name = "National bank of Tajikistan";
$this->bank_url = "http://www.nbt.tj";
$this->currency_name = "таджикского сомони";
$this->date_format = 'd-m-Y';
}


function get_array($xml, $day = '', $replace_currency_array) {

// Handle no data received error
if (! isset ( $xml->document->Valute )) {
$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
$rates ['date'] = $xml->document->attributes ( 'date' );
$data = $xml->document->Valute;

foreach ( $data as $dt ) {
$code = $dt->CharCode [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] ['numcode'] = $dt->NumCode [0]->data (); // num code
$rates ['currency'] [$code] ['scale'] = $dt->Nominal [0]->data (); // units
// Set currency name (array with replacement rules will be searched for the ISO code)
$rates ['currency'] [$code] ['name'] = parent::replace_currency_name ( $dt->Name [0]->data (), $code, $replace_currency_array );
// Get the rate & replace comma to dot for further number processing
$rates ['currency'] [$code] ['rate'] = str_replace ( ',', '.', $dt->Value [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;
}

/**
* Returns URL for receiving XML data file
*
* @param string Date
* @return string URL
*/
public function getUrl($date = "") {

if (strlen ( $date ) > 1) {
$url = $this->url.'&d='.$date;
} else {
$url = $this->url;
}
return $url;
}
}

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...