Source of file BootstrapCurrencyField.php
Size: 1,911 Bytes - Last Modified: 2022-02-21T10:01:11+00:00
/var/www/docs.ssmods.com/process/src/code/forms/BootstrapCurrencyField.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 | <?php /** * Text input field with validation for numeric values. Supports validating * the numeric value as to the {@link i18n::get_locale()} value. * * @package forms * @subpackage fields-formattedinput */ class BootstrapCurrencyField extends NumericField { protected $currency_symbol = null; /** * displays the value in its current locality format */ public function setValue($value, $data = array()) { require_once THIRDPARTY_PATH."/Zend/Locale/Format.php"; // If passing in a non-string number, or a value // directly from a dataobject then localise this number if ((is_numeric($value) && !is_string($value)) || ($value && $data instanceof DataObject) ){ $locale = new Zend_Locale($this->getLocale()); $this->value = Zend_Locale_Format::toNumber($value, array('locale' => $locale)); }else if(Zend_Locale_Format::isNumber( $this->clean($value), array('locale' => i18n::get_locale()) )){ // If an invalid number, store it anyway, but validate() will fail $this->value = $this->clean($value); } return $this; } /** * extracts the * @return type */ public function dataValue() { require_once THIRDPARTY_PATH."/Zend/Locale/Format.php"; $locale = new Zend_Locale(i18n::get_locale()); $number = Zend_Locale_Format::getNumber($this->value, array('locale' => $locale)); return $number; } public function CurrencySymbol(){ if($this->currency_symbol) return $this->currency_symbol; require_once THIRDPARTY_PATH."/Zend/Currency.php"; $locale = new Zend_Locale(i18n::get_locale()); $symbol = new Zend_Currency($locale); return $symbol->getSymbol(); } public function setCurrencySymbol($symbol = null){ $this->currency_symbol = $symbol; return $this; } public function setEmpty(){ $this->value = null; return $this; } } |