MediaWiki  REL1_20
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= '')
 doRedirect ($noRedir=false, $sectionAnchor= '', $extraQuery= '')
 Output a redirect back to the article.
 doRollback ($fromP, $summary, $token, $bot, &$resultDetails, User $user=null)
 doUnwatch ()
 Stop watching a page.
 doUpdateRestrictions (array $limit, array $expiry, &$cascade, $reason, User $user)
 doWatch ()
 Add this page to the current user's watchlist.
 fetchContent ()
 Get text of an article from database Does *NOT* follow redirects.
 forUpdate ()
 No-op.
 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)
 Get the robot policy to be used for the current view.
 getTitle ()
 Get the title object of the article.
 info ()
 Info about this page.
 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.
 markpatrolled ()
 Mark this particular edit/page as patrolled.
 protect ()
 action=protect handler
 purge ()
 Handle action=purge.
 render ()
 Handle action=render.
 revert ()
 Handle action=revert.
 rollback ()
 Handle action=rollback.
 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.
 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)
 unwatch ()
 User interface handler for the "unwatch" action.
 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)
 View redirect.
 watch ()
 User-interface handler for the "watch" action.

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 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 ()

Protected Member Functions

 newPage (Title $title)
 showCssOrJsPage ()
 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.
IContextSource $mContext
 The context this Article is executed in $mContext.
WikiPage $mPage
 The WikiPage object of this instance $mPage.
ParserOptions $mParserOptions
 ParserOptions object for $wgUser articles $mParserOptions.
string $mContent
 Content of the revision we are working on $mContent.
bool $mContentLoaded = false
 Is the content ($mContent) already loaded? $mContentLoaded.
int null $mOldId
 The oldid of the article that is to be shown, 0 for the current revision $mOldId.
Title $mRedirectedFrom = null
 Title from which we were redirected here $mRedirectedFrom.
string false $mRedirectUrl = false
 URL to redirect to or false if none $mRedirectUrl.
int $mRevIdFetched = 0
 Revision ID of revision we are working on $mRevIdFetched.
Revision $mRevision = null
 Revision we are working on $mRevision.
ParserOutput $mParserOutput
 ParserOutput object $mParserOutput.

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:
$titleTitle Reference to a Title object.
$oldIdInteger revision ID, null to fetch from request, zero for current

Definition at line 104 of file Article.php.


Member Function Documentation

Article::__call ( fname,
args 
)

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

Parameters:
$fnameString Name of called method
$argsArray Arguments to the method
Returns:
mixed

Definition at line 1806 of file Article.php.

Article::__get ( fname)

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

Parameters:
$fnameString Field name

Definition at line 1771 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:
$fnameString Field name
$fvaluemixed New value

Definition at line 1786 of file Article.php.

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

Parameters:
$pOutputParserOutput

Definition at line 689 of file Article.php.

Clear the object.

Definition at line 205 of file Article.php.

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

Definition at line 1873 of file Article.php.

Article::confirmDelete ( reason)

Output deletion confirmation dialog.

Todo:
FIXME: Move to another file?
Parameters:
$reasonString: prefilled reason

Definition at line 1400 of file Article.php.

UI entry point for page deletion.

Reimplemented in ImagePage.

Definition at line 1295 of file Article.php.

References protect().

Article::doDelete ( reason,
suppress = false 
)

Perform a deletion and output success or failure messages.

Parameters:
$reason
$suppressbool

Definition at line 1507 of file Article.php.

Article::doDeleteArticle ( reason,
suppress = false,
id = 0,
commit = true,
&$  error = '' 
)
Parameters:
$reasonstring
$suppressbool
$idint
$commitbool
$errorstring
Returns:
bool

Definition at line 1847 of file Article.php.

Article::doRedirect ( noRedir = false,
sectionAnchor = '',
extraQuery = '' 
)

Output a redirect back to the article.

This is typically used after an edit.

Deprecated:
in 1.18; call OutputPage::redirect() directly
Parameters:
$noRedirBoolean: add redirect=no
$sectionAnchorString: section to redirect to, including "#"
$extraQueryString: extra query params

Definition at line 1752 of file Article.php.

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

Definition at line 1860 of file Article.php.

Stop watching a page.

Returns:
bool true on successful unwatch
Deprecated:
since 1.18

Definition at line 1738 of file Article.php.

Article::doUpdateRestrictions ( array $  limit,
array $  expiry,
&$  cascade,
reason,
User user 
)
Parameters:
$limitarray
$expiryarray
$cascadebool
$reasonstring
$userUser
Returns:
Status

Definition at line 1824 of file Article.php.

Add this page to the current user's watchlist.

This is safe to be called multiple times

Returns:
bool true on successful watch operation
Deprecated:
since 1.18

Definition at line 1718 of file Article.php.

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

Returns:
mixed string containing article contents, or false if null

Definition at line 330 of file Article.php.

References wfDeprecated().

Referenced by getRevIdFetched().

static Article::formatRobotPolicy ( policy) [static]

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

Parameters:
$policyMixed, returns empty array on null/false/'', transparent to already-converted arrays, converts String.
Returns:
Array: 'index' => <indexpolicy>, 'follow' => <followpolicy>

Definition at line 829 of file Article.php.

No-op.

Deprecated:
since 1.18

Definition at line 386 of file Article.php.

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

Definition at line 1882 of file Article.php.

static Article::getAutosummary ( oldtext,
newtext,
flags 
) [static]
Parameters:
$oldtext
$newtext
$flags
Returns:
string

Definition at line 1922 of file Article.php.

Referenced by ArticleTest\testStaticFunctions().

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:
string Return the text of this revision

Reimplemented in ImagePage.

Definition at line 225 of file Article.php.

References getContext(), getTitle(), wfMessage(), wfProfileIn(), and wfProfileOut().

Gets the context this Article is executed in.

Returns:
IContextSource
Since:
1.18

Definition at line 1646 of file Article.php.

Referenced by CategoryPage\closeShowCategory(), getContent(), showDiffPage(), showViewFooter(), and CategoryPage\view().

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

Definition at line 255 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 268 of file Article.php.

Get the WikiPage object of this instance.

Since:
1.19
Returns:
WikiPage

Definition at line 198 of file Article.php.

Get parser options suitable for rendering the primary article wikitext.

Returns:
ParserOptions

Definition at line 1622 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:
$oldidmixed integer Revision ID or null
$userUser The relevant user
Returns:
ParserOutput or false if the given revsion ID is not found

Definition at line 1608 of file Article.php.

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

Returns:
int revision ID of last article revision

Definition at line 422 of file Article.php.

References fetchContent().

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

Since:
1.19
Returns:
Revision|null

Definition at line 411 of file Article.php.

Article::getRobotPolicy ( action,
pOutput 
)

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

Parameters:
$actionString the action= GET parameter
$pOutputParserOutput
Returns:
Array the policy that should be set TODO: actions other than 'view'

Definition at line 755 of file Article.php.

Get the title object of the article.

Returns:
Title object of this page

Definition at line 188 of file Article.php.

Referenced by EditPage\__construct(), ImageHistoryList\__construct(), CategoryPage\closeShowCategory(), getContent(), showViewFooter(), and CategoryPage\view().

Info about this page.

Deprecated:
since 1.19

Definition at line 1659 of file Article.php.

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

Returns:
bool

Definition at line 395 of file Article.php.

Check if the page can be cached.

Returns:
bool

Definition at line 1580 of file Article.php.

Load the revision (including text) into this object.

Deprecated:
in 1.19; use fetchContent()

Definition at line 319 of file Article.php.

Mark this particular edit/page as patrolled.

Deprecated:
since 1.18

Definition at line 1668 of file Article.php.

static Article::newFromID ( id) [static]

Constructor from a page id.

Parameters:
$idInt article ID to load
Returns:
Article|null

Reimplemented in ImagePage, and CategoryPage.

Definition at line 122 of file Article.php.

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

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

Parameters:
$titleTitle
$contextIContextSource
Returns:
Article object

Definition at line 136 of file Article.php.

Referenced by ApiEditPage\execute(), RebuildFileCache\execute(), and setRedirectedFrom().

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

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

Parameters:
$pageWikiPage
$contextIContextSource
Returns:
Article object

Definition at line 168 of file Article.php.

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

Reimplemented in ImagePage, and CategoryPage.

Definition at line 113 of file Article.php.

static Article::onArticleCreate ( title) [static]
Parameters:
$titleTitle

Definition at line 1898 of file Article.php.

References selectFields().

Referenced by onArticleDelete().

static Article::onArticleDelete ( title) [static]
Parameters:
$titleTitle

Definition at line 1905 of file Article.php.

References $title, and onArticleCreate().

Referenced by onArticleEdit().

static Article::onArticleEdit ( title) [static]
Parameters:
$titleTitle

Definition at line 1912 of file Article.php.

References $title, and onArticleDelete().

action=protect handler

Definition at line 1280 of file Article.php.

Referenced by delete().

Handle action=purge.

Deprecated:
since 1.19
Returns:
Action|bool|null false if the action is disabled, null if it is not recognised

Definition at line 1678 of file Article.php.

Handle action=render.

Reimplemented in ImagePage.

Definition at line 1272 of file Article.php.

Handle action=revert.

Deprecated:
since 1.19

Definition at line 1686 of file Article.php.

Handle action=rollback.

Deprecated:
since 1.19

Definition at line 1695 of file Article.php.

static Article::selectFields ( ) [static]
Returns:
array

Definition at line 1891 of file Article.php.

Referenced by onArticleCreate(), and ArticleTest\testStaticFunctions().

Article::setContext ( context)

Sets the context this Article is executed in.

Parameters:
$contextIContextSource
Since:
1.18

Definition at line 1636 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:
$oldidint: revision ID of this article revision

Definition at line 1098 of file Article.php.

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

Parameters:
$fromTitle object.

Definition at line 179 of file Article.php.

References $page, WikiPage\getTitle(), and newFromTitle().

Article::showCssOrJsPage ( ) [protected]

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

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

This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these page views.

Definition at line 729 of file Article.php.

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

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

Returns:
boolean true if the view is allowed, false if not.

Definition at line 1055 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.

Definition at line 701 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 976 of file Article.php.

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

For Article::view().

Definition at line 911 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.

Definition at line 941 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:
boolean

Definition at line 858 of file Article.php.

Show the footer section of an ordinary page view.

Definition at line 922 of file Article.php.

References getContext(), getTitle(), and wfMessage().

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:
boolean true if cached version send, false otherwise

Definition at line 1550 of file Article.php.

action=unprotect handler (alias)

Definition at line 1288 of file Article.php.

User interface handler for the "unwatch" action.

Requires Request to pass a token as of 1.18.

Deprecated:
since 1.18

Definition at line 1728 of file Article.php.

Article::updateRestrictions ( limit = array(),
reason = '',
&$  cascade = 0,
expiry = array() 
)
Parameters:
$limitarray
$reasonstring
$cascadeint
$expiryarray
Returns:
bool

Definition at line 1835 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 434 of file Article.php.

Article::viewRedirect ( target,
appendSubtitle = true,
forceKnown = false 
)

View redirect.

Parameters:
$targetTitle|Array of destination(s) to redirect
$appendSubtitleBoolean [optional]
$forceKnownBoolean: should the image be shown as a bluelink regardless of existence?
Returns:
string containing HMTL with redirect link

Definition at line 1223 of file Article.php.

User-interface handler for the "watch" action.

Requires Request to pass a token as of 1.18.

Deprecated:
since 1.18

Definition at line 1705 of file Article.php.


Member Data Documentation

string Article::$mContent

Content of the revision we are working on $mContent.

Definition at line 59 of file Article.php.

bool Article::$mContentLoaded = false

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

Definition at line 64 of file Article.php.

IContextSource Article::$mContext [protected]

The context this Article is executed in $mContext.

{

Access:
private

Definition at line 44 of file Article.php.

int null Article::$mOldId

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

Definition at line 70 of file Article.php.

WikiPage Article::$mPage [protected]

The WikiPage object of this instance $mPage.

Definition at line 49 of file Article.php.

ParserOptions Article::$mParserOptions

ParserOptions object for $wgUser articles $mParserOptions.

Definition at line 54 of file Article.php.

ParserOutput Article::$mParserOutput

ParserOutput object $mParserOutput.

Definition at line 95 of file Article.php.

Title Article::$mRedirectedFrom = null

Title from which we were redirected here $mRedirectedFrom.

Definition at line 75 of file Article.php.

string false Article::$mRedirectUrl = false

URL to redirect to or false if none $mRedirectUrl.

Definition at line 80 of file Article.php.

int Article::$mRevIdFetched = 0

Revision ID of revision we are working on $mRevIdFetched.

Definition at line 85 of file Article.php.

Revision Article::$mRevision = null

Revision we are working on $mRevision.

Definition at line 90 of file Article.php.


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