ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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

 $mNewid
 
 $mTitle
 
 $mOldtitle
 
 $mNewtitle
 
 $mPagetitle
 
 $mOldtext
 
 $mNewtext
 
 $mOldPage
 
 $mNewPage
 
 $mRcidMarkPatrolled
 
 $mOldRev
 
 $mNewRev
 
 $mRevisionsLoaded = false
 
 $mTextLoaded = 0
 

Private Attributes

 $mOldid
 #+ More...
 

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 38 of file class.WordLevelDiff.php.

References $new, $old, and to.

Referenced by _DiffOp_Copy\__construct(), TableDiffFormatter\_block_header(), _HWLDF_WordAccumulator\_flushGroup(), _DiffOp_Delete\reverse(), _DiffOp_Add\reverse(), and _DiffOp_Change\reverse().

38  {
39  $this->mTitle = $titleObj;
40  wfDebug("DifferenceEngine old '$old' new '$new' rcid '$rcid'\n");
41 
42  if ( 'prev' === $new ) {
43  # Show diff between revision $old and the previous one.
44  # Get previous one from DB.
45  #
46  $this->mNewid = intval($old);
47 
48  $this->mOldid = $this->mTitle->getPreviousRevisionID( $this->mNewid );
49 
50  } elseif ( 'next' === $new ) {
51  # Show diff between revision $old and the previous one.
52  # Get previous one from DB.
53  #
54  $this->mOldid = intval($old);
55  $this->mNewid = $this->mTitle->getNextRevisionID( $this->mOldid );
56  if ( false === $this->mNewid ) {
57  # if no result, NewId points to the newest old revision. The only newer
58  # revision is cur, which is "0".
59  $this->mNewid = 0;
60  }
61 
62  } else {
63  $this->mOldid = intval($old);
64  $this->mNewid = intval($new);
65  }
66  $this->mRcidMarkPatrolled = intval($rcid); # force it to be an integer
67  }
File written to
$old
+ 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 485 of file class.WordLevelDiff.php.

References $header.

Referenced by getDiff().

485  {
486  global $wgOut;
487 
488  if ( $this->mOldRev && $this->mOldRev->isDeleted(Revision::DELETED_TEXT) ) {
489  $otitle = '<span class="history-deleted">'.$otitle.'</span>';
490  }
491  if ( $this->mNewRev && $this->mNewRev->isDeleted(Revision::DELETED_TEXT) ) {
492  $ntitle = '<span class="history-deleted">'.$ntitle.'</span>';
493  }
494  $header = "
495  <table border='0' width='98%' cellpadding='0' cellspacing='4' class='diff'>
496  <tr>
497  <td colspan='2' width='50%' align='center' class='diff-otitle'>{$otitle}</td>
498  <td colspan='2' width='50%' align='center' class='diff-ntitle'>{$ntitle}</td>
499  </tr>
500  ";
501 
502  if ( $multi != '' )
503  $header .= "<tr><td colspan='4' align='center' class='diff-multi'>{$multi}</td></tr>";
504 
505  return $header . $diff . "</table>";
506  }
$header
+ 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 371 of file class.WordLevelDiff.php.

References $cmd, and $text.

Referenced by getDiffBody().

371  {
372  global $wgExternalDiffEngine, $wgContLang;
373  $fname = 'DifferenceEngine::generateDiffBody';
374 
375  $otext = str_replace( "\r\n", "\n", $otext );
376  $ntext = str_replace( "\r\n", "\n", $ntext );
377 
378  if ( $wgExternalDiffEngine == 'wikidiff' ) {
379  # For historical reasons, external diff engine expects
380  # input text to be HTML-escaped already
381  $otext = htmlspecialchars ( $wgContLang->segmentForDiff( $otext ) );
382  $ntext = htmlspecialchars ( $wgContLang->segmentForDiff( $ntext ) );
383  if( !function_exists( 'wikidiff_do_diff' ) ) {
384  dl('php_wikidiff.so');
385  }
386  return $wgContLang->unsegementForDiff( wikidiff_do_diff( $otext, $ntext, 2 ) );
387  }
388 
389  if ( $wgExternalDiffEngine == 'wikidiff2' ) {
390  # Better external diff engine, the 2 may some day be dropped
391  # This one does the escaping and segmenting itself
392  if ( !function_exists( 'wikidiff2_do_diff' ) ) {
393  //wfProfileIn( "$fname-dl" );
394  @dl('php_wikidiff2.so');
395  //wfProfileOut( "$fname-dl" );
396  }
397  if ( function_exists( 'wikidiff2_do_diff' ) ) {
398  //wfProfileIn( 'wikidiff2_do_diff' );
399  $text = wikidiff2_do_diff( $otext, $ntext, 2 );
400  //wfProfileOut( 'wikidiff2_do_diff' );
401  return $text;
402  }
403  }
404  if ( $wgExternalDiffEngine !== false ) {
405  # Diff via the shell
406  global $wgTmpDirectory;
407  $tempName1 = tempnam( $wgTmpDirectory, 'diff_' );
408  $tempName2 = tempnam( $wgTmpDirectory, 'diff_' );
409 
410  $tempFile1 = fopen( $tempName1, "w" );
411  if ( !$tempFile1 ) {
412  //wfProfileOut( $fname );
413  return false;
414  }
415  $tempFile2 = fopen( $tempName2, "w" );
416  if ( !$tempFile2 ) {
417  //wfProfileOut( $fname );
418  return false;
419  }
420  fwrite( $tempFile1, $otext );
421  fwrite( $tempFile2, $ntext );
422  fclose( $tempFile1 );
423  fclose( $tempFile2 );
424  $cmd = wfEscapeShellArg( $wgExternalDiffEngine, $tempName1, $tempName2 );
425  //wfProfileIn( "$fname-shellexec" );
426  $difftext = wfShellExec( $cmd );
427  //wfProfileOut( "$fname-shellexec" );
428  unlink( $tempName1 );
429  unlink( $tempName2 );
430  return $difftext;
431  }
432 
433  # Native PHP diff
434  $ota = explode( "\n", $wgContLang->segmentForDiff( $otext ) );
435  $nta = explode( "\n", $wgContLang->segmentForDiff( $ntext ) );
436  $diffs = new Diff( $ota, $nta );
437  $formatter = new TableDiffFormatter();
438  return $wgContLang->unsegmentForDiff( $formatter->format( $diffs ) );
439  }
$cmd
Definition: sahs_server.php:35
$text
+ 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 305 of file class.WordLevelDiff.php.

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

Referenced by showDiff().

305  {
306  $body = $this->getDiffBody();
307  if ( $body === false ) {
308  return false;
309  } else {
310  $multi = $this->getMultiNotice();
311  return $this->addHeader( $body, $otitle, $ntitle, $multi );
312  }
313  }
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 320 of file class.WordLevelDiff.php.

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

Referenced by getDiff().

320  {
321  global $wgMemc;
322  $fname = 'DifferenceEngine::getDiffBody';
323  //wfProfileIn( $fname );
324 
325  // Cacheable?
326  $key = false;
327  if ( $this->mOldid && $this->mNewid ) {
328  // Try cache
329  $key = wfMemcKey( 'diff', 'oldid', $this->mOldid, 'newid', $this->mNewid );
330  $difftext = $wgMemc->get( $key );
331  if ( $difftext ) {
332  wfIncrStats( 'diff_cache_hit' );
333  $difftext = $this->localiseLineNumbers( $difftext );
334  $difftext .= "\n<!-- diff cache key $key -->\n";
335  //wfProfileOut( $fname );
336  return $difftext;
337  }
338  }
339 
340  #loadtext is permission safe, this just clears out the diff
341  if ( !$this->loadText() ) {
342  //wfProfileOut( $fname );
343  return false;
344  } else if ( $this->mOldRev && !$this->mOldRev->userCan(Revision::DELETED_TEXT) ) {
345  return '';
346  } else if ( $this->mNewRev && !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) {
347  return '';
348  }
349 
350  $difftext = $this->generateDiffBody( $this->mOldtext, $this->mNewtext );
351 
352  // Save to cache for 7 days
353  if ( $key !== false && $difftext !== false ) {
354  wfIncrStats( 'diff_cache_miss' );
355  $wgMemc->set( $key, $difftext, 7*86400 );
356  } else {
357  wfIncrStats( 'diff_uncacheable' );
358  }
359  // Replace line numbers with the text in the user's language
360  if ( $difftext !== false ) {
361  $difftext = $this->localiseLineNumbers( $difftext );
362  }
363  //wfProfileOut( $fname );
364  return $difftext;
365  }
generateDiffBody( $otext, $ntext)
Generate a diff, no caching $otext and $ntext must be already segmented.
localiseLineNumbers( $text)
Replace line numbers with the text in the user&#39;s language.
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 459 of file class.WordLevelDiff.php.

References $n, and array.

Referenced by getDiff().

459  {
460  if ( !is_object($this->mOldRev) || !is_object($this->mNewRev) )
461  return '';
462 
463  if( !$this->mOldPage->equals( $this->mNewPage ) ) {
464  // Comparing two different pages? Count would be meaningless.
465  return '';
466  }
467 
468  $oldid = $this->mOldRev->getId();
469  $newid = $this->mNewRev->getId();
470  if ( $oldid > $newid ) {
471  $tmp = $oldid; $oldid = $newid; $newid = $tmp;
472  }
473 
474  $n = $this->mTitle->countRevisionsBetween( $oldid, $newid );
475  if ( !$n )
476  return '';
477 
478  return wfMsgExt( 'diff-multi', array( 'parseinline' ), $n );
479  }
$n
Definition: RandomTest.php:80
Create styles array
The data for the language used.
+ 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 636 of file class.WordLevelDiff.php.

References loadRevisionData().

Referenced by renderNewRevision(), and showFirstRevision().

636  {
637  if ( $this->mTextLoaded >= 1 ) {
638  return true;
639  } else {
640  $this->mTextLoaded = 1;
641  }
642  if ( !$this->loadRevisionData() ) {
643  return false;
644  }
645  $this->mNewtext = $this->mNewRev->getText();
646  return true;
647  }
loadRevisionData()
Load revision metadata for the specified articles.
+ Here is the call graph for this function:
+ 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 527 of file class.WordLevelDiff.php.

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

Referenced by loadNewText(), loadText(), and showDiffPage().

527  {
528  global $wgLang;
529  if ( $this->mRevisionsLoaded ) {
530  return true;
531  } else {
532  // Whether it succeeds or fails, we don't want to try again
533  $this->mRevisionsLoaded = true;
534  }
535 
536  // Load the new revision object
537  if( $this->mNewid ) {
538  $this->mNewRev = Revision::newFromId( $this->mNewid );
539  } else {
540  $this->mNewRev = Revision::newFromTitle( $this->mTitle );
541  }
542 
543  if( is_null( $this->mNewRev ) ) {
544  return false;
545  }
546 
547  // Set assorted variables
548  $timestamp = $wgLang->timeanddate( $this->mNewRev->getTimestamp(), true );
549  $this->mNewPage = $this->mNewRev->getTitle();
550  if( $this->mNewRev->isCurrent() ) {
551  $newLink = $this->mNewPage->escapeLocalUrl();
552  $this->mPagetitle = htmlspecialchars( wfMsg( 'currentrev' ) );
553  $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit' );
554 
555  $this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a> ($timestamp)"
556  . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)";
557 
558  } else {
559  $newLink = $this->mNewPage->escapeLocalUrl( 'oldid=' . $this->mNewid );
560  $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mNewid );
561  $this->mPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $timestamp ) );
562 
563  $this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a>"
564  . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)";
565  }
566 
567  // Load the old revision object
568  $this->mOldRev = false;
569  if( $this->mOldid ) {
570  $this->mOldRev = Revision::newFromId( $this->mOldid );
571  } elseif ( $this->mOldid === 0 ) {
572  $rev = $this->mNewRev->getPrevious();
573  if( $rev ) {
574  $this->mOldid = $rev->getId();
575  $this->mOldRev = $rev;
576  } else {
577  // No previous revision; mark to show as first-version only.
578  $this->mOldid = false;
579  $this->mOldRev = false;
580  }
581  }/* elseif ( $this->mOldid === false ) leave mOldRev false; */
582 
583  if( is_null( $this->mOldRev ) ) {
584  return false;
585  }
586 
587  if ( $this->mOldRev ) {
588  $this->mOldPage = $this->mOldRev->getTitle();
589 
590  $t = $wgLang->timeanddate( $this->mOldRev->getTimestamp(), true );
591  $oldLink = $this->mOldPage->escapeLocalUrl( 'oldid=' . $this->mOldid );
592  $oldEdit = $this->mOldPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mOldid );
593  $this->mOldtitle = "<a href='$oldLink'>" . htmlspecialchars( wfMsg( 'revisionasof', $t ) )
594  . "</a> (<a href='$oldEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)";
595  //now that we considered old rev, we can make undo link (bug 8133, multi-edit undo)
596  $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undoafter=' . $this->mOldid . '&undo=' . $this->mNewid);
597  $this->mNewtitle .= " (<a href='$newUndo'>" . htmlspecialchars( wfMsg( 'editundo' ) ) . "</a>)";
598  }
599 
600  return true;
601  }
wfMsg($x)
Definition: RandomTest.php:60
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 606 of file class.WordLevelDiff.php.

References loadRevisionData().

Referenced by getDiffBody().

606  {
607  if ( $this->mTextLoaded == 2 ) {
608  return true;
609  } else {
610  // Whether it succeeds or fails, we don't want to try again
611  $this->mTextLoaded = 2;
612  }
613 
614  if ( !$this->loadRevisionData() ) {
615  return false;
616  }
617  if ( $this->mOldRev ) {
618  // FIXME: permission tests
619  $this->mOldtext = $this->mOldRev->revText();
620  if ( $this->mOldtext === false ) {
621  return false;
622  }
623  }
624  if ( $this->mNewRev ) {
625  $this->mNewtext = $this->mNewRev->revText();
626  if ( $this->mNewtext === false ) {
627  return false;
628  }
629  }
630  return true;
631  }
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 445 of file class.WordLevelDiff.php.

References $text, and array.

Referenced by getDiffBody().

445  {
446  return preg_replace_callback( '/<!--LINE (\d+)-->/',
447  array( &$this, 'localiseLineNumbersCb' ), $text );
448  }
Create styles array
The data for the language used.
$text
+ Here is the caller graph for this function:

◆ localiseLineNumbersCb()

DifferenceEngine::localiseLineNumbersCb (   $matches)

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

References array.

450  {
451  global $wgLang;
452  return wfMsgExt( 'lineno', array('parseinline'), $wgLang->formatNum( $matches[1] ) );
453  }
Create styles array
The data for the language used.

◆ renderNewRevision()

DifferenceEngine::renderNewRevision ( )

Show the new revision of the page.

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

References loadNewText(), and wfMsg().

Referenced by showDiffPage().

203  {
204  global $wgOut;
205  $fname = 'DifferenceEngine::renderNewRevision';
206  //wfProfileIn( $fname );
207 
208  $wgOut->addHTML( "<hr /><h2>{$this->mPagetitle}</h2>\n" );
209  #add deleted rev tag if needed
210  if ( !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) {
211  $wgOut->addWikiText( wfMsg( 'rev-deleted-text-permission' ) );
212  }
213 
214  if( !$this->mNewRev->isCurrent() ) {
215  $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection( false );
216  }
217 
218  $this->loadNewText();
219  if( is_object( $this->mNewRev ) ) {
220  $wgOut->setRevisionId( $this->mNewRev->getId() );
221  }
222 
223  $wgOut->addWikiTextTidy( $this->mNewtext );
224 
225  if( !$this->mNewRev->isCurrent() ) {
226  $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting );
227  }
228 
229  //wfProfileOut( $fname );
230  }
wfMsg($x)
Definition: RandomTest.php:60
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 511 of file class.WordLevelDiff.php.

511  {
512  $this->mOldtext = $oldText;
513  $this->mNewtext = $newText;
514  $this->mTextLoaded = 2;
515  }

◆ 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 288 of file class.WordLevelDiff.php.

References getDiff(), and wfMsg().

Referenced by showDiffPage().

288  {
289  global $wgOut;
290  $diff = $this->getDiff( $otitle, $ntitle );
291  if ( $diff === false ) {
292  $wgOut->addWikitext( wfMsg( 'missingarticle', "<nowiki>(fixme, bug)</nowiki>" ) );
293  return false;
294  } else {
295  $wgOut->addHTML( $diff );
296  return true;
297  }
298  }
getDiff( $otitle, $ntitle)
Get diff table, including header Note that the interface has changed, it&#39;s no longer static...
wfMsg($x)
Definition: RandomTest.php:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showDiffPage()

DifferenceEngine::showDiffPage (   $diffOnly = false)

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

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

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

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

Referenced by showDiffPage().

236  {
237  global $wgOut, $wgUser;
238 
239  $fname = 'DifferenceEngine::showFirstRevision';
240  //wfProfileIn( $fname );
241 
242  # Get article text from the DB
243  #
244  if ( ! $this->loadNewText() ) {
245  $t = $this->mTitle->getPrefixedText() . " (Diff: {$this->mOldid}, " .
246  "{$this->mNewid})";
247  $mtext = wfMsg( 'missingarticle', "<nowiki>$t</nowiki>" );
248  $wgOut->setPagetitle( wfMsg( 'errorpagetitle' ) );
249  $wgOut->addWikitext( $mtext );
250  //wfProfileOut( $fname );
251  return;
252  }
253  if ( $this->mNewRev->isCurrent() ) {
254  $wgOut->setArticleFlag( true );
255  }
256 
257  # Check if user is allowed to look at this page. If not, bail out.
258  #
259  if ( !( $this->mTitle->userCanRead() ) ) {
260  $wgOut->loginToUse();
261  $wgOut->output();
262  //wfProfileOut( $fname );
263  exit;
264  }
265 
266  # Prepare the header box
267  #
268  $sk = $wgUser->getSkin();
269 
270  $nextlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'nextdiff' ), 'diff=next&oldid='.$this->mNewid, '', '', 'id="differences-nextlink"' );
271  $header = "<div class=\"firstrevisionheader\" style=\"text-align: center\"><strong>{$this->mOldtitle}</strong><br />" .
272  $sk->revUserTools( $this->mNewRev ) . "<br />" .
273  $sk->revComment( $this->mNewRev ) . "<br />" .
274  $nextlink . "</div>\n";
275 
276  $wgOut->addHTML( $header );
277 
278  $wgOut->setSubtitle( wfMsg( 'difference' ) );
279  $wgOut->setRobotpolicy( 'noindex,nofollow' );
280 
281  //wfProfileOut( $fname );
282  }
wfMsg($x)
Definition: RandomTest.php:60
$header
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 21 of file class.WordLevelDiff.php.

◆ $mNewPage

DifferenceEngine::$mNewPage

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

◆ $mNewRev

DifferenceEngine::$mNewRev

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

◆ $mNewtext

DifferenceEngine::$mNewtext

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

◆ $mNewtitle

DifferenceEngine::$mNewtitle

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

◆ $mOldid

DifferenceEngine::$mOldid
private

#+

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

◆ $mOldPage

DifferenceEngine::$mOldPage

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

◆ $mOldRev

DifferenceEngine::$mOldRev

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

◆ $mOldtext

DifferenceEngine::$mOldtext

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

◆ $mOldtitle

DifferenceEngine::$mOldtitle

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

◆ $mPagetitle

DifferenceEngine::$mPagetitle

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

◆ $mRcidMarkPatrolled

DifferenceEngine::$mRcidMarkPatrolled

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

◆ $mRevisionsLoaded

DifferenceEngine::$mRevisionsLoaded = false

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

◆ $mTextLoaded

DifferenceEngine::$mTextLoaded = 0

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

◆ $mTitle

DifferenceEngine::$mTitle

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


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