Jump to content

Manual:WatchedItemStore.php

From mediawiki.org
This page is a translated version of the page Manual:WatchedItemStore.php and the translation is 19% complete.

WatchedItemStore は、ウォッチリスト関連の関数向けのデータベースとの対話を処理する MediaWiki クラスです。 コアの他の部分のウォッチリストのコードは、このクラスの関数のラッパーとして機能します。

メンバー関数

  • countWatchedItems() - Count the number of individual items that are watched by the user. Counts subject and talk page separately.
  • countWatchers() - Count number of watchers for a given page.
  • countWatchersMultiple() - Count number of watchers for a given array of pages. Returns an array with watchers for each page.
  • countVisitingWatchers() - Number of watchers who have visited a recent edit of a page.
  • countVisitingWatchersMultiple() - Number of watchers of each page (from a given set of pages) who have visited recent edits to that page.
  • getNotificationTimestamp() - Retrieve the notification timestamp for an entry on the watchlist for a given user and page.
  • getNotificationTimestampsBatch() - Retrieve the notification timestamps for an array of given entries.
  • getWatchedItem() - Get a WatchedItem object for given user and LinkTarget object.
  • getWatchedItemsForUser() - Get all WatchedItems for a given user.
  • isWatched() - Check if a page is watched. Separate for subject and talk pages.
  • loadWatchedItem() - Loads a WatchedItem from DB with given user and LinkTarget values.
  • removeWatch() - Remove page from watchlist, given a user and LinkTarget.
  • resetNotificationTimestamp() - Reset notification timestamp for given user and page.
  • setNotificationTimestampsForUser() - Set a notification timestamp for given user and page.
  • updateNotificationTimestamp() - Update notification timestamp for given LinkTarget object. Accepts the editor user object to not update timestamp for them.
This list only covers the major functions. For a more complete list, refer to this auto-generated documentation page.

使用例

// Get notification timestamp for a watched item
use MediaWiki\MediaWikiServices;
$item = MediaWikiServices::getInstance()->getWatchedItemStore()->loadWatchedItem( $this->user, $this->linkTarget );
$this->notificationTimestamp = $item->getNotificationTimestamp();
// Count watched items for a given user
use MediaWiki\MediaWikiServices;
$store = MediaWikiServices::getInstance()->getWatchedItemStore();
$count = $store->countWatchedItems( $this->getUser() );