|
TYPO3 API
SVNRelease
|
00001 <?php 00002 00003 /* * 00004 * This script belongs to the FLOW3 package "Fluid". * 00005 * * 00006 * It is free software; you can redistribute it and/or modify it under * 00007 * the terms of the GNU Lesser General Public License as published by the * 00008 * Free Software Foundation, either version 3 of the License, or (at your * 00009 * option) any later version. * 00010 * * 00011 * This script is distributed in the hope that it will be useful, but * 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * 00013 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with the script. * 00018 * If not, see http://www.gnu.org/licenses/lgpl.html * 00019 * * 00020 * The TYPO3 project - inspiring people to share! * 00021 * */ 00022 00023 /** 00024 * Formats a given float to a currency representation. 00025 * 00026 * = Examples = 00027 * 00028 * <code title="Defaults"> 00029 * <f:format.currency>123.456</f:format.currency> 00030 * </code> 00031 * <output> 00032 * 123,46 00033 * </output> 00034 * 00035 * <code title="All parameters"> 00036 * <f:format.currency currencySign="$" decimalSeparator="." thousandsSeparator=",">54321</f:format.currency> 00037 * </code> 00038 * <output> 00039 * 54,321.00 $ 00040 * </output> 00041 * 00042 * <code title="Inline notation"> 00043 * {someNumber -> f:format.currency(thousandsSeparator: ',', currencySign: '€')} 00044 * </code> 00045 * <output> 00046 * 54,321,00 € 00047 * (depending on the value of {someNumber}) 00048 * </output> 00049 * 00050 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later 00051 * @api 00052 */ 00053 class Tx_Fluid_ViewHelpers_Format_CurrencyViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper { 00054 00055 /** 00056 * @param string $currencySign (optional) The currency sign, eg $ or €. 00057 * @param string $decimalSeparator (optional) The separator for the decimal point. 00058 * @param string $thousandsSeparator (optional) The thousands separator. 00059 * @return string the formatted amount. 00060 * @author Bastian Waidelich <bastian@typo3.org> 00061 * @api 00062 */ 00063 public function render($currencySign = '', $decimalSeparator = ',', $thousandsSeparator = '.') { 00064 $stringToFormat = $this->renderChildren(); 00065 $output = number_format($stringToFormat, 2, $decimalSeparator, $thousandsSeparator); 00066 if($currencySign !== '') { 00067 $output.= ' ' . $currencySign; 00068 } 00069 return $output; 00070 } 00071 } 00072 ?>
1.8.0