Manual:WikiPage.php

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page Manual:WikiPage.php and the translation is 48% complete.

Other languages:
English • ‎dansk • ‎español • ‎polski • ‎português do Brasil • ‎中文 • ‎日本語

WikiPage クラスは、MediaWiki のページとその履歴を表現します。 It encapsulates access to page information stored in the database, and allows access to properties such as page text (in Wikitext format), flags, etc.

In theory, WikiPage is supposed to be the model object for pages, while the Article class handles the business and presentation functions. If you have an Article object, you can get a WikiPage object using Article::getPage().

WikiPageオブジェクトの作成

To instantiate WikiPage, call one of the static factory methods:

  • WikiPage::factory( $title ) - $title は Title のインスタンス
  • WikiPage::newFromId( $id ) - $id はページ ID
  • WikiPage::newFromRow( $row ), where $row is a row fetched from the database containing all the fields listed in WikiPage::selectFields().

メソッド

  • getText( $audience ): Get the text of the latest revision, where $audience is one of:
    1. Revision::FOR_PUBLIC - to be displayed to all users
    2. Revision::FOR_THIS_USER - to be displayed to $wgUser
    3. Revision::RAW - get the text regardless of permissions
  • getRawText() - Get the raw text of the latest revision.
  • v1.21 時点で、これらの関数は廃止予定になりました。代わりに以下を使用してください:
$revision = $wikiPage->getRevision();
$content = $revision->getContent( Revision::RAW );
$text = ContentHandler::getContentText( $content );
  • ...

メソッドの完全な一覧については https://doc.wikimedia.org/mediawiki-core/master/php/classWikiPage.html を参照してください。

Accessors

  • getTitle() - Get the title object of the article.

関連項目