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 public function __construct( $page = 'Watchlist', $restriction = 'viewmywatchlist' ) {
43 parent
::__construct( $page, $restriction );
45 $this->maxDays
= $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 );
48 public function doesWrites() {
53 * Main execution point
55 * @param string $subpage
57 function execute( $subpage ) {
58 // Anons don't get a watchlist
59 $this->requireLogin( 'watchlistanontext' );
61 $output = $this->getOutput();
62 $request = $this->getRequest();
63 $this->addHelpLink( 'Help:Watching pages' );
64 $output->addModuleStyles( [ 'mediawiki.special' ] );
65 $output->addModules( [
66 'mediawiki.special.watchlist',
69 $mode = SpecialEditWatchlist
::getMode( $request, $subpage );
70 if ( $mode !== false ) {
71 if ( $mode === SpecialEditWatchlist
::EDIT_RAW
) {
72 $title = SpecialPage
::getTitleFor( 'EditWatchlist', 'raw' );
73 } elseif ( $mode === SpecialEditWatchlist
::EDIT_CLEAR
) {
74 $title = SpecialPage
::getTitleFor( 'EditWatchlist', 'clear' );
76 $title = SpecialPage
::getTitleFor( 'EditWatchlist' );
79 $output->redirect( $title->getLocalURL() );
84 $this->checkPermissions();
86 $user = $this->getUser();
87 $opts = $this->getOptions();
89 $config = $this->getConfig();
90 if ( ( $config->get( 'EnotifWatchlist' ) ||
$config->get( 'ShowUpdatedMarker' ) )
91 && $request->getVal( 'reset' )
92 && $request->wasPosted()
93 && $user->matchEditToken( $request->getVal( 'token' ) )
95 $user->clearAllNotifications();
96 $output->redirect( $this->getPageTitle()->getFullURL( $opts->getChangedValues() ) );
101 parent
::execute( $subpage );
103 if ( $this->isStructuredFilterUiEnabled() ) {
104 $output->addModuleStyles( [ 'mediawiki.rcfilters.highlightCircles.seenunseen.styles' ] );
106 $output->addJsConfigVars(
107 'wgStructuredChangeFiltersEditWatchlistUrl',
108 SpecialPage
::getTitleFor( 'EditWatchlist' )->getLocalURL()
113 public static function checkStructuredFilterUiEnabled( Config
$config, User
$user ) {
114 if ( !$config->get( 'StructuredChangeFiltersOnWatchlist' ) ) {
118 if ( $config->get( 'StructuredChangeFiltersShowWatchlistPreference' ) ) {
119 return !$user->getOption( 'wlenhancedfilters-disable' );
121 return $user->getOption( 'rcenhancedfilters' );
126 * Return an array of subpages that this special page will accept.
128 * @see also SpecialEditWatchlist::getSubpagesForPrefixSearch
129 * @return string[] subpages
131 public function getSubpagesForPrefixSearch() {
142 protected function transformFilterDefinition( array $filterDefinition ) {
143 if ( isset( $filterDefinition['showHideSuffix'] ) ) {
144 $filterDefinition['showHide'] = 'wl' . $filterDefinition['showHideSuffix'];
147 return $filterDefinition;
153 protected function registerFilters() {
154 parent
::registerFilters();
156 // legacy 'extended' filter
157 $this->registerFilterGroup( new ChangesListBooleanFilterGroup( [
158 'name' => 'extended-group',
161 'name' => 'extended',
162 'isReplacedInStructuredUi' => true,
163 'activeValue' => false,
164 'default' => $this->getUser()->getBoolOption( 'extendwatchlist' ),
165 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables,
166 &$fields, &$conds, &$query_options, &$join_conds ) {
167 $nonRevisionTypes = [ RC_LOG
];
168 Hooks
::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] );
169 if ( $nonRevisionTypes ) {
170 $conds[] = $dbr->makeList(
172 'rc_this_oldid=page_latest',
173 'rc_type' => $nonRevisionTypes,
184 if ( $this->isStructuredFilterUiEnabled() ) {
185 $this->getFilterGroup( 'lastRevision' )
186 ->getFilter( 'hidepreviousrevisions' )
187 ->setDefault( !$this->getUser()->getBoolOption( 'extendwatchlist' ) );
190 $this->registerFilterGroup( new ChangesListStringOptionsFilterGroup( [
191 'name' => 'watchlistactivity',
192 'title' => 'rcfilters-filtergroup-watchlistactivity',
193 'class' => ChangesListStringOptionsFilterGroup
::class,
195 'isFullCoverage' => true,
199 'label' => 'rcfilters-filter-watchlistactivity-unseen-label',
200 'description' => 'rcfilters-filter-watchlistactivity-unseen-description',
201 'cssClassSuffix' => 'watchedunseen',
202 'isRowApplicableCallable' => function ( $ctx, $rc ) {
203 $changeTs = $rc->getAttribute( 'rc_timestamp' );
204 $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
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, $rc ) {
214 $changeTs = $rc->getAttribute( 'rc_timestamp' );
215 $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
216 return $lastVisitTs === null ||
$changeTs < $lastVisitTs;
220 'default' => ChangesListStringOptionsFilterGroup
::NONE
,
221 'queryCallable' => function ( $specialPageClassName, $context, $dbr,
222 &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
223 if ( $selectedValues === [ 'seen' ] ) {
224 $conds[] = $dbr->makeList( [
225 'wl_notificationtimestamp IS NULL',
226 'rc_timestamp < wl_notificationtimestamp'
228 } elseif ( $selectedValues === [ 'unseen' ] ) {
229 $conds[] = $dbr->makeList( [
230 'wl_notificationtimestamp IS NOT NULL',
231 'rc_timestamp >= wl_notificationtimestamp'
237 $user = $this->getUser();
239 $significance = $this->getFilterGroup( 'significance' );
240 $hideMinor = $significance->getFilter( 'hideminor' );
241 $hideMinor->setDefault( $user->getBoolOption( 'watchlisthideminor' ) );
243 $automated = $this->getFilterGroup( 'automated' );
244 $hideBots = $automated->getFilter( 'hidebots' );
245 $hideBots->setDefault( $user->getBoolOption( 'watchlisthidebots' ) );
247 $registration = $this->getFilterGroup( 'registration' );
248 $hideAnons = $registration->getFilter( 'hideanons' );
249 $hideAnons->setDefault( $user->getBoolOption( 'watchlisthideanons' ) );
250 $hideLiu = $registration->getFilter( 'hideliu' );
251 $hideLiu->setDefault( $user->getBoolOption( 'watchlisthideliu' ) );
253 // Selecting both hideanons and hideliu on watchlist preferances
254 // gives mutually exclusive filters, so those are ignored
255 if ( $user->getBoolOption( 'watchlisthideanons' ) &&
256 !$user->getBoolOption( 'watchlisthideliu' )
258 $this->getFilterGroup( 'userExpLevel' )
259 ->setDefault( 'registered' );
262 if ( $user->getBoolOption( 'watchlisthideliu' ) &&
263 !$user->getBoolOption( 'watchlisthideanons' )
265 $this->getFilterGroup( 'userExpLevel' )
266 ->setDefault( 'unregistered' );
269 $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
270 if ( $reviewStatus !== null ) {
271 // Conditional on feature being available and rights
272 if ( $user->getBoolOption( 'watchlisthidepatrolled' ) ) {
273 $reviewStatus->setDefault( 'unpatrolled' );
274 $legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' );
275 $legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' );
276 $legacyHidePatrolled->setDefault( true );
280 $authorship = $this->getFilterGroup( 'authorship' );
281 $hideMyself = $authorship->getFilter( 'hidemyself' );
282 $hideMyself->setDefault( $user->getBoolOption( 'watchlisthideown' ) );
284 $changeType = $this->getFilterGroup( 'changeType' );
285 $hideCategorization = $changeType->getFilter( 'hidecategorization' );
286 if ( $hideCategorization !== null ) {
287 // Conditional on feature being available
288 $hideCategorization->setDefault( $user->getBoolOption( 'watchlisthidecategorization' ) );
293 * Fetch values for a FormOptions object from the WebRequest associated with this instance.
295 * Maps old pre-1.23 request parameters Watchlist used to use (different from Recentchanges' ones)
296 * to the current ones.
298 * @param FormOptions $opts
299 * @return FormOptions
301 protected function fetchOptionsFromRequest( $opts ) {
302 static $compatibilityMap = [
303 'hideMinor' => 'hideminor',
304 'hideBots' => 'hidebots',
305 'hideAnons' => 'hideanons',
306 'hideLiu' => 'hideliu',
307 'hidePatrolled' => 'hidepatrolled',
308 'hideOwn' => 'hidemyself',
311 $params = $this->getRequest()->getValues();
312 foreach ( $compatibilityMap as $from => $to ) {
313 if ( isset( $params[$from] ) ) {
314 $params[$to] = $params[$from];
315 unset( $params[$from] );
319 if ( $this->getRequest()->getVal( 'action' ) == 'submit' ) {
320 $allBooleansFalse = [];
322 // If the user submitted the form, start with a baseline of "all
323 // booleans are false", then change the ones they checked. This
324 // means we ignore the defaults.
326 // This is how we handle the fact that HTML forms don't submit
328 foreach ( $this->getLegacyShowHideFilters() as $filter ) {
329 $allBooleansFalse[ $filter->getName() ] = false;
332 $params = $params +
$allBooleansFalse;
335 // Not the prettiest way to achieve this… FormOptions internally depends on data sanitization
336 // methods defined on WebRequest and removing this dependency would cause some code duplication.
337 $request = new DerivativeRequest( $this->getRequest(), $params );
338 $opts->fetchValuesFromRequest( $request );
346 protected function doMainQuery( $tables, $fields, $conds, $query_options,
347 $join_conds, FormOptions
$opts
349 $dbr = $this->getDB();
350 $user = $this->getUser();
352 $rcQuery = RecentChange
::getQueryInfo();
353 $tables = array_merge( $tables, $rcQuery['tables'], [ 'watchlist' ] );
354 $fields = array_merge( $rcQuery['fields'], $fields );
356 $join_conds = array_merge(
361 'wl_user' => $user->getId(),
362 'wl_namespace=rc_namespace',
372 $fields[] = 'page_latest';
373 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
375 $fields[] = 'wl_notificationtimestamp';
377 // Log entries with DELETED_ACTION must not show up unless the user has
378 // the necessary rights.
379 if ( !$user->isAllowed( 'deletedhistory' ) ) {
380 $bitmask = LogPage
::DELETED_ACTION
;
381 } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
382 $bitmask = LogPage
::DELETED_ACTION | LogPage
::DELETED_RESTRICTED
;
387 $conds[] = $dbr->makeList( [
388 'rc_type != ' . RC_LOG
,
389 $dbr->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
393 $tagFilter = $opts['tagfilter'] ?
explode( '|', $opts['tagfilter'] ) : [];
394 ChangeTags
::modifyDisplayQuery(
403 $this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts );
405 if ( $this->areFiltersInConflict() ) {
410 'ORDER BY' => 'rc_timestamp DESC',
411 'LIMIT' => $opts['limit']
413 if ( in_array( 'DISTINCT', $query_options ) ) {
414 // ChangeTags::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
415 // In order to prevent DISTINCT from causing query performance problems,
416 // we have to GROUP BY the primary key. This in turn requires us to add
417 // the primary key to the end of the ORDER BY, and the old ORDER BY to the
418 // start of the GROUP BY
419 $orderByAndLimit['ORDER BY'] = 'rc_timestamp DESC, rc_id DESC';
420 $orderByAndLimit['GROUP BY'] = 'rc_timestamp, rc_id';
422 // array_merge() is used intentionally here so that hooks can, should
423 // they so desire, override the ORDER BY / LIMIT condition(s)
424 $query_options = array_merge( $orderByAndLimit, $query_options );
436 protected function runMainQueryHook( &$tables, &$fields, &$conds, &$query_options,
439 return parent
::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
441 'SpecialWatchlistQuery',
442 [ &$conds, &$tables, &$join_conds, &$fields, $opts ],
448 * Return a IDatabase object for reading
452 protected function getDB() {
453 return wfGetDB( DB_REPLICA
, 'watchlist' );
459 public function outputFeedLinks() {
460 $user = $this->getUser();
461 $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
463 $this->addFeedLinks( [
464 'action' => 'feedwatchlist',
466 'wlowner' => $user->getName(),
467 'wltoken' => $wlToken,
473 * Build and output the actual changes list.
475 * @param IResultWrapper $rows Database rows
476 * @param FormOptions $opts
478 public function outputChangesList( $rows, $opts ) {
479 $dbr = $this->getDB();
480 $user = $this->getUser();
481 $output = $this->getOutput();
482 $services = MediaWikiServices
::getInstance();
484 # Show a message about replica DB lag, if applicable
485 $lag = $services->getDBLoadBalancer()->safeGetLag( $dbr );
487 $output->showLagWarning( $lag );
490 # If no rows to display, show message before try to render the list
491 if ( $rows->numRows() == 0 ) {
492 $output->wrapWikiMsg(
493 "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
498 $dbr->dataSeek( $rows, 0 );
500 $list = ChangesList
::newFromContext( $this->getContext(), $this->filterGroups
);
501 $list->setWatchlistDivs();
502 $list->initChangesListRows( $rows );
503 if ( $user->getOption( 'watchlistunwatchlinks' ) ) {
504 $list->setChangeLinePrefixer( function ( RecentChange
$rc, ChangesList
$cl, $grouped ) {
505 // Don't show unwatch link if the line is a grouped log entry using EnhancedChangesList,
506 // since EnhancedChangesList groups log entries by performer rather than by target article
507 if ( $rc->mAttribs
['rc_type'] == RC_LOG
&& $cl instanceof EnhancedChangesList
&&
511 return $this->getLinkRenderer()
512 ->makeKnownLink( $rc->getTitle(),
513 $this->msg( 'watchlist-unwatch' )->text(), [
514 'class' => 'mw-unwatch-link',
515 'title' => $this->msg( 'tooltip-ca-unwatch' )->text()
516 ], [ 'action' => 'unwatch' ] ) . "\u{00A0}";
520 $dbr->dataSeek( $rows, 0 );
522 if ( $this->getConfig()->get( 'RCShowWatchingUsers' )
523 && $user->getOption( 'shownumberswatching' )
525 $watchedItemStore = $services->getWatchedItemStore();
528 $s = $list->beginRecentChangesList();
530 if ( $this->isStructuredFilterUiEnabled() ) {
531 $s .= $this->makeLegend();
534 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
536 foreach ( $rows as $obj ) {
538 $rc = RecentChange
::newFromRow( $obj );
540 # Skip CatWatch entries for hidden cats based on user preference
542 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE
&&
543 !$userShowHiddenCats &&
544 $rc->getParam( 'hidden-cat' )
549 $rc->counter
= $counter++
;
551 if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
552 $updated = $obj->wl_notificationtimestamp
;
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 $wlInfo = Html
::rawElement(
620 'data-params' => json_encode( [ 'from' => $timestamp ] ),
622 $this->msg( 'wlnote' )->numParams( $numRows, round( $opts['days'] * 24 ) )->params(
623 $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
627 $nondefaults = $opts->getChangedValues();
628 $cutofflinks = Html
::rawElement(
630 [ 'class' => 'cldays cloption' ],
631 $this->msg( 'wlshowtime' ) . ' ' . $this->cutoffselector( $opts )
634 # Spit out some control panel links
636 $namesOfDisplayedFilters = [];
637 foreach ( $this->getLegacyShowHideFilters() as $filterName => $filter ) {
638 $namesOfDisplayedFilters[] = $filterName;
639 $links[] = $this->showHideCheck(
641 $filter->getShowHide(),
643 $opts[ $filterName ],
644 $filter->isFeatureAvailableOnStructuredUi( $this )
648 $hiddenFields = $nondefaults;
649 $hiddenFields['action'] = 'submit';
650 unset( $hiddenFields['namespace'] );
651 unset( $hiddenFields['invert'] );
652 unset( $hiddenFields['associated'] );
653 unset( $hiddenFields['days'] );
654 foreach ( $namesOfDisplayedFilters as $filterName ) {
655 unset( $hiddenFields[$filterName] );
658 # Namespace filter and put the whole form together.
660 $form .= $cutofflinks;
661 $form .= Html
::rawElement(
663 [ 'class' => 'clshowhide' ],
664 $this->msg( 'watchlist-hide' ) .
665 $this->msg( 'colon-separator' )->escaped() .
666 implode( ' ', $links )
668 $form .= "\n<br />\n";
670 $namespaceForm = Html
::namespaceSelector(
672 'selected' => $opts['namespace'],
674 'label' => $this->msg( 'namespace' )->text()
676 'name' => 'namespace',
678 'class' => 'namespaceselector',
681 $namespaceForm .= '<span class="mw-input-with-label">' . Xml
::checkLabel(
682 $this->msg( 'invert' )->text(),
686 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
688 $namespaceForm .= '<span class="mw-input-with-label">' . Xml
::checkLabel(
689 $this->msg( 'namespace_association' )->text(),
693 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
695 $form .= Html
::rawElement(
697 [ 'class' => 'namespaceForm cloption' ],
701 $form .= Xml
::submitButton(
702 $this->msg( 'watchlist-submit' )->text(),
703 [ 'class' => 'cloption-submit' ]
705 foreach ( $hiddenFields as $key => $value ) {
706 $form .= Html
::hidden( $key, $value ) . "\n";
708 $form .= Xml
::closeElement( 'fieldset' ) . "\n";
709 $form .= Xml
::closeElement( 'form' ) . "\n";
711 // Insert a placeholder for RCFilters
712 if ( $this->isStructuredFilterUiEnabled() ) {
713 $rcfilterContainer = Html
::element(
715 [ 'class' => 'rcfilters-container' ]
718 $loadingContainer = Html
::rawElement(
720 [ 'class' => 'rcfilters-spinner' ],
723 [ 'class' => 'rcfilters-spinner-bounce' ]
727 // Wrap both with rcfilters-head
728 $this->getOutput()->addHTML(
731 [ 'class' => 'rcfilters-head' ],
732 $rcfilterContainer . $form
737 $this->getOutput()->addHTML( $loadingContainer );
739 $this->getOutput()->addHTML( $form );
742 $this->setBottomText( $opts );
745 function cutoffselector( $options ) {
746 $selected = (float)$options['days'];
747 if ( $selected <= 0 ) {
748 $selected = $this->maxDays
;
751 $selectedHours = round( $selected * 24 );
753 $hours = array_unique( array_filter( [
761 24 * (float)$this->getUser()->getOption( 'watchlistdays', 0 ),
767 $select = new XmlSelect( 'days', 'days', (float)( $selectedHours / 24 ) );
769 foreach ( $hours as $value ) {
771 $name = $this->msg( 'hours' )->numParams( $value )->text();
773 $name = $this->msg( 'days' )->numParams( $value / 24 )->text();
775 $select->addOption( $name, (float)( $value / 24 ) );
778 return $select->getHTML() . "\n<br />\n";
781 function setTopText( FormOptions
$opts ) {
782 $nondefaults = $opts->getChangedValues();
784 $user = $this->getUser();
786 $numItems = $this->countItems();
787 $showUpdatedMarker = $this->getConfig()->get( 'ShowUpdatedMarker' );
789 // Show watchlist header
790 $watchlistHeader = '';
791 if ( $numItems == 0 ) {
792 $watchlistHeader = $this->msg( 'nowatchlist' )->parse();
794 $watchlistHeader .= $this->msg( 'watchlist-details' )->numParams( $numItems )->parse() . "\n";
795 if ( $this->getConfig()->get( 'EnotifWatchlist' )
796 && $user->getOption( 'enotifwatchlistpages' )
798 $watchlistHeader .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
800 if ( $showUpdatedMarker ) {
801 $watchlistHeader .= $this->msg(
802 $this->isStructuredFilterUiEnabled() ?
803 'rcfilters-watchlist-showupdated' :
804 'wlheader-showupdated'
808 $form .= Html
::rawElement(
810 [ 'class' => 'watchlistDetails' ],
814 if ( $numItems > 0 && $showUpdatedMarker ) {
815 $form .= Xml
::openElement( 'form', [ 'method' => 'post',
816 'action' => $this->getPageTitle()->getLocalURL(),
817 'id' => 'mw-watchlist-resetbutton' ] ) . "\n" .
818 Xml
::submitButton( $this->msg( 'enotif_reset' )->text(),
819 [ 'name' => 'mw-watchlist-reset-submit' ] ) . "\n" .
820 Html
::hidden( 'token', $user->getEditToken() ) . "\n" .
821 Html
::hidden( 'reset', 'all' ) . "\n";
822 foreach ( $nondefaults as $key => $value ) {
823 $form .= Html
::hidden( $key, $value ) . "\n";
825 $form .= Xml
::closeElement( 'form' ) . "\n";
828 $this->getOutput()->addHTML( $form );
831 protected function showHideCheck( $options, $message, $name, $value, $inStructuredUi ) {
832 $options[$name] = 1 - (int)$value;
834 $attribs = [ 'class' => 'mw-input-with-label clshowhideoption cloption' ];
835 if ( $inStructuredUi ) {
836 $attribs[ 'data-feature-in-structured-ui' ] = true;
839 return Html
::rawElement(
842 // not using Html::checkLabel because that would escape the contents
843 Html
::check( $name, (int)$value, [ 'id' => $name ] ) . Html
::rawElement(
845 $attribs +
[ 'for' => $name ],
846 // <nowiki/> at beginning to avoid messages with "$1 ..." being parsed as pre tags
847 $this->msg( $message, '<nowiki/>' )->parse()
853 * Count the number of paired items on a user's watchlist.
854 * The assumption made here is that when a subject page is watched a talk page is also watched.
855 * Hence the number of individual items is halved.
859 protected function countItems() {
860 $store = MediaWikiServices
::getInstance()->getWatchedItemStore();
861 $count = $store->countWatchedItems( $this->getUser() );
862 return floor( $count / 2 );