Jump to content
UTM.SPACE community

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


Recommended Posts

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

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

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

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

Link to comment
Share on other sites

  • 2 weeks later...

В папке 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>

  • Like 1
Link to comment
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...
×
×
  • Create New...