ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
Text_Diff_Renderer Class Reference
+ Inheritance diagram for Text_Diff_Renderer:
+ Collaboration diagram for Text_Diff_Renderer:

Public Member Functions

 Text_Diff_Renderer ($params=array())
 Constructor.
 getParams ()
 Get any renderer parameters.
 render ($diff)
 Renders a diff.
 _block ($xbeg, $xlen, $ybeg, $ylen, &$edits)
 _startDiff ()
 _endDiff ()
 _blockHeader ($xbeg, $xlen, $ybeg, $ylen)
 _startBlock ($header)
 _endBlock ()
 _lines ($lines, $prefix= ' ')
 _context ($lines)
 _added ($lines)
 _deleted ($lines)
 _changed ($orig, $final)

Data Fields

 $_leading_context_lines = 0
 Number of leading context "lines" to preserve.
 $_trailing_context_lines = 0
 Number of trailing context "lines" to preserve.

Detailed Description

Definition at line 12 of file Renderer.php.

Member Function Documentation

Text_Diff_Renderer::_added (   $lines)

Reimplemented in Text_Diff_Renderer_unified.

Definition at line 194 of file Renderer.php.

References _lines().

Referenced by _block(), and _changed().

{
return $this->_lines($lines, '>');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Text_Diff_Renderer::_block (   $xbeg,
  $xlen,
  $ybeg,
  $ylen,
$edits 
)

Definition at line 125 of file Renderer.php.

References _added(), _blockHeader(), _changed(), _context(), _deleted(), _endBlock(), and _startBlock().

Referenced by render().

{
$output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
foreach ($edits as $edit) {
switch (strtolower(get_class($edit))) {
case 'text_diff_op_copy':
$output .= $this->_context($edit->orig);
break;
case 'text_diff_op_add':
$output .= $this->_added($edit->final);
break;
case 'text_diff_op_delete':
$output .= $this->_deleted($edit->orig);
break;
case 'text_diff_op_change':
$output .= $this->_changed($edit->orig, $edit->final);
break;
}
}
return $output . $this->_endBlock();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Text_Diff_Renderer::_blockHeader (   $xbeg,
  $xlen,
  $ybeg,
  $ylen 
)

Reimplemented in Text_Diff_Renderer_unified.

Definition at line 162 of file Renderer.php.

Referenced by _block().

{
if ($xlen > 1) {
$xbeg .= ',' . ($xbeg + $xlen - 1);
}
if ($ylen > 1) {
$ybeg .= ',' . ($ybeg + $ylen - 1);
}
return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
}

+ Here is the caller graph for this function:

Text_Diff_Renderer::_changed (   $orig,
  $final 
)

Reimplemented in Text_Diff_Renderer_unified.

Definition at line 204 of file Renderer.php.

References _added(), and _deleted().

Referenced by _block().

{
return $this->_deleted($orig) . "---\n" . $this->_added($final);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Text_Diff_Renderer::_context (   $lines)

Definition at line 189 of file Renderer.php.

References _lines().

Referenced by _block().

{
return $this->_lines($lines);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Text_Diff_Renderer::_deleted (   $lines)

Reimplemented in Text_Diff_Renderer_unified.

Definition at line 199 of file Renderer.php.

References _lines().

Referenced by _block(), and _changed().

{
return $this->_lines($lines, '<');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Text_Diff_Renderer::_endBlock ( )

Definition at line 179 of file Renderer.php.

Referenced by _block().

{
return '';
}

+ Here is the caller graph for this function:

Text_Diff_Renderer::_endDiff ( )

Definition at line 157 of file Renderer.php.

Referenced by render().

{
return '';
}

+ Here is the caller graph for this function:

Text_Diff_Renderer::_lines (   $lines,
  $prefix = ' ' 
)

Definition at line 184 of file Renderer.php.

Referenced by Text_Diff_Renderer_unified\_added(), _added(), _context(), Text_Diff_Renderer_unified\_deleted(), and _deleted().

{
return $prefix . implode("\n$prefix", $lines) . "\n";
}

+ Here is the caller graph for this function:

Text_Diff_Renderer::_startBlock (   $header)

Definition at line 174 of file Renderer.php.

Referenced by _block().

{
return $header . "\n";
}

+ Here is the caller graph for this function:

Text_Diff_Renderer::_startDiff ( )

Definition at line 152 of file Renderer.php.

Referenced by render().

{
return '';
}

+ Here is the caller graph for this function:

Text_Diff_Renderer::getParams ( )

Get any renderer parameters.

Returns
array All parameters of this renderer object.

Definition at line 48 of file Renderer.php.

{
$params = array();
foreach (get_object_vars($this) as $k => $v) {
if ($k{0} == '_') {
$params[substr($k, 1)] = $v;
}
}
return $params;
}
Text_Diff_Renderer::render (   $diff)

Renders a diff.

Parameters
Text_Diff$diffA Text_Diff object.
Returns
string The formatted output.

Definition at line 67 of file Renderer.php.

References $_leading_context_lines, $_trailing_context_lines, _block(), _endDiff(), and _startDiff().

{
$xi = $yi = 1;
$block = false;
$context = array();
$output = $this->_startDiff();
foreach ($diff->getDiff() as $edit) {
if ($edit instanceof Text_Diff_Op_copy) {
if (is_array($block)) {
if (count($edit->orig) <= $nlead + $ntrail) {
$block[] = $edit;
} else {
if ($ntrail) {
$context = array_slice($edit->orig, 0, $ntrail);
$block[] = new Text_Diff_Op_copy($context);
}
$output .= $this->_block($x0, $ntrail + $xi - $x0,
$y0, $ntrail + $yi - $y0,
$block);
$block = false;
}
}
$context = $edit->orig;
} else {
if (!is_array($block)) {
$context = array_slice($context, count($context) - $nlead);
$x0 = $xi - count($context);
$y0 = $yi - count($context);
$block = array();
if ($context) {
$block[] = new Text_Diff_Op_copy($context);
}
}
$block[] = $edit;
}
if ($edit->orig) {
$xi += count($edit->orig);
}
if ($edit->final) {
$yi += count($edit->final);
}
}
if (is_array($block)) {
$output .= $this->_block($x0, $xi - $x0,
$y0, $yi - $y0,
$block);
}
return $output . $this->_endDiff();
}

+ Here is the call graph for this function:

Text_Diff_Renderer::Text_Diff_Renderer (   $params = array())

Constructor.

Definition at line 33 of file Renderer.php.

{
foreach ($params as $param => $value) {
$v = '_' . $param;
if (isset($this->$v)) {
$this->$v = $value;
}
}
}

Field Documentation

Text_Diff_Renderer::$_leading_context_lines = 0

Number of leading context "lines" to preserve.

This should be left at zero for this class, but subclasses may want to set this to other values.

Definition at line 20 of file Renderer.php.

Referenced by render().

Text_Diff_Renderer::$_trailing_context_lines = 0

Number of trailing context "lines" to preserve.

This should be left at zero for this class, but subclasses may want to set this to other values.

Definition at line 28 of file Renderer.php.

Referenced by render().


The documentation for this class was generated from the following file: