[FEATURE] Make "base" of stdWrap_bytes configurable 74/42274/6
authorManuel Selbach <manuel_selbach@yahoo.de>
Wed, 5 Aug 2015 13:08:51 +0000 (15:08 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 5 Aug 2015 20:06:43 +0000 (22:06 +0200)
It is possible now to set the base parameter via TypoScript to define
a base (1000 or 1024) to calculate with if you add custom labels for file
sizes. This allows proper handling of KB/KiB etc.

Resolves: #68756
Releases: master
Change-Id: I345d4584117ac83cd9d49f0ecda0dc2f686ac7ed
Reviewed-on: http://review.typo3.org/42274
Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Documentation/Changelog/master/Feature-68756-AddConfigBaseToStdWrap.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-68756-AddConfigBaseToStdWrap.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-68756-AddConfigBaseToStdWrap.rst
new file mode 100644 (file)
index 0000000..2bfc11a
--- /dev/null
@@ -0,0 +1,30 @@
+==============================================
+Feature: #68756 - Add config "base" to stdWrap
+==============================================
+
+Description
+===========
+
+Follow up: #22175
+
+The following function was updated and added with a new optional parameter $base:
+TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($sizeInBytes, $labels = '', $base = 0)
+
+This impacts the function:
+TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->stdWrap_bytes
+
+It is not possible now, to set the base parameter via TypoScript if you add custom labels.
+
+
+Impact
+======
+
+Ability to set the base (1000 or 1024) via TypoScript configuration was added.
+
+The following lines should be added to the file "TYPO3CMS-Reference-Typoscript/Documentation/Functions/Stdwrap/Index.rst" in the "Property bytes container".
+
+With the ``base`` property it can be defined whether to use a base of 1000 or 1024 to calculate with
+
+Thus::
+    bytes.labels = " | K| M| G"
+    bytes.base = 1000
\ No newline at end of file
index fb1cb59..e905a07 100755 (executable)
@@ -3012,7 +3012,7 @@ class ContentObjectRenderer {
         * @return string The processed input value
         */
        public function stdWrap_bytes($content = '', $conf = array()) {
-               return GeneralUtility::formatSize($content, $conf['bytes.']['labels']);
+               return GeneralUtility::formatSize($content, $conf['bytes.']['labels'], $conf['bytes.']['base']);
        }
 
        /**