ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
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

Text_Diff_Engine_xdiff::diff (   $from_lines,
  $to_lines 
)

Definition at line 257 of file Diff.php.

{
/* Convert the two input arrays into strings for xdiff processing. */
$from_string = implode("\n", $from_lines);
$to_string = implode("\n", $to_lines);
/* Diff the two strings and convert the result to an array. */
$diff = xdiff_string_diff($from_string, $to_string, count($to_lines));
$diff = explode("\n", $diff);
/* Walk through the diff one line at a time. We build the $edits
* array of diff operations by reading the first character of the
* xdiff output (which is in the "unified diff" format).
*
* Note that we don't have enough information to detect "changed"
* lines using this approach, so we can't add Text_Diff_Op_changed
* instances to the $edits array. The result is still perfectly
* valid, albeit a little less descriptive and efficient. */
$edits = array();
foreach ($diff as $line) {
switch ($line[0]) {
case ' ':
$edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
break;
case '+':
$edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
break;
case '-':
$edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
break;
}
}
return $edits;
}

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