|MediaWiki file: Article.php|
|Source code:||master • 1.34.0 • 1.33.2 • 1.31.6|
Article class handles the presentation of and interaction with MediaWiki pages and their history. It is closely related to the WikiPage class, which provides the model object for pages.
This file contains e.g. one version of function
view() for viewing a page, called from
ViewAction.php (another version is in
RawAction.php). This function fetches the wikitext
$mContent of the page from the database using functions
fetchContent(), and assigns this to
$text. After that it calls function
outputWikiText() to process
|Warning:||Article is a front end UI class not an api for interacting with page contents. Please use WikiPage for that.|
Creating a new Article object
Article, call one of the static factory methods or use the constructor:
Article::newFromId( $id )- where
$idis an article id (which is the same as a page_id).
Article::newFromTitle( Title $title, IContextSource $context )- creates an Article object of the appropriate class for the given title.
Article::newFromWikiPage( WikiPage $page, IContextSource $context )- creates an Article object of the appropriate class for the given page.
new Article( Title $title )- creates an Article object from the given title.
getContent()((removed in 1.29); superseded by WikiPage::getContent()) - get the text of this revision. This function has side effects. Do not use this function if you only want the real revision text if any.
getContext()(1.18+) - gets the context this Article is executed in.
getOldID()- gets the oldid of the article that is to be shown, or 0 for the current revision.
getPage()(1.19+) - gets the WikiPage object of this instance.
getParserOptions()- gets the parser options suitable for rendering the primary article wikitext.
getParserOutput([$oldid, User $user])- a lightweight method to get the parser output for a page, checking the parser cache and so on. It doesn't consider most of the stuff that
WikiPage::view()is forced to consider.
getRevIdFetched()- gets the rev ID used on page views.
getRevisionFetched()(1.19+) - get the fetched Revision object depending on request parameters or null on failure.
getRobotPolicy(string $action, ParserOutput $pOutput)- gets the robot policy to be used for the current view.
$actionis a string containing the action= GET parameter and
getTitle()- gets the Title associated with this page.
isCurrent()- returns true if the currently-referenced revision is the current edit to this page (and it exists).
isFileCacheable()- returns true if the page can be cached.
view()- this method handles the (default) action of viewing a page. Actions (like 'view', 'revert', 'delete', etc) are handled by Action subclasses. The
show()method of the ViewAction calls
Article::view()to do the actual work.
See https://doc.wikimedia.org/mediawiki-core/master/php/classArticle.html for a complete lists of methods.
Hooks called from this file are listed in the Category:MediaWiki hooks included in Article.php category.