ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Text_Diff_Renderer Class Reference
+ Inheritance diagram for Text_Diff_Renderer:
+ Collaboration diagram for Text_Diff_Renderer:

Public Member Functions

 __construct ($params=array())
 Constructor. More...
 
 getParams ()
 Get any renderer parameters. More...
 
 render ($diff)
 Renders a diff. More...
 
 _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. More...
 
 $_trailing_context_lines = 0
 Number of trailing context "lines" to preserve. More...
 

Detailed Description

Definition at line 12 of file Renderer.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Definition at line 34 of file Renderer.php.

References PHPMailer\PHPMailer\$params.

35  {
36  foreach ($params as $param => $value) {
37  $v = '_' . $param;
38  if (isset($this->$v)) {
39  $this->$v = $value;
40  }
41  }
42  }

Member Function Documentation

◆ _added()

Text_Diff_Renderer::_added (   $lines)

Definition at line 203 of file Renderer.php.

References _lines().

Referenced by _block(), and _changed().

204  {
205  return $this->_lines($lines, '>');
206  }
_lines($lines, $prefix=' ')
Definition: Renderer.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _block()

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

Definition at line 134 of file Renderer.php.

References Sabre\VObject\$output, _added(), _blockHeader(), _changed(), _context(), _deleted(), _endBlock(), and _startBlock().

Referenced by render().

135  {
136  $output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
137 
138  foreach ($edits as $edit) {
139  switch (strtolower(get_class($edit))) {
140  case 'text_diff_op_copy':
141  $output .= $this->_context($edit->orig);
142  break;
143 
144  case 'text_diff_op_add':
145  $output .= $this->_added($edit->final);
146  break;
147 
148  case 'text_diff_op_delete':
149  $output .= $this->_deleted($edit->orig);
150  break;
151 
152  case 'text_diff_op_change':
153  $output .= $this->_changed($edit->orig, $edit->final);
154  break;
155  }
156  }
157 
158  return $output . $this->_endBlock();
159  }
_changed($orig, $final)
Definition: Renderer.php:213
_startBlock($header)
Definition: Renderer.php:183
_blockHeader($xbeg, $xlen, $ybeg, $ylen)
Definition: Renderer.php:171
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _blockHeader()

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

Definition at line 171 of file Renderer.php.

Referenced by _block().

172  {
173  if ($xlen > 1) {
174  $xbeg .= ',' . ($xbeg + $xlen - 1);
175  }
176  if ($ylen > 1) {
177  $ybeg .= ',' . ($ybeg + $ylen - 1);
178  }
179 
180  return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
181  }
+ Here is the caller graph for this function:

◆ _changed()

Text_Diff_Renderer::_changed (   $orig,
  $final 
)

Definition at line 213 of file Renderer.php.

References _added(), and _deleted().

Referenced by _block().

214  {
215  return $this->_deleted($orig) . "---\n" . $this->_added($final);
216  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _context()

Text_Diff_Renderer::_context (   $lines)

Definition at line 198 of file Renderer.php.

References _lines().

Referenced by _block().

199  {
200  return $this->_lines($lines);
201  }
_lines($lines, $prefix=' ')
Definition: Renderer.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleted()

Text_Diff_Renderer::_deleted (   $lines)

Definition at line 208 of file Renderer.php.

References _lines().

Referenced by _block(), and _changed().

209  {
210  return $this->_lines($lines, '<');
211  }
_lines($lines, $prefix=' ')
Definition: Renderer.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _endBlock()

Text_Diff_Renderer::_endBlock ( )

Definition at line 188 of file Renderer.php.

Referenced by _block().

189  {
190  return '';
191  }
+ Here is the caller graph for this function:

◆ _endDiff()

Text_Diff_Renderer::_endDiff ( )

Definition at line 166 of file Renderer.php.

Referenced by render().

167  {
168  return '';
169  }
+ Here is the caller graph for this function:

◆ _lines()

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

Definition at line 193 of file Renderer.php.

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

194  {
195  return $prefix . implode("\n$prefix", $lines) . "\n";
196  }
+ Here is the caller graph for this function:

◆ _startBlock()

Text_Diff_Renderer::_startBlock (   $header)

Definition at line 183 of file Renderer.php.

References $header.

Referenced by _block().

184  {
185  return $header . "\n";
186  }
+ Here is the caller graph for this function:

◆ _startDiff()

Text_Diff_Renderer::_startDiff ( )

Definition at line 161 of file Renderer.php.

Referenced by render().

162  {
163  return '';
164  }
+ Here is the caller graph for this function:

◆ getParams()

Text_Diff_Renderer::getParams ( )

Get any renderer parameters.

Returns
array All parameters of this renderer object.

Definition at line 49 of file Renderer.php.

References PHPMailer\PHPMailer\$params.

50  {
51  $params = array();
52  foreach (get_object_vars($this) as $k => $v) {
53  if ($k[0] == '_') {
54  $params[substr($k, 1)] = $v;
55  }
56  }
57 
58  return $params;
59  }

◆ render()

Text_Diff_Renderer::render (   $diff)

Renders a diff.

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

Definition at line 68 of file Renderer.php.

References $_leading_context_lines, $_trailing_context_lines, $context, Sabre\VObject\$output, _block(), _endDiff(), and _startDiff().

69  {
70  $xi = $yi = 1;
71  $block = false;
72  $context = array();
73 
76 
77  $output = $this->_startDiff();
78 
79  foreach ($diff->getDiff() as $edit) {
80  if ($edit instanceof Text_Diff_Op_copy) {
81  if (is_array($block)) {
82  if (count($edit->orig) <= $nlead + $ntrail) {
83  $block[] = $edit;
84  } else {
85  if ($ntrail) {
86  $context = array_slice($edit->orig, 0, $ntrail);
87  $block[] = new Text_Diff_Op_copy($context);
88  }
89  $output .= $this->_block(
90  $x0,
91  $ntrail + $xi - $x0,
92  $y0,
93  $ntrail + $yi - $y0,
94  $block
95  );
96  $block = false;
97  }
98  }
99  $context = $edit->orig;
100  } else {
101  if (!is_array($block)) {
102  $context = array_slice($context, count($context) - $nlead);
103  $x0 = $xi - count($context);
104  $y0 = $yi - count($context);
105  $block = array();
106  if ($context) {
107  $block[] = new Text_Diff_Op_copy($context);
108  }
109  }
110  $block[] = $edit;
111  }
112 
113  if ($edit->orig) {
114  $xi += count($edit->orig);
115  }
116  if ($edit->final) {
117  $yi += count($edit->final);
118  }
119  }
120 
121  if (is_array($block)) {
122  $output .= $this->_block(
123  $x0,
124  $xi - $x0,
125  $y0,
126  $yi - $y0,
127  $block
128  );
129  }
130 
131  return $output . $this->_endDiff();
132  }
$context
Definition: webdav.php:25
$_trailing_context_lines
Number of trailing context "lines" to preserve.
Definition: Renderer.php:29
$_leading_context_lines
Number of leading context "lines" to preserve.
Definition: Renderer.php:21
_block($xbeg, $xlen, $ybeg, $ylen, &$edits)
Definition: Renderer.php:134
+ Here is the call graph for this function:

Field Documentation

◆ $_leading_context_lines

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 21 of file Renderer.php.

Referenced by render().

◆ $_trailing_context_lines

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 29 of file Renderer.php.

Referenced by render().


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