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


Добавление Нового Банка


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

#1 DarkTranquillity

DarkTranquillity

    Новичок

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

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

Всем доброго времени суток!

Хочу модернизировать модуль по отображению курса валют добавив туда Латвийский Лат.

На примере Российского ЦБ подставляю Латвийский:

<?php
/**
 * @author      Darang, Gray <justPHP@gmail.com>
 * @date        10-Oct-2010
 * @copyright   (c)2010 JExt.biz, justPHP.net
 */

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

/**
 * Official exchange rates of the National bank of Russia
 */
class currency_data_cbr extends currency_data {
        
        function __construct() {
                parent::__construct ();
                $this->url = "http://www.bank.lv/vk/xml.xml";
                $this->bank_name = "Latvijas Banka";
                $this->bank_url = "http://www.bank.lv/";
                $this->currency_name = "Lat";
        }
        
        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->ID [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] ['ID'] = $dt->ID [0]->data (); // num code
                                $rates ['currency'] [$code] ['scale'] = $dt->Units [0]->data (); // units
                                // Get the rate & replace comma to dot for further number processing
                                $rates ['currency'] [$code] ['rate'] = str_replace ( ',', '.', $dt->Rate [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 . $date;
                } else {
                        $url = $this->url;
                }
                return $url;
        }
}

Но пишет, что невозможно получить данные...

Помогите решить эту проблему... или обновите модуль, это было бы вообще классно.

Латвийские параметры:

XML: http://www.bank.lv/v...l?date=20010323
CSV: http://www.bank.lv/excel/valkurlv.php
RSS: http://www.bank.lv/lat/rss/kursi.php

Буду очень признателен за помощь.