ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
DifferenceEngine Class Reference
+ Collaboration diagram for DifferenceEngine:

Public Member Functions

 __construct ($titleObj=null, $old=0, $new=0, $rcid=0)
 #- More...
 
 showDiffPage ($diffOnly=false)
 
 renderNewRevision ()
 Show the new revision of the page. More...
 
 showFirstRevision ()
 Show the first revision of an article. More...
 
 showDiff ($otitle, $ntitle)
 Get the diff text, send it to $wgOut Returns false if the diff could not be generated, otherwise returns true. More...
 
 getDiff ($otitle, $ntitle)
 Get diff table, including header Note that the interface has changed, it's no longer static. More...
 
 getDiffBody ()
 Get the diff table body, without header Results are cached Returns false on error. More...
 
 generateDiffBody ($otext, $ntext)
 Generate a diff, no caching $otext and $ntext must be already segmented. More...
 
 localiseLineNumbers ($text)
 Replace line numbers with the text in the user's language. More...
 
 localiseLineNumbersCb ($matches)
 
 getMultiNotice ()
 If there are revisions between the ones being compared, return a note saying so. More...
 
 addHeader ($diff, $otitle, $ntitle, $multi='')
 Add the header to a diff body. More...
 
 setText ($oldText, $newText)
 Use specified text instead of loading from the database. More...
 
 loadRevisionData ()
 Load revision metadata for the specified articles. More...
 
 loadText ()
 Load the text of the revisions, as well as revision data. More...
 
 loadNewText ()
 Load the text of the new revision, not the old one. More...
 

Data Fields

 $mOldid
 #+ More...
 
 $mNewid
 
 $mTitle
 
 $mOldtitle
 
 $mNewtitle
 
 $mPagetitle
 
 $mOldtext
 
 $mNewtext
 
 $mOldPage
 
 $mNewPage
 
 $mRcidMarkPatrolled
 
 $mOldRev
 
 $mNewRev
 
 $mRevisionsLoaded = false
 
 $mTextLoaded = 0
 

Detailed Description

Definition at line 17 of file class.WordLevelDiff.php.

Constructor & Destructor Documentation

◆ __construct()

DifferenceEngine::__construct (   $titleObj = null,
  $old = 0,
  $new = 0,
  $rcid = 0 
)

#-

Constructor

Parameters
$titleObjTitle object that the diff is associated with
$oldInteger: old ID we want to show and diff with.
$newString: either 'prev' or 'next'.
$rcidInteger: ??? FIXME (default 0)

Definition at line 46 of file class.WordLevelDiff.php.

Referenced by _DiffOp_Copy\__construct(), _DiffOp_Delete\__construct(), _DiffOp_Add\__construct(), _DiffOp_Change\__construct(), and TableDiffFormatter\_start_block().

47  {
48  $this->mTitle = $titleObj;
49  wfDebug("DifferenceEngine old '$old' new '$new' rcid '$rcid'\n");
50 
51  if ('prev' === $new) {
52  # Show diff between revision $old and the previous one.
53  # Get previous one from DB.
54  #
55  $this->mNewid = intval($old);
56 
57  $this->mOldid = $this->mTitle->getPreviousRevisionID($this->mNewid);
58  } elseif ('next' === $new) {
59  # Show diff between revision $old and the previous one.
60  # Get previous one from DB.
61  #
62  $this->mOldid = intval($old);
63  $this->mNewid = $this->mTitle->getNextRevisionID($this->mOldid);
64  if (false === $this->mNewid) {
65  # if no result, NewId points to the newest old revision. The only newer
66  # revision is cur, which is "0".
67  $this->mNewid = 0;
68  }
69  } else {
70  $this->mOldid = intval($old);
71  $this->mNewid = intval($new);
72  }
73  $this->mRcidMarkPatrolled = intval($rcid); # force it to be an integer
74  }
+ Here is the caller graph for this function:

Member Function Documentation

◆ addHeader()

DifferenceEngine::addHeader (   $diff,
  $otitle,
  $ntitle,
  $multi = '' 
)

Add the header to a diff body.

Definition at line 528 of file class.WordLevelDiff.php.

References $header.

Referenced by getDiff().

529  {
530  global $wgOut;
531 
532  if ($this->mOldRev && $this->mOldRev->isDeleted(Revision::DELETED_TEXT)) {
533  $otitle = '<span class="history-deleted">' . $otitle . '</span>';
534  }
535  if ($this->mNewRev && $this->mNewRev->isDeleted(Revision::DELETED_TEXT)) {
536  $ntitle = '<span class="history-deleted">' . $ntitle . '</span>';
537  }
538  $header = "
539  <table border='0' width='98%' cellpadding='0' cellspacing='4' class='diff'>
540  <tr>
541  <td colspan='2' width='50%' align='center' class='diff-otitle'>{$otitle}</td>
542  <td colspan='2' width='50%' align='center' class='diff-ntitle'>{$ntitle}</td>
543  </tr>
544  ";
545 
546  if ($multi != '') {
547  $header .= "<tr><td colspan='4' align='center' class='diff-multi'>{$multi}</td></tr>";
548  }
549 
550  return $header . $diff . "</table>";
551  }
+ Here is the caller graph for this function:

◆ generateDiffBody()

DifferenceEngine::generateDiffBody (   $otext,
  $ntext 
)

Generate a diff, no caching $otext and $ntext must be already segmented.

Definition at line 403 of file class.WordLevelDiff.php.

References $text.

Referenced by getDiffBody().

404  {
405  global $wgExternalDiffEngine, $wgContLang;
406  $fname = 'DifferenceEngine::generateDiffBody';
407 
408  $otext = str_replace("\r\n", "\n", $otext);
409  $ntext = str_replace("\r\n", "\n", $ntext);
410 
411  if ($wgExternalDiffEngine == 'wikidiff') {
412  # For historical reasons, external diff engine expects
413  # input text to be HTML-escaped already
414  $otext = htmlspecialchars($wgContLang->segmentForDiff($otext));
415  $ntext = htmlspecialchars($wgContLang->segmentForDiff($ntext));
416  if (!function_exists('wikidiff_do_diff')) {
417  dl('php_wikidiff.so');
418  }
419  return $wgContLang->unsegementForDiff(wikidiff_do_diff($otext, $ntext, 2));
420  }
421 
422  if ($wgExternalDiffEngine == 'wikidiff2') {
423  # Better external diff engine, the 2 may some day be dropped
424  # This one does the escaping and segmenting itself
425  if (!function_exists('wikidiff2_do_diff')) {
426  //wfProfileIn( "$fname-dl" );
427  @dl('php_wikidiff2.so');
428  //wfProfileOut( "$fname-dl" );
429  }
430  if (function_exists('wikidiff2_do_diff')) {
431  //wfProfileIn( 'wikidiff2_do_diff' );
432  $text = wikidiff2_do_diff($otext, $ntext, 2);
433  //wfProfileOut( 'wikidiff2_do_diff' );
434  return $text;
435  }
436  }
437  if ($wgExternalDiffEngine !== false) {
438  # Diff via the shell
439  global $wgTmpDirectory;
440  $tempName1 = tempnam($wgTmpDirectory, 'diff_');
441  $tempName2 = tempnam($wgTmpDirectory, 'diff_');
442 
443  $tempFile1 = fopen($tempName1, "w");
444  if (!$tempFile1) {
445  //wfProfileOut( $fname );
446  return false;
447  }
448  $tempFile2 = fopen($tempName2, "w");
449  if (!$tempFile2) {
450  //wfProfileOut( $fname );
451  return false;
452  }
453  fwrite($tempFile1, $otext);
454  fwrite($tempFile2, $ntext);
455  fclose($tempFile1);
456  fclose($tempFile2);
457  $cmd = wfEscapeShellArg($wgExternalDiffEngine, $tempName1, $tempName2);
458  //wfProfileIn( "$fname-shellexec" );
459  $difftext = wfShellExec($cmd);
460  //wfProfileOut( "$fname-shellexec" );
461  unlink($tempName1);
462  unlink($tempName2);
463  return $difftext;
464  }
465 
466  # Native PHP diff
467  $ota = explode("\n", $wgContLang->segmentForDiff($otext));
468  $nta = explode("\n", $wgContLang->segmentForDiff($ntext));
469  $diffs = new Diff($ota, $nta);
470  $formatter = new TableDiffFormatter();
471  return $wgContLang->unsegmentForDiff($formatter->format($diffs));
472  }
$text
Definition: errorreport.php:18
+ Here is the caller graph for this function:

◆ getDiff()

DifferenceEngine::getDiff (   $otitle,
  $ntitle 
)

Get diff table, including header Note that the interface has changed, it's no longer static.

Returns false on error

Definition at line 335 of file class.WordLevelDiff.php.

References addHeader(), getDiffBody(), and getMultiNotice().

Referenced by showDiff().

336  {
337  $body = $this->getDiffBody();
338  if ($body === false) {
339  return false;
340  } else {
341  $multi = $this->getMultiNotice();
342  return $this->addHeader($body, $otitle, $ntitle, $multi);
343  }
344  }
getDiffBody()
Get the diff table body, without header Results are cached Returns false on error.
addHeader($diff, $otitle, $ntitle, $multi='')
Add the header to a diff body.
getMultiNotice()
If there are revisions between the ones being compared, return a note saying so.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDiffBody()

DifferenceEngine::getDiffBody ( )

Get the diff table body, without header Results are cached Returns false on error.

Definition at line 351 of file class.WordLevelDiff.php.

References $key, generateDiffBody(), loadText(), and localiseLineNumbers().

Referenced by getDiff().

352  {
353  global $wgMemc;
354  $fname = 'DifferenceEngine::getDiffBody';
355  //wfProfileIn( $fname );
356 
357  // Cacheable?
358  $key = false;
359  if ($this->mOldid && $this->mNewid) {
360  // Try cache
361  $key = wfMemcKey('diff', 'oldid', $this->mOldid, 'newid', $this->mNewid);
362  $difftext = $wgMemc->get($key);
363  if ($difftext) {
364  wfIncrStats('diff_cache_hit');
365  $difftext = $this->localiseLineNumbers($difftext);
366  $difftext .= "\n<!-- diff cache key $key -->\n";
367  //wfProfileOut( $fname );
368  return $difftext;
369  }
370  }
371 
372  #loadtext is permission safe, this just clears out the diff
373  if (!$this->loadText()) {
374  //wfProfileOut( $fname );
375  return false;
376  } elseif ($this->mOldRev && !$this->mOldRev->userCan(Revision::DELETED_TEXT)) {
377  return '';
378  } elseif ($this->mNewRev && !$this->mNewRev->userCan(Revision::DELETED_TEXT)) {
379  return '';
380  }
381 
382  $difftext = $this->generateDiffBody($this->mOldtext, $this->mNewtext);
383 
384  // Save to cache for 7 days
385  if ($key !== false && $difftext !== false) {
386  wfIncrStats('diff_cache_miss');
387  $wgMemc->set($key, $difftext, 7 * 86400);
388  } else {
389  wfIncrStats('diff_uncacheable');
390  }
391  // Replace line numbers with the text in the user's language
392  if ($difftext !== false) {
393  $difftext = $this->localiseLineNumbers($difftext);
394  }
395  //wfProfileOut( $fname );
396  return $difftext;
397  }
localiseLineNumbers($text)
Replace line numbers with the text in the user&#39;s language.
generateDiffBody($otext, $ntext)
Generate a diff, no caching $otext and $ntext must be already segmented.
$key
Definition: croninfo.php:18
loadText()
Load the text of the revisions, as well as revision data.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMultiNotice()

DifferenceEngine::getMultiNotice ( )

If there are revisions between the ones being compared, return a note saying so.

Definition at line 497 of file class.WordLevelDiff.php.

References $n.

Referenced by getDiff().

498  {
499  if (!is_object($this->mOldRev) || !is_object($this->mNewRev)) {
500  return '';
501  }
502 
503  if (!$this->mOldPage->equals($this->mNewPage)) {
504  // Comparing two different pages? Count would be meaningless.
505  return '';
506  }
507 
508  $oldid = $this->mOldRev->getId();
509  $newid = $this->mNewRev->getId();
510  if ($oldid > $newid) {
511  $tmp = $oldid;
512  $oldid = $newid;
513  $newid = $tmp;
514  }
515 
516  $n = $this->mTitle->countRevisionsBetween($oldid, $newid);
517  if (!$n) {
518  return '';
519  }
520 
521  return wfMsgExt('diff-multi', array( 'parseinline' ), $n);
522  }
$n
Definition: RandomTest.php:85
+ Here is the caller graph for this function:

◆ loadNewText()

DifferenceEngine::loadNewText ( )

Load the text of the new revision, not the old one.

Definition at line 683 of file class.WordLevelDiff.php.

Referenced by renderNewRevision(), and showFirstRevision().

684  {
685  if ($this->mTextLoaded >= 1) {
686  return true;
687  } else {
688  $this->mTextLoaded = 1;
689  }
690  if (!$this->loadRevisionData()) {
691  return false;
692  }
693  $this->mNewtext = $this->mNewRev->getText();
694  return true;
695  }
loadRevisionData()
Load revision metadata for the specified articles.
+ Here is the caller graph for this function:

◆ loadRevisionData()

DifferenceEngine::loadRevisionData ( )

Load revision metadata for the specified articles.

If newid is 0, then compare the old article in oldid to the current article; if oldid is 0, then compare the current article to the immediately previous one (ignoring the value of newid).

If oldid is false, leave the corresponding revision object set to false. This is impossible via ordinary user input, and is provided for API convenience.

Definition at line 573 of file class.WordLevelDiff.php.

References $t, $timestamp, and wfMsg().

Referenced by loadText(), and showDiffPage().

574  {
575  global $wgLang;
576  if ($this->mRevisionsLoaded) {
577  return true;
578  } else {
579  // Whether it succeeds or fails, we don't want to try again
580  $this->mRevisionsLoaded = true;
581  }
582 
583  // Load the new revision object
584  if ($this->mNewid) {
585  $this->mNewRev = Revision::newFromId($this->mNewid);
586  } else {
587  $this->mNewRev = Revision::newFromTitle($this->mTitle);
588  }
589 
590  if (is_null($this->mNewRev)) {
591  return false;
592  }
593 
594  // Set assorted variables
595  $timestamp = $wgLang->timeanddate($this->mNewRev->getTimestamp(), true);
596  $this->mNewPage = $this->mNewRev->getTitle();
597  if ($this->mNewRev->isCurrent()) {
598  $newLink = $this->mNewPage->escapeLocalUrl();
599  $this->mPagetitle = htmlspecialchars(wfMsg('currentrev'));
600  $newEdit = $this->mNewPage->escapeLocalUrl('action=edit');
601 
602  $this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a> ($timestamp)"
603  . " (<a href='$newEdit'>" . htmlspecialchars(wfMsg('editold')) . "</a>)";
604  } else {
605  $newLink = $this->mNewPage->escapeLocalUrl('oldid=' . $this->mNewid);
606  $newEdit = $this->mNewPage->escapeLocalUrl('action=edit&oldid=' . $this->mNewid);
607  $this->mPagetitle = htmlspecialchars(wfMsg('revisionasof', $timestamp));
608 
609  $this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a>"
610  . " (<a href='$newEdit'>" . htmlspecialchars(wfMsg('editold')) . "</a>)";
611  }
612 
613  // Load the old revision object
614  $this->mOldRev = false;
615  if ($this->mOldid) {
616  $this->mOldRev = Revision::newFromId($this->mOldid);
617  } elseif ($this->mOldid === 0) {
618  $rev = $this->mNewRev->getPrevious();
619  if ($rev) {
620  $this->mOldid = $rev->getId();
621  $this->mOldRev = $rev;
622  } else {
623  // No previous revision; mark to show as first-version only.
624  $this->mOldid = false;
625  $this->mOldRev = false;
626  }
627  }/* elseif ( $this->mOldid === false ) leave mOldRev false; */
628 
629  if (is_null($this->mOldRev)) {
630  return false;
631  }
632 
633  if ($this->mOldRev) {
634  $this->mOldPage = $this->mOldRev->getTitle();
635 
636  $t = $wgLang->timeanddate($this->mOldRev->getTimestamp(), true);
637  $oldLink = $this->mOldPage->escapeLocalUrl('oldid=' . $this->mOldid);
638  $oldEdit = $this->mOldPage->escapeLocalUrl('action=edit&oldid=' . $this->mOldid);
639  $this->mOldtitle = "<a href='$oldLink'>" . htmlspecialchars(wfMsg('revisionasof', $t))
640  . "</a> (<a href='$oldEdit'>" . htmlspecialchars(wfMsg('editold')) . "</a>)";
641  //now that we considered old rev, we can make undo link (bug 8133, multi-edit undo)
642  $newUndo = $this->mNewPage->escapeLocalUrl('action=edit&undoafter=' . $this->mOldid . '&undo=' . $this->mNewid);
643  $this->mNewtitle .= " (<a href='$newUndo'>" . htmlspecialchars(wfMsg('editundo')) . "</a>)";
644  }
645 
646  return true;
647  }
wfMsg($x)
Definition: RandomTest.php:63
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadText()

DifferenceEngine::loadText ( )

Load the text of the revisions, as well as revision data.

Definition at line 652 of file class.WordLevelDiff.php.

References loadRevisionData().

Referenced by getDiffBody().

653  {
654  if ($this->mTextLoaded == 2) {
655  return true;
656  } else {
657  // Whether it succeeds or fails, we don't want to try again
658  $this->mTextLoaded = 2;
659  }
660 
661  if (!$this->loadRevisionData()) {
662  return false;
663  }
664  if ($this->mOldRev) {
665  // FIXME: permission tests
666  $this->mOldtext = $this->mOldRev->revText();
667  if ($this->mOldtext === false) {
668  return false;
669  }
670  }
671  if ($this->mNewRev) {
672  $this->mNewtext = $this->mNewRev->revText();
673  if ($this->mNewtext === false) {
674  return false;
675  }
676  }
677  return true;
678  }
loadRevisionData()
Load revision metadata for the specified articles.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ localiseLineNumbers()

DifferenceEngine::localiseLineNumbers (   $text)

Replace line numbers with the text in the user's language.

Definition at line 478 of file class.WordLevelDiff.php.

References $text.

Referenced by getDiffBody().

479  {
480  return preg_replace_callback(
481  '/<!--LINE (\d+)-->/',
482  array( &$this, 'localiseLineNumbersCb' ),
483  $text
484  );
485  }
$text
Definition: errorreport.php:18
+ Here is the caller graph for this function:

◆ localiseLineNumbersCb()

DifferenceEngine::localiseLineNumbersCb (   $matches)

Definition at line 487 of file class.WordLevelDiff.php.

488  {
489  global $wgLang;
490  return wfMsgExt('lineno', array('parseinline'), $wgLang->formatNum($matches[1]));
491  }

◆ renderNewRevision()

DifferenceEngine::renderNewRevision ( )

Show the new revision of the page.

Definition at line 230 of file class.WordLevelDiff.php.

References loadNewText(), and wfMsg().

Referenced by showDiffPage().

231  {
232  global $wgOut;
233  $fname = 'DifferenceEngine::renderNewRevision';
234  //wfProfileIn( $fname );
235 
236  $wgOut->addHTML("<hr /><h2>{$this->mPagetitle}</h2>\n");
237  #add deleted rev tag if needed
238  if (!$this->mNewRev->userCan(Revision::DELETED_TEXT)) {
239  $wgOut->addWikiText(wfMsg('rev-deleted-text-permission'));
240  }
241 
242  if (!$this->mNewRev->isCurrent()) {
243  $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection(false);
244  }
245 
246  $this->loadNewText();
247  if (is_object($this->mNewRev)) {
248  $wgOut->setRevisionId($this->mNewRev->getId());
249  }
250 
251  $wgOut->addWikiTextTidy($this->mNewtext);
252 
253  if (!$this->mNewRev->isCurrent()) {
254  $wgOut->parserOptions()->setEditSection($oldEditSectionSetting);
255  }
256 
257  //wfProfileOut( $fname );
258  }
wfMsg($x)
Definition: RandomTest.php:63
loadNewText()
Load the text of the new revision, not the old one.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setText()

DifferenceEngine::setText (   $oldText,
  $newText 
)

Use specified text instead of loading from the database.

Definition at line 556 of file class.WordLevelDiff.php.

557  {
558  $this->mOldtext = $oldText;
559  $this->mNewtext = $newText;
560  $this->mTextLoaded = 2;
561  }

◆ showDiff()

DifferenceEngine::showDiff (   $otitle,
  $ntitle 
)

Get the diff text, send it to $wgOut Returns false if the diff could not be generated, otherwise returns true.

Definition at line 317 of file class.WordLevelDiff.php.

References getDiff(), and wfMsg().

Referenced by showDiffPage().

318  {
319  global $wgOut;
320  $diff = $this->getDiff($otitle, $ntitle);
321  if ($diff === false) {
322  $wgOut->addWikitext(wfMsg('missingarticle', "<nowiki>(fixme, bug)</nowiki>"));
323  return false;
324  } else {
325  $wgOut->addHTML($diff);
326  return true;
327  }
328  }
wfMsg($x)
Definition: RandomTest.php:63
getDiff($otitle, $ntitle)
Get diff table, including header Note that the interface has changed, it&#39;s no longer static...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showDiffPage()

DifferenceEngine::showDiffPage (   $diffOnly = false)

Definition at line 76 of file class.WordLevelDiff.php.

References $t, exit, loadRevisionData(), NS_SPECIAL, renderNewRevision(), showDiff(), showFirstRevision(), and wfMsg().

77  {
78  global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol;
79  $fname = 'DifferenceEngine::showDiffPage';
80  //wfProfileIn( $fname );
81 
82  # If external diffs are enabled both globally and for the user,
83  # we'll use the application/x-external-editor interface to call
84  # an external diff tool like kompare, kdiff3, etc.
85  if ($wgUseExternalEditor && $wgUser->getOption('externaldiff')) {
86  global $wgInputEncoding,$wgServer,$wgScript,$wgLang;
87  $wgOut->disable();
88  header("Content-type: application/x-external-editor; charset=" . $wgInputEncoding);
89  $url1 = $this->mTitle->getFullURL("action=raw&oldid=" . $this->mOldid);
90  $url2 = $this->mTitle->getFullURL("action=raw&oldid=" . $this->mNewid);
91  $special = $wgLang->getNsText(NS_SPECIAL);
92  $control = <<<CONTROL
93 [Process]
94 Type=Diff text
95 Engine=MediaWiki
96 Script={$wgServer}{$wgScript}
97 Special namespace={$special}
98 
99 [File]
100 Extension=wiki
101 URL=$url1
102 
103 [File 2]
104 Extension=wiki
105 URL=$url2
106 CONTROL;
107  echo($control);
108  return;
109  }
110 
111  $wgOut->setArticleFlag(false);
112  if (!$this->loadRevisionData()) {
113  $t = $this->mTitle->getPrefixedText() . " (Diff: {$this->mOldid}, {$this->mNewid})";
114  $mtext = wfMsg('missingarticle', "<nowiki>$t</nowiki>");
115  $wgOut->setPagetitle(wfMsg('errorpagetitle'));
116  $wgOut->addWikitext($mtext);
117  //wfProfileOut( $fname );
118  return;
119  }
120 
121  wfRunHooks('DiffViewHeader', array( $this, $this->mOldRev, $this->mNewRev ));
122 
123  if ($this->mNewRev->isCurrent()) {
124  $wgOut->setArticleFlag(true);
125  }
126 
127  # mOldid is false if the difference engine is called with a "vague" query for
128  # a diff between a version V and its previous version V' AND the version V
129  # is the first version of that article. In that case, V' does not exist.
130  if ($this->mOldid === false) {
131  $this->showFirstRevision();
132  $this->renderNewRevision(); // should we respect $diffOnly here or not?
133  //wfProfileOut( $fname );
134  return;
135  }
136 
137  $wgOut->suppressQuickbar();
138 
139  $oldTitle = $this->mOldPage->getPrefixedText();
140  $newTitle = $this->mNewPage->getPrefixedText();
141  if ($oldTitle == $newTitle) {
142  $wgOut->setPageTitle($newTitle);
143  } else {
144  $wgOut->setPageTitle($oldTitle . ', ' . $newTitle);
145  }
146  $wgOut->setSubtitle(wfMsg('difference'));
147  $wgOut->setRobotpolicy('noindex,nofollow');
148 
149  if (!($this->mOldPage->userCanRead() && $this->mNewPage->userCanRead())) {
150  $wgOut->loginToUse();
151  $wgOut->output();
152  //wfProfileOut( $fname );
153  exit;
154  }
155 
156  $sk = $wgUser->getSkin();
157 
158  if ($this->mNewRev->isCurrent() && $wgUser->isAllowed('rollback')) {
159  $rollback = '&nbsp;&nbsp;&nbsp;' . $sk->generateRollback($this->mNewRev);
160  } else {
161  $rollback = '';
162  }
163  if ($wgUseRCPatrol && $this->mRcidMarkPatrolled != 0 && $wgUser->isAllowed('patrol')) {
164  $patrol = ' [' . $sk->makeKnownLinkObj($this->mTitle, wfMsg('markaspatrolleddiff'), "action=markpatrolled&rcid={$this->mRcidMarkPatrolled}") . ']';
165  } else {
166  $patrol = '';
167  }
168 
169  $prevlink = $sk->makeKnownLinkObj(
170  $this->mTitle,
171  wfMsgHtml('previousdiff'),
172  'diff=prev&oldid=' . $this->mOldid,
173  '',
174  '',
175  'id="differences-prevlink"'
176  );
177  if ($this->mNewRev->isCurrent()) {
178  $nextlink = '&nbsp;';
179  } else {
180  $nextlink = $sk->makeKnownLinkObj(
181  $this->mTitle,
182  wfMsgHtml('nextdiff'),
183  'diff=next&oldid=' . $this->mNewid,
184  '',
185  '',
186  'id="differences-nextlink"'
187  );
188  }
189 
190  $oldminor = '';
191  $newminor = '';
192 
193  if ($this->mOldRev->mMinorEdit == 1) {
194  $oldminor = wfElement(
195  'span',
196  array( 'class' => 'minor' ),
197  wfMsg('minoreditletter')
198  ) . ' ';
199  }
200 
201  if ($this->mNewRev->mMinorEdit == 1) {
202  $newminor = wfElement(
203  'span',
204  array( 'class' => 'minor' ),
205  wfMsg('minoreditletter')
206  ) . ' ';
207  }
208 
209  $oldHeader = "<strong>{$this->mOldtitle}</strong><br />" .
210  $sk->revUserTools($this->mOldRev) . "<br />" .
211  $oldminor . $sk->revComment($this->mOldRev, !$diffOnly) . "<br />" .
212  $prevlink;
213  $newHeader = "<strong>{$this->mNewtitle}</strong><br />" .
214  $sk->revUserTools($this->mNewRev) . " $rollback<br />" .
215  $newminor . $sk->revComment($this->mNewRev, !$diffOnly) . "<br />" .
216  $nextlink . $patrol;
217 
218  $this->showDiff($oldHeader, $newHeader);
219 
220  if (!$diffOnly) {
221  $this->renderNewRevision();
222  }
223 
224  //wfProfileOut( $fname );
225  }
showDiff($otitle, $ntitle)
Get the diff text, send it to $wgOut Returns false if the diff could not be generated, otherwise returns true.
renderNewRevision()
Show the new revision of the page.
wfMsg($x)
Definition: RandomTest.php:63
const NS_SPECIAL
Definition: Title.php:16
exit
Definition: backend.php:16
showFirstRevision()
Show the first revision of an article.
loadRevisionData()
Load revision metadata for the specified articles.
+ Here is the call graph for this function:

◆ showFirstRevision()

DifferenceEngine::showFirstRevision ( )

Show the first revision of an article.

Uses normal diff headers in contrast to normal "old revision" display style.

Definition at line 264 of file class.WordLevelDiff.php.

References $header, $t, exit, loadNewText(), and wfMsg().

Referenced by showDiffPage().

265  {
266  global $wgOut, $wgUser;
267 
268  $fname = 'DifferenceEngine::showFirstRevision';
269  //wfProfileIn( $fname );
270 
271  # Get article text from the DB
272  #
273  if (!$this->loadNewText()) {
274  $t = $this->mTitle->getPrefixedText() . " (Diff: {$this->mOldid}, " .
275  "{$this->mNewid})";
276  $mtext = wfMsg('missingarticle', "<nowiki>$t</nowiki>");
277  $wgOut->setPagetitle(wfMsg('errorpagetitle'));
278  $wgOut->addWikitext($mtext);
279  //wfProfileOut( $fname );
280  return;
281  }
282  if ($this->mNewRev->isCurrent()) {
283  $wgOut->setArticleFlag(true);
284  }
285 
286  # Check if user is allowed to look at this page. If not, bail out.
287  #
288  if (!($this->mTitle->userCanRead())) {
289  $wgOut->loginToUse();
290  $wgOut->output();
291  //wfProfileOut( $fname );
292  exit;
293  }
294 
295  # Prepare the header box
296  #
297  $sk = $wgUser->getSkin();
298 
299  $nextlink = $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('nextdiff'), 'diff=next&oldid=' . $this->mNewid, '', '', 'id="differences-nextlink"');
300  $header = "<div class=\"firstrevisionheader\" style=\"text-align: center\"><strong>{$this->mOldtitle}</strong><br />" .
301  $sk->revUserTools($this->mNewRev) . "<br />" .
302  $sk->revComment($this->mNewRev) . "<br />" .
303  $nextlink . "</div>\n";
304 
305  $wgOut->addHTML($header);
306 
307  $wgOut->setSubtitle(wfMsg('difference'));
308  $wgOut->setRobotpolicy('noindex,nofollow');
309 
310  //wfProfileOut( $fname );
311  }
wfMsg($x)
Definition: RandomTest.php:63
exit
Definition: backend.php:16
loadNewText()
Load the text of the new revision, not the old one.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $mNewid

DifferenceEngine::$mNewid

Definition at line 23 of file class.WordLevelDiff.php.

◆ $mNewPage

DifferenceEngine::$mNewPage

Definition at line 31 of file class.WordLevelDiff.php.

◆ $mNewRev

DifferenceEngine::$mNewRev

Definition at line 34 of file class.WordLevelDiff.php.

◆ $mNewtext

DifferenceEngine::$mNewtext

Definition at line 29 of file class.WordLevelDiff.php.

◆ $mNewtitle

DifferenceEngine::$mNewtitle

Definition at line 26 of file class.WordLevelDiff.php.

◆ $mOldid

DifferenceEngine::$mOldid

#+

Definition at line 22 of file class.WordLevelDiff.php.

◆ $mOldPage

DifferenceEngine::$mOldPage

Definition at line 30 of file class.WordLevelDiff.php.

◆ $mOldRev

DifferenceEngine::$mOldRev

Definition at line 33 of file class.WordLevelDiff.php.

◆ $mOldtext

DifferenceEngine::$mOldtext

Definition at line 28 of file class.WordLevelDiff.php.

◆ $mOldtitle

DifferenceEngine::$mOldtitle

Definition at line 25 of file class.WordLevelDiff.php.

◆ $mPagetitle

DifferenceEngine::$mPagetitle

Definition at line 27 of file class.WordLevelDiff.php.

◆ $mRcidMarkPatrolled

DifferenceEngine::$mRcidMarkPatrolled

Definition at line 32 of file class.WordLevelDiff.php.

◆ $mRevisionsLoaded

DifferenceEngine::$mRevisionsLoaded = false

Definition at line 35 of file class.WordLevelDiff.php.

◆ $mTextLoaded

DifferenceEngine::$mTextLoaded = 0

Definition at line 36 of file class.WordLevelDiff.php.

◆ $mTitle

DifferenceEngine::$mTitle

Definition at line 24 of file class.WordLevelDiff.php.


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