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' ] );
113 public static function checkStructuredFilterUiEnabled( Config
$config, User
$user ) {
114 return !$user->getOption( 'wlenhancedfilters-disable' );
118 * Return an array of subpages that this special page will accept.
120 * @see also SpecialEditWatchlist::getSubpagesForPrefixSearch
121 * @return string[] subpages
123 public function getSubpagesForPrefixSearch() {
134 protected function transformFilterDefinition( array $filterDefinition ) {
135 if ( isset( $filterDefinition['showHideSuffix'] ) ) {
136 $filterDefinition['showHide'] = 'wl' . $filterDefinition['showHideSuffix'];
139 return $filterDefinition;
145 protected function registerFilters() {
146 parent
::registerFilters();
148 // legacy 'extended' filter
149 $this->registerFilterGroup( new ChangesListBooleanFilterGroup( [
150 'name' => 'extended-group',
153 'name' => 'extended',
154 'isReplacedInStructuredUi' => true,
155 'activeValue' => false,
156 'default' => $this->getUser()->getBoolOption( 'extendwatchlist' ),
157 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables,
158 &$fields, &$conds, &$query_options, &$join_conds ) {
159 $nonRevisionTypes = [ RC_LOG
];
160 Hooks
::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] );
161 if ( $nonRevisionTypes ) {
162 $conds[] = $dbr->makeList(
164 'rc_this_oldid=page_latest',
165 'rc_type' => $nonRevisionTypes,
176 if ( $this->isStructuredFilterUiEnabled() ) {
177 $this->getFilterGroup( 'lastRevision' )
178 ->getFilter( 'hidepreviousrevisions' )
179 ->setDefault( !$this->getUser()->getBoolOption( 'extendwatchlist' ) );
182 $this->registerFilterGroup( new ChangesListStringOptionsFilterGroup( [
183 'name' => 'watchlistactivity',
184 'title' => 'rcfilters-filtergroup-watchlistactivity',
185 'class' => ChangesListStringOptionsFilterGroup
::class,
187 'isFullCoverage' => true,
191 'label' => 'rcfilters-filter-watchlistactivity-unseen-label',
192 'description' => 'rcfilters-filter-watchlistactivity-unseen-description',
193 'cssClassSuffix' => 'watchedunseen',
194 'isRowApplicableCallable' => function ( $ctx, RecentChange
$rc ) {
195 $changeTs = $rc->getAttribute( 'rc_timestamp' );
196 $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
198 return $lastVisitTs !== null && $changeTs >= $lastVisitTs;
203 'label' => 'rcfilters-filter-watchlistactivity-seen-label',
204 'description' => 'rcfilters-filter-watchlistactivity-seen-description',
205 'cssClassSuffix' => 'watchedseen',
206 'isRowApplicableCallable' => function ( $ctx, RecentChange
$rc ) {
207 $changeTs = $rc->getAttribute( 'rc_timestamp' );
208 $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
210 return $lastVisitTs === null ||
$changeTs < $lastVisitTs;
214 'default' => ChangesListStringOptionsFilterGroup
::NONE
,
215 'queryCallable' => function (
216 $specialPageClassName,
226 if ( $selectedValues === [ 'seen' ] ) {
227 $conds[] = $dbr->makeList( [
228 'wl_notificationtimestamp IS NULL',
229 'rc_timestamp < wl_notificationtimestamp'
231 } elseif ( $selectedValues === [ 'unseen' ] ) {
232 $conds[] = $dbr->makeList( [
233 'wl_notificationtimestamp IS NOT NULL',
234 'rc_timestamp >= wl_notificationtimestamp'
240 $user = $this->getUser();
242 $significance = $this->getFilterGroup( 'significance' );
243 $hideMinor = $significance->getFilter( 'hideminor' );
244 $hideMinor->setDefault( $user->getBoolOption( 'watchlisthideminor' ) );
246 $automated = $this->getFilterGroup( 'automated' );
247 $hideBots = $automated->getFilter( 'hidebots' );
248 $hideBots->setDefault( $user->getBoolOption( 'watchlisthidebots' ) );
250 $registration = $this->getFilterGroup( 'registration' );
251 $hideAnons = $registration->getFilter( 'hideanons' );
252 $hideAnons->setDefault( $user->getBoolOption( 'watchlisthideanons' ) );
253 $hideLiu = $registration->getFilter( 'hideliu' );
254 $hideLiu->setDefault( $user->getBoolOption( 'watchlisthideliu' ) );
256 // Selecting both hideanons and hideliu on watchlist preferances
257 // gives mutually exclusive filters, so those are ignored
258 if ( $user->getBoolOption( 'watchlisthideanons' ) &&
259 !$user->getBoolOption( 'watchlisthideliu' )
261 $this->getFilterGroup( 'userExpLevel' )
262 ->setDefault( 'registered' );
265 if ( $user->getBoolOption( 'watchlisthideliu' ) &&
266 !$user->getBoolOption( 'watchlisthideanons' )
268 $this->getFilterGroup( 'userExpLevel' )
269 ->setDefault( 'unregistered' );
272 $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
273 if ( $reviewStatus !== null ) {
274 // Conditional on feature being available and rights
275 if ( $user->getBoolOption( 'watchlisthidepatrolled' ) ) {
276 $reviewStatus->setDefault( 'unpatrolled' );
277 $legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' );
278 $legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' );
279 $legacyHidePatrolled->setDefault( true );
283 $authorship = $this->getFilterGroup( 'authorship' );
284 $hideMyself = $authorship->getFilter( 'hidemyself' );
285 $hideMyself->setDefault( $user->getBoolOption( 'watchlisthideown' ) );
287 $changeType = $this->getFilterGroup( 'changeType' );
288 $hideCategorization = $changeType->getFilter( 'hidecategorization' );
289 if ( $hideCategorization !== null ) {
290 // Conditional on feature being available
291 $hideCategorization->setDefault( $user->getBoolOption( 'watchlisthidecategorization' ) );
296 * Fetch values for a FormOptions object from the WebRequest associated with this instance.
298 * Maps old pre-1.23 request parameters Watchlist used to use (different from Recentchanges' ones)
299 * to the current ones.
301 * @param FormOptions $opts
302 * @return FormOptions
304 protected function fetchOptionsFromRequest( $opts ) {
305 static $compatibilityMap = [
306 'hideMinor' => 'hideminor',
307 'hideBots' => 'hidebots',
308 'hideAnons' => 'hideanons',
309 'hideLiu' => 'hideliu',
310 'hidePatrolled' => 'hidepatrolled',
311 'hideOwn' => 'hidemyself',
314 $params = $this->getRequest()->getValues();
315 foreach ( $compatibilityMap as $from => $to ) {
316 if ( isset( $params[$from] ) ) {
317 $params[$to] = $params[$from];
318 unset( $params[$from] );
322 if ( $this->getRequest()->getVal( 'action' ) == 'submit' ) {
323 $allBooleansFalse = [];
325 // If the user submitted the form, start with a baseline of "all
326 // booleans are false", then change the ones they checked. This
327 // means we ignore the defaults.
329 // This is how we handle the fact that HTML forms don't submit
331 foreach ( $this->getLegacyShowHideFilters() as $filter ) {
332 $allBooleansFalse[ $filter->getName() ] = false;
335 $params = $params +
$allBooleansFalse;
338 // Not the prettiest way to achieve this… FormOptions internally depends on data sanitization
339 // methods defined on WebRequest and removing this dependency would cause some code duplication.
340 $request = new DerivativeRequest( $this->getRequest(), $params );
341 $opts->fetchValuesFromRequest( $request );
349 protected function doMainQuery( $tables, $fields, $conds, $query_options,
350 $join_conds, FormOptions
$opts
352 $dbr = $this->getDB();
353 $user = $this->getUser();
355 $rcQuery = RecentChange
::getQueryInfo();
356 $tables = array_merge( $tables, $rcQuery['tables'], [ 'watchlist' ] );
357 $fields = array_merge( $rcQuery['fields'], $fields );
359 $join_conds = array_merge(
364 'wl_user' => $user->getId(),
365 'wl_namespace=rc_namespace',
375 $fields[] = 'page_latest';
376 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
378 $fields[] = 'wl_notificationtimestamp';
380 // Log entries with DELETED_ACTION must not show up unless the user has
381 // the necessary rights.
382 if ( !$user->isAllowed( 'deletedhistory' ) ) {
383 $bitmask = LogPage
::DELETED_ACTION
;
384 } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
385 $bitmask = LogPage
::DELETED_ACTION | LogPage
::DELETED_RESTRICTED
;
390 $conds[] = $dbr->makeList( [
391 'rc_type != ' . RC_LOG
,
392 $dbr->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
396 $tagFilter = $opts['tagfilter'] ?
explode( '|', $opts['tagfilter'] ) : [];
397 ChangeTags
::modifyDisplayQuery(
406 $this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts );
408 if ( $this->areFiltersInConflict() ) {
413 'ORDER BY' => 'rc_timestamp DESC',
414 'LIMIT' => $opts['limit']
416 if ( in_array( 'DISTINCT', $query_options ) ) {
417 // ChangeTags::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
418 // In order to prevent DISTINCT from causing query performance problems,
419 // we have to GROUP BY the primary key. This in turn requires us to add
420 // the primary key to the end of the ORDER BY, and the old ORDER BY to the
421 // start of the GROUP BY
422 $orderByAndLimit['ORDER BY'] = 'rc_timestamp DESC, rc_id DESC';
423 $orderByAndLimit['GROUP BY'] = 'rc_timestamp, rc_id';
425 // array_merge() is used intentionally here so that hooks can, should
426 // they so desire, override the ORDER BY / LIMIT condition(s)
427 $query_options = array_merge( $orderByAndLimit, $query_options );
440 * Return a IDatabase object for reading
444 protected function getDB() {
445 return wfGetDB( DB_REPLICA
, 'watchlist' );
451 public function outputFeedLinks() {
452 $user = $this->getUser();
453 $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
455 $this->addFeedLinks( [
456 'action' => 'feedwatchlist',
458 'wlowner' => $user->getName(),
459 'wltoken' => $wlToken,
465 * Build and output the actual changes list.
467 * @param IResultWrapper $rows Database rows
468 * @param FormOptions $opts
470 public function outputChangesList( $rows, $opts ) {
471 $dbr = $this->getDB();
472 $user = $this->getUser();
473 $output = $this->getOutput();
474 $services = MediaWikiServices
::getInstance();
476 # Show a message about replica DB lag, if applicable
477 $lag = $dbr->getSessionLagStatus()['lag'];
479 $output->showLagWarning( $lag );
482 # If no rows to display, show message before try to render the list
483 if ( $rows->numRows() == 0 ) {
484 $output->wrapWikiMsg(
485 "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
490 $dbr->dataSeek( $rows, 0 );
492 $list = ChangesList
::newFromContext( $this->getContext(), $this->filterGroups
);
493 $list->setWatchlistDivs();
494 $list->initChangesListRows( $rows );
495 if ( $user->getOption( 'watchlistunwatchlinks' ) ) {
496 $list->setChangeLinePrefixer( function ( RecentChange
$rc, ChangesList
$cl, $grouped ) {
497 // Don't show unwatch link if the line is a grouped log entry using EnhancedChangesList,
498 // since EnhancedChangesList groups log entries by performer rather than by target article
499 if ( $rc->mAttribs
['rc_type'] == RC_LOG
&& $cl instanceof EnhancedChangesList
&&
503 return $this->getLinkRenderer()
504 ->makeKnownLink( $rc->getTitle(),
505 $this->msg( 'watchlist-unwatch' )->text(), [
506 'class' => 'mw-unwatch-link',
507 'title' => $this->msg( 'tooltip-ca-unwatch' )->text()
508 ], [ 'action' => 'unwatch' ] ) . "\u{00A0}";
512 $dbr->dataSeek( $rows, 0 );
514 if ( $this->getConfig()->get( 'RCShowWatchingUsers' )
515 && $user->getOption( 'shownumberswatching' )
517 $watchedItemStore = $services->getWatchedItemStore();
520 $s = $list->beginRecentChangesList();
522 if ( $this->isStructuredFilterUiEnabled() ) {
523 $s .= $this->makeLegend();
526 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
528 foreach ( $rows as $obj ) {
530 $rc = RecentChange
::newFromRow( $obj );
532 # Skip CatWatch entries for hidden cats based on user preference
534 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE
&&
535 !$userShowHiddenCats &&
536 $rc->getParam( 'hidden-cat' )
541 $rc->counter
= $counter++
;
543 if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
544 $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
545 $updated = ( $lastVisitTs > $rc->getAttribute( 'timestamp' ) );
550 if ( isset( $watchedItemStore ) ) {
551 $rcTitleValue = new TitleValue( (int)$obj->rc_namespace
, $obj->rc_title
);
552 $rc->numberofWatchingusers
= $watchedItemStore->countWatchers( $rcTitleValue );
554 $rc->numberofWatchingusers
= 0;
557 $changeLine = $list->recentChangesLine( $rc, $updated, $counter );
558 if ( $changeLine !== false ) {
562 $s .= $list->endRecentChangesList();
564 $output->addHTML( $s );
568 * Set the text to be displayed above the changes
570 * @param FormOptions $opts
571 * @param int $numRows Number of rows in the result to show after this header
573 public function doHeader( $opts, $numRows ) {
574 $user = $this->getUser();
575 $out = $this->getOutput();
578 $this->msg( 'watchlistfor2', $user->getName() )
579 ->rawParams( SpecialEditWatchlist
::buildTools(
580 $this->getLanguage(),
581 $this->getLinkRenderer()
585 $this->setTopText( $opts );
589 $form .= Xml
::openElement( 'form', [
591 'action' => wfScript(),
592 'id' => 'mw-watchlist-form'
594 $form .= Html
::hidden( 'title', $this->getPageTitle()->getPrefixedText() );
595 $form .= Xml
::openElement(
597 [ 'id' => 'mw-watchlist-options', 'class' => 'cloptions' ]
599 $form .= Xml
::element(
600 'legend', null, $this->msg( 'watchlist-options' )->text()
603 if ( !$this->isStructuredFilterUiEnabled() ) {
604 $form .= $this->makeLegend();
607 $lang = $this->getLanguage();
608 $timestamp = wfTimestampNow();
609 $now = $lang->userTimeAndDate( $timestamp, $user );
610 $wlInfo = Html
::rawElement(
614 'data-params' => json_encode( [ 'from' => $timestamp, 'fromFormatted' => $now ] ),
616 $this->msg( 'wlnote' )->numParams( $numRows, round( $opts['days'] * 24 ) )->params(
617 $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
621 $nondefaults = $opts->getChangedValues();
622 $cutofflinks = Html
::rawElement(
624 [ 'class' => 'cldays cloption' ],
625 $this->msg( 'wlshowtime' ) . ' ' . $this->cutoffselector( $opts )
628 # Spit out some control panel links
630 $namesOfDisplayedFilters = [];
631 foreach ( $this->getLegacyShowHideFilters() as $filterName => $filter ) {
632 $namesOfDisplayedFilters[] = $filterName;
633 $links[] = $this->showHideCheck(
635 $filter->getShowHide(),
637 $opts[ $filterName ],
638 $filter->isFeatureAvailableOnStructuredUi( $this )
642 $hiddenFields = $nondefaults;
643 $hiddenFields['action'] = 'submit';
644 unset( $hiddenFields['namespace'] );
645 unset( $hiddenFields['invert'] );
646 unset( $hiddenFields['associated'] );
647 unset( $hiddenFields['days'] );
648 foreach ( $namesOfDisplayedFilters as $filterName ) {
649 unset( $hiddenFields[$filterName] );
652 # Namespace filter and put the whole form together.
654 $form .= $cutofflinks;
655 $form .= Html
::rawElement(
657 [ 'class' => 'clshowhide' ],
658 $this->msg( 'watchlist-hide' ) .
659 $this->msg( 'colon-separator' )->escaped() .
660 implode( ' ', $links )
662 $form .= "\n<br />\n";
664 $namespaceForm = Html
::namespaceSelector(
666 'selected' => $opts['namespace'],
668 'label' => $this->msg( 'namespace' )->text(),
669 'in-user-lang' => true,
671 'name' => 'namespace',
673 'class' => 'namespaceselector',
676 $hidden = $opts['namespace'] === '' ?
' mw-input-hidden' : '';
677 $namespaceForm .= '<span class="mw-input-with-label' . $hidden . '">' . Xml
::checkLabel(
678 $this->msg( 'invert' )->text(),
682 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
684 $namespaceForm .= '<span class="mw-input-with-label' . $hidden . '">' . Xml
::checkLabel(
685 $this->msg( 'namespace_association' )->text(),
689 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
691 $form .= Html
::rawElement(
693 [ 'class' => 'namespaceForm cloption' ],
697 $form .= Xml
::submitButton(
698 $this->msg( 'watchlist-submit' )->text(),
699 [ 'class' => 'cloption-submit' ]
701 foreach ( $hiddenFields as $key => $value ) {
702 $form .= Html
::hidden( $key, $value ) . "\n";
704 $form .= Xml
::closeElement( 'fieldset' ) . "\n";
705 $form .= Xml
::closeElement( 'form' ) . "\n";
707 // Insert a placeholder for RCFilters
708 if ( $this->isStructuredFilterUiEnabled() ) {
709 $rcfilterContainer = Html
::element(
711 // TODO: Remove deprecated rcfilters-container class
712 [ 'class' => 'rcfilters-container mw-rcfilters-container' ]
715 $loadingContainer = Html
::rawElement(
717 [ 'class' => 'mw-rcfilters-spinner' ],
720 [ 'class' => 'mw-rcfilters-spinner-bounce' ]
724 // Wrap both with rcfilters-head
725 $this->getOutput()->addHTML(
728 // TODO: Remove deprecated rcfilters-head class
729 [ 'class' => 'rcfilters-head mw-rcfilters-head' ],
730 $rcfilterContainer . $form
735 $this->getOutput()->addHTML( $loadingContainer );
737 $this->getOutput()->addHTML( $form );
740 $this->setBottomText( $opts );
743 function cutoffselector( $options ) {
744 $selected = (float)$options['days'];
745 if ( $selected <= 0 ) {
746 $selected = $this->maxDays
;
749 $selectedHours = round( $selected * 24 );
751 $hours = array_unique( array_filter( [
759 24 * (float)$this->getUser()->getOption( 'watchlistdays', 0 ),
765 $select = new XmlSelect( 'days', 'days', (float)( $selectedHours / 24 ) );
767 foreach ( $hours as $value ) {
769 $name = $this->msg( 'hours' )->numParams( $value )->text();
771 $name = $this->msg( 'days' )->numParams( $value / 24 )->text();
773 $select->addOption( $name, (float)( $value / 24 ) );
776 return $select->getHTML() . "\n<br />\n";
779 function setTopText( FormOptions
$opts ) {
780 $nondefaults = $opts->getChangedValues();
782 $user = $this->getUser();
784 $numItems = $this->countItems();
785 $showUpdatedMarker = $this->getConfig()->get( 'ShowUpdatedMarker' );
787 // Show watchlist header
788 $watchlistHeader = '';
789 if ( $numItems == 0 ) {
790 $watchlistHeader = $this->msg( 'nowatchlist' )->parse();
792 $watchlistHeader .= $this->msg( 'watchlist-details' )->numParams( $numItems )->parse() . "\n";
793 if ( $this->getConfig()->get( 'EnotifWatchlist' )
794 && $user->getOption( 'enotifwatchlistpages' )
796 $watchlistHeader .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
798 if ( $showUpdatedMarker ) {
799 $watchlistHeader .= $this->msg(
800 $this->isStructuredFilterUiEnabled() ?
801 'rcfilters-watchlist-showupdated' :
802 'wlheader-showupdated'
806 $form .= Html
::rawElement(
808 [ 'class' => 'watchlistDetails' ],
812 if ( $numItems > 0 && $showUpdatedMarker ) {
813 $form .= Xml
::openElement( 'form', [ 'method' => 'post',
814 'action' => $this->getPageTitle()->getLocalURL(),
815 'id' => 'mw-watchlist-resetbutton' ] ) . "\n" .
816 Xml
::submitButton( $this->msg( 'enotif_reset' )->text(),
817 [ 'name' => 'mw-watchlist-reset-submit' ] ) . "\n" .
818 Html
::hidden( 'token', $user->getEditToken() ) . "\n" .
819 Html
::hidden( 'reset', 'all' ) . "\n";
820 foreach ( $nondefaults as $key => $value ) {
821 $form .= Html
::hidden( $key, $value ) . "\n";
823 $form .= Xml
::closeElement( 'form' ) . "\n";
826 $this->getOutput()->addHTML( $form );
829 protected function showHideCheck( $options, $message, $name, $value, $inStructuredUi ) {
830 $options[$name] = 1 - (int)$value;
832 $attribs = [ 'class' => 'mw-input-with-label clshowhideoption cloption' ];
833 if ( $inStructuredUi ) {
834 $attribs[ 'data-feature-in-structured-ui' ] = true;
837 return Html
::rawElement(
840 // not using Html::checkLabel because that would escape the contents
841 Html
::check( $name, (int)$value, [ 'id' => $name ] ) . Html
::rawElement(
843 $attribs +
[ 'for' => $name ],
844 // <nowiki/> at beginning to avoid messages with "$1 ..." being parsed as pre tags
845 $this->msg( $message, '<nowiki/>' )->parse()
851 * Count the number of paired items on a user's watchlist.
852 * The assumption made here is that when a subject page is watched a talk page is also watched.
853 * Hence the number of individual items is halved.
857 protected function countItems() {
858 $store = MediaWikiServices
::getInstance()->getWatchedItemStore();
859 $count = $store->countWatchedItems( $this->getUser() );
860 return floor( $count / 2 );
864 * @param RecentChange $rc
865 * @return string TS_MW timestamp
867 protected function getLatestSeenTimestamp( RecentChange
$rc ) {
868 return $this->watchStore
->getLatestNotificationTimestamp(
869 $rc->getAttribute( 'wl_notificationtimestamp' ),