[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZCurrency class 4 // 5 // Created on: <01-Mar-2002 13:47:55 amos> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! 30 \class eZCurrency ezcurrency.php 31 \ingroup eZLocale 32 \brief Locale aware currency class 33 34 eZCurrency handles currency values and allows for easy 35 output with toString() and conversion with adjustValue(). 36 37 A new instance of eZCurrency will automaticly use the current locale, 38 if you however want a different locale use the setLocale() function. 39 The current locale can be fetched with locale(). 40 41 Change the currency value with setValue() or convert it to a new currency type 42 with adjustValue() and setLocale(). 43 If you want more detiled information on the currency use type(), name() and shortName(). 44 45 Text output is done with toString() which returns a representation according to the current locale. 46 47 \sa eZLocale 48 */ 49 50 include_once ( "lib/ezlocale/classes/ezlocale.php" ); 51 52 class eZCurrency 53 { 54 /*! 55 Creates a new eZCurrency object with the currency value $value. $value can be a numerical 56 value or an eZCurrency object in which case the value is extracted and copied. 57 */ 58 function eZCurrency( $value ) 59 { 60 if ( get_class( $value ) == "ezcurrency" ) 61 $value =& $value->value(); 62 $this->Value =& $value; 63 $this->Locale =& eZLocale::instance(); 64 } 65 66 /*! 67 Sets the locale to $locale which is used in text output. 68 */ 69 function setLocale( &$locale ) 70 { 71 $this->Locale =& $locale; 72 } 73 74 /*! 75 Adjust the value so that it can be represented in a different currency. 76 The $old_scale is a float value which represents the current currency rate 77 while $new_scale represents the new currency rate. All rates should be calculated 78 from the dollar which then gets the rate 1.0. 79 */ 80 function adjustValue( $old_scale, $new_scale ) 81 { 82 $this->Value = ( $this->Value * $new_scale ) / $old_scale; 83 } 84 85 /*! 86 Sets the currency value to $value. 87 */ 88 function setValue( $value ) 89 { 90 $this->Value =& $value; 91 } 92 93 /*! 94 Returns a reference to the current locale. 95 */ 96 function &locale() 97 { 98 return $this->Locale; 99 } 100 101 /*! 102 Returns the currency value. 103 */ 104 function value() 105 { 106 return $this->Value; 107 } 108 109 /*! 110 Returns the currency symbol, for instance kr for NOK or $ for USD. 111 */ 112 function symbol() 113 { 114 return $this->Locale->currencySymbol(); 115 } 116 117 /*! 118 Returns the name of the currency, for instance Norwegian Kroner or US dollar. 119 */ 120 function name() 121 { 122 return $this->Locale->currencyName(); 123 } 124 125 /*! 126 Returns a 3 letter name for the currency, for instance NOK or USD. 127 */ 128 function shortName() 129 { 130 return $this->Locale->currencyShortName(); 131 } 132 133 /*! 134 Returns a text representation of the currency according to the current locale. 135 */ 136 function toString() 137 { 138 return $this->Locale->formatCurrency( $this->Value ); 139 } 140 141 /// The currency value. 142 var $Value; 143 /// The current locale object 144 var $Locale; 145 } 146 147 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |