MediaWiki  REL1_24
DifferenceEngine Class Reference
Inheritance diagram for DifferenceEngine:
Collaboration diagram for DifferenceEngine:

List of all members.

Public Member Functions

 __construct ($context=null, $old=0, $new=0, $rcid=0, $refreshCache=false, $unhide=false)
 #@-
 addHeader ($diff, $otitle, $ntitle, $multi= '', $notice= '')
 Add the header to a diff body.
 deletedIdMarker ($id)
 Build a wikitext link toward a deleted revision, if viewable.
 deletedLink ($id)
 Look up a special:Undelete link to the given deleted revision id, as a workaround for being unable to load deleted diffs in currently.
 generateContentDiffBody (Content $old, Content $new)
 Generate a diff, no caching.
 generateDiffBody ($otext, $ntext)
 Generate a diff, no caching.
 generateTextDiffBody ($otext, $ntext)
 Generate a diff, no caching.
 getDiff ($otitle, $ntitle, $notice= '')
 Get complete diff table, including header.
 getDiffBody ()
 Get the diff table body, without header.
 getDiffLang ()
 getMultiNotice ()
 If there are revisions between the ones being compared, return a note saying so.
 getNewid ()
 getOldid ()
 loadNewText ()
 Load the text of the new revision, not the old one.
 loadRevisionData ()
 Load revision metadata for the specified articles.
 loadText ()
 Load the text of the revisions, as well as revision data.
 localiseLineNumbers ($text)
 Replace line numbers with the text in the user's language.
 localiseLineNumbersCb ($matches)
 mapDiffPrevNext ($old, $new)
 Maps a revision pair definition as accepted by DifferenceEngine constructor to a pair of actual integers representing revision ids.
 renderNewRevision ()
 Show the new revision of the page.
 setContent (Content $oldContent, Content $newContent)
 Use specified text instead of loading from the database.
 setReducedLineNumbers ($value=true)
 setText ($oldText, $newText)
 Use specified text instead of loading from the database.
 setTextLanguage ($lang)
 Set the language in which the diff text is written (Defaults to page content language).
 showDiff ($otitle, $ntitle, $notice= '')
 Get the diff text, send it to the OutputPage object Returns false if the diff could not be generated, otherwise returns true.
 showDiffPage ($diffOnly=false)
 showDiffStyle ()
 Add style sheets and supporting JS for diff display.
 wasCacheHit ()

Static Public Member Functions

static intermediateEditsMsg ($numEdits, $numUsers, $limit)
 Get a notice about how many intermediate edits and users there are.

Public Attributes

 $enableDebugComment = false
 Set this to true to add debug info to the HTML output.
bool $mCacheHit = false
 Was the diff fetched from cache? *.
Content $mNewContent
 *
int $mNewid
 *
Title $mNewPage
 *
Revision $mNewRev
 *
Content $mOldContent
 *
int $mOldid
 *
Title $mOldPage
 *
Revision $mOldRev
 *
bool $mRevisionsLoaded = false
 Have the revisions been loaded *.
int $mTextLoaded = 0
 How many text blobs have been loaded, 0, 1 or 2? *.

Protected Member Functions

 debug ($generator="internal")
 Generate a debug comment indicating diff generating time, server node, and generator backend.
 getDiffBodyCacheKey ()
 Returns the cache key for diff body text or content.
 getParserOutput (WikiPage $page, Revision $rev)
 getRevisionHeader (Revision $rev, $complete= '')
 Get a header for a specified revision.
 markPatrolledLink ()
 Get a link to mark the change as patrolled, or '' if there's either no revision to patrol or the user is not allowed to to it.
 revisionDeleteLink ($rev)

Protected Attributes

Language $mDiffLang
 *
string $mMarkPatrolledLink = null
 Link to action=markpatrolled *.
bool $mReducedLineNumbers = false
 If true, line X is not displayed when X is 1, for example to increase readability and conserve space with many small diffs.
bool $unhide = false
 Show rev_deleted content if allowed *.

Private Member Functions

 loadRevisionIds ()
 Load revision IDs.
 showMissingRevision ()

Private Attributes

 $mNewTags
 $mOldTags
bool $mRevisionsIdsLoaded = false
 Have the revisions IDs been loaded *.

Detailed Description

Todo:
document

Definition at line 36 of file DifferenceEngine.php.


Constructor & Destructor Documentation

DifferenceEngine::__construct ( context = null,
old = 0,
new = 0,
rcid = 0,
refreshCache = false,
unhide = false 
)

#@-

Constructor

Parameters:
IContextSource$contextContext to use, anything else will be ignored
int$oldOld ID we want to show and diff with.
string | int$newEither revision ID or 'prev' or 'next'. Default: 0.
int$rcidDeprecated, no longer used!
bool$refreshCacheIf set, refreshes the diff cache
bool$unhideIf set, allow viewing deleted revs

Definition at line 92 of file DifferenceEngine.php.


Member Function Documentation

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

Add the header to a diff body.

Parameters:
string$diffDiff body
string$otitleOld revision header
string$ntitleNew revision header
string$multiNotice telling user that there are intermediate revisions between the ones being compared
string$noticeOther notices, e.g. that user is viewing deleted content
Returns:
string

Definition at line 1078 of file DifferenceEngine.php.

DifferenceEngine::debug ( generator = "internal") [protected]

Generate a debug comment indicating diff generating time, server node, and generator backend.

Parameters:
string$generator: What diff engine was used
Returns:
string

Definition at line 904 of file DifferenceEngine.php.

Build a wikitext link toward a deleted revision, if viewable.

Parameters:
int$idRevision ID
Returns:
string Wikitext fragment

Definition at line 186 of file DifferenceEngine.php.

Referenced by showDiffPage().

Look up a special:Undelete link to the given deleted revision id, as a workaround for being unable to load deleted diffs in currently.

Parameters:
int$idRevision ID
Returns:
mixed URL or false

Definition at line 159 of file DifferenceEngine.php.

Generate a diff, no caching.

This implementation uses generateTextDiffBody() to generate a diff based on the default serialization of the given Content objects. This will fail if $old or $new are not instances of TextContent.

Subclasses may override this to provide a different rendering for the diff, perhaps taking advantage of the content's native form. This is required for all content models that are not text based.

Since:
1.21
Parameters:
Content$oldOld content
Content$newNew content
Exceptions:
MWExceptionIf old or new content is not an instance of TextContent.
Returns:
bool|string

Definition at line 779 of file DifferenceEngine.php.

DifferenceEngine::generateDiffBody ( otext,
ntext 
)

Generate a diff, no caching.

Parameters:
string$otextOld text, must be already segmented
string$ntextNew text, must be already segmented
Returns:
bool|string
Deprecated:
since 1.21, use generateContentDiffBody() instead!

Definition at line 805 of file DifferenceEngine.php.

DifferenceEngine::generateTextDiffBody ( otext,
ntext 
)

Generate a diff, no caching.

Todo:
move this to TextDifferenceEngine, make DifferenceEngine abstract. At some point.
Parameters:
string$otextOld text, must be already segmented
string$ntextNew text, must be already segmented
Returns:
bool|string

Definition at line 821 of file DifferenceEngine.php.

References ContentHandler\deprecated().

DifferenceEngine::getDiff ( otitle,
ntitle,
notice = '' 
)

Get complete diff table, including header.

Parameters:
string | bool$otitleHeader for old text or false
string | bool$ntitleHeader for new text or false
string$noticeHTML between diff header and body
Returns:
mixed

Definition at line 644 of file DifferenceEngine.php.

Get the diff table body, without header.

Returns:
mixed (string/false)

Definition at line 666 of file DifferenceEngine.php.

Returns the cache key for diff body text or content.

Since:
1.23
Exceptions:
MWException
Returns:
string

Definition at line 751 of file DifferenceEngine.php.

References localiseLineNumbers().

Returns:
Language

Definition at line 117 of file DifferenceEngine.php.

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

Returns:
string

Definition at line 948 of file DifferenceEngine.php.

Returns:
bool|int

Definition at line 145 of file DifferenceEngine.php.

Returns:
int

Definition at line 136 of file DifferenceEngine.php.

DifferenceEngine::getParserOutput ( WikiPage page,
Revision rev 
) [protected]

Definition at line 592 of file DifferenceEngine.php.

DifferenceEngine::getRevisionHeader ( Revision rev,
complete = '' 
) [protected]

Get a header for a specified revision.

Parameters:
Revision$rev
string$complete'complete' to get the header wrapped depending the visibility of the revision and a link to edit the page.
Returns:
string HTML fragment

Definition at line 1013 of file DifferenceEngine.php.

static DifferenceEngine::intermediateEditsMsg ( numEdits,
numUsers,
limit 
) [static]

Get a notice about how many intermediate edits and users there are.

Parameters:
int$numEdits
int$numUsers
int$limit
Returns:
string

Definition at line 991 of file DifferenceEngine.php.

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

Returns:
bool

Definition at line 1340 of file DifferenceEngine.php.

References Revision\FOR_THIS_USER, and ContextSource\getUser().

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.

Returns:
bool

Definition at line 1226 of file DifferenceEngine.php.

Load revision IDs.

Definition at line 1191 of file DifferenceEngine.php.

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

Returns:
bool

Definition at line 1306 of file DifferenceEngine.php.

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

Parameters:
string$text
Returns:
mixed

Definition at line 927 of file DifferenceEngine.php.

Referenced by getDiffBodyCacheKey().

Definition at line 935 of file DifferenceEngine.php.

References array().

DifferenceEngine::mapDiffPrevNext ( old,
new 
)

Maps a revision pair definition as accepted by DifferenceEngine constructor to a pair of actual integers representing revision ids.

Parameters:
int$oldRevision id, e.g. from URL parameter 'oldid'
int | string$newRevision id or strings 'next' or 'prev', e.g. from URL parameter 'diff'
Returns:
int[] List of two revision ids, older first, later second. Zero signifies invalid argument passed. false signifies that there is no previous/next revision ($old is the oldest/newest one).

Definition at line 1171 of file DifferenceEngine.php.

Get a link to mark the change as patrolled, or '' if there's either no revision to patrol or the user is not allowed to to it.

Side effect: When the patrol link is build, this method will call OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.

Returns:
string

Definition at line 449 of file DifferenceEngine.php.

Show the new revision of the page.

Definition at line 530 of file DifferenceEngine.php.

DifferenceEngine::revisionDeleteLink ( rev) [protected]
Parameters:
Revision$rev
Returns:
string

Definition at line 518 of file DifferenceEngine.php.

DifferenceEngine::setContent ( Content oldContent,
Content newContent 
)

Use specified text instead of loading from the database.

Parameters:
Content$oldContent
Content$newContent
Since:
1.21

Definition at line 1142 of file DifferenceEngine.php.

Parameters:
bool$value

Definition at line 110 of file DifferenceEngine.php.

References ContextSource\$context, ContextSource\setContext(), and wfDebug().

DifferenceEngine::setText ( oldText,
newText 
)

Use specified text instead of loading from the database.

Deprecated:
since 1.21, use setContent() instead.

Definition at line 1127 of file DifferenceEngine.php.

Set the language in which the diff text is written (Defaults to page content language).

Parameters:
Language | string$lang
Since:
1.19

Definition at line 1156 of file DifferenceEngine.php.

DifferenceEngine::showDiff ( otitle,
ntitle,
notice = '' 
)

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

Parameters:
string | bool$otitleHeader for old text or false
string | bool$ntitleHeader for new text or false
string$noticeHTML between diff header and body
Returns:
bool

Definition at line 614 of file DifferenceEngine.php.

Definition at line 215 of file DifferenceEngine.php.

References deletedIdMarker().

Add style sheets and supporting JS for diff display.

Definition at line 631 of file DifferenceEngine.php.

Definition at line 195 of file DifferenceEngine.php.

Returns:
bool

Definition at line 129 of file DifferenceEngine.php.


Member Data Documentation

DifferenceEngine::$enableDebugComment = false

Set this to true to add debug info to the HTML output.

Warning: this may cause RSS readers to spuriously mark articles as "new" (bug 20601)

Definition at line 72 of file DifferenceEngine.php.

bool DifferenceEngine::$mCacheHit = false

Was the diff fetched from cache? *.

Definition at line 65 of file DifferenceEngine.php.

Language DifferenceEngine::$mDiffLang [protected]

*

Definition at line 49 of file DifferenceEngine.php.

string DifferenceEngine::$mMarkPatrolledLink = null [protected]

Link to action=markpatrolled *.

Definition at line 78 of file DifferenceEngine.php.

Content DifferenceEngine::$mNewContent

*

Definition at line 47 of file DifferenceEngine.php.

int DifferenceEngine::$mNewid

*

Definition at line 40 of file DifferenceEngine.php.

Title DifferenceEngine::$mNewPage

*

Definition at line 53 of file DifferenceEngine.php.

Revision DifferenceEngine::$mNewRev

*

Definition at line 57 of file DifferenceEngine.php.

DifferenceEngine::$mNewTags [private]

Definition at line 43 of file DifferenceEngine.php.

Content DifferenceEngine::$mOldContent

*

Definition at line 45 of file DifferenceEngine.php.

int DifferenceEngine::$mOldid

*

Definition at line 38 of file DifferenceEngine.php.

Title DifferenceEngine::$mOldPage

*

Definition at line 51 of file DifferenceEngine.php.

Revision DifferenceEngine::$mOldRev

*

Definition at line 55 of file DifferenceEngine.php.

DifferenceEngine::$mOldTags [private]

Definition at line 42 of file DifferenceEngine.php.

bool DifferenceEngine::$mReducedLineNumbers = false [protected]

If true, line X is not displayed when X is 1, for example to increase readability and conserve space with many small diffs.

Definition at line 76 of file DifferenceEngine.php.

bool DifferenceEngine::$mRevisionsIdsLoaded = false [private]

Have the revisions IDs been loaded *.

Definition at line 59 of file DifferenceEngine.php.

bool DifferenceEngine::$mRevisionsLoaded = false

Have the revisions been loaded *.

Definition at line 61 of file DifferenceEngine.php.

int DifferenceEngine::$mTextLoaded = 0

How many text blobs have been loaded, 0, 1 or 2? *.

Definition at line 63 of file DifferenceEngine.php.

bool DifferenceEngine::$unhide = false [protected]

Show rev_deleted content if allowed *.

Definition at line 80 of file DifferenceEngine.php.


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