File indexing completed on 2025-03-02 05:29:19
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Dojo 0017 * @subpackage Form_Element 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 */ 0021 0022 /** Zend_Dojo_Form_Element_NumberTextBox */ 0023 // require_once 'Zend/Dojo/Form/Element/NumberTextBox.php'; 0024 0025 /** 0026 * CurrencyTextBox dijit 0027 * 0028 * @uses Zend_Dojo_Form_Element_NumberTextBox 0029 * @package Zend_Dojo 0030 * @subpackage Form_Element 0031 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0032 * @license http://framework.zend.com/license/new-bsd New BSD License 0033 * @version $Id$ 0034 */ 0035 class Zend_Dojo_Form_Element_CurrencyTextBox extends Zend_Dojo_Form_Element_NumberTextBox 0036 { 0037 /** 0038 * Use CurrencyTextBox dijit view helper 0039 * @var string 0040 */ 0041 public $helper = 'CurrencyTextBox'; 0042 0043 /** 0044 * Set currency 0045 * 0046 * @param string $currency 0047 * @return Zend_Dojo_Form_Element_CurrencyTextBox 0048 */ 0049 public function setCurrency($currency) 0050 { 0051 $this->setDijitParam('currency', (string) $currency); 0052 return $this; 0053 } 0054 0055 /** 0056 * Retrieve currency 0057 * 0058 * @return string|null 0059 */ 0060 public function getCurrency() 0061 { 0062 return $this->getDijitParam('currency'); 0063 } 0064 0065 /** 0066 * Set currency symbol 0067 * 0068 * Casts to string, uppercases, and trims to three characters. 0069 * 0070 * @param string $symbol 0071 * @return Zend_Dojo_Form_Element_CurrencyTextBox 0072 */ 0073 public function setSymbol($symbol) 0074 { 0075 $symbol = strtoupper((string) $symbol); 0076 $length = strlen($symbol); 0077 if (3 > $length) { 0078 // require_once 'Zend/Form/Element/Exception.php'; 0079 throw new Zend_Form_Element_Exception('Invalid symbol provided; please provide ISO 4217 alphabetic currency code'); 0080 } 0081 if (3 < $length) { 0082 $symbol = substr($symbol, 0, 3); 0083 } 0084 0085 $this->setConstraint('symbol', $symbol); 0086 return $this; 0087 } 0088 0089 /** 0090 * Retrieve symbol 0091 * 0092 * @return string|null 0093 */ 0094 public function getSymbol() 0095 { 0096 return $this->getConstraint('symbol'); 0097 } 0098 0099 /** 0100 * Set whether currency is fractional 0101 * 0102 * @param bool $flag 0103 * @return Zend_Dojo_Form_Element_CurrencyTextBox 0104 */ 0105 public function setFractional($flag) 0106 { 0107 $this->setConstraint('fractional', (bool) $flag); 0108 return $this; 0109 } 0110 0111 /** 0112 * Get whether or not to present fractional values 0113 * 0114 * @return bool 0115 */ 0116 public function getFractional() 0117 { 0118 return ('true' == $this->getConstraint('fractional')); 0119 } 0120 }