Index: trunk/phase3/includes/DifferenceEngine.php |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | * @param $rcid Integer: ??? FIXME (default 0) |
42 | 42 | * @param $refreshCache boolean If set, refreshes the diff cache |
43 | 43 | */ |
44 | | - function DifferenceEngine( $titleObj = null, $old = 0, $new = 0, $rcid = 0, $refreshCache = false ) { |
| 44 | + function __construct( $titleObj = null, $old = 0, $new = 0, $rcid = 0, $refreshCache = false ) { |
45 | 45 | $this->mTitle = $titleObj; |
46 | 46 | wfDebug("DifferenceEngine old '$old' new '$new' rcid '$rcid'\n"); |
47 | 47 | |
— | — | @@ -74,8 +74,7 @@ |
75 | 75 | |
76 | 76 | function showDiffPage( $diffOnly = false ) { |
77 | 77 | global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol; |
78 | | - $fname = 'DifferenceEngine::showDiffPage'; |
79 | | - wfProfileIn( $fname ); |
| 78 | + wfProfileIn( __METHOD__ ); |
80 | 79 | |
81 | 80 | # If external diffs are enabled both globally and for the user, |
82 | 81 | # we'll use the application/x-external-editor interface to call |
— | — | @@ -111,7 +110,7 @@ |
112 | 111 | $t = $this->mTitle->getPrefixedText() . " (Diff: {$this->mOldid}, {$this->mNewid})"; |
113 | 112 | $wgOut->setPagetitle( wfMsg( 'errorpagetitle' ) ); |
114 | 113 | $wgOut->addWikiMsg( 'missingarticle', "<nowiki>$t</nowiki>" ); |
115 | | - wfProfileOut( $fname ); |
| 114 | + wfProfileOut( __METHOD__ ); |
116 | 115 | return; |
117 | 116 | } |
118 | 117 | |
— | — | @@ -127,7 +126,7 @@ |
128 | 127 | if ( $this->mOldid === false ) { |
129 | 128 | $this->showFirstRevision(); |
130 | 129 | $this->renderNewRevision(); // should we respect $diffOnly here or not? |
131 | | - wfProfileOut( $fname ); |
| 130 | + wfProfileOut( __METHOD__ ); |
132 | 131 | return; |
133 | 132 | } |
134 | 133 | |
— | — | @@ -146,7 +145,7 @@ |
147 | 146 | if ( !( $this->mOldPage->userCanRead() && $this->mNewPage->userCanRead() ) ) { |
148 | 147 | $wgOut->loginToUse(); |
149 | 148 | $wgOut->output(); |
150 | | - wfProfileOut( $fname ); |
| 149 | + wfProfileOut( __METHOD__ ); |
151 | 150 | exit; |
152 | 151 | } |
153 | 152 | |
— | — | @@ -211,13 +210,11 @@ |
212 | 211 | $newminor = ''; |
213 | 212 | |
214 | 213 | if ($this->mOldRev->mMinorEdit == 1) { |
215 | | - $oldminor = wfElement( 'span', array( 'class' => 'minor' ), |
216 | | - wfMsg( 'minoreditletter') ) . ' '; |
| 214 | + $oldminor = Xml::span( wfMsg( 'minoreditletter'), 'minor' ) . ' '; |
217 | 215 | } |
218 | 216 | |
219 | 217 | if ($this->mNewRev->mMinorEdit == 1) { |
220 | | - $newminor = wfElement( 'span', array( 'class' => 'minor' ), |
221 | | - wfMsg( 'minoreditletter') ) . ' '; |
| 218 | + $newminor = Xml::span( wfMsg( 'minoreditletter'), 'minor' ) . ' '; |
222 | 219 | } |
223 | 220 | |
224 | 221 | $rdel = ''; $ldel = ''; |
— | — | @@ -225,7 +222,7 @@ |
226 | 223 | $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); |
227 | 224 | if( !$this->mOldRev->userCan( Revision::DELETED_RESTRICTED ) ) { |
228 | 225 | // If revision was hidden from sysops |
229 | | - $ldel = wfMsgHtml('rev-delundel'); |
| 226 | + $ldel = wfMsgHtml('rev-delundel'); |
230 | 227 | } else { |
231 | 228 | $ldel = $sk->makeKnownLinkObj( $revdel, |
232 | 229 | wfMsgHtml('rev-delundel'), |
— | — | @@ -269,7 +266,7 @@ |
270 | 267 | if ( !$diffOnly ) |
271 | 268 | $this->renderNewRevision(); |
272 | 269 | |
273 | | - wfProfileOut( $fname ); |
| 270 | + wfProfileOut( __METHOD__ ); |
274 | 271 | } |
275 | 272 | |
276 | 273 | /** |
— | — | @@ -277,8 +274,7 @@ |
278 | 275 | */ |
279 | 276 | function renderNewRevision() { |
280 | 277 | global $wgOut; |
281 | | - $fname = 'DifferenceEngine::renderNewRevision'; |
282 | | - wfProfileIn( $fname ); |
| 278 | + wfProfileIn( __METHOD__ ); |
283 | 279 | |
284 | 280 | $wgOut->addHTML( "<hr /><h2>{$this->mPagetitle}</h2>\n" ); |
285 | 281 | #add deleted rev tag if needed |
— | — | @@ -316,7 +312,7 @@ |
317 | 313 | $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting ); |
318 | 314 | } |
319 | 315 | |
320 | | - wfProfileOut( $fname ); |
| 316 | + wfProfileOut( __METHOD__ ); |
321 | 317 | } |
322 | 318 | |
323 | 319 | /** |
— | — | @@ -325,10 +321,8 @@ |
326 | 322 | */ |
327 | 323 | function showFirstRevision() { |
328 | 324 | global $wgOut, $wgUser; |
| 325 | + wfProfileIn( __METHOD__ ); |
329 | 326 | |
330 | | - $fname = 'DifferenceEngine::showFirstRevision'; |
331 | | - wfProfileIn( $fname ); |
332 | | - |
333 | 327 | # Get article text from the DB |
334 | 328 | # |
335 | 329 | if ( ! $this->loadNewText() ) { |
— | — | @@ -336,7 +330,7 @@ |
337 | 331 | "{$this->mNewid})"; |
338 | 332 | $wgOut->setPagetitle( wfMsg( 'errorpagetitle' ) ); |
339 | 333 | $wgOut->addWikiMsg( 'missingarticle', "<nowiki>$t</nowiki>" ); |
340 | | - wfProfileOut( $fname ); |
| 334 | + wfProfileOut( __METHOD__ ); |
341 | 335 | return; |
342 | 336 | } |
343 | 337 | if ( $this->mNewRev->isCurrent() ) { |
— | — | @@ -348,7 +342,7 @@ |
349 | 343 | if ( !( $this->mTitle->userCanRead() ) ) { |
350 | 344 | $wgOut->loginToUse(); |
351 | 345 | $wgOut->output(); |
352 | | - wfProfileOut( $fname ); |
| 346 | + wfProfileOut( __METHOD__ ); |
353 | 347 | exit; |
354 | 348 | } |
355 | 349 | |
— | — | @@ -367,7 +361,7 @@ |
368 | 362 | $wgOut->setSubtitle( wfMsg( 'difference' ) ); |
369 | 363 | $wgOut->setRobotpolicy( 'noindex,nofollow' ); |
370 | 364 | |
371 | | - wfProfileOut( $fname ); |
| 365 | + wfProfileOut( __METHOD__ ); |
372 | 366 | } |
373 | 367 | |
374 | 368 | /** |
— | — | @@ -422,8 +416,7 @@ |
423 | 417 | */ |
424 | 418 | function getDiffBody() { |
425 | 419 | global $wgMemc; |
426 | | - $fname = 'DifferenceEngine::getDiffBody'; |
427 | | - wfProfileIn( $fname ); |
| 420 | + wfProfileIn( __METHOD__ ); |
428 | 421 | // Check if the diff should be hidden from this user |
429 | 422 | if ( $this->mOldRev && !$this->mOldRev->userCan(Revision::DELETED_TEXT) ) { |
430 | 423 | return ''; |
— | — | @@ -441,7 +434,7 @@ |
442 | 435 | wfIncrStats( 'diff_cache_hit' ); |
443 | 436 | $difftext = $this->localiseLineNumbers( $difftext ); |
444 | 437 | $difftext .= "\n<!-- diff cache key $key -->\n"; |
445 | | - wfProfileOut( $fname ); |
| 438 | + wfProfileOut( __METHOD__ ); |
446 | 439 | return $difftext; |
447 | 440 | } |
448 | 441 | } // don't try to load but save the result |
— | — | @@ -449,7 +442,7 @@ |
450 | 443 | |
451 | 444 | // Loadtext is permission safe, this just clears out the diff |
452 | 445 | if ( !$this->loadText() ) { |
453 | | - wfProfileOut( $fname ); |
| 446 | + wfProfileOut( __METHOD__ ); |
454 | 447 | return false; |
455 | 448 | } |
456 | 449 | |
— | — | @@ -466,7 +459,7 @@ |
467 | 460 | if ( $difftext !== false ) { |
468 | 461 | $difftext = $this->localiseLineNumbers( $difftext ); |
469 | 462 | } |
470 | | - wfProfileOut( $fname ); |
| 463 | + wfProfileOut( __METHOD__ ); |
471 | 464 | return $difftext; |
472 | 465 | } |
473 | 466 | |
— | — | @@ -476,7 +469,6 @@ |
477 | 470 | */ |
478 | 471 | function generateDiffBody( $otext, $ntext ) { |
479 | 472 | global $wgExternalDiffEngine, $wgContLang; |
480 | | - $fname = 'DifferenceEngine::generateDiffBody'; |
481 | 473 | |
482 | 474 | $otext = str_replace( "\r\n", "\n", $otext ); |
483 | 475 | $ntext = str_replace( "\r\n", "\n", $ntext ); |
— | — | @@ -496,9 +488,9 @@ |
497 | 489 | # Better external diff engine, the 2 may some day be dropped |
498 | 490 | # This one does the escaping and segmenting itself |
499 | 491 | if ( !function_exists( 'wikidiff2_do_diff' ) ) { |
500 | | - wfProfileIn( "$fname-dl" ); |
| 492 | + wfProfileIn( __METHOD__ . "-dl" ); |
501 | 493 | @dl('php_wikidiff2.so'); |
502 | | - wfProfileOut( "$fname-dl" ); |
| 494 | + wfProfileOut( __METHOD__ . "-dl" ); |
503 | 495 | } |
504 | 496 | if ( function_exists( 'wikidiff2_do_diff' ) ) { |
505 | 497 | wfProfileIn( 'wikidiff2_do_diff' ); |
— | — | @@ -515,12 +507,12 @@ |
516 | 508 | |
517 | 509 | $tempFile1 = fopen( $tempName1, "w" ); |
518 | 510 | if ( !$tempFile1 ) { |
519 | | - wfProfileOut( $fname ); |
| 511 | + wfProfileOut( __METHOD__ ); |
520 | 512 | return false; |
521 | 513 | } |
522 | 514 | $tempFile2 = fopen( $tempName2, "w" ); |
523 | 515 | if ( !$tempFile2 ) { |
524 | | - wfProfileOut( $fname ); |
| 516 | + wfProfileOut( __METHOD__ ); |
525 | 517 | return false; |
526 | 518 | } |
527 | 519 | fwrite( $tempFile1, $otext ); |
— | — | @@ -528,9 +520,9 @@ |
529 | 521 | fclose( $tempFile1 ); |
530 | 522 | fclose( $tempFile2 ); |
531 | 523 | $cmd = wfEscapeShellArg( $wgExternalDiffEngine, $tempName1, $tempName2 ); |
532 | | - wfProfileIn( "$fname-shellexec" ); |
| 524 | + wfProfileIn( __METHOD__ . "-shellexec" ); |
533 | 525 | $difftext = wfShellExec( $cmd ); |
534 | | - wfProfileOut( "$fname-shellexec" ); |
| 526 | + wfProfileOut( __METHOD__ . "-shellexec" ); |
535 | 527 | unlink( $tempName1 ); |
536 | 528 | unlink( $tempName2 ); |
537 | 529 | return $difftext; |
— | — | @@ -894,13 +886,11 @@ |
895 | 887 | * @private |
896 | 888 | * @addtogroup DifferenceEngine |
897 | 889 | */ |
898 | | -class _DiffEngine |
899 | | -{ |
| 890 | +class _DiffEngine { |
900 | 891 | const MAX_XREF_LENGTH = 10000; |
901 | 892 | |
902 | 893 | function diff ($from_lines, $to_lines) { |
903 | | - $fname = '_DiffEngine::diff'; |
904 | | - wfProfileIn( $fname ); |
| 894 | + wfProfileIn( __METHOD__ ); |
905 | 895 | |
906 | 896 | $n_from = sizeof($from_lines); |
907 | 897 | $n_to = sizeof($to_lines); |
— | — | @@ -987,7 +977,7 @@ |
988 | 978 | elseif ($add) |
989 | 979 | $edits[] = new _DiffOp_Add($add); |
990 | 980 | } |
991 | | - wfProfileOut( $fname ); |
| 981 | + wfProfileOut( __METHOD__ ); |
992 | 982 | return $edits; |
993 | 983 | } |
994 | 984 | |
— | — | @@ -1020,8 +1010,7 @@ |
1021 | 1011 | * of the portions it is going to specify. |
1022 | 1012 | */ |
1023 | 1013 | function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks) { |
1024 | | - $fname = '_DiffEngine::_diag'; |
1025 | | - wfProfileIn( $fname ); |
| 1014 | + wfProfileIn( __METHOD__ ); |
1026 | 1015 | $flip = false; |
1027 | 1016 | |
1028 | 1017 | if ($xlim - $xoff > $ylim - $yoff) { |
— | — | @@ -1047,7 +1036,7 @@ |
1048 | 1037 | $numer = $xlim - $xoff + $nchunks - 1; |
1049 | 1038 | $x = $xoff; |
1050 | 1039 | for ($chunk = 0; $chunk < $nchunks; $chunk++) { |
1051 | | - wfProfileIn( "$fname-chunk" ); |
| 1040 | + wfProfileIn( __METHOD__ . "-chunk" ); |
1052 | 1041 | if ($chunk > 0) |
1053 | 1042 | for ($i = 0; $i <= $this->lcs; $i++) |
1054 | 1043 | $ymids[$i][$chunk-1] = $this->seq[$i]; |
— | — | @@ -1081,7 +1070,7 @@ |
1082 | 1071 | } |
1083 | 1072 | } |
1084 | 1073 | } |
1085 | | - wfProfileOut( "$fname-chunk" ); |
| 1074 | + wfProfileOut( __METHOD__ . "-chunk" ); |
1086 | 1075 | } |
1087 | 1076 | |
1088 | 1077 | $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff); |
— | — | @@ -1093,19 +1082,18 @@ |
1094 | 1083 | } |
1095 | 1084 | $seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim); |
1096 | 1085 | |
1097 | | - wfProfileOut( $fname ); |
| 1086 | + wfProfileOut( __METHOD__ ); |
1098 | 1087 | return array($this->lcs, $seps); |
1099 | 1088 | } |
1100 | 1089 | |
1101 | 1090 | function _lcs_pos ($ypos) { |
1102 | | - $fname = '_DiffEngine::_lcs_pos'; |
1103 | | - wfProfileIn( $fname ); |
| 1091 | + wfProfileIn( __METHOD__ ); |
1104 | 1092 | |
1105 | 1093 | $end = $this->lcs; |
1106 | 1094 | if ($end == 0 || $ypos > $this->seq[$end]) { |
1107 | 1095 | $this->seq[++$this->lcs] = $ypos; |
1108 | 1096 | $this->in_seq[$ypos] = 1; |
1109 | | - wfProfileOut( $fname ); |
| 1097 | + wfProfileOut( __METHOD__ ); |
1110 | 1098 | return $this->lcs; |
1111 | 1099 | } |
1112 | 1100 | |
— | — | @@ -1123,7 +1111,7 @@ |
1124 | 1112 | $this->in_seq[$this->seq[$end]] = false; |
1125 | 1113 | $this->seq[$end] = $ypos; |
1126 | 1114 | $this->in_seq[$ypos] = 1; |
1127 | | - wfProfileOut( $fname ); |
| 1115 | + wfProfileOut( __METHOD__ ); |
1128 | 1116 | return $end; |
1129 | 1117 | } |
1130 | 1118 | |
— | — | @@ -1139,8 +1127,7 @@ |
1140 | 1128 | * All line numbers are origin-0 and discarded lines are not counted. |
1141 | 1129 | */ |
1142 | 1130 | function _compareseq ($xoff, $xlim, $yoff, $ylim) { |
1143 | | - $fname = '_DiffEngine::_compareseq'; |
1144 | | - wfProfileIn( $fname ); |
| 1131 | + wfProfileIn( __METHOD__ ); |
1145 | 1132 | |
1146 | 1133 | // Slide down the bottom initial diagonal. |
1147 | 1134 | while ($xoff < $xlim && $yoff < $ylim |
— | — | @@ -1183,7 +1170,7 @@ |
1184 | 1171 | $pt1 = $pt2; |
1185 | 1172 | } |
1186 | 1173 | } |
1187 | | - wfProfileOut( $fname ); |
| 1174 | + wfProfileOut( __METHOD__ ); |
1188 | 1175 | } |
1189 | 1176 | |
1190 | 1177 | /* Adjust inserts/deletes of identical lines to join changes |
— | — | @@ -1199,8 +1186,7 @@ |
1200 | 1187 | * This is extracted verbatim from analyze.c (GNU diffutils-2.7). |
1201 | 1188 | */ |
1202 | 1189 | function _shift_boundaries ($lines, &$changed, $other_changed) { |
1203 | | - $fname = '_DiffEngine::_shift_boundaries'; |
1204 | | - wfProfileIn( $fname ); |
| 1190 | + wfProfileIn( __METHOD__ ); |
1205 | 1191 | $i = 0; |
1206 | 1192 | $j = 0; |
1207 | 1193 | |
— | — | @@ -1305,7 +1291,7 @@ |
1306 | 1292 | USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); |
1307 | 1293 | } |
1308 | 1294 | } |
1309 | | - wfProfileOut( $fname ); |
| 1295 | + wfProfileOut( __METHOD__ ); |
1310 | 1296 | } |
1311 | 1297 | } |
1312 | 1298 | |
— | — | @@ -1423,8 +1409,7 @@ |
1424 | 1410 | * This is here only for debugging purposes. |
1425 | 1411 | */ |
1426 | 1412 | function _check ($from_lines, $to_lines) { |
1427 | | - $fname = 'Diff::_check'; |
1428 | | - wfProfileIn( $fname ); |
| 1413 | + wfProfileIn( __METHOD__ ); |
1429 | 1414 | if (serialize($from_lines) != serialize($this->orig())) |
1430 | 1415 | trigger_error("Reconstructed original doesn't match", E_USER_ERROR); |
1431 | 1416 | if (serialize($to_lines) != serialize($this->closing())) |
— | — | @@ -1446,7 +1431,7 @@ |
1447 | 1432 | |
1448 | 1433 | $lcs = $this->lcs(); |
1449 | 1434 | trigger_error('Diff okay: LCS = '.$lcs, E_USER_NOTICE); |
1450 | | - wfProfileOut( $fname ); |
| 1435 | + wfProfileOut( __METHOD__ ); |
1451 | 1436 | } |
1452 | 1437 | } |
1453 | 1438 | |
— | — | @@ -1481,9 +1466,8 @@ |
1482 | 1467 | * have the same number of elements as $to_lines. |
1483 | 1468 | */ |
1484 | 1469 | function MappedDiff($from_lines, $to_lines, |
1485 | | - $mapped_from_lines, $mapped_to_lines) { |
1486 | | - $fname = 'MappedDiff::MappedDiff'; |
1487 | | - wfProfileIn( $fname ); |
| 1470 | + $mapped_from_lines, $mapped_to_lines) { |
| 1471 | + wfProfileIn( __METHOD__ ); |
1488 | 1472 | |
1489 | 1473 | assert(sizeof($from_lines) == sizeof($mapped_from_lines)); |
1490 | 1474 | assert(sizeof($to_lines) == sizeof($mapped_to_lines)); |
— | — | @@ -1504,7 +1488,7 @@ |
1505 | 1489 | $yi += sizeof($closing); |
1506 | 1490 | } |
1507 | 1491 | } |
1508 | | - wfProfileOut( $fname ); |
| 1492 | + wfProfileOut( __METHOD__ ); |
1509 | 1493 | } |
1510 | 1494 | } |
1511 | 1495 | |
— | — | @@ -1518,8 +1502,7 @@ |
1519 | 1503 | * @private |
1520 | 1504 | * @addtogroup DifferenceEngine |
1521 | 1505 | */ |
1522 | | -class DiffFormatter |
1523 | | -{ |
| 1506 | +class DiffFormatter { |
1524 | 1507 | /** |
1525 | 1508 | * Number of leading context "lines" to preserve. |
1526 | 1509 | * |
— | — | @@ -1543,8 +1526,7 @@ |
1544 | 1527 | * @return string The formatted output. |
1545 | 1528 | */ |
1546 | 1529 | function format($diff) { |
1547 | | - $fname = 'DiffFormatter::format'; |
1548 | | - wfProfileIn( $fname ); |
| 1530 | + wfProfileIn( __METHOD__ ); |
1549 | 1531 | |
1550 | 1532 | $xi = $yi = 1; |
1551 | 1533 | $block = false; |
— | — | @@ -1598,13 +1580,12 @@ |
1599 | 1581 | $block); |
1600 | 1582 | |
1601 | 1583 | $end = $this->_end_diff(); |
1602 | | - wfProfileOut( $fname ); |
| 1584 | + wfProfileOut( __METHOD__ ); |
1603 | 1585 | return $end; |
1604 | 1586 | } |
1605 | 1587 | |
1606 | 1588 | function _block($xbeg, $xlen, $ybeg, $ylen, &$edits) { |
1607 | | - $fname = 'DiffFormatter::_block'; |
1608 | | - wfProfileIn( $fname ); |
| 1589 | + wfProfileIn( __METHOD__ ); |
1609 | 1590 | $this->_start_block($this->_block_header($xbeg, $xlen, $ybeg, $ylen)); |
1610 | 1591 | foreach ($edits as $edit) { |
1611 | 1592 | if ($edit->type == 'copy') |
— | — | @@ -1619,7 +1600,7 @@ |
1620 | 1601 | trigger_error('Unknown edit type', E_USER_ERROR); |
1621 | 1602 | } |
1622 | 1603 | $this->_end_block(); |
1623 | | - wfProfileOut( $fname ); |
| 1604 | + wfProfileOut( __METHOD__ ); |
1624 | 1605 | } |
1625 | 1606 | |
1626 | 1607 | function _start_diff() { |
— | — | @@ -1676,8 +1657,7 @@ |
1677 | 1658 | * @addtogroup DifferenceEngine |
1678 | 1659 | */ |
1679 | 1660 | |
1680 | | -class UnifiedDiffFormatter extends DiffFormatter |
1681 | | -{ |
| 1661 | +class UnifiedDiffFormatter extends DiffFormatter { |
1682 | 1662 | var $leading_context_lines = 2; |
1683 | 1663 | var $trailing_context_lines = 2; |
1684 | 1664 | |
— | — | @@ -1700,19 +1680,15 @@ |
1701 | 1681 | * A pseudo-formatter that just passes along the Diff::$edits array |
1702 | 1682 | * @addtogroup DifferenceEngine |
1703 | 1683 | */ |
1704 | | -class ArrayDiffFormatter extends DiffFormatter |
1705 | | -{ |
1706 | | - function format($diff) |
1707 | | - { |
| 1684 | +class ArrayDiffFormatter extends DiffFormatter { |
| 1685 | + function format($diff) { |
1708 | 1686 | $oldline = 1; |
1709 | 1687 | $newline = 1; |
1710 | 1688 | $retval = array(); |
1711 | 1689 | foreach($diff->edits as $edit) |
1712 | | - switch($edit->type) |
1713 | | - { |
| 1690 | + switch($edit->type) { |
1714 | 1691 | case 'add': |
1715 | | - foreach($edit->closing as $l) |
1716 | | - { |
| 1692 | + foreach($edit->closing as $l) { |
1717 | 1693 | $retval[] = array( |
1718 | 1694 | 'action' => 'add', |
1719 | 1695 | 'new'=> $l, |
— | — | @@ -1721,8 +1697,7 @@ |
1722 | 1698 | } |
1723 | 1699 | break; |
1724 | 1700 | case 'delete': |
1725 | | - foreach($edit->orig as $l) |
1726 | | - { |
| 1701 | + foreach($edit->orig as $l) { |
1727 | 1702 | $retval[] = array( |
1728 | 1703 | 'action' => 'delete', |
1729 | 1704 | 'old' => $l, |
— | — | @@ -1731,8 +1706,7 @@ |
1732 | 1707 | } |
1733 | 1708 | break; |
1734 | 1709 | case 'change': |
1735 | | - foreach($edit->orig as $i => $l) |
1736 | | - { |
| 1710 | + foreach($edit->orig as $i => $l) { |
1737 | 1711 | $retval[] = array( |
1738 | 1712 | 'action' => 'change', |
1739 | 1713 | 'old' => $l, |
— | — | @@ -1747,7 +1721,7 @@ |
1748 | 1722 | $newline += count($edit->orig); |
1749 | 1723 | } |
1750 | 1724 | return $retval; |
1751 | | - } |
| 1725 | + } |
1752 | 1726 | } |
1753 | 1727 | |
1754 | 1728 | /** |
— | — | @@ -1755,7 +1729,7 @@ |
1756 | 1730 | * |
1757 | 1731 | */ |
1758 | 1732 | |
1759 | | -define('NBSP', ' '); // iso-8859-x non-breaking space. |
| 1733 | +define('NBSP', ' '); // iso-8859-x non-breaking space. |
1760 | 1734 | |
1761 | 1735 | /** |
1762 | 1736 | * @todo document |
— | — | @@ -1823,25 +1797,22 @@ |
1824 | 1798 | * @private |
1825 | 1799 | * @addtogroup DifferenceEngine |
1826 | 1800 | */ |
1827 | | -class WordLevelDiff extends MappedDiff |
1828 | | -{ |
| 1801 | +class WordLevelDiff extends MappedDiff { |
1829 | 1802 | const MAX_LINE_LENGTH = 10000; |
1830 | 1803 | |
1831 | 1804 | function WordLevelDiff ($orig_lines, $closing_lines) { |
1832 | | - $fname = 'WordLevelDiff::WordLevelDiff'; |
1833 | | - wfProfileIn( $fname ); |
| 1805 | + wfProfileIn( __METHOD__ ); |
1834 | 1806 | |
1835 | 1807 | list ($orig_words, $orig_stripped) = $this->_split($orig_lines); |
1836 | 1808 | list ($closing_words, $closing_stripped) = $this->_split($closing_lines); |
1837 | 1809 | |
1838 | 1810 | $this->MappedDiff($orig_words, $closing_words, |
1839 | | - $orig_stripped, $closing_stripped); |
1840 | | - wfProfileOut( $fname ); |
| 1811 | + $orig_stripped, $closing_stripped); |
| 1812 | + wfProfileOut( __METHOD__ ); |
1841 | 1813 | } |
1842 | 1814 | |
1843 | 1815 | function _split($lines) { |
1844 | | - $fname = 'WordLevelDiff::_split'; |
1845 | | - wfProfileIn( $fname ); |
| 1816 | + wfProfileIn( __METHOD__ ); |
1846 | 1817 | |
1847 | 1818 | $words = array(); |
1848 | 1819 | $stripped = array(); |
— | — | @@ -1868,13 +1839,12 @@ |
1869 | 1840 | } |
1870 | 1841 | } |
1871 | 1842 | } |
1872 | | - wfProfileOut( $fname ); |
| 1843 | + wfProfileOut( __METHOD__ ); |
1873 | 1844 | return array($words, $stripped); |
1874 | 1845 | } |
1875 | 1846 | |
1876 | 1847 | function orig () { |
1877 | | - $fname = 'WordLevelDiff::orig'; |
1878 | | - wfProfileIn( $fname ); |
| 1848 | + wfProfileIn( __METHOD__ ); |
1879 | 1849 | $orig = new _HWLDF_WordAccumulator; |
1880 | 1850 | |
1881 | 1851 | foreach ($this->edits as $edit) { |
— | — | @@ -1884,13 +1854,12 @@ |
1885 | 1855 | $orig->addWords($edit->orig, 'del'); |
1886 | 1856 | } |
1887 | 1857 | $lines = $orig->getLines(); |
1888 | | - wfProfileOut( $fname ); |
| 1858 | + wfProfileOut( __METHOD__ ); |
1889 | 1859 | return $lines; |
1890 | 1860 | } |
1891 | 1861 | |
1892 | 1862 | function closing () { |
1893 | | - $fname = 'WordLevelDiff::closing'; |
1894 | | - wfProfileIn( $fname ); |
| 1863 | + wfProfileIn( __METHOD__ ); |
1895 | 1864 | $closing = new _HWLDF_WordAccumulator; |
1896 | 1865 | |
1897 | 1866 | foreach ($this->edits as $edit) { |
— | — | @@ -1900,19 +1869,18 @@ |
1901 | 1870 | $closing->addWords($edit->closing, 'ins'); |
1902 | 1871 | } |
1903 | 1872 | $lines = $closing->getLines(); |
1904 | | - wfProfileOut( $fname ); |
| 1873 | + wfProfileOut( __METHOD__ ); |
1905 | 1874 | return $lines; |
1906 | 1875 | } |
1907 | 1876 | } |
1908 | 1877 | |
1909 | 1878 | /** |
1910 | | - * Wikipedia Table style diff formatter. |
| 1879 | + * Wikipedia Table style diff formatter. |
1911 | 1880 | * @todo document |
1912 | 1881 | * @private |
1913 | 1882 | * @addtogroup DifferenceEngine |
1914 | 1883 | */ |
1915 | | -class TableDiffFormatter extends DiffFormatter |
1916 | | -{ |
| 1884 | +class TableDiffFormatter extends DiffFormatter { |
1917 | 1885 | function TableDiffFormatter() { |
1918 | 1886 | $this->leading_context_lines = 2; |
1919 | 1887 | $this->trailing_context_lines = 2; |
— | — | @@ -1993,8 +1961,7 @@ |
1994 | 1962 | } |
1995 | 1963 | |
1996 | 1964 | function _changed( $orig, $closing ) { |
1997 | | - $fname = 'TableDiffFormatter::_changed'; |
1998 | | - wfProfileIn( $fname ); |
| 1965 | + wfProfileIn( __METHOD__ ); |
1999 | 1966 | |
2000 | 1967 | $diff = new WordLevelDiff( $orig, $closing ); |
2001 | 1968 | $del = $diff->orig(); |
— | — | @@ -2012,7 +1979,7 @@ |
2013 | 1980 | echo '<tr>' . $this->emptyLine() . |
2014 | 1981 | $this->addedLine( $line ) . "</tr>\n"; |
2015 | 1982 | } |
2016 | | - wfProfileOut( $fname ); |
| 1983 | + wfProfileOut( __METHOD__ ); |
2017 | 1984 | } |
2018 | 1985 | } |
2019 | 1986 | |