Manual:WatchedItemStore.php

From Linux Web Expert

Revision as of 05:23, 6 December 2023 by imported>FuzzyBot (Updating to match new version of source page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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