[FEATURE] Add missing stdWrap to the new "strPad" properties 78/20278/3
authorWouter Wolters <typo3@wouterwolters.nl>
Sun, 28 Apr 2013 21:09:26 +0000 (23:09 +0200)
committerPhilipp Gampe <philipp.gampe@typo3.org>
Sun, 5 May 2013 12:24:15 +0000 (14:24 +0200)
Change-Id: Id054b5b831d4b3cb83447c01648bb5ed6cde4589
Resolves: #43604
Releases: 6.2
Reviewed-on: https://review.typo3.org/20278
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index 0a24ef2..1229a5b 100644 (file)
@@ -2353,15 +2353,17 @@ class ContentObjectRenderer {
                // Padding on the right side is PHP-default
                $padType = STR_PAD_RIGHT;
                if (!empty($conf['strPad.']['length'])) {
-                       $length = intval($conf['strPad.']['length']);
+                       $length = isset($conf['strPad.']['length.']) ? $this->stdWrap($conf['strPad.']['length'], $conf['strPad.']['length.']) : $conf['strPad.']['length'];
+                       $length = intval($length);
                }
                if (!empty($conf['strPad.']['padWith'])) {
-                       $padWith = $conf['strPad.']['padWith'];
+                       $padWith = isset($conf['strPad.']['padWith.']) ? $this->stdWrap($conf['strPad.']['padWith'], $conf['strPad.']['padWith.']) : $conf['strPad.']['padWith'];
                }
                if (!empty($conf['strPad.']['type'])) {
-                       if (strtolower($conf['strPad.']['type']) === 'left') {
+                       $type = isset($conf['strPad.']['type.']) ? $this->stdWrap($conf['strPad.']['type'], $conf['strPad.']['type.']) : $conf['strPad.']['type'];
+                       if (strtolower($type) === 'left') {
                                $padType = STR_PAD_LEFT;
-                       } elseif (strtolower($conf['strPad.']['type']) === 'both') {
+                       } elseif (strtolower($type) === 'both') {
                                $padType = STR_PAD_BOTH;
                        }
                }
@@ -7837,4 +7839,4 @@ class ContentObjectRenderer {
 
 }
 
-?>
\ No newline at end of file
+?>
index 82b2c28..4eccc2a 100644 (file)
@@ -843,7 +843,7 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                ),
                                '__Alien___',
                        ),
-                       'pad string with padWith _ and type both and length 6' => array(
+                       'pad string with padWith ___ and type both and length 6' => array(
                                'Alien',
                                array(
                                        'length' => '6',
@@ -852,6 +852,44 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                ),
                                'Alien_',
                        ),
+                       'pad string with padWith _ and type both and length 12, using stdWrap for length' => array(
+                               'Alien',
+                               array(
+                                       'length' => '1',
+                                       'length.' => array(
+                                               'wrap' => '|2',
+                                       ),
+                                       'padWith' => '_',
+                                       'type' => 'both',
+                               ),
+                               '___Alien____',
+                       ),
+                       'pad string with padWith _ and type both and length 12, using stdWrap for padWidth' => array(
+                               'Alien',
+                               array(
+                                       'length' => '12',
+                                       'padWith' => '_',
+                                       'padWith.' => array(
+                                               'wrap' => '-|=',
+                                       ),
+                                       'type' => 'both',
+                               ),
+                               '-_=Alien-_=-',
+                       ),
+                       'pad string with padWith _ and type both and length 12, using stdWrap for type' => array(
+                               'Alien',
+                               array(
+                                       'length' => '12',
+                                       'padWith' => '_',
+                                       'type' => 'both',
+                                       // make type become "left"
+                                       'type.' => array(
+                                               'substring' => '2,1',
+                                               'wrap' => 'lef|',
+                                       ),
+                               ),
+                               '_______Alien',
+                       ),
                );
        }