Manual:WikiPage.php
Appearance
MediaWiki file: WikiPage.php | |
---|---|
Location: | includes/page/ |
Source code: | master • 1.43.0 • 1.42.4 • 1.39.11 |
Classes: | WikiPage • Page |
The WikiPage
class represents a MediaWiki page and its history.
It encapsulates access to page information stored in the database, and allows access to properties such as page text (in Wikitext format), flags, etc.
In theory, WikiPage is supposed to be the model object for pages, while the Article class handles the business and presentation functions.
If you have an Article object, you can get a WikiPage object using Article::getPage()
.
Creating a new WikiPage object
To instantiate WikiPage
, call one of the static factory methods:
WikiPage::factory( $title )
, where$title
is a Title instance.WikiPage::newFromId( $id )
, where$id
is a page id.WikiPage::newFromRow( $row )
, where$row
is a row fetched from the database containing all the fields listed in WikiPage::selectFields().
Methods
getContent( $audience )
: Get the content of the latest revision, where $audience is one of:Revision::FOR_PUBLIC
- to be displayed to all usersRevision::FOR_THIS_USER
- to be displayed to$wgUser
Revision::RAW
- get the text regardless of permissions
- To get the text of the latest revision, use:
$content = $wikiPage->getContent( Revision::RAW ); $text = ContentHandler::getContentText( $content );
See https://doc.wikimedia.org/mediawiki-core/master/php/classWikiPage.html for a complete lists of methods.
Accessors
getTitle()
- Get the title object of the article.