Fixed bug #13815: Feature: Add .numberFormat function to stdWrap (Thanks to Sebastian...
authorSteffen Kamper <info@sk-typo3.de>
Thu, 12 Aug 2010 12:05:57 +0000 (12:05 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Thu, 12 Aug 2010 12:05:57 +0000 (12:05 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8579 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/tslib/class.tslib_content.php

index eaf7ed3..fe2a4e5 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-08-12 Steffen Kamper  <steffen@typo3.org>
+
+       * Fixed bug #13815: Feature: Add .numberFormat function to stdWrap (Thanks to Sebastian Michaelsen)
+
 2010-08-12  Xavier Perseguers  <typo3@perseguers.ch>
 
        * Fixed bug #15396: [scheduler] Wrong query - crashes with DBAL
index 23fe2c9..a4df156 100644 (file)
@@ -3808,6 +3808,9 @@ class tslib_cObj {
                                if ($conf['prioriCalc']){$content=t3lib_div::calcParenthesis($content); if ($conf['prioriCalc']=='intval') $content=intval($content);}
                                if ((string)$conf['char']!=''){$content=chr(intval($conf['char']));}
                                if ($conf['intval']){$content=intval($content);}
+                               if ($conf['numberFormat.']) {
+                                       $content = $this->numberFormat($content, $conf['numberFormat.']);
+                               }
                                if ($conf['date']) {
                                        $content = ($conf['date.']['GMT'] ? gmdate($conf['date'], $content) : date($conf['date'], $content));
                                }
@@ -4838,6 +4841,21 @@ class tslib_cObj {
        }
 
        /**
+        * Implements the stdWrap property "numberFormat"
+        * This is a Wrapper function for php's number_format()
+        *
+        * @param       float   Value to process
+        * @param       array   TypoScript Configuration for numberFormat
+        * @return      string  The formated number
+        */
+       function numberFormat($content, $conf) {
+               $decimals = $this->stdWrap($conf['decimals'], $conf['decimals.']);
+               $dec_point = $this->stdWrap($conf['dec_point'], $conf['dec_point.']);
+               $thousands_sep = $this->stdWrap($conf['thousands_sep'], $conf['thousands_sep.']);
+               return number_format($content, $decimals, $dec_point, $thousands_sep);
+       }
+       
+       /**
         * Implements the stdWrap property, "parseFunc".
         * This is a function with a lot of interesting uses. In classic TypoScript this is used to process text from the bodytext field; This included highlighting of search words, changing http:// and mailto: prefixed strings into links, parsing <typolist>, <typohead> and <typocode> tags etc.
         * It is still a very important function for processing of bodytext which is normally stored in the database in a format which is not fully ready to be outputted. This situation has not become better by having a RTE around...