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' ] );
108 public static function checkStructuredFilterUiEnabled( Config
$config, User
$user ) {
109 return !$user->getOption( 'wlenhancedfilters-disable' );
113 * Return an array of subpages that this special page will accept.
115 * @see also SpecialEditWatchlist::getSubpagesForPrefixSearch
116 * @return string[] subpages
118 public function getSubpagesForPrefixSearch() {
129 protected function transformFilterDefinition( array $filterDefinition ) {
130 if ( isset( $filterDefinition['showHideSuffix'] ) ) {
131 $filterDefinition['showHide'] = 'wl' . $filterDefinition['showHideSuffix'];
134 return $filterDefinition;
140 protected function registerFilters() {
141 parent
::registerFilters();
143 // legacy 'extended' filter
144 $this->registerFilterGroup( new ChangesListBooleanFilterGroup( [
145 'name' => 'extended-group',
148 'name' => 'extended',
149 'isReplacedInStructuredUi' => true,
150 'activeValue' => false,
151 'default' => $this->getUser()->getBoolOption( 'extendwatchlist' ),
152 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables,
153 &$fields, &$conds, &$query_options, &$join_conds ) {
154 $nonRevisionTypes = [ RC_LOG
];
155 Hooks
::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] );
156 if ( $nonRevisionTypes ) {
157 $conds[] = $dbr->makeList(
159 'rc_this_oldid=page_latest',
160 'rc_type' => $nonRevisionTypes,
171 if ( $this->isStructuredFilterUiEnabled() ) {
172 $this->getFilterGroup( 'lastRevision' )
173 ->getFilter( 'hidepreviousrevisions' )
174 ->setDefault( !$this->getUser()->getBoolOption( 'extendwatchlist' ) );
177 $this->registerFilterGroup( new ChangesListStringOptionsFilterGroup( [
178 'name' => 'watchlistactivity',
179 'title' => 'rcfilters-filtergroup-watchlistactivity',
180 'class' => ChangesListStringOptionsFilterGroup
::class,
182 'isFullCoverage' => true,
186 'label' => 'rcfilters-filter-watchlistactivity-unseen-label',
187 'description' => 'rcfilters-filter-watchlistactivity-unseen-description',
188 'cssClassSuffix' => 'watchedunseen',
189 'isRowApplicableCallable' => function ( $ctx, $rc ) {
190 $changeTs = $rc->getAttribute( 'rc_timestamp' );
191 $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
192 return $lastVisitTs !== null && $changeTs >= $lastVisitTs;
197 'label' => 'rcfilters-filter-watchlistactivity-seen-label',
198 'description' => 'rcfilters-filter-watchlistactivity-seen-description',
199 'cssClassSuffix' => 'watchedseen',
200 'isRowApplicableCallable' => function ( $ctx, $rc ) {
201 $changeTs = $rc->getAttribute( 'rc_timestamp' );
202 $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
203 return $lastVisitTs === null ||
$changeTs < $lastVisitTs;
207 'default' => ChangesListStringOptionsFilterGroup
::NONE
,
208 'queryCallable' => function ( $specialPageClassName, $context, $dbr,
209 &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
210 if ( $selectedValues === [ 'seen' ] ) {
211 $conds[] = $dbr->makeList( [
212 'wl_notificationtimestamp IS NULL',
213 'rc_timestamp < wl_notificationtimestamp'
215 } elseif ( $selectedValues === [ 'unseen' ] ) {
216 $conds[] = $dbr->makeList( [
217 'wl_notificationtimestamp IS NOT NULL',
218 'rc_timestamp >= wl_notificationtimestamp'
224 $user = $this->getUser();
226 $significance = $this->getFilterGroup( 'significance' );
227 $hideMinor = $significance->getFilter( 'hideminor' );
228 $hideMinor->setDefault( $user->getBoolOption( 'watchlisthideminor' ) );
230 $automated = $this->getFilterGroup( 'automated' );
231 $hideBots = $automated->getFilter( 'hidebots' );
232 $hideBots->setDefault( $user->getBoolOption( 'watchlisthidebots' ) );
234 $registration = $this->getFilterGroup( 'registration' );
235 $hideAnons = $registration->getFilter( 'hideanons' );
236 $hideAnons->setDefault( $user->getBoolOption( 'watchlisthideanons' ) );
237 $hideLiu = $registration->getFilter( 'hideliu' );
238 $hideLiu->setDefault( $user->getBoolOption( 'watchlisthideliu' ) );
240 // Selecting both hideanons and hideliu on watchlist preferances
241 // gives mutually exclusive filters, so those are ignored
242 if ( $user->getBoolOption( 'watchlisthideanons' ) &&
243 !$user->getBoolOption( 'watchlisthideliu' )
245 $this->getFilterGroup( 'userExpLevel' )
246 ->setDefault( 'registered' );
249 if ( $user->getBoolOption( 'watchlisthideliu' ) &&
250 !$user->getBoolOption( 'watchlisthideanons' )
252 $this->getFilterGroup( 'userExpLevel' )
253 ->setDefault( 'unregistered' );
256 $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
257 if ( $reviewStatus !== null ) {
258 // Conditional on feature being available and rights
259 if ( $user->getBoolOption( 'watchlisthidepatrolled' ) ) {
260 $reviewStatus->setDefault( 'unpatrolled' );
261 $legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' );
262 $legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' );
263 $legacyHidePatrolled->setDefault( true );
267 $authorship = $this->getFilterGroup( 'authorship' );
268 $hideMyself = $authorship->getFilter( 'hidemyself' );
269 $hideMyself->setDefault( $user->getBoolOption( 'watchlisthideown' ) );
271 $changeType = $this->getFilterGroup( 'changeType' );
272 $hideCategorization = $changeType->getFilter( 'hidecategorization' );
273 if ( $hideCategorization !== null ) {
274 // Conditional on feature being available
275 $hideCategorization->setDefault( $user->getBoolOption( 'watchlisthidecategorization' ) );
280 * Fetch values for a FormOptions object from the WebRequest associated with this instance.
282 * Maps old pre-1.23 request parameters Watchlist used to use (different from Recentchanges' ones)
283 * to the current ones.
285 * @param FormOptions $opts
286 * @return FormOptions
288 protected function fetchOptionsFromRequest( $opts ) {
289 static $compatibilityMap = [
290 'hideMinor' => 'hideminor',
291 'hideBots' => 'hidebots',
292 'hideAnons' => 'hideanons',
293 'hideLiu' => 'hideliu',
294 'hidePatrolled' => 'hidepatrolled',
295 'hideOwn' => 'hidemyself',
298 $params = $this->getRequest()->getValues();
299 foreach ( $compatibilityMap as $from => $to ) {
300 if ( isset( $params[$from] ) ) {
301 $params[$to] = $params[$from];
302 unset( $params[$from] );
306 if ( $this->getRequest()->getVal( 'action' ) == 'submit' ) {
307 $allBooleansFalse = [];
309 // If the user submitted the form, start with a baseline of "all
310 // booleans are false", then change the ones they checked. This
311 // means we ignore the defaults.
313 // This is how we handle the fact that HTML forms don't submit
315 foreach ( $this->getLegacyShowHideFilters() as $filter ) {
316 $allBooleansFalse[ $filter->getName() ] = false;
319 $params = $params +
$allBooleansFalse;
322 // Not the prettiest way to achieve this… FormOptions internally depends on data sanitization
323 // methods defined on WebRequest and removing this dependency would cause some code duplication.
324 $request = new DerivativeRequest( $this->getRequest(), $params );
325 $opts->fetchValuesFromRequest( $request );
333 protected function doMainQuery( $tables, $fields, $conds, $query_options,
334 $join_conds, FormOptions
$opts
336 $dbr = $this->getDB();
337 $user = $this->getUser();
339 $rcQuery = RecentChange
::getQueryInfo();
340 $tables = array_merge( $tables, $rcQuery['tables'], [ 'watchlist' ] );
341 $fields = array_merge( $rcQuery['fields'], $fields );
343 $join_conds = array_merge(
348 'wl_user' => $user->getId(),
349 'wl_namespace=rc_namespace',
359 $fields[] = 'page_latest';
360 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
362 $fields[] = 'wl_notificationtimestamp';
364 // Log entries with DELETED_ACTION must not show up unless the user has
365 // the necessary rights.
366 if ( !$user->isAllowed( 'deletedhistory' ) ) {
367 $bitmask = LogPage
::DELETED_ACTION
;
368 } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
369 $bitmask = LogPage
::DELETED_ACTION | LogPage
::DELETED_RESTRICTED
;
374 $conds[] = $dbr->makeList( [
375 'rc_type != ' . RC_LOG
,
376 $dbr->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
380 $tagFilter = $opts['tagfilter'] ?
explode( '|', $opts['tagfilter'] ) : [];
381 ChangeTags
::modifyDisplayQuery(
390 $this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts );
392 if ( $this->areFiltersInConflict() ) {
397 'ORDER BY' => 'rc_timestamp DESC',
398 'LIMIT' => $opts['limit']
400 if ( in_array( 'DISTINCT', $query_options ) ) {
401 // ChangeTags::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
402 // In order to prevent DISTINCT from causing query performance problems,
403 // we have to GROUP BY the primary key. This in turn requires us to add
404 // the primary key to the end of the ORDER BY, and the old ORDER BY to the
405 // start of the GROUP BY
406 $orderByAndLimit['ORDER BY'] = 'rc_timestamp DESC, rc_id DESC';
407 $orderByAndLimit['GROUP BY'] = 'rc_timestamp, rc_id';
409 // array_merge() is used intentionally here so that hooks can, should
410 // they so desire, override the ORDER BY / LIMIT condition(s)
411 $query_options = array_merge( $orderByAndLimit, $query_options );
424 * Return a IDatabase object for reading
428 protected function getDB() {
429 return wfGetDB( DB_REPLICA
, 'watchlist' );
435 public function outputFeedLinks() {
436 $user = $this->getUser();
437 $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
439 $this->addFeedLinks( [
440 'action' => 'feedwatchlist',
442 'wlowner' => $user->getName(),
443 'wltoken' => $wlToken,
449 * Build and output the actual changes list.
451 * @param IResultWrapper $rows Database rows
452 * @param FormOptions $opts
454 public function outputChangesList( $rows, $opts ) {
455 $dbr = $this->getDB();
456 $user = $this->getUser();
457 $output = $this->getOutput();
458 $services = MediaWikiServices
::getInstance();
460 # Show a message about replica DB lag, if applicable
461 $lag = $services->getDBLoadBalancer()->safeGetLag( $dbr );
463 $output->showLagWarning( $lag );
466 # If no rows to display, show message before try to render the list
467 if ( $rows->numRows() == 0 ) {
468 $output->wrapWikiMsg(
469 "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
474 $dbr->dataSeek( $rows, 0 );
476 $list = ChangesList
::newFromContext( $this->getContext(), $this->filterGroups
);
477 $list->setWatchlistDivs();
478 $list->initChangesListRows( $rows );
479 if ( $user->getOption( 'watchlistunwatchlinks' ) ) {
480 $list->setChangeLinePrefixer( function ( RecentChange
$rc, ChangesList
$cl, $grouped ) {
481 // Don't show unwatch link if the line is a grouped log entry using EnhancedChangesList,
482 // since EnhancedChangesList groups log entries by performer rather than by target article
483 if ( $rc->mAttribs
['rc_type'] == RC_LOG
&& $cl instanceof EnhancedChangesList
&&
487 return $this->getLinkRenderer()
488 ->makeKnownLink( $rc->getTitle(),
489 $this->msg( 'watchlist-unwatch' )->text(), [
490 'class' => 'mw-unwatch-link',
491 'title' => $this->msg( 'tooltip-ca-unwatch' )->text()
492 ], [ 'action' => 'unwatch' ] ) . "\u{00A0}";
496 $dbr->dataSeek( $rows, 0 );
498 if ( $this->getConfig()->get( 'RCShowWatchingUsers' )
499 && $user->getOption( 'shownumberswatching' )
501 $watchedItemStore = $services->getWatchedItemStore();
504 $s = $list->beginRecentChangesList();
506 if ( $this->isStructuredFilterUiEnabled() ) {
507 $s .= $this->makeLegend();
510 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
512 foreach ( $rows as $obj ) {
514 $rc = RecentChange
::newFromRow( $obj );
516 # Skip CatWatch entries for hidden cats based on user preference
518 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE
&&
519 !$userShowHiddenCats &&
520 $rc->getParam( 'hidden-cat' )
525 $rc->counter
= $counter++
;
527 if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
528 $updated = $obj->wl_notificationtimestamp
;
533 if ( isset( $watchedItemStore ) ) {
534 $rcTitleValue = new TitleValue( (int)$obj->rc_namespace
, $obj->rc_title
);
535 $rc->numberofWatchingusers
= $watchedItemStore->countWatchers( $rcTitleValue );
537 $rc->numberofWatchingusers
= 0;
540 $changeLine = $list->recentChangesLine( $rc, $updated, $counter );
541 if ( $changeLine !== false ) {
545 $s .= $list->endRecentChangesList();
547 $output->addHTML( $s );
551 * Set the text to be displayed above the changes
553 * @param FormOptions $opts
554 * @param int $numRows Number of rows in the result to show after this header
556 public function doHeader( $opts, $numRows ) {
557 $user = $this->getUser();
558 $out = $this->getOutput();
561 $this->msg( 'watchlistfor2', $user->getName() )
562 ->rawParams( SpecialEditWatchlist
::buildTools(
563 $this->getLanguage(),
564 $this->getLinkRenderer()
568 $this->setTopText( $opts );
572 $form .= Xml
::openElement( 'form', [
574 'action' => wfScript(),
575 'id' => 'mw-watchlist-form'
577 $form .= Html
::hidden( 'title', $this->getPageTitle()->getPrefixedText() );
578 $form .= Xml
::openElement(
580 [ 'id' => 'mw-watchlist-options', 'class' => 'cloptions' ]
582 $form .= Xml
::element(
583 'legend', null, $this->msg( 'watchlist-options' )->text()
586 if ( !$this->isStructuredFilterUiEnabled() ) {
587 $form .= $this->makeLegend();
590 $lang = $this->getLanguage();
591 $timestamp = wfTimestampNow();
592 $wlInfo = Html
::rawElement(
596 'data-params' => json_encode( [ 'from' => $timestamp ] ),
598 $this->msg( 'wlnote' )->numParams( $numRows, round( $opts['days'] * 24 ) )->params(
599 $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
603 $nondefaults = $opts->getChangedValues();
604 $cutofflinks = Html
::rawElement(
606 [ 'class' => 'cldays cloption' ],
607 $this->msg( 'wlshowtime' ) . ' ' . $this->cutoffselector( $opts )
610 # Spit out some control panel links
612 $namesOfDisplayedFilters = [];
613 foreach ( $this->getLegacyShowHideFilters() as $filterName => $filter ) {
614 $namesOfDisplayedFilters[] = $filterName;
615 $links[] = $this->showHideCheck(
617 $filter->getShowHide(),
619 $opts[ $filterName ],
620 $filter->isFeatureAvailableOnStructuredUi( $this )
624 $hiddenFields = $nondefaults;
625 $hiddenFields['action'] = 'submit';
626 unset( $hiddenFields['namespace'] );
627 unset( $hiddenFields['invert'] );
628 unset( $hiddenFields['associated'] );
629 unset( $hiddenFields['days'] );
630 foreach ( $namesOfDisplayedFilters as $filterName ) {
631 unset( $hiddenFields[$filterName] );
634 # Namespace filter and put the whole form together.
636 $form .= $cutofflinks;
637 $form .= Html
::rawElement(
639 [ 'class' => 'clshowhide' ],
640 $this->msg( 'watchlist-hide' ) .
641 $this->msg( 'colon-separator' )->escaped() .
642 implode( ' ', $links )
644 $form .= "\n<br />\n";
646 $namespaceForm = Html
::namespaceSelector(
648 'selected' => $opts['namespace'],
650 'label' => $this->msg( 'namespace' )->text(),
651 'in-user-lang' => true,
653 'name' => 'namespace',
655 'class' => 'namespaceselector',
658 $namespaceForm .= '<span class="mw-input-with-label">' . Xml
::checkLabel(
659 $this->msg( 'invert' )->text(),
663 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
665 $namespaceForm .= '<span class="mw-input-with-label">' . Xml
::checkLabel(
666 $this->msg( 'namespace_association' )->text(),
670 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
672 $form .= Html
::rawElement(
674 [ 'class' => 'namespaceForm cloption' ],
678 $form .= Xml
::submitButton(
679 $this->msg( 'watchlist-submit' )->text(),
680 [ 'class' => 'cloption-submit' ]
682 foreach ( $hiddenFields as $key => $value ) {
683 $form .= Html
::hidden( $key, $value ) . "\n";
685 $form .= Xml
::closeElement( 'fieldset' ) . "\n";
686 $form .= Xml
::closeElement( 'form' ) . "\n";
688 // Insert a placeholder for RCFilters
689 if ( $this->isStructuredFilterUiEnabled() ) {
690 $rcfilterContainer = Html
::element(
692 [ 'class' => 'rcfilters-container' ]
695 $loadingContainer = Html
::rawElement(
697 [ 'class' => 'rcfilters-spinner' ],
700 [ 'class' => 'rcfilters-spinner-bounce' ]
704 // Wrap both with rcfilters-head
705 $this->getOutput()->addHTML(
708 [ 'class' => 'rcfilters-head' ],
709 $rcfilterContainer . $form
714 $this->getOutput()->addHTML( $loadingContainer );
716 $this->getOutput()->addHTML( $form );
719 $this->setBottomText( $opts );
722 function cutoffselector( $options ) {
723 $selected = (float)$options['days'];
724 if ( $selected <= 0 ) {
725 $selected = $this->maxDays
;
728 $selectedHours = round( $selected * 24 );
730 $hours = array_unique( array_filter( [
738 24 * (float)$this->getUser()->getOption( 'watchlistdays', 0 ),
744 $select = new XmlSelect( 'days', 'days', (float)( $selectedHours / 24 ) );
746 foreach ( $hours as $value ) {
748 $name = $this->msg( 'hours' )->numParams( $value )->text();
750 $name = $this->msg( 'days' )->numParams( $value / 24 )->text();
752 $select->addOption( $name, (float)( $value / 24 ) );
755 return $select->getHTML() . "\n<br />\n";
758 function setTopText( FormOptions
$opts ) {
759 $nondefaults = $opts->getChangedValues();
761 $user = $this->getUser();
763 $numItems = $this->countItems();
764 $showUpdatedMarker = $this->getConfig()->get( 'ShowUpdatedMarker' );
766 // Show watchlist header
767 $watchlistHeader = '';
768 if ( $numItems == 0 ) {
769 $watchlistHeader = $this->msg( 'nowatchlist' )->parse();
771 $watchlistHeader .= $this->msg( 'watchlist-details' )->numParams( $numItems )->parse() . "\n";
772 if ( $this->getConfig()->get( 'EnotifWatchlist' )
773 && $user->getOption( 'enotifwatchlistpages' )
775 $watchlistHeader .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
777 if ( $showUpdatedMarker ) {
778 $watchlistHeader .= $this->msg(
779 $this->isStructuredFilterUiEnabled() ?
780 'rcfilters-watchlist-showupdated' :
781 'wlheader-showupdated'
785 $form .= Html
::rawElement(
787 [ 'class' => 'watchlistDetails' ],
791 if ( $numItems > 0 && $showUpdatedMarker ) {
792 $form .= Xml
::openElement( 'form', [ 'method' => 'post',
793 'action' => $this->getPageTitle()->getLocalURL(),
794 'id' => 'mw-watchlist-resetbutton' ] ) . "\n" .
795 Xml
::submitButton( $this->msg( 'enotif_reset' )->text(),
796 [ 'name' => 'mw-watchlist-reset-submit' ] ) . "\n" .
797 Html
::hidden( 'token', $user->getEditToken() ) . "\n" .
798 Html
::hidden( 'reset', 'all' ) . "\n";
799 foreach ( $nondefaults as $key => $value ) {
800 $form .= Html
::hidden( $key, $value ) . "\n";
802 $form .= Xml
::closeElement( 'form' ) . "\n";
805 $this->getOutput()->addHTML( $form );
808 protected function showHideCheck( $options, $message, $name, $value, $inStructuredUi ) {
809 $options[$name] = 1 - (int)$value;
811 $attribs = [ 'class' => 'mw-input-with-label clshowhideoption cloption' ];
812 if ( $inStructuredUi ) {
813 $attribs[ 'data-feature-in-structured-ui' ] = true;
816 return Html
::rawElement(
819 // not using Html::checkLabel because that would escape the contents
820 Html
::check( $name, (int)$value, [ 'id' => $name ] ) . Html
::rawElement(
822 $attribs +
[ 'for' => $name ],
823 // <nowiki/> at beginning to avoid messages with "$1 ..." being parsed as pre tags
824 $this->msg( $message, '<nowiki/>' )->parse()
830 * Count the number of paired items on a user's watchlist.
831 * The assumption made here is that when a subject page is watched a talk page is also watched.
832 * Hence the number of individual items is halved.
836 protected function countItems() {
837 $store = MediaWikiServices
::getInstance()->getWatchedItemStore();
838 $count = $store->countWatchedItems( $this->getUser() );
839 return floor( $count / 2 );