MediaWiki  REL1_24
Article Class Reference

Class for viewing MediaWiki article and history. More...

Inheritance diagram for Article:
Collaboration diagram for Article:

List of all members.

Public Member Functions

 __call ($fname, $args)
 Use PHP's magic __call handler to transform instance calls to WikiPage functions for backwards compatibility.
 __construct (Title $title, $oldId=null)
 Constructor and clear the article.
 __get ($fname)
 Use PHP's magic __get handler to handle accessing of raw WikiPage fields for backwards compatibility.
 __set ($fname, $fvalue)
 Use PHP's magic __set handler to handle setting of raw WikiPage fields for backwards compatibility.
 adjustDisplayTitle (ParserOutput $pOutput)
 Adjust title for pages with displaytitle, -{T|}- or language conversion.
 clear ()
 Clear the object.
 commitRollback ($fromP, $summary, $bot, &$resultDetails, User $guser=null)
 confirmDelete ($reason)
 Output deletion confirmation dialog.
 delete ()
 UI entry point for page deletion.
 doDelete ($reason, $suppress=false)
 Perform a deletion and output success or failure messages.
 doDeleteArticle ($reason, $suppress=false, $id=0, $commit=true, &$error= '')
 doRollback ($fromP, $summary, $token, $bot, &$resultDetails, User $user=null)
 doUpdateRestrictions (array $limit, array $expiry, &$cascade, $reason, User $user)
 fetchContent ()
 Get text of an article from database Does *NOT* follow redirects.
 generateReason (&$hasHistory)
 getContent ()
 Note that getContent/loadContent do not follow redirects anymore.
 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)
 #@-
 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, $pOutput=null)
 Get the robot policy to be used for the current view.
 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 ()
 Check if the page can be cached.
 loadContent ()
 Load the revision (including text) into this object.
 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 ->
 setParserOptions (ParserOptions $options)
 Override the ParserOptions used to render the primary article wikitext.
 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.
 showDiffPage ()
 Show a diff page according to current request variables.
 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)
 updateRestrictions ($limit=array(), $reason= '', &$cascade=0, $expiry=array())
 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 getAutosummary ($oldtext, $newtext, $flags)
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 onArticleCreate ($title)
static onArticleDelete ($title)
static onArticleEdit ($title)
static selectFields ()

Public Attributes

string $mContent
 Text of the revision we are working on.
bool $mContentLoaded = false
 Is the content ($mContent) already loaded? *.
Content $mContentObject
 Content of the revision we are working on.
int null $mOldId
 The oldid of the article that is to be shown, 0 for the current revision *.
ParserOptions $mParserOptions
 ParserOptions object for $wgUser articles *.
ParserOutput $mParserOutput
 *
Title $mRedirectedFrom = null
 Title from which we were redirected here *.
string bool $mRedirectUrl = false
 URL to redirect to or false if none *.
int $mRevIdFetched = 0
 Revision ID of revision we are working on *.
Revision $mRevision = null
 Revision we are working on *.

Protected Member Functions

 fetchContentObject ()
 Get text content object Does *NOT* follow redirects.
 getContentObject ()
 Returns a Content object representing the pages effective display content, not necessarily the revision's content!
 newPage (Title $title)
 showCssOrJsPage ($showCacheHint=true)
 Show a page view for a page formatted as CSS or JavaScript.
 tryFileCache ()
 checkLastModified returns true if it has taken care of all output to the client that is necessary for this request.

Protected Attributes

IContextSource $mContext
 The context this Article is executed in *.
WikiPage $mPage
 The WikiPage object of this instance *.

Detailed Description

Class for viewing MediaWiki article and history.

This maintains WikiPage functions for backwards compatibility.

Todo:
Move and rewrite code to an Action class

See design.txt for an overview. Note: edit user interface and cache support functions have been moved to separate EditPage and HTMLFileCache classes.

Definition at line 36 of file Article.php.


Constructor & Destructor Documentation

Article::__construct ( Title title,
oldId = null 
)

Constructor and clear the article.

Parameters:
Title$titleReference to a Title object.
int$oldIdRevision ID, null to fetch from request, zero for current

Definition at line 72 of file Article.php.

References newPage().


Member Function Documentation

Article::__call ( fname,
args 
)

Use PHP's magic __call handler to transform instance calls to WikiPage functions for backwards compatibility.

Parameters:
string$fnameName of called method
array$argsArguments to the method
Returns:
mixed

Definition at line 1987 of file Article.php.

Article::__get ( fname)

Use PHP's magic __get handler to handle accessing of raw WikiPage fields for backwards compatibility.

Parameters:
string$fnameField name
Returns:
mixed

Definition at line 1952 of file Article.php.

Article::__set ( fname,
fvalue 
)

Use PHP's magic __set handler to handle setting of raw WikiPage fields for backwards compatibility.

Parameters:
string$fnameField name
mixed$fvalueNew value

Definition at line 1967 of file Article.php.

Adjust title for pages with displaytitle, -{T|}- or language conversion.

Parameters:
ParserOutput$pOutput

Definition at line 753 of file Article.php.

Clear the object.

Definition at line 173 of file Article.php.

Article::commitRollback ( fromP,
summary,
bot,
&$  resultDetails,
User guser = null 
)
Parameters:
string$fromP
string$summary
bool$bot
array$resultDetails
User | null$guser
Returns:
array

Definition at line 2066 of file Article.php.

Article::confirmDelete ( reason)

Output deletion confirmation dialog.

Todo:
FIXME: Move to another file?
Parameters:
string$reasonPrefilled reason

Definition at line 1655 of file Article.php.

UI entry point for page deletion.

Reimplemented in ImagePage.

Definition at line 1532 of file Article.php.

Article::doDelete ( reason,
suppress = false 
)

Perform a deletion and output success or failure messages.

Parameters:
string$reason
bool$suppress

Definition at line 1774 of file Article.php.

Article::doDeleteArticle ( reason,
suppress = false,
id = 0,
commit = true,
&$  error = '' 
)
Parameters:
string$reason
bool$suppress
int$id
bool$commit
string$error
Returns:
bool

Definition at line 2038 of file Article.php.

Article::doRollback ( fromP,
summary,
token,
bot,
&$  resultDetails,
User user = null 
)
Parameters:
string$fromP
string$summary
string$token
bool$bot
array$resultDetails
User | null$user
Returns:
array

Definition at line 2053 of file Article.php.

Article::doUpdateRestrictions ( array limit,
array expiry,
&$  cascade,
reason,
User user 
)
Parameters:
array$limit
array$expiry
bool$cascade
string$reason
User$user
Returns:
Status

Definition at line 2005 of file Article.php.

Get text of an article from database Does *NOT* follow redirects.

Access:
protected
Note:
This is really internal functionality that should really NOT be used by other functions. For accessing article content, use the WikiPage class, especially WikiBase::getContent(). However, a lot of legacy code uses this method to retrieve page text from the database, so the function has to remain public for now.
Returns:
string|bool String containing article contents, or false if null
Deprecated:
since 1.21, use WikiPage::getContent() instead

Definition at line 328 of file Article.php.

Article::fetchContentObject ( ) [protected]

Get text content object Does *NOT* follow redirects.

Todo:
When is this null?
Note:
Code that wants to retrieve page content from the database should use WikiPage::getContent().
Returns:
Content|null|bool
Since:
1.21

Definition at line 365 of file Article.php.

Referenced by showCssOrJsPage().

static Article::formatRobotPolicy ( policy) [static]

Converts a String robot policy into an associative array, to allow merging of several policies using array_merge().

Parameters:
array | string$policyReturns empty array on null/false/'', transparent to already-converted arrays, converts string.
Returns:
array 'index' => <indexpolicy>, 'follow' => <followpolicy>

Definition at line 933 of file Article.php.

Article::generateReason ( &$  hasHistory)
Parameters:
bool$hasHistory
Returns:
mixed

Definition at line 2075 of file Article.php.

static Article::getAutosummary ( oldtext,
newtext,
flags 
) [static]
Parameters:
string$oldtext
string$newtext
int$flags
Returns:
string
Deprecated:
since 1.21, use ContentHandler::getAutosummary() instead

Definition at line 2130 of file Article.php.

References onArticleEdit(), and wfDeprecated().

Note that getContent/loadContent do 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.

Deprecated:
since 1.21; use WikiPage::getContent() instead
Returns:
string Return the text of this revision

Definition at line 195 of file Article.php.

Article::getContentObject ( ) [protected]

Returns a Content object representing the pages effective display content, not necessarily the revision's content!

Note that getContent/loadContent do 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.

Returns:
Content Return the content of this revision
Since:
1.21

Reimplemented in ImagePage.

Definition at line 216 of file Article.php.

Returns:
int The oldid of the article that is to be shown, 0 for the current revision

Definition at line 245 of file Article.php.

Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect.

Returns:
int The old id for the request

Definition at line 258 of file Article.php.

Get the WikiPage object of this instance.

Since:
1.19
Returns:
WikiPage

Definition at line 166 of file Article.php.

Get parser options suitable for rendering the primary article wikitext.

Returns:
ParserOptions

Definition at line 1911 of file Article.php.

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 WikiPage::view is forced to consider, so it's not appropriate to use there.

Since:
1.16 (r52326) for LiquidThreads
Parameters:
int | null$oldidRevision ID or null
User$userThe relevant user
Returns:
ParserOutput|bool ParserOutput or false if the given revision ID is not found

Definition at line 1880 of file Article.php.

static Article::getRedirectHeaderHtml ( Language lang,
target,
forceKnown = false 
) [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.

Since:
1.23
Parameters:
Language$lang
Title | array$targetDestination(s) to redirect
bool$forceKnownShould the image be shown as a bluelink regardless of existence?
Returns:
string Containing HTML with redirect link

Definition at line 1477 of file Article.php.

Referenced by WikitextContent\fillParserOutput(), and viewRedirect().

Use this to fetch the rev ID used on page views.

Returns:
int Revision ID of last article revision

Definition at line 458 of file Article.php.

Get the fetched Revision object depending on request parameters or null on failure.

Since:
1.19
Returns:
Revision|null

Definition at line 447 of file Article.php.

Article::getRobotPolicy ( action,
pOutput = null 
)

Get the robot policy to be used for the current view.

Parameters:
string$actionThe action= GET parameter
ParserOutput | null$pOutput
Returns:
array The policy that should be set
Todo:
actions other than 'view'

Definition at line 853 of file Article.php.

Get the title object of the article.

Returns:
Title Title object of this page

Definition at line 156 of file Article.php.

Referenced by ImageHistoryList\__construct(), CategoryPage\closeShowCategory(), showCssOrJsPage(), CategoryPage\view(), and viewRedirect().

Returns true if the currently-referenced revision is the current edit to this page (and it exists).

Returns:
bool

Definition at line 431 of file Article.php.

Check if the page can be cached.

Returns:
bool

Definition at line 1852 of file Article.php.

Load the revision (including text) into this object.

Deprecated:
since 1.19; use fetchContent()

Definition at line 309 of file Article.php.

static Article::newFromID ( id) [static]

Constructor from a page id.

Parameters:
int$idArticle ID to load
Returns:
Article|null

Reimplemented in ImagePage, and CategoryPage.

Definition at line 90 of file Article.php.

static Article::newFromTitle ( title,
IContextSource context 
) [static]

Create an Article object of the appropriate class for the given page.

Parameters:
Title$title
IContextSource$context
Returns:
Article

Definition at line 104 of file Article.php.

Referenced by RebuildFileCache\execute().

static Article::newFromWikiPage ( WikiPage page,
IContextSource context 
) [static]

Create an Article object of the appropriate class for the given page.

Parameters:
WikiPage$page
IContextSource$context
Returns:
Article

Definition at line 136 of file Article.php.

Referenced by ApiEditPage\execute().

Article::newPage ( Title title) [protected]
Parameters:
Title$title
Returns:
WikiPage

Reimplemented in ImagePage, and CategoryPage.

Definition at line 81 of file Article.php.

Referenced by __construct().

static Article::onArticleCreate ( title) [static]
Parameters:
Title$title
Deprecated:
since 1.24, use WikiPage::onArticleCreate() instead

Definition at line 2098 of file Article.php.

static Article::onArticleDelete ( title) [static]
Parameters:
Title$title
Deprecated:
since 1.24, use WikiPage::onArticleDelete() instead

Definition at line 2108 of file Article.php.

static Article::onArticleEdit ( title) [static]
Parameters:
Title$title
Deprecated:
since 1.24, use WikiPage::onArticleEdit() instead

Definition at line 2118 of file Article.php.

Referenced by getAutosummary().

action=protect handler

Definition at line 1517 of file Article.php.

Handle action=render.

Reimplemented in ImagePage.

Definition at line 1507 of file Article.php.

static Article::selectFields ( ) [static]
Returns:
array
Deprecated:
since 1.24, use WikiPage::selectFields() instead

Definition at line 2088 of file Article.php.

Article::setContext ( context)

Sets the context this Article is executed in.

Parameters:
IContextSource$context
Since:
1.18

Definition at line 1925 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 ->

Parameters:
int$oldidRevision ID of this article revision

Definition at line 1327 of file Article.php.

Override the ParserOptions used to render the primary article wikitext.

Parameters:
ParserOptions$options
Exceptions:
MWExceptionIf the parser options where already initialized.

Definition at line 1898 of file Article.php.

Tell the page view functions that this view was redirected from another page on the wiki.

Parameters:
Title$from

Definition at line 147 of file Article.php.

Article::showCssOrJsPage ( showCacheHint = true) [protected]

Show a page view for a page formatted as CSS or JavaScript.

To be called by Article::view() only.

This exists mostly to serve the deprecated ShowRawCssJs hook (used to customize these views). It has been replaced by the ContentGetParserOutput hook, which lets you do the same but with more flexibility.

Parameters:
bool$showCacheHintWhether to show a message telling the user to clear the browser cache (default: true).

Definition at line 817 of file Article.php.

References $dir, array(), fetchContentObject(), getContext(), getTitle(), and ContentHandler\runLegacyHooks().

If the revision requested for view is deleted, check permissions.

Send either an error message or a warning header to the output.

Returns:
bool True if the view is allowed, false if not.

Definition at line 1284 of file Article.php.

Show a diff page according to current request variables.

For use within Article::view() only, other callers should use the DifferenceEngine class.

Todo:
Make protected

Definition at line 767 of file Article.php.

References getContext().

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 1179 of file Article.php.

Show a header specific to the namespace currently being viewed, like [[MediaWiki:Talkpagetext]].

For Article::view().

Definition at line 1027 of file Article.php.

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 mediawiki.page.patrol.ajax.

Returns:
bool

Definition at line 1064 of file Article.php.

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.

Returns:
bool

Definition at line 962 of file Article.php.

Show the footer section of an ordinary page view.

Definition at line 1041 of file Article.php.

References array(), and getContext().

Article::tryFileCache ( ) [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)

Returns:
bool True if cached version send, false otherwise

Definition at line 1822 of file Article.php.

action=unprotect handler (alias)

Definition at line 1525 of file Article.php.

References $form.

Article::updateRestrictions ( limit = array(),
reason = '',
&$  cascade = 0,
expiry = array() 
)
Parameters:
array$limit
string$reason
int$cascade
array$expiry
Returns:
bool

Definition at line 2018 of file Article.php.

This is the default action of the index.php entry point: just view the page of the given title.

Reimplemented in ImagePage, and CategoryPage.

Definition at line 470 of file Article.php.

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.

Parameters:
Title | array$targetDestination(s) to redirect
bool$appendSubtitle[optional]
bool$forceKnownShould the image be shown as a bluelink regardless of existence?
Returns:
string Containing HTML with redirect link

Definition at line 1455 of file Article.php.

References $out, getContext(), getRedirectHeaderHtml(), getTitle(), and wfMessage().


Member Data Documentation

string Article::$mContent

Text of the revision we are working on.

Todo:
BC cruft

Definition at line 46 of file Article.php.

bool Article::$mContentLoaded = false

Is the content ($mContent) already loaded? *.

Definition at line 53 of file Article.php.

Content Article::$mContentObject

Content of the revision we are working on.

Since:
1.21

Definition at line 51 of file Article.php.

IContextSource Article::$mContext [protected]

The context this Article is executed in *.

Definition at line 37 of file Article.php.

int null Article::$mOldId

The oldid of the article that is to be shown, 0 for the current revision *.

Definition at line 55 of file Article.php.

WikiPage Article::$mPage [protected]

The WikiPage object of this instance *.

Definition at line 39 of file Article.php.

ParserOptions Article::$mParserOptions

ParserOptions object for $wgUser articles *.

Definition at line 41 of file Article.php.

ParserOutput Article::$mParserOutput

*

Definition at line 65 of file Article.php.

Title Article::$mRedirectedFrom = null

Title from which we were redirected here *.

Definition at line 57 of file Article.php.

string bool Article::$mRedirectUrl = false

URL to redirect to or false if none *.

Definition at line 59 of file Article.php.

int Article::$mRevIdFetched = 0

Revision ID of revision we are working on *.

Definition at line 61 of file Article.php.

Revision Article::$mRevision = null

Revision we are working on *.

Definition at line 63 of file Article.php.


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