Перейти к содержимому


National Bank Of Tajikistan


  • Авторизуйтесь для ответа в теме
В теме одно сообщение

#1 Orif

Orif

    Новичок

  • Пользователи
  • Pip
  • 3 сообщений

Отправлено 18 июня 2011 - 02:56

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

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

НБТ: http://nbt.tj/ru/kur...1&export=xmlout

Далее добавил в mod_jextcurrency.xml след. строку: <option value="nbt">PLG_JEXTCURRENCY_SOURCE_OPTION_NBT</option>
Результат: Пишет невозможно получить данные.

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

#2 admin

admin

    Администратор

  • Администраторы
  • 377 сообщений

Отправлено 18 июня 2011 - 06:48

<?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;
        }
}