79 parent::__construct( $article,
$context );
81 if ( $this->watchlistExpiry ) {
88 $this->watchlistManager = $watchlistManager;
89 $this->userOptionsLookup = $userOptionsLookup;
111 $result = $this->watchlistManager->setWatch(
115 $this->
getRequest()->getVal(
'wp' . $this->expiryFormFieldName )
118 return Status::wrap( $result );
134 parent::checkCanExecute( $user );
139 return 'editmywatchlist';
150 if ( !$this->watchlistExpiry ) {
155 'default' => $this->
msg(
'confirm-watch-top' )->parse(),
162 $default = $this->userOptionsLookup->getOption( $this->
getUser(),
'watchstar-expiry' );
163 $expiryOptions = static::getExpiryOptions( $this->
getContext(), $this->watchedItem, $default );
165 $this->expiryFormFieldName => [
167 'label-message' =>
'confirm-watch-label',
168 'options' => $expiryOptions[
'options'],
169 'default' => $expiryOptions[
'default'],
189 string $defaultExpiry =
'infinite'
193 if ( !in_array( $defaultExpiry, $expiryOptions ) ) {
194 $expiryOptions = array_merge( [ $defaultExpiry => $defaultExpiry ], $expiryOptions );
201 $expiryOptions = array_merge( [ $daysLeft => $currentExpiry ], $expiryOptions );
204 $defaultExpiry = $currentExpiry;
208 'options' => $expiryOptions,
209 'default' => $defaultExpiry,
225 $expiryOptionsMsg = $msgLocalizer->
msg(
'watchlist-expiry-options' );
226 $optionsText = !$lang ? $expiryOptionsMsg->text() : $expiryOptionsMsg->inLanguage( $lang )->text();
232 foreach ( $options as $label => $value ) {
234 $expiryOptions[$label] = $value;
240 if ( !$expiryOptions && $expiryOptionsMsg->getLanguage()->getCode() !==
'en' ) {
244 return $expiryOptions;
248 $msg = $this->watchlistExpiry && $this->watchedItem ?
'updatewatchlist' :
'addwatch';
250 $submitMsg = $this->watchlistExpiry ?
'confirm-watch-button-expiry' :
'confirm-watch-button';
268 $submittedExpiry = $this->getContext()->getRequest()->getText(
'wp' . $this->expiryFormFieldName );
269 $this->getOutput()->addWikiMsg( $this->makeSuccessMessage( $submittedExpiry ) );
273 $msgKey = $this->
getTitle()->isTalkPage() ?
'addedwatchtext-talk' :
'addedwatchtext';
275 if ( $submittedExpiry ) {
282 $defaultLabels = static::getExpiryOptionsFromMessage( $this->getContext() );
283 $localizedExpiry = array_search( $submittedExpiry, $defaultLabels );
287 $isTalk = $this->
getTitle()->isTalkPage();
289 $msgKey = $isTalk ?
'addedwatchindefinitelytext-talk' :
'addedwatchindefinitelytext';
290 } elseif ( $expiryDays >= 1 ) {
291 $msgKey = $isTalk ?
'addedwatchexpirytext-talk' :
'addedwatchexpirytext';
292 $params[] = $localizedExpiry ===
false
293 ? $this->getContext()->msg(
'days', $expiryDays )->text()
297 $msgKey = $isTalk ?
'addedwatchexpiryhours-talk' :
'addedwatchexpiryhours';
310class_alias( WatchAction::class,
'WatchAction' );
wfIsInfinity( $str)
Determine input string is represents as infinity.
A class containing constants representing the names of configuration variables.
const WatchlistExpiry
Name constant for the WatchlistExpiry setting, for use with Config::get()
Legacy class representing an editable page and handling UI for some page actions.
Interface for objects which can provide a MediaWiki context on request.
Interface for localizing messages in MediaWiki.