View Source

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

{zone-data:component-name}
Zend_View_Helper_IndentLines
{zone-data}

{zone-data:proposer-list}
[Jon Whitcraft|mailto:jon.zf@mac.com]
{zone-data}

{zone-data:liaison}
TBD
{zone-data}

{zone-data:revision}
1.0 - 6 Feb 2009: Initial Draft.
{zone-data}

{zone-data:overview}
Zend_View_Helper_IndentLines
{zone-data}

{zone-data:requirements}

* This helper *will* add whitespace to each line of anything passed to it.
* This helper *will* be extendable to allow you to easily add this functionality to other view helpers
{zone-data}

{zone-data:dependencies}
* Zend_View_Exception
{zone-data}

{zone-data:milestones}
* Milestone 1: [design notes will be published here|http://framework.zend.com/wiki/x/sg]
* Milestone 2: Working prototype checked into the incubator supporting use cases
* Milestone 4: Unit tests exist, work, and are checked into SVN.
* Milestone 5: Initial documentation exists.
{zone-data}

{zone-data:class-list}
* Zend_View_Helper_IndentLines
{zone-data}

{zone-data:references}
{zone-data}

{zone-data:operation}
{zone-data}

{zone-data:use-cases}
||UC-01||
{code}
$content = 'Hello
World';

print $this->indentLines(4, $content);

// outputs
Hello
World
{code}
{zone-data}

{zone-data:skeletons}
{code}
<?php

class Zend_View_Helper_IndentLines extends Zend_View_Helper_Abstract
{

protected $_indentCharacter = ' ';

protected $_endOfLineCharacter = PHP_EOL;

public function indentLines($indentLength, $content)
{
if(func_num_args() == 0) {
return $this;
}

$lines = preg_split('/\r\n|\r|\n/', $content);

$text = '';
$indent = str_repeat($this->_indentCharacter, $indentLength)
foreach($lines as $line) {
$text .= $indent . $line . $_endOfLineCharacter;
}

return $text;
}

public function setIndentCharacter($newCharacter)
{
$this->_indentCharacter = $newCharager;

return $this;
}

public function getIndentCharacter()
{
return $this->_indentCharacter;
}

public function setEndOfLineCharacter($newCharacter)
{
$this->_endOfLineCharacter = $newCharacter;

return $this;
}

public function getEndOfLineCharacter()
{
return $this->_endOfLineCharacter;
}
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>