diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Dojo/Form/Element/CurrencyTextBox.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Dojo/Form/Element/CurrencyTextBox.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,120 @@ +setDijitParam('currency', (string) $currency); + return $this; + } + + /** + * Retrieve currency + * + * @return string|null + */ + public function getCurrency() + { + return $this->getDijitParam('currency'); + } + + /** + * Set currency symbol + * + * Casts to string, uppercases, and trims to three characters. + * + * @param string $symbol + * @return Zend_Dojo_Form_Element_CurrencyTextBox + */ + public function setSymbol($symbol) + { + $symbol = strtoupper((string) $symbol); + $length = strlen($symbol); + if (3 > $length) { + require_once 'Zend/Form/Element/Exception.php'; + throw new Zend_Form_Element_Exception('Invalid symbol provided; please provide ISO 4217 alphabetic currency code'); + } + if (3 < $length) { + $symbol = substr($symbol, 0, 3); + } + + $this->setConstraint('symbol', $symbol); + return $this; + } + + /** + * Retrieve symbol + * + * @return string|null + */ + public function getSymbol() + { + return $this->getConstraint('symbol'); + } + + /** + * Set whether currency is fractional + * + * @param bool $flag + * @return Zend_Dojo_Form_Element_CurrencyTextBox + */ + public function setFractional($flag) + { + $this->setConstraint('fractional', (bool) $flag); + return $this; + } + + /** + * Get whether or not to present fractional values + * + * @return bool + */ + public function getFractional() + { + return ('true' == $this->getConstraint('fractional')); + } +}