ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Text_Diff_Engine_xdiff Class Reference
+ Collaboration diagram for Text_Diff_Engine_xdiff:

Public Member Functions

 diff ($from_lines, $to_lines)
 

Detailed Description

Definition at line 255 of file Diff.php.

Member Function Documentation

◆ diff()

Text_Diff_Engine_xdiff::diff (   $from_lines,
  $to_lines 
)

Definition at line 257 of file Diff.php.

References array.

258  {
259  /* Convert the two input arrays into strings for xdiff processing. */
260  $from_string = implode("\n", $from_lines);
261  $to_string = implode("\n", $to_lines);
262 
263  /* Diff the two strings and convert the result to an array. */
264  $diff = xdiff_string_diff($from_string, $to_string, count($to_lines));
265  $diff = explode("\n", $diff);
266 
267  /* Walk through the diff one line at a time. We build the $edits
268  * array of diff operations by reading the first character of the
269  * xdiff output (which is in the "unified diff" format).
270  *
271  * Note that we don't have enough information to detect "changed"
272  * lines using this approach, so we can't add Text_Diff_Op_changed
273  * instances to the $edits array. The result is still perfectly
274  * valid, albeit a little less descriptive and efficient. */
275  $edits = array();
276  foreach ($diff as $line) {
277  switch ($line[0]) {
278  case ' ':
279  $edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
280  break;
281 
282  case '+':
283  $edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
284  break;
285 
286  case '-':
287  $edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
288  break;
289  }
290  }
291 
292  return $edits;
293  }
Create styles array
The data for the language used.

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