yurakr Posted February 1, 2013 Report Share Posted February 1, 2013 Здравствуйте!Подскажите, как сделать плагин и добавить в модуль курсы валют Приднестровского банка (Агропромбанк).Вот ссылка на xml: http://www.agroprombank.com/xmlinformer.php?type=officialЗаранее благодарен Quote Link to comment Share on other sites More sharing options...
admin Posted February 10, 2013 Report Share Posted February 10, 2013 В папке models создать файл agroprombank.class.php<?php/*** @author Darang* @date 10-Feb-2013* @copyright (c)2010-2013 JExt.biz*/// no direct accessdefined ( '_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 errorif (! 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 setif (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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.