yurakr

Зао Акб Агропромбанк (Приднестровье)

2 posts in this topic

Здравствуйте!

Подскажите, как сделать плагин и добавить в модуль курсы валют Приднестровского банка (Агропромбанк).

Вот ссылка на xml: http://www.agroprombank.com/xmlinformer.php?type=official

Заранее благодарен

Share this post


Link to post
Share on other sites

В папке models создать файл agroprombank.class.php


<?php
/**
* @author Darang
* @date 10-Feb-2013
* @copyright (c)2010-2013 JExt.biz
*/
// no direct access
defined ( '_JEXEC' ) or die ( 'Restricted access' );
/**
* exchange rates of Agroprombank
*/
class currency_data_agroprombank extends currency_data {

function __construct() {
parent::__construct ();
$this->url = "http://www.agroprombank.com/xmlinformer.php?type=official&date=";
$this->bank_name = "Агропромбанк";
$this->bank_url = "http://www.agroprombank.com";
$this->currency_name = "";
$this->date_format = 'Y-m-d';
}

function get_array($xml, $day = '', $replace_currency_array) {
// Handle no data received error
if (! isset ( $xml->document->course)) {
$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->course[0]->attributes ( 'date' );
$data = $xml->document->course[0]->currency;
foreach ( $data as $dt ) {
$code = $dt->attributes ( 'code' );
// 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->ID [0]->data (); // num code
$rates ['currency'] [$code] ['scale'] = 1; // units
// Set currency name (array with replacement rules will be searched for the ISO code)
$rates ['currency'] [$code] ['name'] = parent::replace_currency_name ( $code, $code, $replace_currency_array );
$rates ['currency'] [$code] ['rate'] = $dt->data (); // exchange rate
}
}

// 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.date($this->date_format,time());
}
//print_r($url);
return $url;
}
}

в mod_jextcurrency.xml в секцию source_class добавить


<option value="agroprombank">Агропромбанк</option>

1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now