MediaWiki REL1_36
|
Class for viewing MediaWiki article and history. More...
Public Member Functions | |
__construct (Title $title, $oldId=null) | |
__get ( $fname) | |
__set ( $fname, $fvalue) | |
addHelpLink ( $to, $overrideBaseUrl=false) | |
Adds help link with an icon via page indicators. | |
adjustDisplayTitle (ParserOutput $pOutput) | |
Adjust title for pages with displaytitle, -{T|}- or language conversion. | |
clear () | |
confirmDelete ( $reason) | |
Output deletion confirmation dialog. | |
delete () | |
UI entry point for page deletion. | |
doDelete ( $reason, $suppress=false, $immediate=false) | |
Perform a deletion and output success or failure messages. | |
fetchRevisionRecord () | |
Fetches the revision to work on. | |
getActionOverrides () | |
Call to WikiPage function for backwards compatibility. | |
getContext () | |
Gets the context this Article is executed in. | |
getOldID () | |
getOldIDFromRequest () | |
Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect. | |
getPage () | |
Get the WikiPage object of this instance. | |
getParserOptions () | |
Get parser options suitable for rendering the primary article wikitext. | |
getParserOutput ( $oldid=null, User $user=null) | |
#- | |
getRedirectedFrom () | |
Get the page this view was redirected from. | |
getRevIdFetched () | |
Use this to fetch the rev ID used on page views. | |
getRevisionFetched () | |
Get the fetched Revision object depending on request parameters or null on failure. | |
getRobotPolicy ( $action, ParserOutput $pOutput=null) | |
Get the robot policy to be used for the current view. | |
getTimestamp () | |
getTitle () | |
Get the title object of the article. | |
isCurrent () | |
Returns true if the currently-referenced revision is the current edit to this page (and it exists). | |
isFileCacheable ( $mode=HTMLFileCache::MODE_NORMAL) | |
Check if the page can be cached. | |
protect () | |
action=protect handler | |
render () | |
Handle action=render. | |
setContext ( $context) | |
Sets the context this Article is executed in. | |
setOldSubtitle ( $oldid=0) | |
Generate the navigation links when browsing through an article revisions It shows the information as: Revision as of \<date\>; view current revision \<- Previous version | Next Version -\> | |
setRedirectedFrom (Title $from) | |
Tell the page view functions that this view was redirected from another page on the wiki. | |
showDeletedRevisionHeader () | |
If the revision requested for view is deleted, check permissions. | |
showMissingArticle () | |
Show the error text for a missing article. | |
showNamespaceHeader () | |
Show a header specific to the namespace currently being viewed, like [[MediaWiki:Talkpagetext]]. | |
showPatrolFooter () | |
If patrol is possible, output a patrol UI box. | |
showRedirectedFromHeader () | |
If this request is a redirect view, send "redirected from" subtitle to the output. | |
showViewFooter () | |
Show the footer section of an ordinary page view. | |
unprotect () | |
action=unprotect handler (alias) | |
view () | |
This is the default action of the index.php entry point: just view the page of the given title. | |
viewRedirect ( $target, $appendSubtitle=true, $forceKnown=false) | |
Return the HTML for the top of a redirect page. | |
Static Public Member Functions | |
static | formatRobotPolicy ( $policy) |
Converts a String robot policy into an associative array, to allow merging of several policies using array_merge(). | |
static | getRedirectHeaderHtml (Language $lang, $target, $forceKnown=false) |
Return the HTML for the top of a redirect page. | |
static | newFromID ( $id) |
Constructor from a page id. | |
static | newFromTitle ( $title, IContextSource $context) |
Create an Article object of the appropriate class for the given page. | |
static | newFromWikiPage (WikiPage $page, IContextSource $context) |
Create an Article object of the appropriate class for the given page. | |
static | purgePatrolFooterCache ( $articleID) |
Purge the cache used to check if it is worth showing the patrol footer For example, it is done during re-uploads when file patrol is used. | |
Public Attributes | |
int null | $mOldId |
The oldid of the article that was requested to be shown, 0 for the current revision. | |
ParserOutput null false | $mParserOutput = null |
The ParserOutput generated for viewing the page, initialized by view(). | |
Title null | $mRedirectedFrom = null |
Title from which we were redirected here, if any. | |
string bool | $mRedirectUrl = false |
URL to redirect to or false if none. | |
Protected Member Functions | |
getContentObject () | |
Returns a Content object representing the pages effective display content, not necessarily the revision's content! | |
newPage (Title $title) | |
showDiffPage () | |
Show a diff page according to current request variables. | |
tryFileCache () | |
checkLastModified returns true if it has taken care of all output to the client that is necessary for this request. | |
Protected Attributes | |
LinkRenderer | $linkRenderer |
IContextSource null | $mContext |
The context this Article is executed in. | |
WikiPage | $mPage |
The WikiPage object of this instance. | |
bool | $viewIsRenderAction = false |
Whether render() was called. | |
Private Member Functions | |
doOutputFromParserCache (ParserOutput $pOutput, OutputPage $outputPage, array $textOptions) | |
doOutputFromRenderStatus (?RevisionRecord $rev, Status $renderStatus, OutputPage $outputPage, array $textOptions) | |
doOutputMetaData (?ParserOutput $pOutput, OutputPage $outputPage) | |
generateContentOutput (User $user, ParserOptions $parserOptions, int $oldid, OutputPage $outputPage, array $textOptions) | |
Determines the desired ParserOutput and passes it to $outputPage. | |
getRevisionRedirectTarget (RevisionRecord $revision) | |
getSubstituteContent () | |
Returns Content object to use when the page does not exist. | |
showViewError (string $errortext) | |
Show error text for errors generated in Article::view(). | |
Private Attributes | |
Status null | $fetchResult = null |
represents the outcome of fetchRevisionRecord(). | |
RevisionRecord null | $mRevisionRecord = null |
Revision to be shown. | |
RevisionStore | $revisionStore |
Class for viewing MediaWiki article and history.
This maintains WikiPage functions for backwards compatibility.
Note: edit user interface and cache support functions have been moved to separate EditPage and HTMLFileCache classes.
Definition at line 45 of file Article.php.
Article::__construct | ( | Title | $title, |
$oldId = null |
|||
) |
Article::__get | ( | $fname | ) |
Use PHP's magic __get handler to handle accessing of raw WikiPage fields for backwards compatibility, as well as the deprecated $mRevision
string | $fname | Field name |
Definition at line 2349 of file Article.php.
References wfDeprecatedMsg().
Article::__set | ( | $fname, | |
$fvalue | |||
) |
Use PHP's magic __set handler to handle setting of raw WikiPage fields for backwards compatibility, as well as the deprecated $mRevision
string | $fname | Field name |
mixed | $fvalue | New value |
Definition at line 2373 of file Article.php.
References wfDeprecatedMsg().
Article::addHelpLink | ( | $to, | |
$overrideBaseUrl = false |
|||
) |
Adds help link with an icon via page indicators.
Link target can be overridden by a local message containing a wikilink: the message key is: 'namespace-' + namespace number + '-helppage'.
string | $to | Target MediaWiki.org page title or encoded URL. |
bool | $overrideBaseUrl | Whether $url is a full URL, to avoid MW.o. |
Definition at line 1804 of file Article.php.
References $title, getContext(), and getTitle().
Referenced by CategoryPage\closeShowCategory().
Article::adjustDisplayTitle | ( | ParserOutput | $pOutput | ) |
Adjust title for pages with displaytitle, -{T|}- or language conversion.
ParserOutput | $pOutput |
Definition at line 869 of file Article.php.
References getContext(), and ParserOutput\getTitleText().
Article::clear | ( | ) |
Definition at line 225 of file Article.php.
Article::confirmDelete | ( | $reason | ) |
Output deletion confirmation dialog.
string | $reason | Prefilled reason |
Definition at line 1979 of file Article.php.
References $title, OutputPage\addBacklinkSubtitle(), OutputPage\addHTML(), OutputPage\addModules(), OutputPage\addModuleStyles(), OutputPage\addWikiMsg(), OutputPage\enableOOUI(), getAuthority(), getContext(), User\getEditToken(), ContextSource\getOutput(), getTitle(), User\getUser(), User\isRegistered(), User\isWatched(), ContextSource\msg(), Message\numParam(), OutputPage\setPageTitle(), OutputPage\setRobotPolicy(), wfDebug(), and wfMessage().
Article::delete | ( | ) |
UI entry point for page deletion.
Reimplemented in ImagePage.
Definition at line 1847 of file Article.php.
References $dbr, $title, $wgDeleteRevisionsLimit, OutputPage\addHTML(), DB_REPLICA, WatchAction\doWatchOrUnwatch(), getContext(), ContextSource\getOutput(), getTitle(), User\getUser(), User\matchEditToken(), OutputPage\setPageTitle(), wfDebug(), wfEscapeWikiText(), wfGetDB(), wfMessage(), wfReadOnly(), and OutputPage\wrapWikiMsg().
Article::doDelete | ( | $reason, | |
$suppress = false , |
|||
$immediate = false |
|||
) |
Perform a deletion and output success or failure messages.
string | $reason | |
bool | $suppress | |
bool | $immediate | false allows deleting over time via the job queue |
FatalError | |
MWException |
Definition at line 2178 of file Article.php.
References OutputPage\addHTML(), OutputPage\addWikiMsg(), getContext(), ContextSource\getOutput(), getTitle(), User\getUser(), OutputPage\returnToMain(), OutputPage\setPageTitle(), OutputPage\setRobotPolicy(), wfEscapeWikiText(), wfMessage(), and OutputPage\wrapWikiTextAsInterface().
|
private |
ParserOutput | $pOutput | |
OutputPage | $outputPage | |
array | $textOptions |
Definition at line 791 of file Article.php.
References OutputPage\addParserOutput(), CacheTime\getCacheRevisionId(), ParserOutput\getTimestamp(), OutputPage\setRevisionId(), and OutputPage\setRevisionTimestamp().
|
private |
RevisionRecord | null | $rev | |
Status | $renderStatus | |
OutputPage | $outputPage | |
array | $textOptions |
Definition at line 814 of file Article.php.
References $wgCdnMaxageStale, OutputPage\addHTML(), OutputPage\addParserOutput(), OutputPage\addSubtitle(), getContext(), StatusValue\getValue(), Status\getWikiText(), StatusValue\hasMessage(), StatusValue\isOK(), OutputPage\setCdnMaxage(), and OutputPage\setLastModified().
|
private |
?ParserOutput | $pOutput | |
OutputPage | $outputPage |
Definition at line 772 of file Article.php.
References OutputPage\setFollowPolicy(), and OutputPage\setIndexPolicy().
Referenced by generateContentOutput().
Article::fetchRevisionRecord | ( | ) |
Fetches the revision to work on.
The revision is loaded from the database. Refer to $this->fetchResult for the revision or any errors encountered while loading it.
Public since 1.35
Definition at line 383 of file Article.php.
References getOldID(), getTitle(), and wfDebug().
Referenced by getContentObject(), and getRevisionFetched().
|
static |
Converts a String robot policy into an associative array, to allow merging of several policies using array_merge().
array | string | $policy | Returns empty array on null/false/'', transparent to already-converted arrays, converts string. |
Definition at line 1027 of file Article.php.
|
private |
Determines the desired ParserOutput and passes it to $outputPage.
User | $user | |
ParserOptions | $parserOptions | |
int | $oldid | |
OutputPage | $outputPage | |
array | $textOptions |
Definition at line 610 of file Article.php.
References doOutputMetaData().
Referenced by view().
Article::getActionOverrides | ( | ) |
Call to WikiPage function for backwards compatibility.
Definition at line 2399 of file Article.php.
Referenced by Action\factory().
|
protected |
Returns a Content object representing the pages effective display content, not necessarily the revision's content!
Note that getContent does not follow redirects anymore. If you need to fetch redirectable content easily, try the shortcut in WikiPage::getRedirectTarget()
This function has side effects! Do not use this function if you only want the real revision text if any.
Definition at line 253 of file Article.php.
References $content, fetchRevisionRecord(), getContext(), getSubstituteContent(), and wfDeprecated().
Article::getContext | ( | ) |
Gets the context this Article is executed in.
Definition at line 2330 of file Article.php.
References wfDebug().
Referenced by ImageHistoryList\__construct(), EditPage\__construct(), and ProtectionForm\__construct().
Article::getOldID | ( | ) |
Definition at line 301 of file Article.php.
References getOldIDFromRequest().
Referenced by fetchRevisionRecord(), isCurrent(), view(), and ImagePage\view().
Article::getOldIDFromRequest | ( | ) |
Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect.
Definition at line 314 of file Article.php.
References getContext(), and getTitle().
Referenced by getOldID().
Article::getPage | ( | ) |
Get the WikiPage object of this instance.
Definition at line 221 of file Article.php.
Referenced by ImageHistoryList\__construct(), EditPage\__construct(), ImagePage\getDuplicates(), ImagePage\getFile(), ImagePage\getForeignCategories(), ImagePage\imageDupes(), ImagePage\isLocal(), ImagePage\loadFile(), ImagePage\openShowImage(), ImagePage\printSharedImageText(), ImagePage\setFile(), CategoryPage\view(), and ImagePage\view().
Article::getParserOptions | ( | ) |
Get parser options suitable for rendering the primary article wikitext.
Definition at line 2310 of file Article.php.
References getContext().
Referenced by view().
Article::getParserOutput | ( | $oldid = null , |
|
User | $user = null |
||
) |
#-
Lightweight method to get the parser output for a page, checking the parser cache and so on. Doesn't consider most of the stuff that Article::view() is forced to consider, so it's not appropriate to use there.
Definition at line 2296 of file Article.php.
Article::getRedirectedFrom | ( | ) |
Get the page this view was redirected from.
Definition at line 193 of file Article.php.
|
static |
Return the HTML for the top of a redirect page.
Chances are you should just be using the ParserOutput from WikitextContent::getParserOutput instead of calling this for redirects.
Language | $lang | |
Title | Title[] | $target | Destination(s) to redirect |
bool | $forceKnown | Should the image be shown as a bluelink regardless of existence? |
Definition at line 1757 of file Article.php.
References $lang, $title, MediaWiki\Linker\LinkRenderer\makeKnownLink(), MediaWiki\Linker\LinkRenderer\makeLink(), and wfMessage().
Article::getRevIdFetched | ( | ) |
Use this to fetch the rev ID used on page views.
Before fetchRevisionRecord was called, this returns the page's latest revision, regardless of what getOldID() returns.
Definition at line 470 of file Article.php.
Referenced by view().
Article::getRevisionFetched | ( | ) |
Get the fetched Revision object depending on request parameters or null on failure.
Refer to $this->fetchResult for the revision actually loaded from the database.
Definition at line 455 of file Article.php.
References fetchRevisionRecord(), and wfDeprecated().
|
private |
RevisionRecord | $revision |
Definition at line 857 of file Article.php.
References $content, and MediaWiki\Revision\RevisionRecord\getContent().
Article::getRobotPolicy | ( | $action, | |
ParserOutput | $pOutput = null |
||
) |
Get the robot policy to be used for the current view.
string | $action | The action= GET parameter |
ParserOutput | null | $pOutput |
Definition at line 947 of file Article.php.
References $wgArticleRobotPolicies, $wgDefaultRobotPolicy, $wgNamespaceRobotPolicies, getContext(), getTitle(), NS_USER, and NS_USER_TALK.
|
private |
Returns Content object to use when the page does not exist.
Definition at line 276 of file Article.php.
References $content, getContext(), getTitle(), and NS_MEDIAWIKI.
Referenced by getContentObject().
Article::getTimestamp | ( | ) |
Definition at line 2408 of file Article.php.
References wfDeprecated().
Article::getTitle | ( | ) |
Get the title object of the article.
Definition at line 211 of file Article.php.
Referenced by ImageHistoryList\__construct(), EditPage\__construct(), and ProtectionForm\__construct().
Article::isCurrent | ( | ) |
Returns true if the currently-referenced revision is the current edit to this page (and it exists).
Definition at line 435 of file Article.php.
References getOldID().
Referenced by view().
Article::isFileCacheable | ( | $mode = HTMLFileCache::MODE_NORMAL | ) |
Check if the page can be cached.
int | $mode | One of the HTMLFileCache::MODE_* constants (since 1.28) |
Definition at line 2268 of file Article.php.
References getContext(), getTitle(), and HTMLFileCache\useFileCache().
|
static |
Constructor from a page id.
int | $id | Article ID to load |
Definition at line 138 of file Article.php.
References $t.
|
static |
Create an Article object of the appropriate class for the given page.
Title | $title | |
IContextSource | $context |
Definition at line 150 of file Article.php.
References $title, NS_CATEGORY, NS_FILE, and NS_MEDIA.
|
static |
Create an Article object of the appropriate class for the given page.
WikiPage | $page | |
IContextSource | $context |
Definition at line 182 of file Article.php.
References WikiPage\getTitle().
|
protected |
Title | $title |
Reimplemented in CategoryPage, and ImagePage.
Definition at line 129 of file Article.php.
References $title.
Referenced by __construct().
Article::protect | ( | ) |
action=protect handler
Definition at line 1832 of file Article.php.
|
static |
Purge the cache used to check if it is worth showing the patrol footer For example, it is done during re-uploads when file patrol is used.
int | $articleID | ID of the article to purge |
Definition at line 1335 of file Article.php.
References $cache.
Article::render | ( | ) |
Article::setContext | ( | $context | ) |
Sets the context this Article is executed in.
IContextSource | $context |
Definition at line 2320 of file Article.php.
Article::setOldSubtitle | ( | $oldid = 0 | ) |
Generate the navigation links when browsing through an article revisions It shows the information as: Revision as of \<date\>; view current revision \<- Previous version | Next Version -\>
int | $oldid | Revision ID of this article revision |
Definition at line 1579 of file Article.php.
References OutputPage\addModuleStyles(), OutputPage\addSubtitle(), getContext(), ContextSource\getOutput(), Linker\getRevDeleteLink(), getTitle(), User\getUser(), Linker\revComment(), and Linker\revUserTools().
Article::setRedirectedFrom | ( | Title | $from | ) |
Tell the page view functions that this view was redirected from another page on the wiki.
Title | $from |
Definition at line 202 of file Article.php.
Article::showDeletedRevisionHeader | ( | ) |
If the revision requested for view is deleted, check permissions.
Send either an error message or a warning header to the output.
Definition at line 1518 of file Article.php.
References getContext(), ContextSource\getOutput(), getTitle(), User\getUser(), and ContextSource\msg().
|
protected |
Show a diff page according to current request variables.
For use within Article::view() only, other callers should use the DifferenceEngine class.
Definition at line 884 of file Article.php.
References getContext(), User\getOption(), User\getUser(), and wfMessage().
Referenced by view().
Article::showMissingArticle | ( | ) |
Show the error text for a missing article.
For articles in the MediaWiki namespace, show the default message text. To be called from Article::view().
Definition at line 1344 of file Article.php.
References $dbr, $lang, $title, $wgSend404Code, OutputPage\addWikiTextAsContent(), OutputPage\addWikiTextAsInterface(), DB_REPLICA, getAuthority(), getContext(), User\getName(), ContextSource\getOutput(), OutputPage\getTarget(), getTitle(), User\isBlockedFrom(), User\isHidden(), User\isIP(), User\isRegistered(), User\newFromName(), NS_MEDIAWIKI, NS_USER, NS_USER_TALK, OutputPage\setFollowPolicy(), OutputPage\setIndexPolicy(), wfEscapeWikiText(), wfGetDB(), wfMessage(), and OutputPage\wrapWikiMsg().
Article::showNamespaceHeader | ( | ) |
Show a header specific to the namespace currently being viewed, like [[MediaWiki:Talkpagetext]].
For Article::view().
Definition at line 1130 of file Article.php.
References getContext(), getTitle(), and wfMessage().
Referenced by view().
Article::showPatrolFooter | ( | ) |
If patrol is possible, output a patrol UI box.
This is called from the footer section of ordinary page views. If patrol is not possible or not desired, does nothing.
Side effect: When the patrol link is build, this method will call OutputPage::preventClickjacking() and load a JS module.
Definition at line 1166 of file Article.php.
References $cache, $dbr, $title, $wgUseFilePatrol, $wgUseNPPatrol, $wgUseRCPatrol, OutputPage\addHTML(), OutputPage\addModules(), DB_REPLICA, getAuthority(), getContext(), ContextSource\getOutput(), getTitle(), User\getUser(), NS_FILE, OutputPage\preventClickjacking(), RC_LOG, wfGetDB(), and wfMessage().
Article::showRedirectedFromHeader | ( | ) |
If this request is a redirect view, send "redirected from" subtitle to the output.
Returns true if the header was needed, false if this is not a redirect view. Handles both local and remote redirects.
Definition at line 1056 of file Article.php.
References $wgRedirectSources, OutputPage\addJsConfigVars(), OutputPage\addModules(), OutputPage\addSubtitle(), getContext(), ContextSource\getOutput(), getTitle(), Linker\makeExternalLink(), OutputPage\setCanonicalUrl(), and OutputPage\setRedirectedFrom().
Referenced by view().
|
private |
Show error text for errors generated in Article::view().
string | $errortext | localized wikitext error message |
Definition at line 1503 of file Article.php.
References OutputPage\clearHTML(), OutputPage\enableClientCache(), getContext(), ContextSource\getOutput(), OutputPage\setPageTitle(), OutputPage\setRobotPolicy(), and OutputPage\wrapWikiTextAsInterface().
Article::showViewFooter | ( | ) |
Show the footer section of an ordinary page view.
Definition at line 1142 of file Article.php.
References getContext(), getTitle(), and NS_USER_TALK.
Referenced by view().
|
protected |
checkLastModified returns true if it has taken care of all output to the client that is necessary for this request.
(that is, it has sent a cached version of the page)
Definition at line 2237 of file Article.php.
References $cache, getContext(), getTitle(), and wfDebug().
Referenced by view().
Article::unprotect | ( | ) |
action=unprotect handler (alias)
Definition at line 1840 of file Article.php.
Article::view | ( | ) |
This is the default action of the index.php entry point: just view the page of the given title.
Reimplemented in CategoryPage, and ImagePage.
Definition at line 482 of file Article.php.
References $wgUseFileCache, generateContentOutput(), getAuthority(), getContext(), getOldID(), getParserOptions(), getRevIdFetched(), getTitle(), isCurrent(), EditPage\POST_EDIT_COOKIE_KEY_PREFIX, showDiffPage(), showNamespaceHeader(), showRedirectedFromHeader(), showViewFooter(), tryFileCache(), wfDebug(), and wfMessage().
Article::viewRedirect | ( | $target, | |
$appendSubtitle = true , |
|||
$forceKnown = false |
|||
) |
Return the HTML for the top of a redirect page.
Chances are you should just be using the ParserOutput from WikitextContent::getParserOutput instead of calling this for redirects.
Title | array | $target | Destination(s) to redirect |
bool | $appendSubtitle | [optional] |
bool | $forceKnown | Should the image be shown as a bluelink regardless of existence? |
Definition at line 1735 of file Article.php.
References $lang, getContext(), getTitle(), and wfMessage().
|
private |
represents the outcome of fetchRevisionRecord().
$fetchResult->value is the RevisionRecord object, if the operation was successful.
Definition at line 75 of file Article.php.
|
protected |
Definition at line 94 of file Article.php.
Referenced by ImagePage\imageDupes(), ImagePage\imageLinks(), and ImagePage\openShowImage().
|
protected |
The context this Article is executed in.
If null, RequestContext::getMain() is used.
getContext
Definition at line 54 of file Article.php.
int null Article::$mOldId |
The oldid of the article that was requested to be shown, 0 for the current revision.
Definition at line 63 of file Article.php.
|
protected |
The WikiPage object of this instance.
Definition at line 57 of file Article.php.
ParserOutput null false Article::$mParserOutput = null |
The ParserOutput generated for viewing the page, initialized by view().
If no ParserOutput could be generated, this is set to false.
Definition at line 82 of file Article.php.
Title null Article::$mRedirectedFrom = null |
Title from which we were redirected here, if any.
Definition at line 66 of file Article.php.
string bool Article::$mRedirectUrl = false |
URL to redirect to or false if none.
Definition at line 69 of file Article.php.
|
private |
Revision to be shown.
Initialized by getOldIDFromRequest() or fetchRevisionRecord(). While the output of Article::view is typically based on this revision, it may be replaced by extensions.
Replaced $mRevision, which was public and is provided in a deprecated manner via __get and __set
Definition at line 110 of file Article.php.
|
private |
Definition at line 99 of file Article.php.
|
protected |
Whether render() was called.
With the way subclasses work here, there doesn't seem to be any other way to stop calling OutputPage::enableSectionEditLinks() and still have it work as it did before.
Definition at line 89 of file Article.php.