dolibarr 19.0.3
|
A class containing functions for computing diffs and formatting the output. More...
Static Public Member Functions | |
static | compare ($string1, $string2, $compareCharacters=false) |
Returns the diff for two strings. | |
static | compareFiles ( $file1, $file2, $compareCharacters=false) |
Returns the diff for two files. | |
static | toString ($diff, $separator="\n") |
Returns a diff as a string, where unmodified lines are prefixed by ' ', deletions are prefixed by '- ', and insertions are prefixed by '+ '. | |
static | toHTML ($diff, $separator='< br >') |
Returns a diff as an HTML string, where unmodified lines are contained within 'span' elements, deletions are contained within 'del' elements, and insertions are contained within 'ins' elements. | |
static | toTable ($diff, $indentation='', $separator='< br >') |
Returns a diff as an HTML table. | |
Static Private Member Functions | |
static | computeTable ($sequence1, $sequence2, $start, $end1, $end2) |
Returns the table of longest common subsequence lengths for the specified sequences. | |
static | generatePartialDiff ($table, $sequence1, $sequence2, $start) |
Returns the partial diff for the specificed sequences, in reverse order. | |
static | getCellContent ($diff, $indentation, $separator, &$index, $type) |
Returns the content of the cell, for use in the toTable function. | |
A class containing functions for computing diffs and formatting the output.
We can compare 2 strings or 2 files (as one string or line by line)
Definition at line 17 of file utils_diff.class.php.
|
static |
Returns the diff for two strings.
The return value is an array, each of whose values is an array containing two values: a line (or character, if $compareCharacters is true), and one of the constants DIFF\UNMODIFIED (the line or character is in both strings), DIFF\DELETED (the line or character is only in the first string), and DIFF\INSERTED (the line or character is only in the second string). The parameters are:
string | $string1 | First string |
string | $string2 | Second string |
string | $compareCharacters | true to compare characters, and false to compare lines; this optional parameter defaults to false |
Definition at line 37 of file utils_diff.class.php.
References computeTable(), and generatePartialDiff().
Referenced by compareFiles().
|
static |
Returns the diff for two files.
The parameters are:
string | $file1 | Path to the first file |
string | $file2 | Path to the second file |
boolean | $compareCharacters | true to compare characters, and false to compare lines; this optional parameter defaults to false |
Definition at line 98 of file utils_diff.class.php.
References compare().
|
staticprivate |
Returns the table of longest common subsequence lengths for the specified sequences.
The parameters are:
string | $sequence1 | the first sequence |
string | $sequence2 | the second sequence |
string | $start | the starting index |
string | $end1 | the ending index for the first sequence |
string | $end2 | the ending index for the second sequence |
Definition at line 122 of file utils_diff.class.php.
Referenced by compare().
|
staticprivate |
Returns the partial diff for the specificed sequences, in reverse order.
The parameters are:
string | $table | the table returned by the computeTable function |
string | $sequence1 | the first sequence |
string | $sequence2 | the second sequence |
string | $start | the starting index |
Definition at line 162 of file utils_diff.class.php.
Referenced by compare().
|
staticprivate |
Returns the content of the cell, for use in the toTable function.
The parameters are:
array | $diff | the diff array |
string | $indentation | indentation to add to every line of the generated HTML |
string | $separator | the separator between lines |
string | $index | the current index, passes by reference |
string | $type | the type of line |
Definition at line 377 of file utils_diff.class.php.
Referenced by toTable().
|
static |
Returns a diff as an HTML string, where unmodified lines are contained within 'span' elements, deletions are contained within 'del' elements, and insertions are contained within 'ins' elements.
The parameters are:
array | $diff | the diff array |
string | $separator | the separator between lines; this optional parameter defaults to ' ' |
Definition at line 244 of file utils_diff.class.php.
References dol_escape_htmltag().
|
static |
Returns a diff as a string, where unmodified lines are prefixed by ' ', deletions are prefixed by '- ', and insertions are prefixed by '+ '.
The parameters are:
array | $diff | the diff array |
string | $separator | the separator between lines; this optional parameter defaults to "\n" |
Definition at line 207 of file utils_diff.class.php.
|
static |
Returns a diff as an HTML table.
The parameters are:
array | $diff | the diff array |
string | $indentation | indentation to add to every line of the generated HTML; this optional parameter defaults to '' |
string | $separator | the separator between lines; this optional parameter defaults to ' ' |
Definition at line 282 of file utils_diff.class.php.
References getCellContent().