Index: branches/5.2.x/units/helpers/currency_rates.php =================================================================== diff -u -N -r15166 -r15367 --- branches/5.2.x/units/helpers/currency_rates.php (.../currency_rates.php) (revision 15166) +++ branches/5.2.x/units/helpers/currency_rates.php (.../currency_rates.php) (revision 15367) @@ -1,6 +1,6 @@ GetRate($source_cur, $target_cur); } + function AddCurrencySymbol($value, $iso, $decimal_tag = '') + { + static $decimal_separator = false; + + $cache_key = 'iso_masks[%CurrSerial%]'; + $iso_masks = $this->Application->getCache($cache_key); + + if ( $iso_masks === false ) { + $this->Conn->nextQueryCachable = true; + $symbol_sql = 'IF(COALESCE(Symbol, "") = "", CONCAT(ISO, " "), Symbol)'; + + $sql = 'SELECT IF(SymbolPosition = 0, CONCAT(' . $symbol_sql . ', "%s"), CONCAT("%s", ' . $symbol_sql . ')), LOWER(ISO) AS ISO + FROM ' . $this->Application->getUnitOption('curr', 'TableName') . ' + WHERE Status = ' . STATUS_ACTIVE; + $iso_masks = $this->Conn->GetCol($sql, 'ISO'); + $this->Application->setCache($cache_key, $iso_masks); + } + + if ( $decimal_tag ) { + if ( $decimal_separator === false ) { + $language = $this->Application->recallObject('lang.current'); + /* @var $language LanguagesItem */ + + $decimal_separator = $language->GetDBField('DecimalPoint'); + } + + list ($integer_part, $decimal_part) = explode($decimal_separator, $value); + $value = $integer_part . $decimal_separator . '<' . $decimal_tag . '>' . $decimal_part . ''; + } + + $iso = strtolower($iso); + + return array_key_exists($iso, $iso_masks) ? sprintf($iso_masks[$iso], $value) : $value; + } + function SetRate($source_cur, $target_cur, $rate, $units = 1) { $this->ExchangeRates[$target_cur]['TARGET'] = $source_cur;