MediaWiki  master
WatchedItem Class Reference

Representation of a pair of user and title for watchlist entries. More...

Collaboration diagram for WatchedItem:

Public Member Functions

 __construct (UserIdentity $user, LinkTarget $linkTarget, $notificationTimestamp, ?string $expiry=null)
 
 getExpiry (?int $style=TS_MW)
 When the watched item will expire. More...
 
 getExpiryInDays ()
 Get days remaining until a watched item expires. More...
 
 getExpiryInDaysText (MessageLocalizer $msgLocalizer, $isDropdownOption=false)
 Get days remaining until a watched item expires as a text. More...
 
 getLinkTarget ()
 
 getNotificationTimestamp ()
 Get the notification timestamp of this entry. More...
 
 getUser ()
 
 getUserIdentity ()
 
 isExpired ()
 Has the watched item expired? More...
 

Static Public Member Functions

static calculateExpiryInDays (?string $expiry)
 Get the number of days remaining until the given expiry time. More...
 
static newFromRecentChange (RecentChange $recentChange, UserIdentity $user)
 

Private Attributes

ConvertibleTimestamp null $expiry
 value that determines when a watched item will expire. More...
 
LinkTarget $linkTarget
 
null string $notificationTimestamp
 the value of the wl_notificationtimestamp field More...
 
UserIdentity $user
 
const SECONDS_IN_A_DAY = 86400
 Used to calculate how many days are remaining until a watched item will expire. More...
 

Detailed Description

Representation of a pair of user and title for watchlist entries.

Author
Tim Starling
Addshore

Definition at line 35 of file WatchedItem.php.

Constructor & Destructor Documentation

◆ __construct()

WatchedItem::__construct ( UserIdentity  $user,
LinkTarget  $linkTarget,
  $notificationTimestamp,
?string  $expiry = null 
)
Parameters
UserIdentity$user
LinkTarget$linkTarget
null | string$notificationTimestampthe value of the wl_notificationtimestamp field
null | string$expiryOptional expiry timestamp in any format acceptable to wfTimestamp()

Definition at line 72 of file WatchedItem.php.

References $expiry, $linkTarget, $notificationTimestamp, and $user.

Member Function Documentation

◆ calculateExpiryInDays()

static WatchedItem::calculateExpiryInDays ( ?string  $expiry)
static

Get the number of days remaining until the given expiry time.

Since
1.35
Parameters
string | null$expiryThe expiry to calculate from, in any format supported by MWTimestamp::convert().
Returns
int|null The remaining number of days or null if $expiry is null.

Definition at line 187 of file WatchedItem.php.

References $expiry, SECONDS_IN_A_DAY, and wfTimestamp().

Referenced by getExpiryInDays(), and WatchAction\onSuccess().

◆ getExpiry()

WatchedItem::getExpiry ( ?int  $style = TS_MW)

When the watched item will expire.

Since
1.35
Parameters
int | null$styleGiven timestamp format to style the ConvertibleTimestamp
Returns
string|null null or in a format acceptable to ConvertibleTimestamp (TS_* constants). Default is TS_MW format.

Definition at line 145 of file WatchedItem.php.

References $expiry.

Referenced by getExpiryInDays(), WatchAction\getExpiryOptions(), isExpired(), SpecialWatchlist\outputChangesList(), and Linker\tooltipAndAccesskeyAttribs().

◆ getExpiryInDays()

WatchedItem::getExpiryInDays ( )

Get days remaining until a watched item expires.

Since
1.35
Returns
int|null days remaining or null if no expiration is present

Definition at line 173 of file WatchedItem.php.

References calculateExpiryInDays(), and getExpiry().

Referenced by getExpiryInDaysText().

◆ getExpiryInDaysText()

WatchedItem::getExpiryInDaysText ( MessageLocalizer  $msgLocalizer,
  $isDropdownOption = false 
)

Get days remaining until a watched item expires as a text.

Since
1.35
Parameters
MessageLocalizer$msgLocalizer
bool$isDropdownOptionWhether the text is being displayed as a dropdown option. The text is different as a dropdown option from when it is used in other places as a watchlist indicator.
Returns
string days remaining text and '' if no expiration is present

Definition at line 213 of file WatchedItem.php.

References getExpiryInDays(), and MessageLocalizer\msg().

Referenced by WatchAction\getExpiryOptions().

◆ getLinkTarget()

WatchedItem::getLinkTarget ( )
Returns
LinkTarget

Definition at line 124 of file WatchedItem.php.

References $linkTarget.

Referenced by WatchedItemStore\cache(), ApiQueryWatchlist\extractOutputData(), and ApiQueryWatchlist\run().

◆ getNotificationTimestamp()

WatchedItem::getNotificationTimestamp ( )

Get the notification timestamp of this entry.

Returns
bool|null|string

Definition at line 133 of file WatchedItem.php.

References $notificationTimestamp.

Referenced by ApiQueryWatchlist\extractOutputData().

◆ getUser()

WatchedItem::getUser ( )
Deprecated:
since 1.34, use getUserIdentity()
Returns
User

Definition at line 110 of file WatchedItem.php.

References User\newFromIdentity().

◆ getUserIdentity()

WatchedItem::getUserIdentity ( )
Returns
UserIdentity

Definition at line 117 of file WatchedItem.php.

References $user.

Referenced by WatchedItemStore\cache().

◆ isExpired()

WatchedItem::isExpired ( )

Has the watched item expired?

Since
1.35
Returns
bool

Definition at line 158 of file WatchedItem.php.

References $expiry, and getExpiry().

◆ newFromRecentChange()

static WatchedItem::newFromRecentChange ( RecentChange  $recentChange,
UserIdentity  $user 
)
static
Since
1.35
Parameters
RecentChange$recentChange
UserIdentity$user
Returns
WatchedItem

Definition at line 97 of file WatchedItem.php.

References $user, and RecentChange\getTitle().

Referenced by ChangesList\getWatchlistExpiry().

Member Data Documentation

◆ $expiry

ConvertibleTimestamp null WatchedItem::$expiry
private

value that determines when a watched item will expire.

'null' means that there is no expiration.

Definition at line 55 of file WatchedItem.php.

Referenced by __construct(), calculateExpiryInDays(), getExpiry(), and isExpired().

◆ $linkTarget

LinkTarget WatchedItem::$linkTarget
private

Definition at line 39 of file WatchedItem.php.

Referenced by __construct(), and getLinkTarget().

◆ $notificationTimestamp

null string WatchedItem::$notificationTimestamp
private

the value of the wl_notificationtimestamp field

Definition at line 49 of file WatchedItem.php.

Referenced by __construct(), and getNotificationTimestamp().

◆ $user

UserIdentity WatchedItem::$user
private

Definition at line 44 of file WatchedItem.php.

Referenced by __construct(), getUserIdentity(), and newFromRecentChange().

◆ SECONDS_IN_A_DAY

const WatchedItem::SECONDS_IN_A_DAY = 86400
private

Used to calculate how many days are remaining until a watched item will expire.

Uses a different algorithm from Language::getDurationIntervals for calculating days remaining in an interval of time

Since
1.35

Definition at line 64 of file WatchedItem.php.

Referenced by calculateExpiryInDays().


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