Source of file I18nCurrency.php
Size: 2,013 Bytes - Last Modified: 2021-12-24T05:19:36+00:00
/var/www/docs.ssmods.com/process/src/code/model/I18nCurrency.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 | <?php /** * allows more customization of the Silverstripe Currency Formating * * @package modules: i18n_fieldtype * @author ivo.bathke */ class I18nCurrency extends Currency { protected static $decimalDelimiter = false; protected static $thousandDelimiter = false; public static function getCurrencySymbol() { return self::$currencySymbol; } /** * formats value with Symbol and Delimiter * @see Currency::Nice() */ public function Nice() { if (isset($this->value)) { self::init(); $val = self::$currencySymbol . number_format(abs($this->value), 2, self::$decimalDelimiter, self::$thousandDelimiter); if ($this->value < 0) { return "($val)"; } else { return $val; } } } /** * formats without symbol but with delimiter * @return string */ public function Pure() { if (isset($this->value)) { self::init(); return number_format(abs($this->value), 2, self::$decimalDelimiter, self::$thousandDelimiter); } } /** * return unformatted value */ public function Raw() { $this->getValue(); } public static function setDecimalDelimiter($value) { self::$decimalDelimiter = $value; } public static function setThousandDelimiter($value) { self::$thousandDelimiter = $value; } public static function getDecimalDelimiter() { return self::$decimalDelimiter; } public static function getThousandDelimiter() { return self::$thousandDelimiter; } private static function init() { if (self::$decimalDelimiter === false) { self::$decimalDelimiter = _t('CURRENCY.DECIMALDELIMITER', '.'); } if (self::$thousandDelimiter === false) { self::$thousandDelimiter = _t('CURRENCY.THOUSANDDELIMITER', ''); } } } |