View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}




1.0 - 23 July 2009: Initial Draft.

Zend_Filter_StringPad is a filter which allows to extend strings to a specific length.

* [PHP's str_pad|]
* [Based on the StringLength Proposal - see Zend comments|]

* This component *will* correctly handle multi byte strings.
* This component *will* support the same parameters as PHP's own str_pad method.


This filter extends given strings to the wished length. It accepts and other string for extension/padding and default to whitespace if non is given.
It also supports extension from left, right or both sides.
For simplicity this component adds also a view helper which makes use of this filter.

* Milestone 1: \[DONE\] Proposal finished
* Milestone 2: Proposal accepted
* Milestone 3: Working implementation
* Milestone 4: Unit tests
* Milestone 5: Documentation
* Milestone 6: Moved to core

* Zend_Filter_StringPad
* Zend_View_Helper_StringPad

Extends a string to 15 chars
$filter = new Zend_Filter_StringPad(array('length' => 15);
$filter->filter('My string');
// returns 'My string '
Extends a string to 15 chars, using another pad char
$filter = new Zend_Filter_StringPad(array('length' => 15, 'ending' => '.'));
$filter->filter('My string');
// returns 'My string......'
Extends a string to 15 chars, using another pad char and another direction
$filter = new Zend_Filter_StringPad(array('length' => 15, 'ending' => '.', 'type' => Zend_Filter_StringPad::LEFT));
$filter->filter('My string');
// returns '......My string'

class Zend_Filter_StringPad implements Zend_Filter_Interface {
constant LEFT = 'left';
constant BOTH = 'both';
constant RIGHT = 'right';

public function __construct($options);
public function getLength();
public function setLength($length);
public function getEnding();
public function setEnding();
public function getType();
public function setType($type);

class Zend_View_Helper_StringPad extends Zend_View_Helper_Abstract {
public function stringPad($options);