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_Filter_Newline
{zone-data}

{zone-data:proposer-list}
[~thomas]
{zone-data}

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

{zone-data:revision}
1.0 - 8 August 2009: Initial Draft.
{zone-data}

{zone-data:overview}
Zend_Filter_Newline is a filter which handles conversion between various line termination styles used on different architectures.
{zone-data}

{zone-data:references}
* [Wikipedia Entry on Newline|http://en.wikipedia.org/wiki/Newline]
* [Prototype of previous proposal here - works slightly different than this proposal|http://code.google.com/p/zfunixtoolchain/source/browse/trunk/unix-toolchain/library/Zend/Filter/ConvertNewlines.php]
{zone-data}

{zone-data:requirements}
* This component *will* support Windows, Unix, Mac, Native and custom line terminators
* This component *will* also support Unicode line terminators
* This component *will* allow to replace newlines with arbitrary text
{zone-data}

{zone-data:dependencies}
* Zend_Filter_Interface
* Zend_View_Helper_Newline
{zone-data}

{zone-data:operation}
Zend_Filter_Newline is a filter which can change/filter newlines of given strings. It takes also care of unicode line terminators. For simplicity this filter also adds a view helper which makes use of this filter.
{zone-data}

{zone-data:milestones}
* 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
{zone-data}

{zone-data:class-list}
* Zend_Filter_Newline
* Zend_View_Helper_Newline
{zone-data}

{zone-data:use-cases}
||UC-01||
Converting Mac to Windows
{code}
$filter = new Zend_Filter_Newline(array('delimiter' => Zend_Filter_Newline::WINDOWS));

$filter->filter("a\rb\r");
// returns a\r\nb\r\n
{code}
||UC-02||
Converting Windows-style into '<br />'s
{code}
$filter = new Zend_Filter_Newline(array('delimiter' => '<br />'));

$filter->filter("abc\r\ndef\r\n");
// returns abc<br />def<br />
{code}
{zone-data}

{zone-data:skeletons}
{code}
class Zend_Filter_Newline implements Zend_Filter_Interface
{
const NATIVE;
const WINDOWS;
const UNIX;
const MAC;
const NEXTLINE;
const FORMFEED;
const LINESEPARATOR
const FORMSEPARATOR
const ALL

public function __construct($options)
public function setDelimiter($delimiter = null)
public function getDelimiter()
public function filter($value)
}

class Zend_View_Helper_Newline implements Zend_View_Helper_Abstract
{
public newline($value);
}
{code}
{zone-data}

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