Movatterモバイル変換


[0]ホーム

URL:


Jump to content
MediaWiki
Search

Manual:WikiPage.php

From mediawiki.org
Translate this page
Languages:
MediaWiki file: WikiPage.php
Location:includes/page/
Source code:master1.44.01.43.31.39.13
Classes:MediaWiki\Page\WikiPage • Page

TheWikiPage 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 theArticle class handles the business and presentation functions.

Accessing a WikiPage object

[edit]

Creating a new WikiPage object

[edit]

Use aWikiPageFactory to create new WikiPage objects.

Public methods

[edit]
  • getContent( $audience ): Get the content of the latest revision, where $audience is one of:
    1. RevisionRecord::FOR_PUBLIC - to be displayed to all users
    2. RevisionRecord::FOR_THIS_USER - to be displayed to$wgUser
    3. RevisionRecord::RAW - get the text regardless of permissions
  • If the ContentHandler supports it, you can do something like the following to get the text of the latest revision in the main slot:
$text=$wikiPage->getContent(RevisionRecord::RAW)->getText();
  • convertSelectType() - convert 'fromdb', 'fromdbmaster' and 'forupdate' to READ_* constants.
  • getActionOverrides() - compare: ContentHandler::getActionOverrides()
  • clear() - clear object.
  • clearPreparedEdit()
  • pageDataFromTitle() - fetch a page record matching the Title object's namespace and title using a sanitized title string
  • pageDataFromId()
  • loadPageData() - load from a given source by title
  • wasLoadedFrom() - check if page data was loaded
  • loadFromRow() - load object from database row
  • exists() - check if given page exists
  • canExist()
  • hasViewableContent()
  • isNew() - check if the page has only one revision
  • checkTouched() - check if page exists and is not a redirect. Loadspage_touched
  • isSamePageAs()

Accessors and checks

[edit]
  • getId() - get thepage ID
  • getTitle() - Get theTitle object of the article.
  • get data from the Title object:
    • getNamespace() - returns an integer
    • getDBkey()
    • getWikiId()
  • getLanguage() - get language code for the page
  • getContentHandler() - returnContentHandler instance to be used to deal with the content of this WikiPage.
  • getContentModel() - return the page's content model id (see the CONTENT_MODEL_XXX constants).
  • getRevisionRecord() - get latestRevisionRecord
  • getContent() - get the content of the current revision.
  • Get data from thepage table
    • getQueryInfo() - return the tables, fields, and join conditions to be selected to create a new page object.
    • getTouched() - get thepage_touched field
    • getLinksTimestamp() - getpage_links_updated field
    • getLatest() - getpage_latest field
    • getPageIsRedirectField() - see below
  • getTimestamp() - get timestamp of latest revision. See also setTimestamp().
  • Relating to contributing users:
    • getContributors() - get a list of users who have edited this article, excluding the user who made the last article revision
    • getUser() - get User ID of the user who made the last article revision.
    • getCreator() - get User ID of the user who created the page
  • getUserText()
  • getComment()
  • getMinorEdit()
  • isCountable()
  • Relating tocategories
    • getCategories() - get a list of categories this page is a member of.
    • getHiddenCategories()
  • Relating toredirects
    • isRedirect()
    • getPageIsRedirectField() - get the value of thepage_is_redirect field in the database
    • followRedirect() - get the Title object or URL this page redirects to.
    • getRedirectURL()
  • Relating to parsing:
    • getParserOutput() - get aParserOutput for the given ParserOptions and revision ID.
    • shouldCheckParserCache()
  • Relating to the possibility of non-local databases
    • isLocal() - check if content shown on this page comes from the local DB.
    • getWikiDisplayName()
    • getSourceURL()
  • getMutableCacheKeys()

Setters, page actions and checks

[edit]
  • setTimestamp()
  • Relating toredirects:
    • insertRedirect()
    • insertRedirectEntry()
  • doViewUpdates()
  • doPurge() - run the actions ofpurging a page.
  • insertOn() - insert a new empty page record for this article. Must be followed up by creating a revision and running $this->updateRevisionOn().
  • updateRevisionOn() - update the page record to point to a newly saved revision.
  • Relating to page sections:
    • supportsSections()
    • replaceSectionAtRev()
  • newPageUpdater() - returnPageUpdater for creating the page or creating new page revisions.
    • makeParserOptions() - getparser options suitable for rendering the primary article wikitext.
  • updateParserCache() - update the parser cache. Likely to become deprecated.
  • doSecondaryDataUpdates() - likely to become deprecated.
  • doUpdateRestrictions() - update the article's restriction field, and leave a log entry. This works for protection both existing and non-existing pages.
  • getCurrentUpdate() - get the state of an ongoing update, shortly before or just after it is saved to the database (since 1.38). Generally to be avoided.
  • Relating to page protection:
    • insertNullProtectionRevision() - insert a newnull/dummy revision for this page.
    • protectDescription() - build the description to serve as comment for the edit.
    • protectDescriptionLog() - build the description to serve as comment for the log entry.
  • lockAndGetLatest() - Lock the page row for this title, namespace and id and returnpage_latest (or 0).
  • getAutoDeleteReason() - auto-generates a deletion reason
  • updateCategoryCounts() - should only be called from deferred updates or jobs to avoid contention.
  • toPageRecord() - get the page represented by this WikiPage as aPageStoreRecord.
  • magic methods: __clone(), __wakeup(), __toString()

Hook-like methods

[edit]
  • onArticleCreate(), onArticleDelete() and onArticleEdit()

Deprecated methods

[edit]
  • factory(), newFromID() and newFromRow() - methods for creating a WikiPage object - have been deprecated in favour of methods provided byWikiPageFactory.
  • getRedirectTarget()
  • replaceSectionContent()
  • checkFlags()
  • doUserEditContent()
  • doEditUpdates()
  • doDeleteArticleReal()
  • doDeleteArticleBatched()
  • doDeleteUpdates()
  • getDeletionUpdates()
  • hasDifferencesOutsideMainSlot()
  • prepareContentForEdit() -prepare the content which is about to be saved.
  • isBatchedDelete() - checks if deletion of this page would be batched. See now DeletePage::isBatchedDelete().

Seewmdoc:mediawiki-core/master/php/classWikiPage.html for a complete list of methods.

See also

[edit]
Retrieved from "https://www.mediawiki.org/w/index.php?title=Manual:WikiPage.php&oldid=7637344"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp