3 * Implements Special:Watchlist
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
24 use MediaWiki\MediaWikiServices
;
25 use Wikimedia\Rdbms\IResultWrapper
;
26 use Wikimedia\Rdbms\IDatabase
;
29 * A special page that lists last changes made to the wiki,
30 * limited to user-defined list of titles.
32 * @ingroup SpecialPage
34 class SpecialWatchlist
extends ChangesListSpecialPage
{
35 protected static $savedQueriesPreferenceName = 'rcfilters-wl-saved-queries';
36 protected static $daysPreferenceName = 'watchlistdays';
37 protected static $limitPreferenceName = 'wllimit';
38 protected static $collapsedPreferenceName = 'rcfilters-wl-collapsed';
42 /** WatchedItemStore */
45 public function __construct( $page = 'Watchlist', $restriction = 'viewmywatchlist' ) {
46 parent
::__construct( $page, $restriction );
48 $this->maxDays
= $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 );
49 $this->watchStore
= MediaWikiServices
::getInstance()->getWatchedItemStore();
52 public function doesWrites() {
57 * Main execution point
59 * @param string $subpage
61 function execute( $subpage ) {
62 // Anons don't get a watchlist
63 $this->requireLogin( 'watchlistanontext' );
65 $output = $this->getOutput();
66 $request = $this->getRequest();
67 $this->addHelpLink( 'Help:Watching pages' );
68 $output->addModuleStyles( [ 'mediawiki.special' ] );
69 $output->addModules( [
70 'mediawiki.special.recentchanges',
71 'mediawiki.special.watchlist',
74 $mode = SpecialEditWatchlist
::getMode( $request, $subpage );
75 if ( $mode !== false ) {
76 if ( $mode === SpecialEditWatchlist
::EDIT_RAW
) {
77 $title = SpecialPage
::getTitleFor( 'EditWatchlist', 'raw' );
78 } elseif ( $mode === SpecialEditWatchlist
::EDIT_CLEAR
) {
79 $title = SpecialPage
::getTitleFor( 'EditWatchlist', 'clear' );
81 $title = SpecialPage
::getTitleFor( 'EditWatchlist' );
84 $output->redirect( $title->getLocalURL() );
89 $this->checkPermissions();
91 $user = $this->getUser();
92 $opts = $this->getOptions();
94 $config = $this->getConfig();
95 if ( ( $config->get( 'EnotifWatchlist' ) ||
$config->get( 'ShowUpdatedMarker' ) )
96 && $request->getVal( 'reset' )
97 && $request->wasPosted()
98 && $user->matchEditToken( $request->getVal( 'token' ) )
100 $user->clearAllNotifications();
101 $output->redirect( $this->getPageTitle()->getFullURL( $opts->getChangedValues() ) );
106 parent
::execute( $subpage );
108 if ( $this->isStructuredFilterUiEnabled() ) {
109 $output->addModuleStyles( [ 'mediawiki.rcfilters.highlightCircles.seenunseen.styles' ] );
114 * @see ChangesListSpecialPage::checkStructuredFilterUiEnabled
116 public static function checkStructuredFilterUiEnabled( $user ) {
117 if ( $user instanceof Config
) {
118 wfDeprecated( __METHOD__
. ' with Config argument', '1.34' );
119 $user = func_get_arg( 1 );
121 return !$user->getOption( 'wlenhancedfilters-disable' );
125 * Return an array of subpages that this special page will accept.
127 * @see also SpecialEditWatchlist::getSubpagesForPrefixSearch
128 * @return string[] subpages
130 public function getSubpagesForPrefixSearch() {
141 protected function transformFilterDefinition( array $filterDefinition ) {
142 if ( isset( $filterDefinition['showHideSuffix'] ) ) {
143 $filterDefinition['showHide'] = 'wl' . $filterDefinition['showHideSuffix'];
146 return $filterDefinition;
152 protected function registerFilters() {
153 parent
::registerFilters();
155 // legacy 'extended' filter
156 $this->registerFilterGroup( new ChangesListBooleanFilterGroup( [
157 'name' => 'extended-group',
160 'name' => 'extended',
161 'isReplacedInStructuredUi' => true,
162 'activeValue' => false,
163 'default' => $this->getUser()->getBoolOption( 'extendwatchlist' ),
164 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables,
165 &$fields, &$conds, &$query_options, &$join_conds ) {
166 $nonRevisionTypes = [ RC_LOG
];
167 Hooks
::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] );
168 if ( $nonRevisionTypes ) {
169 $conds[] = $dbr->makeList(
171 'rc_this_oldid=page_latest',
172 'rc_type' => $nonRevisionTypes,
183 if ( $this->isStructuredFilterUiEnabled() ) {
184 $this->getFilterGroup( 'lastRevision' )
185 ->getFilter( 'hidepreviousrevisions' )
186 ->setDefault( !$this->getUser()->getBoolOption( 'extendwatchlist' ) );
189 $this->registerFilterGroup( new ChangesListStringOptionsFilterGroup( [
190 'name' => 'watchlistactivity',
191 'title' => 'rcfilters-filtergroup-watchlistactivity',
192 'class' => ChangesListStringOptionsFilterGroup
::class,
194 'isFullCoverage' => true,
198 'label' => 'rcfilters-filter-watchlistactivity-unseen-label',
199 'description' => 'rcfilters-filter-watchlistactivity-unseen-description',
200 'cssClassSuffix' => 'watchedunseen',
201 'isRowApplicableCallable' => function ( $ctx, RecentChange
$rc ) {
202 $changeTs = $rc->getAttribute( 'rc_timestamp' );
203 $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
205 return $lastVisitTs !== null && $changeTs >= $lastVisitTs;
210 'label' => 'rcfilters-filter-watchlistactivity-seen-label',
211 'description' => 'rcfilters-filter-watchlistactivity-seen-description',
212 'cssClassSuffix' => 'watchedseen',
213 'isRowApplicableCallable' => function ( $ctx, RecentChange
$rc ) {
214 $changeTs = $rc->getAttribute( 'rc_timestamp' );
215 $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
217 return $lastVisitTs === null ||
$changeTs < $lastVisitTs;
221 'default' => ChangesListStringOptionsFilterGroup
::NONE
,
222 'queryCallable' => function (
223 $specialPageClassName,
233 if ( $selectedValues === [ 'seen' ] ) {
234 $conds[] = $dbr->makeList( [
235 'wl_notificationtimestamp IS NULL',
236 'rc_timestamp < wl_notificationtimestamp'
238 } elseif ( $selectedValues === [ 'unseen' ] ) {
239 $conds[] = $dbr->makeList( [
240 'wl_notificationtimestamp IS NOT NULL',
241 'rc_timestamp >= wl_notificationtimestamp'
247 $user = $this->getUser();
249 $significance = $this->getFilterGroup( 'significance' );
250 $hideMinor = $significance->getFilter( 'hideminor' );
251 $hideMinor->setDefault( $user->getBoolOption( 'watchlisthideminor' ) );
253 $automated = $this->getFilterGroup( 'automated' );
254 $hideBots = $automated->getFilter( 'hidebots' );
255 $hideBots->setDefault( $user->getBoolOption( 'watchlisthidebots' ) );
257 $registration = $this->getFilterGroup( 'registration' );
258 $hideAnons = $registration->getFilter( 'hideanons' );
259 $hideAnons->setDefault( $user->getBoolOption( 'watchlisthideanons' ) );
260 $hideLiu = $registration->getFilter( 'hideliu' );
261 $hideLiu->setDefault( $user->getBoolOption( 'watchlisthideliu' ) );
263 // Selecting both hideanons and hideliu on watchlist preferances
264 // gives mutually exclusive filters, so those are ignored
265 if ( $user->getBoolOption( 'watchlisthideanons' ) &&
266 !$user->getBoolOption( 'watchlisthideliu' )
268 $this->getFilterGroup( 'userExpLevel' )
269 ->setDefault( 'registered' );
272 if ( $user->getBoolOption( 'watchlisthideliu' ) &&
273 !$user->getBoolOption( 'watchlisthideanons' )
275 $this->getFilterGroup( 'userExpLevel' )
276 ->setDefault( 'unregistered' );
279 $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
280 if ( $reviewStatus !== null ) {
281 // Conditional on feature being available and rights
282 if ( $user->getBoolOption( 'watchlisthidepatrolled' ) ) {
283 $reviewStatus->setDefault( 'unpatrolled' );
284 $legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' );
285 $legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' );
286 $legacyHidePatrolled->setDefault( true );
290 $authorship = $this->getFilterGroup( 'authorship' );
291 $hideMyself = $authorship->getFilter( 'hidemyself' );
292 $hideMyself->setDefault( $user->getBoolOption( 'watchlisthideown' ) );
294 $changeType = $this->getFilterGroup( 'changeType' );
295 $hideCategorization = $changeType->getFilter( 'hidecategorization' );
296 if ( $hideCategorization !== null ) {
297 // Conditional on feature being available
298 $hideCategorization->setDefault( $user->getBoolOption( 'watchlisthidecategorization' ) );
303 * Fetch values for a FormOptions object from the WebRequest associated with this instance.
305 * Maps old pre-1.23 request parameters Watchlist used to use (different from Recentchanges' ones)
306 * to the current ones.
308 * @param FormOptions $opts
309 * @return FormOptions
311 protected function fetchOptionsFromRequest( $opts ) {
312 static $compatibilityMap = [
313 'hideMinor' => 'hideminor',
314 'hideBots' => 'hidebots',
315 'hideAnons' => 'hideanons',
316 'hideLiu' => 'hideliu',
317 'hidePatrolled' => 'hidepatrolled',
318 'hideOwn' => 'hidemyself',
321 $params = $this->getRequest()->getValues();
322 foreach ( $compatibilityMap as $from => $to ) {
323 if ( isset( $params[$from] ) ) {
324 $params[$to] = $params[$from];
325 unset( $params[$from] );
329 if ( $this->getRequest()->getVal( 'action' ) == 'submit' ) {
330 $allBooleansFalse = [];
332 // If the user submitted the form, start with a baseline of "all
333 // booleans are false", then change the ones they checked. This
334 // means we ignore the defaults.
336 // This is how we handle the fact that HTML forms don't submit
338 foreach ( $this->getLegacyShowHideFilters() as $filter ) {
339 $allBooleansFalse[ $filter->getName() ] = false;
342 $params = $params +
$allBooleansFalse;
345 // Not the prettiest way to achieve this… FormOptions internally depends on data sanitization
346 // methods defined on WebRequest and removing this dependency would cause some code duplication.
347 $request = new DerivativeRequest( $this->getRequest(), $params );
348 $opts->fetchValuesFromRequest( $request );
356 protected function doMainQuery( $tables, $fields, $conds, $query_options,
357 $join_conds, FormOptions
$opts
359 $dbr = $this->getDB();
360 $user = $this->getUser();
362 $rcQuery = RecentChange
::getQueryInfo();
363 $tables = array_merge( $tables, $rcQuery['tables'], [ 'watchlist' ] );
364 $fields = array_merge( $rcQuery['fields'], $fields );
366 $join_conds = array_merge(
371 'wl_user' => $user->getId(),
372 'wl_namespace=rc_namespace',
382 $fields[] = 'page_latest';
383 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
385 $fields[] = 'wl_notificationtimestamp';
387 // Log entries with DELETED_ACTION must not show up unless the user has
388 // the necessary rights.
389 if ( !$user->isAllowed( 'deletedhistory' ) ) {
390 $bitmask = LogPage
::DELETED_ACTION
;
391 } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
392 $bitmask = LogPage
::DELETED_ACTION | LogPage
::DELETED_RESTRICTED
;
397 $conds[] = $dbr->makeList( [
398 'rc_type != ' . RC_LOG
,
399 $dbr->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
403 $tagFilter = $opts['tagfilter'] ?
explode( '|', $opts['tagfilter'] ) : [];
404 ChangeTags
::modifyDisplayQuery(
413 $this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts );
415 if ( $this->areFiltersInConflict() ) {
420 'ORDER BY' => 'rc_timestamp DESC',
421 'LIMIT' => $opts['limit']
423 if ( in_array( 'DISTINCT', $query_options ) ) {
424 // ChangeTags::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
425 // In order to prevent DISTINCT from causing query performance problems,
426 // we have to GROUP BY the primary key. This in turn requires us to add
427 // the primary key to the end of the ORDER BY, and the old ORDER BY to the
428 // start of the GROUP BY
429 $orderByAndLimit['ORDER BY'] = 'rc_timestamp DESC, rc_id DESC';
430 $orderByAndLimit['GROUP BY'] = 'rc_timestamp, rc_id';
432 // array_merge() is used intentionally here so that hooks can, should
433 // they so desire, override the ORDER BY / LIMIT condition(s)
434 $query_options = array_merge( $orderByAndLimit, $query_options );
447 * Return a IDatabase object for reading
451 protected function getDB() {
452 return wfGetDB( DB_REPLICA
, 'watchlist' );
458 public function outputFeedLinks() {
459 $user = $this->getUser();
460 $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
462 $this->addFeedLinks( [
463 'action' => 'feedwatchlist',
465 'wlowner' => $user->getName(),
466 'wltoken' => $wlToken,
472 * Build and output the actual changes list.
474 * @param IResultWrapper $rows Database rows
475 * @param FormOptions $opts
477 public function outputChangesList( $rows, $opts ) {
478 $dbr = $this->getDB();
479 $user = $this->getUser();
480 $output = $this->getOutput();
481 $services = MediaWikiServices
::getInstance();
483 # Show a message about replica DB lag, if applicable
484 $lag = $dbr->getSessionLagStatus()['lag'];
486 $output->showLagWarning( $lag );
489 # If no rows to display, show message before try to render the list
490 if ( $rows->numRows() == 0 ) {
491 $output->wrapWikiMsg(
492 "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
497 $dbr->dataSeek( $rows, 0 );
499 $list = ChangesList
::newFromContext( $this->getContext(), $this->filterGroups
);
500 $list->setWatchlistDivs();
501 $list->initChangesListRows( $rows );
502 if ( $user->getOption( 'watchlistunwatchlinks' ) ) {
503 $list->setChangeLinePrefixer( function ( RecentChange
$rc, ChangesList
$cl, $grouped ) {
504 // Don't show unwatch link if the line is a grouped log entry using EnhancedChangesList,
505 // since EnhancedChangesList groups log entries by performer rather than by target article
506 if ( $rc->mAttribs
['rc_type'] == RC_LOG
&& $cl instanceof EnhancedChangesList
&&
510 return $this->getLinkRenderer()
511 ->makeKnownLink( $rc->getTitle(),
512 $this->msg( 'watchlist-unwatch' )->text(), [
513 'class' => 'mw-unwatch-link',
514 'title' => $this->msg( 'tooltip-ca-unwatch' )->text()
515 ], [ 'action' => 'unwatch' ] ) . "\u{00A0}";
519 $dbr->dataSeek( $rows, 0 );
521 if ( $this->getConfig()->get( 'RCShowWatchingUsers' )
522 && $user->getOption( 'shownumberswatching' )
524 $watchedItemStore = $services->getWatchedItemStore();
527 $s = $list->beginRecentChangesList();
529 if ( $this->isStructuredFilterUiEnabled() ) {
530 $s .= $this->makeLegend();
533 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
535 foreach ( $rows as $obj ) {
537 $rc = RecentChange
::newFromRow( $obj );
539 # Skip CatWatch entries for hidden cats based on user preference
541 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE
&&
542 !$userShowHiddenCats &&
543 $rc->getParam( 'hidden-cat' )
548 $rc->counter
= $counter++
;
550 if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
551 $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
552 $updated = ( $lastVisitTs > $rc->getAttribute( 'timestamp' ) );
557 if ( isset( $watchedItemStore ) ) {
558 $rcTitleValue = new TitleValue( (int)$obj->rc_namespace
, $obj->rc_title
);
559 $rc->numberofWatchingusers
= $watchedItemStore->countWatchers( $rcTitleValue );
561 $rc->numberofWatchingusers
= 0;
564 $changeLine = $list->recentChangesLine( $rc, $updated, $counter );
565 if ( $changeLine !== false ) {
569 $s .= $list->endRecentChangesList();
571 $output->addHTML( $s );
575 * Set the text to be displayed above the changes
577 * @param FormOptions $opts
578 * @param int $numRows Number of rows in the result to show after this header
580 public function doHeader( $opts, $numRows ) {
581 $user = $this->getUser();
582 $out = $this->getOutput();
585 $this->msg( 'watchlistfor2', $user->getName() )
586 ->rawParams( SpecialEditWatchlist
::buildTools(
587 $this->getLanguage(),
588 $this->getLinkRenderer()
592 $this->setTopText( $opts );
596 $form .= Xml
::openElement( 'form', [
598 'action' => wfScript(),
599 'id' => 'mw-watchlist-form'
601 $form .= Html
::hidden( 'title', $this->getPageTitle()->getPrefixedText() );
602 $form .= Xml
::openElement(
604 [ 'id' => 'mw-watchlist-options', 'class' => 'cloptions' ]
606 $form .= Xml
::element(
607 'legend', null, $this->msg( 'watchlist-options' )->text()
610 if ( !$this->isStructuredFilterUiEnabled() ) {
611 $form .= $this->makeLegend();
614 $lang = $this->getLanguage();
615 $timestamp = wfTimestampNow();
616 $now = $lang->userTimeAndDate( $timestamp, $user );
617 $wlInfo = Html
::rawElement(
621 'data-params' => json_encode( [ 'from' => $timestamp, 'fromFormatted' => $now ] ),
623 $this->msg( 'wlnote' )->numParams( $numRows, round( $opts['days'] * 24 ) )->params(
624 $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
628 $nondefaults = $opts->getChangedValues();
629 $cutofflinks = Html
::rawElement(
631 [ 'class' => 'cldays cloption' ],
632 $this->msg( 'wlshowtime' ) . ' ' . $this->cutoffselector( $opts )
635 # Spit out some control panel links
637 $namesOfDisplayedFilters = [];
638 foreach ( $this->getLegacyShowHideFilters() as $filterName => $filter ) {
639 $namesOfDisplayedFilters[] = $filterName;
640 $links[] = $this->showHideCheck(
642 $filter->getShowHide(),
644 $opts[ $filterName ],
645 $filter->isFeatureAvailableOnStructuredUi( $this )
649 $hiddenFields = $nondefaults;
650 $hiddenFields['action'] = 'submit';
651 unset( $hiddenFields['namespace'] );
652 unset( $hiddenFields['invert'] );
653 unset( $hiddenFields['associated'] );
654 unset( $hiddenFields['days'] );
655 foreach ( $namesOfDisplayedFilters as $filterName ) {
656 unset( $hiddenFields[$filterName] );
659 # Namespace filter and put the whole form together.
661 $form .= $cutofflinks;
662 $form .= Html
::rawElement(
664 [ 'class' => 'clshowhide' ],
665 $this->msg( 'watchlist-hide' ) .
666 $this->msg( 'colon-separator' )->escaped() .
667 implode( ' ', $links )
669 $form .= "\n<br />\n";
671 $namespaceForm = Html
::namespaceSelector(
673 'selected' => $opts['namespace'],
675 'label' => $this->msg( 'namespace' )->text(),
676 'in-user-lang' => true,
678 'name' => 'namespace',
680 'class' => 'namespaceselector',
683 $hidden = $opts['namespace'] === '' ?
' mw-input-hidden' : '';
684 $namespaceForm .= '<span class="mw-input-with-label' . $hidden . '">' . Xml
::checkLabel(
685 $this->msg( 'invert' )->text(),
689 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
691 $namespaceForm .= '<span class="mw-input-with-label' . $hidden . '">' . Xml
::checkLabel(
692 $this->msg( 'namespace_association' )->text(),
696 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
698 $form .= Html
::rawElement(
700 [ 'class' => 'namespaceForm cloption' ],
704 $form .= Xml
::submitButton(
705 $this->msg( 'watchlist-submit' )->text(),
706 [ 'class' => 'cloption-submit' ]
708 foreach ( $hiddenFields as $key => $value ) {
709 $form .= Html
::hidden( $key, $value ) . "\n";
711 $form .= Xml
::closeElement( 'fieldset' ) . "\n";
712 $form .= Xml
::closeElement( 'form' ) . "\n";
714 // Insert a placeholder for RCFilters
715 if ( $this->isStructuredFilterUiEnabled() ) {
716 $rcfilterContainer = Html
::element(
718 // TODO: Remove deprecated rcfilters-container class
719 [ 'class' => 'rcfilters-container mw-rcfilters-container' ]
722 $loadingContainer = Html
::rawElement(
724 [ 'class' => 'mw-rcfilters-spinner' ],
727 [ 'class' => 'mw-rcfilters-spinner-bounce' ]
731 // Wrap both with rcfilters-head
732 $this->getOutput()->addHTML(
735 // TODO: Remove deprecated rcfilters-head class
736 [ 'class' => 'rcfilters-head mw-rcfilters-head' ],
737 $rcfilterContainer . $form
742 $this->getOutput()->addHTML( $loadingContainer );
744 $this->getOutput()->addHTML( $form );
747 $this->setBottomText( $opts );
750 function cutoffselector( $options ) {
751 $selected = (float)$options['days'];
752 if ( $selected <= 0 ) {
753 $selected = $this->maxDays
;
756 $selectedHours = round( $selected * 24 );
758 $hours = array_unique( array_filter( [
766 24 * (float)$this->getUser()->getOption( 'watchlistdays', 0 ),
772 $select = new XmlSelect( 'days', 'days', (float)( $selectedHours / 24 ) );
774 foreach ( $hours as $value ) {
776 $name = $this->msg( 'hours' )->numParams( $value )->text();
778 $name = $this->msg( 'days' )->numParams( $value / 24 )->text();
780 $select->addOption( $name, (float)( $value / 24 ) );
783 return $select->getHTML() . "\n<br />\n";
786 function setTopText( FormOptions
$opts ) {
787 $nondefaults = $opts->getChangedValues();
789 $user = $this->getUser();
791 $numItems = $this->countItems();
792 $showUpdatedMarker = $this->getConfig()->get( 'ShowUpdatedMarker' );
794 // Show watchlist header
795 $watchlistHeader = '';
796 if ( $numItems == 0 ) {
797 $watchlistHeader = $this->msg( 'nowatchlist' )->parse();
799 $watchlistHeader .= $this->msg( 'watchlist-details' )->numParams( $numItems )->parse() . "\n";
800 if ( $this->getConfig()->get( 'EnotifWatchlist' )
801 && $user->getOption( 'enotifwatchlistpages' )
803 $watchlistHeader .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
805 if ( $showUpdatedMarker ) {
806 $watchlistHeader .= $this->msg(
807 $this->isStructuredFilterUiEnabled() ?
808 'rcfilters-watchlist-showupdated' :
809 'wlheader-showupdated'
813 $form .= Html
::rawElement(
815 [ 'class' => 'watchlistDetails' ],
819 if ( $numItems > 0 && $showUpdatedMarker ) {
820 $form .= Xml
::openElement( 'form', [ 'method' => 'post',
821 'action' => $this->getPageTitle()->getLocalURL(),
822 'id' => 'mw-watchlist-resetbutton' ] ) . "\n" .
823 Xml
::submitButton( $this->msg( 'enotif_reset' )->text(),
824 [ 'name' => 'mw-watchlist-reset-submit' ] ) . "\n" .
825 Html
::hidden( 'token', $user->getEditToken() ) . "\n" .
826 Html
::hidden( 'reset', 'all' ) . "\n";
827 foreach ( $nondefaults as $key => $value ) {
828 $form .= Html
::hidden( $key, $value ) . "\n";
830 $form .= Xml
::closeElement( 'form' ) . "\n";
833 $this->getOutput()->addHTML( $form );
836 protected function showHideCheck( $options, $message, $name, $value, $inStructuredUi ) {
837 $options[$name] = 1 - (int)$value;
839 $attribs = [ 'class' => 'mw-input-with-label clshowhideoption cloption' ];
840 if ( $inStructuredUi ) {
841 $attribs[ 'data-feature-in-structured-ui' ] = true;
844 return Html
::rawElement(
847 // not using Html::checkLabel because that would escape the contents
848 Html
::check( $name, (int)$value, [ 'id' => $name ] ) . Html
::rawElement(
850 $attribs +
[ 'for' => $name ],
851 // <nowiki/> at beginning to avoid messages with "$1 ..." being parsed as pre tags
852 $this->msg( $message, '<nowiki/>' )->parse()
858 * Count the number of paired items on a user's watchlist.
859 * The assumption made here is that when a subject page is watched a talk page is also watched.
860 * Hence the number of individual items is halved.
864 protected function countItems() {
865 $store = MediaWikiServices
::getInstance()->getWatchedItemStore();
866 $count = $store->countWatchedItems( $this->getUser() );
867 return floor( $count / 2 );
871 * @param RecentChange $rc
872 * @return string TS_MW timestamp
874 protected function getLatestSeenTimestamp( RecentChange
$rc ) {
875 return $this->watchStore
->getLatestNotificationTimestamp(
876 $rc->getAttribute( 'wl_notificationtimestamp' ),