Article Class Reference

Class representing a MediaWiki article and history. More...

Inherited by CategoryPage, and ImagePage.

List of all members.

Public Member Functions

 __construct (Title $title, $oldId=null)
 Constructor and clear the article.
 setRedirectedFrom ($from)
 Tell the page view functions that this view was redirected from another page on the wiki.
 getRedirectTarget ()
 If this page is a redirect, get its target.
 insertRedirect ()
 Insert an entry for this page into the redirect table.
 followRedirect ()
 Get the Title object this page redirects to.
 followRedirectText ($text)
 Get the Title object this text redirects to.
 getTitle ()
 get the title object of the article
 clear ()
 Clear the object.
 getContent ()
 Note that getContent/loadContent do not follow redirects anymore.
 getRawText ()
 Get the text of the current revision.
 getSection ($text, $section)
 This function returns the text of a section, specified by a number ($section).
 getUndoText (Revision $undo, Revision $undoafter=null)
 Get the text that needs to be saved in order to undo all revisions between $undo and $undoafter.
 getOldID ()
 getOldIDFromRequest ()
 Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect.
 loadContent ()
 Load the revision (including text) into this object.
 pageDataFromTitle ($dbr, $title)
 loadPageData ($data= 'fromdb')
 Set the general counter, title etc data loaded from some source.
 fetchContent ($oldid=0)
 Get text of an article from database Does *NOT* follow redirects.
 forUpdate ($x=NULL)
 Read/write accessor to select FOR UPDATE.
 getDB ()
 Get the database which should be used for reads.
 getID ()
 exists ()
 hasViewableContent ()
 Check if this page is something we're going to be showing some sort of sensible content for.
 getCount ()
 isCountable ($text)
 Determine whether a page would be suitable for being counted as an article in the site_stats table based on the title & its content.
 isRedirect ($text=false)
 Tests if the article text represents a redirect.
 isCurrent ()
 Returns true if the currently-referenced revision is the current edit to this page (and it exists).
 getTimestamp ()
 getUser ()
 getUserText ()
 getComment ()
 getMinorEdit ()
 getRevIdFetched ()
 getContributors ($limit=0, $offset=0)
 view ()
 This is the default action of the script: just view the page of the given title.
 viewRedirect ($target, $appendSubtitle=true, $forceKnown=false)
 View redirect.
 addTrackbacks ()
 deletetrackback ()
 render ()
 purge ()
 Handle action=purge.
 doPurge ()
 Perform the actions of a page purging.
 insertOn ($dbw)
 Insert a new empty page record for this article.
 updateRevisionOn (&$dbw, $revision, $lastRevision=null, $lastRevIsRedirect=null)
 Update the page record to point to a newly saved revision.
 updateRedirectOn (&$dbw, $redirectTitle, $lastRevIsRedirect=null)
 Add row to the redirect table if this is a redirect, remove otherwise.
 updateIfNewerOn (&$dbw, $revision)
 If the given revision is newer than the currently set page_latest, update the page record.
 replaceSection ($section, $text, $summary= '', $edittime=NULL)
 insertNewArticle ($text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false, $bot=false)
 updateArticle ($text, $summary, $minor, $watchthis, $forceBot=false, $sectionanchor= '')
 doEdit ($text, $summary, $flags=0, $baseRevId=false, $user=null)
 Article::doEdit().
 showArticle ($text, $subtitle, $sectionanchor= '', $me2, $now, $summary, $oldid)
 doRedirect ($noRedir=false, $sectionAnchor= '', $extraQuery= '')
 Output a redirect back to the article.
 markpatrolled ()
 Mark this particular edit/page as patrolled.
 watch ()
 User-interface handler for the "watch" action.
 doWatch ()
 Add this page to $wgUser's watchlist.
 unwatch ()
 User interface handler for the "unwatch" action.
 doUnwatch ()
 Stop watching a page.
 protect ()
 action=protect handler
 unprotect ()
 action=unprotect handler (alias)
 updateRestrictions ($limit=array(), $reason= '', &$cascade=0, $expiry=array())
 Update the article's restriction field, and leave a log entry.
 generateReason (&$hasHistory)
 Auto-generates a deletion reason.
 delete ()
 isBigDeletion ()
 estimateRevisionCount ()
 getLastNAuthors ($num, $revLatest=0)
 Get the last N authors.
 confirmDelete ($reason)
 Output deletion confirmation dialog.
 doDelete ($reason, $suppress=false)
 Perform a deletion and output success or failure messages.
 doDeleteArticle ($reason, $suppress=false, $id=0)
 Back-end article deletion Deletes the article with database consistency, writes logs, purges caches Returns success.
 doRollback ($fromP, $summary, $token, $bot, &$resultDetails)
 Roll back the most recent consecutive set of edits to a page from the same user; fails if there are no eligible edits to roll back to, e.g.
 commitRollback ($fromP, $summary, $bot, &$resultDetails)
 Backend implementation of doRollback(), please refer there for parameter and return value documentation.
 rollback ()
 User interface for rollback operations.
 viewUpdates ()
 Do standard deferred updates after page view.
 prepareTextForEdit ($text, $revid=null)
 Prepare text which is about to be saved.
 editUpdates ($text, $summary, $minoredit, $timestamp_of_pagechange, $newid, $changed=true)
 Do standard deferred updates after page edit.
 createUpdates ($rev)
 Perform article updates on a special page creation.
 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 ->.
 preSaveTransform ($text)
 This function is called right before saving the wikitext, so we can do things like signatures and links-in-context.
 isFileCacheable ()
 Check if the page can be cached.
 checkTouched ()
 Loads page_touched and returns a value indicating if it should be used.
 getTouched ()
 Get the page_touched field.
 getLatest ()
 Get the page_latest field.
 quickEdit ($text, $comment= '', $minor=0)
 Edit an article without doing all that other stuff The article must already exist; link tables etc are not updated, caches are not flushed.
 revert ()
 #@-
 info ()
 Info about this page Called for ?action=info when $wgAllowPageInfo is on.
 getUsedTemplates ()
 Return a list of templates used by this article.
 getHiddenCategories ()
 Returns a list of hidden categories this page is a member of.
 outputWikiText ($text, $cache=true)
 Add the primary page-view wikitext to the output buffer Saves the text into the parser cache if possible.
 updateCategoryCounts ($added, $deleted)
 Update all the appropriate counts in the category table, given that we've added the categories $added and deleted the categories $deleted.

Static Public Member Functions

static newFromID ($id)
 Constructor from an article article.
static incViewCount ($id)
 Used to increment the view counter.
static onArticleCreate ($title)
 #@+ The onArticle*() functions are supposed to be a kind of hooks which should be called whenever any of the specified actions are done.
static onArticleDelete ($title)
static onArticleEdit ($title, $flags= '')
 Purge caches on page update etc.
static getAutosummary ($oldtext, $newtext, $flags)
 Return an applicable autosummary if one exists for the given edit.

Public Attributes

 $mComment = ''
 $mContent
 $mContentLoaded = false
 $mCounter = -1
 Not loaded.
 $mCurID = -1
 Not loaded.
 $mDataLoaded = false
 $mForUpdate = false
 $mGoodAdjustment = 0
 $mIsRedirect = false
 $mLatest = false
 $mMinorEdit
 $mOldId
 $mPreparedEdit = false
 Title object if set.
 $mRedirectedFrom = null
 Title object if set.
 $mRedirectTarget = null
 Title object if set.
 $mRedirectUrl = false
 $mRevIdFetched = 0
 $mRevision
 $mTimestamp = ''
 $mTitle
 $mTotalAdjustment = 0
 $mTouched = '19700101000000'
 $mUser = -1
 Not loaded.
 $mUserText = ''

Protected Member Functions

 pageData ($dbr, $conditions)
 Fetch a page record with the given conditions.
 pageDataFromId ($dbr, $id)
 getSelectOptions ($options= '')
 Get options for all SELECT statements.
 loadLastEdit ()
 Loads everything except the text This isn't necessary for all uses, so it's only done if needed.
 showDeletionLog ()
 useParserCache ($oldid)
 tryFileCache ()
 checkLastModified returns true if it has taken care of all output to the client that is necessary for this request.
 pageCountInfo ($title)
 Return the total number of edits and number of unique editors on a given page.

Static Protected Member Functions

static flattenRestrictions ($limit)
 Take an array of page restrictions and flatten it to a string suitable for insertion into the page_restrictions field.


Detailed Description

Class representing a MediaWiki article and history.

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


Constructor & Destructor Documentation

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

Constructor and clear the article.

Parameters:
$title Reference to a Title object.
$oldId Integer revision ID, null to fetch from request, zero for current

Definition at line 50 of file Article.php.


Member Function Documentation

Article::addTrackbacks (  ) 

Definition at line 1126 of file Article.php.

References $dbr, $wgOut, $wgUser, getID(), wfGetDB(), and wfMsg().

Referenced by view().

Article::checkTouched (  ) 

Loads page_touched and returns a value indicating if it should be used.

Definition at line 3146 of file Article.php.

References loadPageData().

Referenced by view().

Article::clear (  ) 

Clear the object.

Access:
private

Definition at line 181 of file Article.php.

Article::commitRollback ( fromP,
summary,
bot,
&$  resultDetails 
)

Backend implementation of doRollback(), please refer there for parameter and return value documentation.

NOTE: This function does NOT check ANY permissions, it just commits the rollback to the DB Therefore, you should only call this function direct- ly if you want to use custom permissions checks. If you don't, use doRollback() instead.

Definition at line 2678 of file Article.php.

References $args, $bot, $dbw, $flags, $s, $status, $summary, $user, $wgLang, $wgUser, $wgUseRCPatrol, doEdit(), Revision::newFromId(), Revision::newFromTitle(), wfGetDB(), wfMsgForContent(), wfMsgReplaceArgs(), wfReadOnly(), wfRunHooks(), and wfTimestamp().

Referenced by doRollback().

Article::confirmDelete ( reason  ) 

Output deletion confirmation dialog.

Parameters:
$reason String: prefilled reason

Definition at line 2383 of file Article.php.

References $reason, $wgOut, $wgUser, Xml::checkLabel(), Xml::closeElement(), Xml::hidden(), Xml::input(), Xml::label(), Xml::listDropDown(), Xml::openElement(), LogEventsList::showLogExtract(), Xml::submitButton(), Xml::tags(), wfDebug(), wfMsg(), wfMsgExt(), wfMsgForContent(), and wfMsgHtml().

Referenced by delete().

Article::createUpdates ( rev  ) 

Perform article updates on a special page creation.

Parameters:
$rev Revision object
Todo:
This is a shitty interface function. Kill it and replace the other shitty functions like editUpdates and such so it's not needed anymore.

Definition at line 3001 of file Article.php.

References editUpdates(), isCountable(), and wfTimestamp().

Article::delete (  ) 

Article::deletetrackback (  ) 

Definition at line 1155 of file Article.php.

References $db, $wgOut, $wgRequest, $wgTitle, $wgUser, and wfGetDB().

Article::doDelete ( reason,
suppress = false 
)

Perform a deletion and output success or failure messages.

Definition at line 2462 of file Article.php.

References $error, $reason, $wgOut, $wgUser, doDeleteArticle(), Xml::element(), LogPage::logName(), LogEventsList::showLogExtract(), wfMsg(), wfMsgExt(), wfMsgNoTrans(), and wfRunHooks().

Referenced by delete().

Article::doDeleteArticle ( reason,
suppress = false,
id = 0 
)

Back-end article deletion Deletes the article with database consistency, writes logs, purges caches Returns success.

Definition at line 2496 of file Article.php.

References $dbw, $ns, $ok, $reason, $res, $row, $t, $u, $wgDeferredUpdateList, $wgUseSquid, $wgUseTrackbacks, Revision::DELETED_COMMENT, Revision::DELETED_RESTRICTED, Revision::DELETED_TEXT, Revision::DELETED_USER, getRawText(), isCountable(), onArticleDelete(), updateCategoryCounts(), wfDebug(), and wfGetDB().

Referenced by doDelete().

Article::doEdit ( text,
summary,
flags = 0,
baseRevId = false,
user = null 
)

Article::doEdit().

Change an existing article or create a new article. Updates RC and all necessary caches, optionally via the deferred update array.

$wgUser must be set before calling this function.

Parameters:
$text String: new text
$summary String: edit summary
$flags Integer bitfield: EDIT_NEW Article is known or assumed to be non-existent, create a new one EDIT_UPDATE Article is known or assumed to be pre-existing, update it EDIT_MINOR Mark this edit minor, if the user is allowed to do so EDIT_SUPPRESS_RC Do not log the change in recentchanges EDIT_FORCE_BOT Mark the edit a "bot" edit regardless of user rights EDIT_DEFER_UPDATES Defer some of the updates until the end of index.php EDIT_AUTOSUMMARY Fill in blank summaries with generated text where possible
If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the article will be detected. If EDIT_UPDATE is specified and the article doesn't exist, the function will an edit-gone-missing error. If EDIT_NEW is specified and the article does exist, an edit-already-exists error will be returned. These two conditions are also possible with auto-detection due to MediaWiki's performance-optimised locking strategy.

Parameters:
$baseRevId the revision ID this edit was based off, if any
$user Optional user object, $wgUser will be used if not passed
Returns:
Status object. Possible errors: edit-hook-aborted: The ArticleSave hook aborted the edit but didn't set the fatal flag of $status edit-gone-missing: In update mode, but the article didn't exist edit-conflict: In update mode, the article changed unexpectedly edit-no-change: Warning that the text was the same as before edit-already-exists: In creation mode, but the article already exists
Extensions may define additional errors.

$return->value will contain an associative array with members as follows: new: Boolean indicating if the function attempted to create a new article revision: The revision object for the inserted revision, or null

Compatibility note: this function previously returned a boolean value indicating success/failure

Definition at line 1549 of file Article.php.

References $bot, $changed, $dbw, $flags, $ok, $revision, $status, $summary, $text, $user, $wgDBtransactions, $wgUseAutomaticEditSummaries, $wgUseNPPatrol, $wgUser, $wgUseRCPatrol, editUpdates(), getAutosummary(), getRawText(), getRevIdFetched(), getTimestamp(), insertOn(), isCountable(), loadPageData(), Status::newGood(), RecentChange::notifyEdit(), RecentChange::notifyNew(), onArticleCreate(), onArticleEdit(), prepareTextForEdit(), PatrolLog::record(), updateRevisionOn(), wfDebug(), wfDoUpdates(), wfGetDB(), wfProfileIn(), wfProfileOut(), wfRunHooks(), and wfTimestampNow().

Referenced by commitRollback(), insertNewArticle(), and updateArticle().

Article::doPurge (  ) 

Perform the actions of a page purging.

Reimplemented in ImagePage.

Definition at line 1208 of file Article.php.

References $dbw, $text, $wgMessageCache, $wgUseSquid, getID(), getRawText(), SquidUpdate::newSimplePurge(), and wfGetDB().

Referenced by purge().

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

Output a redirect back to the article.

This is typically used after an edit.

Parameters:
$noRedir Boolean: add redirect=no
$sectionAnchor String: section to redirect to, including "#"
$extraQuery String: extra query params

Definition at line 1801 of file Article.php.

References $wgOut.

Referenced by insertNewArticle(), showArticle(), and updateArticle().

Article::doRollback ( fromP,
summary,
token,
bot,
&$  resultDetails 
)

Roll back the most recent consecutive set of edits to a page from the same user; fails if there are no eligible edits to roll back to, e.g.

user is the sole contributor. This function performs permissions checks on $wgUser, then calls commitRollback() to do the dirty work

Parameters:
$fromP String: Name of the user whose edits to rollback.
$summary String: Custom summary. Set to default summary if empty.
$token String: Rollback token.
$bot Boolean: If true, mark all reverted edits as bot.
$resultDetails Array: contains result-specific array of additional values 'alreadyrolled' : 'current' (rev) success : 'summary' (str), 'current' (rev), 'target' (rev)
Returns:
array of errors, each error formatted as array(messagekey, param1, param2, ...). On success, the array is empty. This array can also be passed to OutputPage::showPermissionsErrorPage().

Definition at line 2647 of file Article.php.

References $bot, $summary, $wgUser, commitRollback(), and wfArrayDiff2().

Referenced by rollback().

Article::doUnwatch (  ) 

Stop watching a page.

Returns:
bool true on successful unwatch

Definition at line 1926 of file Article.php.

References $wgUser, and wfRunHooks().

Referenced by delete(), insertNewArticle(), unwatch(), and updateArticle().

Article::doWatch (  ) 

Add this page to $wgUser's watchlist.

Returns:
bool true on successful watch operation

Definition at line 1889 of file Article.php.

References $wgUser, and wfRunHooks().

Referenced by delete(), insertNewArticle(), updateArticle(), and watch().

Article::editUpdates ( text,
summary,
minoredit,
timestamp_of_pagechange,
newid,
changed = true 
)

Do standard deferred updates after page edit.

Update links tables, site stats, search index and message cache. Purges pages that include this page if the text was changed here. Every 100th edit, prune the recent changes table.

Access:
private
Parameters:
$text New text of the article
$summary Edit summary
$minoredit Minor edit
$timestamp_of_pagechange Timestamp associated with the page change
$newid rev_id value of the new revision
$changed Whether or not the content actually changed

Definition at line 2907 of file Article.php.

References $changed, $dbw, $sql, $text, $title, $u, $wgDeferredUpdateList, $wgEnableParserCache, $wgMessageCache, $wgParser, $wgRCMaxAge, $wgUser, getID(), User::isIP(), User::newFromName(), prepareTextForEdit(), ParserCache::singleton(), wfDebug(), wfGetDB(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

Referenced by createUpdates(), and doEdit().

Article::estimateRevisionCount (  ) 

Returns:
int approximate revision count

Definition at line 2325 of file Article.php.

References $dbr, and wfGetDB().

Referenced by isBigDeletion().

Article::exists (  ) 

Returns:
bool Whether or not the page exists in the database

Definition at line 545 of file Article.php.

Referenced by ProtectionForm::__construct(), hasViewableContent(), isCurrent(), and useParserCache().

Article::fetchContent ( oldid = 0  ) 

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

Parameters:
$oldid Int: 0 for whatever the latest revision is
Returns:
string

Definition at line 433 of file Article.php.

References $dbr, $revision, $t, Revision::FOR_THIS_USER, loadPageData(), Title::makeTitle(), Revision::newFromId(), pageDataFromId(), pageDataFromTitle(), wfDebug(), wfGetDB(), wfMsg(), wfMsgExt(), wfRunHooks(), and wfTimestamp().

Referenced by isRedirect(), and loadContent().

static Article::flattenRestrictions ( limit  )  [static, protected]

Take an array of page restrictions and flatten it to a string suitable for insertion into the page_restrictions field.

Parameters:
$limit Array
Returns:
String

Definition at line 2126 of file Article.php.

References $action.

Referenced by updateRestrictions().

Article::followRedirect (  ) 

Get the Title object this page redirects to.

Returns:
mixed false, Title of in-wiki target, or string with URL

Reimplemented in ImagePage.

Definition at line 127 of file Article.php.

References $text, followRedirectText(), and getContent().

Article::followRedirectText ( text  ) 

Get the Title object this text redirects to.

Returns:
mixed false, Title of in-wiki target, or string with URL

Definition at line 137 of file Article.php.

References $source, $text, and Title::newFromRedirectRecurse().

Referenced by followRedirect().

Article::forUpdate ( x = NULL  ) 

Read/write accessor to select FOR UPDATE.

Parameters:
$x Mixed: FIXME

Definition at line 498 of file Article.php.

References wfSetVar().

Article::generateReason ( &$  hasHistory  ) 

Auto-generates a deletion reason.

Parameters:
&$hasHistory Boolean: whether the page has a history

Definition at line 2144 of file Article.php.

References $dbw, $reason, $res, $row, $wgContLang, getID(), Revision::newFromTitle(), wfGetDB(), and wfMsgForContent().

Referenced by delete().

static Article::getAutosummary ( oldtext,
newtext,
flags 
) [static]

Return an applicable autosummary if one exists for the given edit.

Parameters:
$oldtext String: the previous text of the page.
$newtext String: The submitted text of the page.
$flags Bitmask: a bitmask of flags submitted for the edit.
Returns:
string An appropriate autosummary, or an empty string.

Definition at line 3505 of file Article.php.

References $flags, $wgContLang, Title::newFromRedirect(), and wfMsgForContent().

Referenced by doEdit().

Article::getComment (  ) 

Definition at line 670 of file Article.php.

References loadLastEdit().

Article::getContent (  ) 

Note that getContent/loadContent do not follow redirects anymore.

If you need to fetch redirectable content easily, try the shortcut in Article::followContent()

Returns:
Return the text of this revision

Reimplemented in ImagePage.

Definition at line 207 of file Article.php.

References $text, $wgContLang, $wgMessageCache, $wgOut, $wgUser, getID(), loadContent(), wfEmptyMsg(), wfMsgExt(), wfMsgGetKey(), wfProfileIn(), and wfProfileOut().

Referenced by followRedirect(), getUndoText(), insertRedirect(), prepareTextForEdit(), and view().

Article::getContributors ( limit = 0,
offset = 0 
)

Parameters:
$limit Integer: default 0.
$offset Integer: default 0.

Definition at line 690 of file Article.php.

References $dbr, $offset, $res, $sql, $user, Revision::DELETED_USER, getSelectOptions(), getUser(), and wfGetDB().

Referenced by Credits::getContributors().

Article::getCount (  ) 

Returns:
int The view count for the page

Definition at line 564 of file Article.php.

References $dbr, getID(), getSelectOptions(), and wfGetDB().

Article::getDB (  ) 

Get the database which should be used for reads.

Returns:
Database
Deprecated:
  • just call wfGetDB( DB_MASTER ) instead

Definition at line 508 of file Article.php.

References wfDeprecated(), and wfGetDB().

Article::getHiddenCategories (  ) 

Returns a list of hidden categories this page is a member of.

Uses the page_props and categorylinks tables.

Returns:
Array of Title objects

Definition at line 3477 of file Article.php.

References $dbr, $res, $result, $row, Title::makeTitle(), and wfGetDB().

Article::getID (  ) 

Article::getLastNAuthors ( num,
revLatest = 0 
)

Get the last N authors.

Parameters:
$num Integer: number of revisions to get
$revLatest String: the latest rev_id, selected from the master (optional)
Returns:
array Array of authors, duplicates not removed

Definition at line 2340 of file Article.php.

References $db, $res, $row, getSelectOptions(), wfGetDB(), wfProfileIn(), and wfProfileOut().

Article::getLatest (  ) 

Get the page_latest field.

Definition at line 3167 of file Article.php.

References loadPageData().

Referenced by updateRestrictions(), and view().

Article::getMinorEdit (  ) 

Definition at line 675 of file Article.php.

References loadLastEdit().

Article::getOldID (  ) 

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

Definition at line 290 of file Article.php.

References getOldIDFromRequest().

Referenced by isCurrent(), loadContent(), and view().

Article::getOldIDFromRequest (  ) 

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

Returns:
int The old id for the request

Definition at line 302 of file Article.php.

References $wgRequest.

Referenced by getOldID().

Article::getRawText (  ) 

Get the text of the current revision.

No side-effects...

Returns:
Return the text of the current revision

Definition at line 237 of file Article.php.

References $text, and Revision::newFromTitle().

Referenced by doDeleteArticle(), doEdit(), and doPurge().

Article::getRedirectTarget (  ) 

If this page is a redirect, get its target.

The target will be fetched from the redirect table if possible. If this page doesn't have an entry there, call insertRedirect()

Returns:
mixed Title object, or null if this page is not a redirect

Reimplemented in ImagePage.

Definition at line 80 of file Article.php.

References $dbr, $row, getID(), insertRedirect(), Title::makeTitle(), and wfGetDB().

Article::getRevIdFetched (  ) 

Definition at line 681 of file Article.php.

References loadLastEdit().

Referenced by doEdit(), outputWikiText(), and view().

Article::getSection ( text,
section 
)

This function returns the text of a section, specified by a number ($section).

A section is text under a heading like == Heading == or <h1>Heading</h1>, or the first section before any such heading (section 0).

If a section contains subsections, these are also returned.

Parameters:
$text String: text to look in
$section Integer: section number
Returns:
string text of the requested section
Deprecated:

Definition at line 259 of file Article.php.

References $section, $text, and $wgParser.

Article::getSelectOptions ( options = ''  )  [protected]

Get options for all SELECT statements.

Parameters:
$options Array: an optional options array which'll be appended to the default
Returns:
Array: options

Definition at line 520 of file Article.php.

References $options.

Referenced by getContributors(), getCount(), getLastNAuthors(), info(), and pageCountInfo().

Article::getTimestamp (  ) 

Definition at line 652 of file Article.php.

References loadLastEdit(), and wfTimestamp().

Referenced by doEdit(), and Credits::getAuthor().

Article::getTitle (  ) 

get the title object of the article

Definition at line 173 of file Article.php.

Referenced by ImagePage::imageRedirects(), ImagePage::openShowImage(), Credits::othersLink(), and updateRedirectOn().

Article::getTouched (  ) 

Get the page_touched field.

Definition at line 3156 of file Article.php.

References loadPageData().

Article::getUndoText ( Revision undo,
Revision undoafter = null 
)

Get the text that needs to be saved in order to undo all revisions between $undo and $undoafter.

Revisions must belong to the same page, must exist and must not be deleted

Parameters:
$undo Revision
$undoafter Revision Must be an earlier revision than $undo
Returns:
mixed string on success, false on failure

Definition at line 272 of file Article.php.

References getContent(), Revision::getText(), and wfMerge().

Article::getUsedTemplates (  ) 

Return a list of templates used by this article.

Uses the templatelinks table

Returns:
Array of Title objects

Definition at line 3451 of file Article.php.

References $dbr, $res, $result, $row, Title::makeTitle(), and wfGetDB().

Article::getUser (  ) 

Definition at line 660 of file Article.php.

References loadLastEdit().

Referenced by Credits::getAuthor(), and getContributors().

Article::getUserText (  ) 

Definition at line 665 of file Article.php.

References loadLastEdit().

Article::hasViewableContent (  ) 

Check if this page is something we're going to be showing some sort of sensible content for.

If we return false, page views (plain action=view) will return an HTTP 404 response, so spiders and robots can know they're following a bad link.

Returns:
bool

Reimplemented in CategoryPage.

Definition at line 557 of file Article.php.

References exists().

Referenced by view().

static Article::incViewCount ( id  )  [static]

Used to increment the view counter.

Parameters:
$id Integer: article id

Definition at line 3206 of file Article.php.

References $dbw, $res, $row, $wgDBtype, $wgHitcounterUpdateFreq, wfGetDB(), wfProfileIn(), and wfProfileOut().

Referenced by viewUpdates().

Article::info (  ) 

Info about this page Called for ?action=info when $wgAllowPageInfo is on.

Definition at line 3359 of file Article.php.

References $dbr, $msg, $page, $wgAllowPageInfo, $wgLang, $wgOut, $wgUser, getSelectOptions(), pageCountInfo(), wfGetDB(), wfMsg(), wfMsgExt(), wfMsgHtml(), and wfMsgWeirdKey().

Article::insertNewArticle ( text,
summary,
isminor,
watchthis,
suppressRC = false,
comment = false,
bot = false 
)

Article::insertOn ( dbw  ) 

Insert a new empty page record for this article.

This *must* be followed up by creating a revision and running $this->updateToLatest( $rev_id ); or else the record will be left in a funky state. Best if all done inside a transaction.

Parameters:
$dbw Database
Returns:
int The newly created page_id key, or false if the title already existed
Access:
private

Definition at line 1244 of file Article.php.

References $affected, $dbw, wfProfileIn(), wfProfileOut(), and wfRandom().

Referenced by doEdit().

Article::insertRedirect (  ) 

Insert an entry for this page into the redirect table.

Don't call this function directly unless you know what you're doing.

Returns:
Title object

Definition at line 105 of file Article.php.

References $dbw, getContent(), getID(), Title::newFromRedirect(), and wfGetDB().

Referenced by getRedirectTarget().

Article::isBigDeletion (  ) 

Returns:
bool whether or not the page surpasses $wgDeleteRevisionsLimit revisions

Definition at line 2313 of file Article.php.

References $wgDeleteRevisionsLimit, and estimateRevisionCount().

Referenced by delete().

Article::isCountable ( text  ) 

Determine whether a page would be suitable for being counted as an article in the site_stats table based on the title & its content.

Parameters:
$text String: text to analyze
Returns:
bool

Definition at line 589 of file Article.php.

References $text, $wgUseCommaCount, in_string(), and isRedirect().

Referenced by createUpdates(), doDeleteArticle(), and doEdit().

Article::isCurrent (  ) 

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

Returns:
bool

Definition at line 621 of file Article.php.

References exists(), and getOldID().

Referenced by outputWikiText(), and view().

Article::isFileCacheable (  ) 

Check if the page can be cached.

Returns:
bool

Definition at line 3130 of file Article.php.

References getID(), HTMLFileCache::useFileCache(), and wfRunHooks().

Referenced by tryFileCache().

Article::isRedirect ( text = false  ) 

Tests if the article text represents a redirect.

Parameters:
$text String: FIXME
Returns:
bool

Reimplemented in ImagePage.

Definition at line 602 of file Article.php.

References $text, fetchContent(), loadContent(), Title::newFromRedirect(), and Title::newFromRedirectRecurse().

Referenced by insertNewArticle(), isCountable(), showArticle(), and updateArticle().

Article::loadContent (  ) 

Load the revision (including text) into this object.

Definition at line 331 of file Article.php.

References fetchContent(), getOldID(), wfProfileIn(), and wfProfileOut().

Referenced by getContent(), and isRedirect().

Article::loadLastEdit (  )  [protected]

Loads everything except the text This isn't necessary for all uses, so it's only done if needed.

Definition at line 633 of file Article.php.

References getID(), Revision::loadFromPageId(), and wfGetDB().

Referenced by getComment(), getMinorEdit(), getRevIdFetched(), getTimestamp(), getUser(), and getUserText().

Article::loadPageData ( data = 'fromdb'  ) 

Set the general counter, title etc data loaded from some source.

Parameters:
$data Database row object or "fromdb"

Definition at line 398 of file Article.php.

References $dbr, pageDataFromId(), LinkCache::singleton(), wfGetDB(), and wfTimestamp().

Referenced by checkTouched(), doEdit(), fetchContent(), getLatest(), getTouched(), and view().

Article::markpatrolled (  ) 

Mark this particular edit/page as patrolled.

Definition at line 1816 of file Article.php.

References $dbw, $wgOut, $wgRequest, $wgUseNPPatrol, $wgUser, $wgUseRCPatrol, SpecialPage::getTitleFor(), RecentChange::newFromId(), wfGetDB(), and wfMsg().

static Article::newFromID ( id  )  [static]

Constructor from an article article.

Parameters:
$id The article ID to load

Definition at line 59 of file Article.php.

References $t.

static Article::onArticleCreate ( title  )  [static]

#@+ The onArticle*() functions are supposed to be a kind of hooks which should be called whenever any of the specified actions are done.

This is a good place to put code to clear caches, for instance.

This is called on page move and undelete, as well as edit

Parameters:
$title a title object

Definition at line 3275 of file Article.php.

References $title.

Referenced by doEdit(), WikiRevision::importOldRevision(), Title::moveToNewTitle(), and PageArchive::undeleteRevisions().

static Article::onArticleDelete ( title  )  [static]

static Article::onArticleEdit ( title,
flags = '' 
) [static]

Purge caches on page update etc.

Definition at line 3328 of file Article.php.

References $title, $wgDeferredUpdateList, and HTMLFileCache::clearFileCache().

Referenced by doEdit(), WikiRevision::importOldRevision(), and PageArchive::undeleteRevisions().

Article::outputWikiText ( text,
cache = true 
)

Add the primary page-view wikitext to the output buffer Saves the text into the parser cache if possible.

Updates templatelinks if it is out of date.

Parameters:
$text String
$cache Boolean

Definition at line 3550 of file Article.php.

References $dbr, $key, $ns, $res, $row, $text, $u, $wgContLang, $wgEnableParserCache, $wgOut, $wgParser, $wgUseFileCache, $wgUser, getRevIdFetched(), isCurrent(), ParserCache::singleton(), wfGetDB(), and wfReadOnly().

Referenced by view().

Article::pageCountInfo ( title  )  [protected]

Return the total number of edits and number of unique editors on a given page.

If page does not exist, returns false.

Parameters:
$title Title object
Returns:
array

Definition at line 3421 of file Article.php.

References $dbr, $title, getSelectOptions(), and wfGetDB().

Referenced by info().

Article::pageData ( dbr,
conditions 
) [protected]

Fetch a page record with the given conditions.

Parameters:
$dbr Database object
$conditions Array

Definition at line 349 of file Article.php.

References $dbr, $fields, $row, and wfRunHooks().

Referenced by pageDataFromId(), and pageDataFromTitle().

Article::pageDataFromId ( dbr,
id 
) [protected]

Parameters:
$dbr Database
$id Integer

Definition at line 388 of file Article.php.

References $dbr, and pageData().

Referenced by fetchContent(), and loadPageData().

Article::pageDataFromTitle ( dbr,
title 
)

Parameters:
$dbr Database object
$title Title object

Definition at line 378 of file Article.php.

References $dbr, $title, and pageData().

Referenced by fetchContent().

Article::prepareTextForEdit ( text,
revid = null 
)

Prepare text which is about to be saved.

Returns a stdclass with source, pst and output members

Definition at line 2874 of file Article.php.

References $options, $text, $wgParser, getContent(), and preSaveTransform().

Referenced by doEdit(), and editUpdates().

Article::preSaveTransform ( text  ) 

This function is called right before saving the wikitext, so we can do things like signatures and links-in-context.

Parameters:
$text String

Definition at line 3091 of file Article.php.

References $text, $wgParser, $wgUser, and ParserOptions::newFromUser().

Referenced by prepareTextForEdit().

Article::protect (  ) 

action=protect handler

Definition at line 1941 of file Article.php.

Referenced by unprotect().

Article::purge (  ) 

Handle action=purge.

Definition at line 1184 of file Article.php.

References $action, $wgOut, $wgRequest, $wgUser, doPurge(), view(), wfMsgExt(), and wfRunHooks().

Article::quickEdit ( text,
comment = '',
minor = 0 
)

Edit an article without doing all that other stuff The article must already exist; link tables etc are not updated, caches are not flushed.

Parameters:
$text String: text submitted
$comment String: comment submitted
$minor Boolean: whereas it's a minor modification

Definition at line 3183 of file Article.php.

References $dbw, $minor, $revision, $text, $wgUser, updateRevisionOn(), wfGetDB(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

Article::render (  ) 

Reimplemented in ImagePage.

Definition at line 1175 of file Article.php.

References $wgOut, and view().

Article::replaceSection ( section,
text,
summary = '',
edittime = NULL 
)

Parameters:
$section empty/null/false or a section number (0, 1, 2, T1, T2...)
Returns:
string Complete article text, or null if error

Definition at line 1395 of file Article.php.

References $dbw, $section, $summary, $text, $wgParser, Revision::loadFromTimestamp(), Revision::newFromTitle(), wfDebug(), wfGetDB(), wfMsgForContent(), wfProfileIn(), and wfProfileOut().

Article::revert (  ) 

#@-

Overriden by ImagePage class, only present here to avoid a fatal error Called for ?action=revert

Reimplemented in ImagePage.

Definition at line 3350 of file Article.php.

References $wgOut.

Article::rollback (  ) 

User interface for rollback operations.

Definition at line 2786 of file Article.php.

References $error, $out, $result, $wgOut, $wgRequest, $wgUser, $wgUseRCPatrol, doRollback(), wfMsg(), and wfMsgExt().

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:
$oldid String: revision ID of this article revision

Definition at line 3016 of file Article.php.

References $revision, $wgLang, $wgOut, $wgRequest, $wgUser, Revision::DELETED_RESTRICTED, SpecialPage::getTitleFor(), Revision::newFromId(), wfEmptyMsg(), wfMsg(), wfMsgExt(), wfMsgHtml(), and wfRunHooks().

Referenced by view().

Article::setRedirectedFrom ( from  ) 

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

Parameters:
$from Title object.

Definition at line 69 of file Article.php.

Article::showArticle ( text,
subtitle,
sectionanchor = '',
me2,
now,
summary,
oldid 
)

Deprecated:
wrapper for doRedirect

Definition at line 1788 of file Article.php.

References $text, doRedirect(), isRedirect(), and wfDeprecated().

Article::showDeletionLog (  )  [protected]

Definition at line 1044 of file Article.php.

References $wgOut, $wgUser, LogEventsList::endLogEventsList(), SpecialPage::getTitleFor(), and wfMsgHtml().

Referenced by view().

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)

Definition at line 3103 of file Article.php.

References isFileCacheable(), and wfDebug().

Referenced by view().

Article::unprotect (  ) 

action=unprotect handler (alias)

Definition at line 1949 of file Article.php.

References protect().

Article::unwatch (  ) 

User interface handler for the "unwatch" action.

Definition at line 1904 of file Article.php.

References $wgOut, $wgUser, doUnwatch(), wfMsg(), and wfReadOnly().

Article::updateArticle ( text,
summary,
minor,
watchthis,
forceBot = false,
sectionanchor = '' 
)

Article::updateCategoryCounts ( added,
deleted 
)

Update all the appropriate counts in the category table, given that we've added the categories $added and deleted the categories $deleted.

Parameters:
$added array The names of categories that were added
$deleted array The names of categories that were deleted
Returns:
null

Definition at line 3626 of file Article.php.

References $added, $dbw, $ns, and wfGetDB().

Referenced by doDeleteArticle().

Article::updateIfNewerOn ( &$  dbw,
revision 
)

If the given revision is newer than the currently set page_latest, update the page record.

Otherwise, do nothing.

Parameters:
$dbw Database object
$revision Revision object

Definition at line 1365 of file Article.php.

References $dbw, $revision, $row, updateRevisionOn(), wfProfileIn(), wfProfileOut(), and wfTimestamp().

Article::updateRedirectOn ( &$  dbw,
redirectTitle,
lastRevIsRedirect = null 
)

Add row to the redirect table if this is a redirect, remove otherwise.

Parameters:
$dbw Database
$redirectTitle a title object pointing to the redirect target, or NULL if this is not a redirect
$lastRevIsRedirect If given, will optimize adding and removing rows in redirect table.
Returns:
bool true on success, false on failure
Access:
private

Definition at line 1329 of file Article.php.

References $dbw, getTitle(), RepoGroup::singleton(), wfProfileIn(), and wfProfileOut().

Referenced by updateRevisionOn().

Article::updateRestrictions ( limit = array(),
reason = '',
&$  cascade = 0,
expiry = array() 
)

Update the article's restriction field, and leave a log entry.

Parameters:
$limit Array: set of restriction keys
$reason String
&$cascade Integer. Set to false if cascading protection isn't allowed.
$expiry Array: per restriction type expiration
Returns:
bool true on success

Definition at line 1962 of file Article.php.

References $action, $changed, $dbw, $reason, $wgContLang, $wgRestrictionTypes, $wgUser, Block::encodeExpiry(), flattenRestrictions(), getLatest(), Revision::newNullRevision(), Title::purgeExpiredRestrictions(), wfDebug(), wfGetDB(), wfMsgForContent(), wfReadOnly(), and wfRunHooks().

Article::updateRevisionOn ( &$  dbw,
revision,
lastRevision = null,
lastRevIsRedirect = null 
)

Update the page record to point to a newly saved revision.

Parameters:
$dbw Database object
$revision Revision: For ID number, and text used to set length and redirect status fields
$lastRevision Integer: if given, will not overwrite the page field when different from the currently set value. Giving 0 indicates the new page flag should be set on.
$lastRevIsRedirect Boolean: if given, will optimize adding and removing rows in redirect table.
Returns:
bool true on success, false on failure
Access:
private

Definition at line 1286 of file Article.php.

References $dbw, $result, $revision, $text, Title::newFromRedirect(), updateRedirectOn(), wfProfileIn(), and wfProfileOut().

Referenced by doEdit(), quickEdit(), and updateIfNewerOn().

Article::useParserCache ( oldid  )  [protected]

Definition at line 1072 of file Article.php.

References $wgEnableParserCache, $wgUser, and exists().

Referenced by view().

Article::view (  ) 

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

View redirect.

Parameters:
$target Title object or Array of destination(s) to redirect
$appendSubtitle Boolean [optional]
$forceKnown Boolean: should the image be shown as a bluelink regardless of existence?

Definition at line 1089 of file Article.php.

References $title, $wgContLang, $wgOut, $wgParser, $wgStylePath, $wgUser, and wfMsgHtml().

Referenced by ImagePage::view(), and view().

Article::viewUpdates (  ) 

Do standard deferred updates after page view.

Definition at line 2858 of file Article.php.

References $u, $wgDeferredUpdateList, $wgDisableCounters, $wgUser, getID(), and incViewCount().

Referenced by ImagePage::view(), and view().

Article::watch (  ) 

User-interface handler for the "watch" action.

Definition at line 1867 of file Article.php.

References $wgOut, $wgUser, doWatch(), wfMsg(), and wfReadOnly().


Member Data Documentation

Article::$mComment = ''

{

Access:
private

Definition at line 19 of file Article.php.

Article::$mContent

{

Access:
private

Definition at line 20 of file Article.php.

Article::$mContentLoaded = false

{

Access:
private

Definition at line 21 of file Article.php.

Article::$mCounter = -1

Not loaded.

Definition at line 22 of file Article.php.

Article::$mCurID = -1

Not loaded.

Definition at line 23 of file Article.php.

Article::$mDataLoaded = false

{

Access:
private

Definition at line 24 of file Article.php.

Article::$mForUpdate = false

{

Access:
private

Definition at line 25 of file Article.php.

Article::$mGoodAdjustment = 0

{

Access:
private

Definition at line 26 of file Article.php.

Article::$mIsRedirect = false

{

Access:
private

Definition at line 27 of file Article.php.

Article::$mLatest = false

{

Access:
private

Definition at line 28 of file Article.php.

Article::$mMinorEdit

{

Access:
private

Definition at line 29 of file Article.php.

Article::$mOldId

{

Access:
private

Definition at line 30 of file Article.php.

Article::$mPreparedEdit = false

Title object if set.

Definition at line 31 of file Article.php.

Article::$mRedirectedFrom = null

Title object if set.

Definition at line 32 of file Article.php.

Article::$mRedirectTarget = null

Title object if set.

Definition at line 33 of file Article.php.

Article::$mRedirectUrl = false

{

Access:
private

Definition at line 34 of file Article.php.

Article::$mRevIdFetched = 0

{

Access:
private

Definition at line 35 of file Article.php.

Article::$mRevision

{

Access:
private

Definition at line 36 of file Article.php.

Article::$mTimestamp = ''

{

Access:
private

Definition at line 37 of file Article.php.

Article::$mTitle

{

Access:
private

Definition at line 38 of file Article.php.

Article::$mTotalAdjustment = 0

{

Access:
private

Definition at line 39 of file Article.php.

Article::$mTouched = '19700101000000'

{

Access:
private

Definition at line 40 of file Article.php.

Article::$mUser = -1

Not loaded.

Definition at line 41 of file Article.php.

Article::$mUserText = ''

{

Access:
private

Definition at line 42 of file Article.php.


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

Generated on Sat Sep 5 02:08:33 2009 for MediaWiki by  doxygen 1.5.9