Skip to content

Commit

Permalink
Currency Module - Multiplier Tag xibosignage/xibo#1001
Browse files Browse the repository at this point in the history
  • Loading branch information
maurofmferrao committed Jan 6, 2017
1 parent 1b16104 commit b0c33dd
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions lib/Widget/Currencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,23 +326,33 @@ private function makeSubstitutions($data, $source, $baseCurrency)
if (isset($data['Name']))
$replacement = trim(str_replace($replaceBase,'',$data['Name']));

// If there's a multiplier, add it to the currency name
break;

case 'Multiplier':

// Initialize replacement with empty string
$replacement = '';

// Get the current currency name/code
$pairName = ( $reverseConversion ) ? ('/' . $baseCurrency) : ($baseCurrency . '/');

if (isset($data['Name']))
$currencyName = trim(str_replace($pairName,'',$data['Name']));

// Search for the item that relates to the actual currency
foreach ($items as $item) {

// Get the item name
$itemName = trim(explode('|', $item)[0]);

// Compare the item name with the actual currency and test if the inputed value has a multiplier flag
if( sizeof(explode('|', $item)) > 1 && strcmp($itemName, $replacement) == 0 ){
// Get the multiplier
$multiplier = explode('|', $item)[1];
if( sizeof(explode('|', $item)) > 1 && strcmp($itemName, $currencyName) == 0 ){

// Set the replacement to be the API value times the multiplier
$replacement = $multiplier . ' ' . $replacement;
// Get the multiplier
$replacement = explode('|', $item)[1];
}
}
}

break;

case 'CurrencyFlag':
Expand Down

0 comments on commit b0c33dd

Please sign in to comment.