Feature #26843

Padding Type in ViewHelper

Added by Lars Malach over 10 years ago. Updated about 10 years ago.

Status:
Resolved
Priority:
Should have
Category:
ViewHelpers
Target version:
-
Start date:
2011-05-17
Due date:
% Done:

100%

Estimated time:
Has patch:
No

Description

Add the padding type as possible parameters to the PaddingViewHelper.

Of Example:

class Tx_Fluid_ViewHelpers_Format_PaddingViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
    /**
     * Pad a string to a certain length with another string
     *
     * @param integer $padLength Length of the resulting string. If the value of pad_length is negative or less than the length of the input string, no padding takes place.
     * @param string $padString The padding string
     * @param string $padType Append the padding at this site (Possible values: right,left,both. Default: right)
     * @return string The formatted value
     * @author Bastian Waidelich <bastian@typo3.org>
     * @api
     */
    public function render($padLength, $padString = ' ', $padType = 'right') {
        $string = $this->renderChildren();

        $padTypes = array(
            'left' => STR_PAD_LEFT,
            'right' => STR_PAD_RIGHT,
            'both' => STR_PAD_BOTH,
        );
        if (!isset($padTypes[$padType])) {
            $padType = 'right';
        }

        return str_pad($string, $padLength, $padString, $padTypes[$padType]);
    }
}

#1

Updated by Mr. Hudson over 10 years ago

Patch set 1 of change I129a20878ee8831807e9add5ac87d388c79a3737 has been pushed to the review server.
It is available at http://review.typo3.org/3421

#2

Updated by Mr. Hudson over 10 years ago

Patch set 2 of change I129a20878ee8831807e9add5ac87d388c79a3737 has been pushed to the review server.
It is available at http://review.typo3.org/3421

#3

Updated by Bastian Waidelich about 10 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF