Révision 661d64c9
Ajouté par Assos Assos il y a plus de 7 ans
drupal7/sites/all/modules/diff/DiffEngine.php | ||
---|---|---|
41 | 41 |
class _DiffOp_Copy extends _DiffOp { |
42 | 42 |
var $type = 'copy'; |
43 | 43 |
|
44 |
function _DiffOp_Copy($orig, $closing = FALSE) {
|
|
44 |
function __construct($orig, $closing = FALSE) {
|
|
45 | 45 |
if (!is_array($closing)) { |
46 | 46 |
$closing = $orig; |
47 | 47 |
} |
... | ... | |
62 | 62 |
class _DiffOp_Delete extends _DiffOp { |
63 | 63 |
var $type = 'delete'; |
64 | 64 |
|
65 |
function _DiffOp_Delete($lines) {
|
|
65 |
function __construct($lines) {
|
|
66 | 66 |
$this->orig = $lines; |
67 | 67 |
$this->closing = FALSE; |
68 | 68 |
} |
... | ... | |
80 | 80 |
class _DiffOp_Add extends _DiffOp { |
81 | 81 |
var $type = 'add'; |
82 | 82 |
|
83 |
function _DiffOp_Add($lines) {
|
|
83 |
function __construct($lines) {
|
|
84 | 84 |
$this->closing = $lines; |
85 | 85 |
$this->orig = FALSE; |
86 | 86 |
} |
... | ... | |
98 | 98 |
class _DiffOp_Change extends _DiffOp { |
99 | 99 |
var $type = 'change'; |
100 | 100 |
|
101 |
function _DiffOp_Change($orig, $closing) {
|
|
101 |
function __construct($orig, $closing) {
|
|
102 | 102 |
$this->orig = $orig; |
103 | 103 |
$this->closing = $closing; |
104 | 104 |
} |
... | ... | |
215 | 215 |
// Find deletes & adds. |
216 | 216 |
$delete = array(); |
217 | 217 |
while ($xi < $n_from && $this->xchanged[$xi]) { |
218 |
$delete[] = $from_lines[$xi++]; |
|
218 |
$_fl = $from_lines[$xi++]; |
|
219 |
if (strlen($_fl)) { |
|
220 |
$delete[] = $_fl; |
|
221 |
} |
|
219 | 222 |
} |
220 | 223 |
$add = array(); |
221 | 224 |
while ($yi < $n_to && $this->ychanged[$yi]) { |
222 |
$add[] = $to_lines[$yi++]; |
|
225 |
$_tl = $to_lines[$yi++]; |
|
226 |
if (strlen($_tl)) { |
|
227 |
$add[] = $_tl; |
|
228 |
} |
|
223 | 229 |
} |
224 | 230 |
if ($delete && $add) { |
225 | 231 |
$edits[] = new _DiffOp_Change($delete, $add); |
... | ... | |
576 | 582 |
* (Typically these are lines from a file.) |
577 | 583 |
* @param $to_lines array An array of strings. |
578 | 584 |
*/ |
579 |
function Diff($from_lines, $to_lines) {
|
|
585 |
function __construct($from_lines, $to_lines) {
|
|
580 | 586 |
$eng = new _DiffEngine; |
581 | 587 |
$this->edits = $eng->diff($from_lines, $to_lines); |
582 | 588 |
//$this->_check($from_lines, $to_lines); |
... | ... | |
735 | 741 |
* @param $mapped_to_lines array This array should |
736 | 742 |
* have the same number of elements as $to_lines. |
737 | 743 |
*/ |
738 |
function MappedDiff($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) { |
|
739 |
|
|
744 |
function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) { |
|
740 | 745 |
assert(sizeof($from_lines) == sizeof($mapped_from_lines)); |
741 | 746 |
assert(sizeof($to_lines) == sizeof($mapped_to_lines)); |
742 | 747 |
|
743 |
$this->Diff($mapped_from_lines, $mapped_to_lines);
|
|
748 |
parent::__construct($mapped_from_lines, $mapped_to_lines);
|
|
744 | 749 |
|
745 | 750 |
$xi = $yi = 0; |
746 | 751 |
for ($i = 0; $i < sizeof($this->edits); $i++) { |
... | ... | |
950 | 955 |
* @subpackage DifferenceEngine |
951 | 956 |
*/ |
952 | 957 |
class _HWLDF_WordAccumulator { |
953 |
function _HWLDF_WordAccumulator() {
|
|
958 |
function __construct() {
|
|
954 | 959 |
$this->_lines = array(); |
955 | 960 |
$this->_line = ''; |
956 | 961 |
$this->_group = ''; |
... | ... | |
1016 | 1021 |
return 10000; |
1017 | 1022 |
} |
1018 | 1023 |
|
1019 |
function WordLevelDiff($orig_lines, $closing_lines) {
|
|
1024 |
function __construct($orig_lines, $closing_lines) {
|
|
1020 | 1025 |
list($orig_words, $orig_stripped) = $this->_split($orig_lines); |
1021 | 1026 |
list($closing_words, $closing_stripped) = $this->_split($closing_lines); |
1022 | 1027 |
|
1023 |
$this->MappedDiff($orig_words, $closing_words, $orig_stripped, $closing_stripped);
|
|
1028 |
parent::__construct($orig_words, $closing_words, $orig_stripped, $closing_stripped);
|
|
1024 | 1029 |
} |
1025 | 1030 |
|
1026 | 1031 |
function _split($lines) { |
... | ... | |
1095 | 1100 |
'offset' => array('x' => 0, 'y' => 0), |
1096 | 1101 |
); |
1097 | 1102 |
|
1098 |
function DrupalDiffFormatter() {
|
|
1103 |
function __construct() {
|
|
1099 | 1104 |
$this->leading_context_lines = variable_get('diff_context_lines_leading', 2); |
1100 | 1105 |
$this->trailing_context_lines = variable_get('diff_context_lines_trailing', 2); |
1101 | 1106 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules