<?php
// vim:filetype=php expandtab tabstop=2 softtabstop=2 shiftwidth=2 autoindent smartindent
// $Id$
function tribune_xurrency_info() {
$status = class_exists("SoapClient") ? t
("available") : t
("<strong>not</strong> available");
return t
('Converts between currencies using data from !url (needs Soap which is !status)', array('!url' => l
('Xurrency', 'http://xurrency.com/api'), '!status' => $status));
}
function tribune_xurrency_filter(&$post) {
'info' => variable_get('tribune_xurrency_name', "Xurrency"),
);
if (variable_get('tribune_xurrency_authentified', FALSE)) {
$answer['login'] = $answer['info'];
}
if (preg_match(':([0-9]+([,\.][0-9]{2})?) ?([A-Z]{3}) '. t
('[ei]n') .' ([A-Z]{3}):', $post['message'], $matches)) {
$comma = FALSE;
$amount = $matches[1];
if (strpos($amount, ',') !== FALSE) {
$comma = TRUE;
}
$cur1 = $matches[3];
$cur2 = $matches[4];
$response = array('error' => FALSE, 'text' => "");
if (_tribune_xurrency_are_symbols_valid
(array($cur1, $cur2))) {
$result = _tribune_xurrency_convert($amount, $cur1, $cur2);
if ($result) {
if ($comma) {
}
$answer['message'] = tribune_filters_print_clock($post) ." ". $amount ." ". $cur1 ." = ". $result ." ". $cur2;
}
}
}
}
function _tribune_xurrency_are_symbols_valid($symbols) {
$xurrency = new SoapClient('http://xurrency.com/api.wsdl');
foreach ($symbols as $symbol) {
if (!$xurrency->isCurrency(strtolower($symbol))) {
return FALSE;
}
}
return TRUE;
}
function _tribune_xurrency_convert($amount, $from, $to) {
$xurrency = new SoapClient('http://xurrency.com/api.wsdl');
}
function tribune_xurrency_settings() {
$form['tribune_xurrency_name'] = array(
'#type' => "textfield",
'#title' => t("Display name"),
'#default_value' => variable_get('tribune_xurrency_name', "Xurrency"),
);
$form['tribune_xurrency_authentified'] = array(
'#type' => "checkbox",
'#title' => t("Appear to be authentified"),
'#default_value' => variable_get('tribune_xurrency_authentified', FALSE),
'#description' => t("Whether this filter will appear to be 'anonymous' or 'authentified'. Since the filter does not correspond to a real user, posting as authentified may result in 'nickname collisions'."),
);
return system_settings_form($form);
}