web/lib/Zend/Currency.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    12  * obtain it through the world-wide-web, please send an email
    12  * obtain it through the world-wide-web, please send an email
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category  Zend
    15  * @category  Zend
    16  * @package   Zend_Currency
    16  * @package   Zend_Currency
    17  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    17  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @license   http://framework.zend.com/license/new-bsd     New BSD License
    18  * @license   http://framework.zend.com/license/new-bsd     New BSD License
    19  * @version   $Id: Currency.php 22708 2010-07-28 07:25:16Z thomas $
    19  * @version   $Id: Currency.php 24855 2012-06-01 00:12:25Z adamlundrigan $
    20  */
    20  */
    21 
    21 
    22 /**
    22 /**
    23  * include needed classes
    23  * include needed classes
    24  */
    24  */
    29 /**
    29 /**
    30  * Class for handling currency notations
    30  * Class for handling currency notations
    31  *
    31  *
    32  * @category  Zend
    32  * @category  Zend
    33  * @package   Zend_Currency
    33  * @package   Zend_Currency
    34  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    34  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    35  * @license   http://framework.zend.com/license/new-bsd     New BSD License
    35  * @license   http://framework.zend.com/license/new-bsd     New BSD License
    36  */
    36  */
    37 class Zend_Currency
    37 class Zend_Currency
    38 {
    38 {
    39     // Constants for defining what currency symbol should be displayed
    39     // Constants for defining what currency symbol should be displayed
    89      * @param  string|Zend_Locale $locale  OPTIONAL locale name
    89      * @param  string|Zend_Locale $locale  OPTIONAL locale name
    90      * @throws Zend_Currency_Exception When currency is invalid
    90      * @throws Zend_Currency_Exception When currency is invalid
    91      */
    91      */
    92     public function __construct($options = null, $locale = null)
    92     public function __construct($options = null, $locale = null)
    93     {
    93     {
       
    94         $calloptions = $options;
       
    95         if (is_array($options) && isset($options['display'])) {
       
    96             $this->_options['display'] = $options['display'];
       
    97         }
       
    98 
    94         if (is_array($options)) {
    99         if (is_array($options)) {
    95             $this->setLocale($locale);
   100             $this->setLocale($locale);
    96             $this->setFormat($options);
   101             $this->setFormat($options);
    97         } else if (Zend_Locale::isLocale($options, false, false)) {
   102         } else if (Zend_Locale::isLocale($options, false, false)) {
    98             $this->setLocale($options);
   103             $this->setLocale($options);
   118             require_once 'Zend/Currency/Exception.php';
   123             require_once 'Zend/Currency/Exception.php';
   119             throw new Zend_Currency_Exception("Currency '$options' not found");
   124             throw new Zend_Currency_Exception("Currency '$options' not found");
   120         }
   125         }
   121 
   126 
   122         // Get the format
   127         // Get the format
   123         if (!empty($this->_options['symbol'])) {
   128         if ((is_array($calloptions) && !isset($calloptions['display']))
   124             $this->_options['display'] = self::USE_SYMBOL;
   129                 || (!is_array($calloptions) && $this->_options['display'] == self::NO_SYMBOL)) {
   125         } else if (!empty($this->_options['currency'])) {
   130             if (!empty($this->_options['symbol'])) {
   126             $this->_options['display'] = self::USE_SHORTNAME;
   131                 $this->_options['display'] = self::USE_SYMBOL;
       
   132             } else if (!empty($this->_options['currency'])) {
       
   133                 $this->_options['display'] = self::USE_SHORTNAME;
       
   134             }
   127         }
   135         }
   128     }
   136     }
   129 
   137 
   130     /**
   138     /**
   131      * Returns a localized currency string
   139      * Returns a localized currency string
   792         if (is_string($service)) {
   800         if (is_string($service)) {
   793             require_once 'Zend/Loader.php';
   801             require_once 'Zend/Loader.php';
   794             if (!class_exists($service)) {
   802             if (!class_exists($service)) {
   795                 $file = str_replace('_', DIRECTORY_SEPARATOR, $service) . '.php';
   803                 $file = str_replace('_', DIRECTORY_SEPARATOR, $service) . '.php';
   796                 if (Zend_Loader::isReadable($file)) {
   804                 if (Zend_Loader::isReadable($file)) {
   797                     Zend_Loader::loadClass($class);
   805                     Zend_Loader::loadClass($service);
   798                 }
   806                 }
   799             }
   807             }
   800 
   808 
   801             $service = new $service;
   809             $service = new $service;
   802         }
   810         }