Commit 79ea59da authored by Tim Steiner's avatar Tim Steiner
Browse files

Create a view helper for doing plain-text diffs. @0h20

parent 80e404a4
<?php
class Unl_View_Helper_TextDiff extends Zend_View_Helper_Abstract
{
static protected $_diffRenderer;
public function textDiff($from, $to)
{
if ($from == $to) {
return $from;
}
if (!self::$_diffRenderer) {
Zend_Loader_Autoloader::getInstance()->registerNamespace('Horde_');
self::$_diffRenderer = new Horde_Text_Diff_Renderer_Inline();
}
$diff = new Horde_Text_Diff('auto',
array(
explode(' ', strtr($from, array("\n" => '*NEWLINE*'))),
explode(' ', strtr($to, array("\n" => '*NEWLINE*')))
)
);
$render = new Horde_Text_Diff_Renderer_Inline();
return strtr($render->render($diff), array('*NEWLINE*' => '<br/>'));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment