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\ResultWrapper
;
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
{
37 public function __construct( $page = 'Watchlist', $restriction = 'viewmywatchlist' ) {
38 parent
::__construct( $page, $restriction );
40 $this->maxDays
= $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 );
43 public function doesWrites() {
48 * Main execution point
50 * @param string $subpage
52 function execute( $subpage ) {
53 // Anons don't get a watchlist
54 $this->requireLogin( 'watchlistanontext' );
56 $output = $this->getOutput();
57 $request = $this->getRequest();
58 $this->addHelpLink( 'Help:Watching pages' );
59 $output->addModules( [
60 'mediawiki.special.changeslist.visitedstatus',
61 'mediawiki.special.watchlist',
63 $output->addModuleStyles( [ 'mediawiki.special.watchlist.styles' ] );
65 $mode = SpecialEditWatchlist
::getMode( $request, $subpage );
66 if ( $mode !== false ) {
67 if ( $mode === SpecialEditWatchlist
::EDIT_RAW
) {
68 $title = SpecialPage
::getTitleFor( 'EditWatchlist', 'raw' );
69 } elseif ( $mode === SpecialEditWatchlist
::EDIT_CLEAR
) {
70 $title = SpecialPage
::getTitleFor( 'EditWatchlist', 'clear' );
72 $title = SpecialPage
::getTitleFor( 'EditWatchlist' );
75 $output->redirect( $title->getLocalURL() );
80 $this->checkPermissions();
82 $user = $this->getUser();
83 $opts = $this->getOptions();
85 $config = $this->getConfig();
86 if ( ( $config->get( 'EnotifWatchlist' ) ||
$config->get( 'ShowUpdatedMarker' ) )
87 && $request->getVal( 'reset' )
88 && $request->wasPosted()
89 && $user->matchEditToken( $request->getVal( 'token' ) )
91 $user->clearAllNotifications();
92 $output->redirect( $this->getPageTitle()->getFullURL( $opts->getChangedValues() ) );
97 parent
::execute( $subpage );
99 if ( $this->isStructuredFilterUiEnabled() ) {
100 $output->addModuleStyles( [ 'mediawiki.rcfilters.highlightCircles.seenunseen.styles' ] );
102 $output->addJsConfigVars( 'wgStructuredChangeFiltersLiveUpdateSupported', false );
103 $output->addJsConfigVars(
104 'wgStructuredChangeFiltersSavedQueriesPreferenceName',
105 'rcfilters-wl-saved-queries'
110 protected function isStructuredFilterUiEnabled() {
111 return parent
::isStructuredFilterUiEnabled()
112 && ( $this->getConfig()->get( 'StructuredChangeFiltersOnWatchlist' )
113 ||
$this->getRequest()->getBool( 'rcfilters' ) );
117 * Return an array of subpages that this special page will accept.
119 * @see also SpecialEditWatchlist::getSubpagesForPrefixSearch
120 * @return string[] subpages
122 public function getSubpagesForPrefixSearch() {
133 protected function transformFilterDefinition( array $filterDefinition ) {
134 if ( isset( $filterDefinition['showHideSuffix'] ) ) {
135 $filterDefinition['showHide'] = 'wl' . $filterDefinition['showHideSuffix'];
138 return $filterDefinition;
144 protected function registerFilters() {
145 parent
::registerFilters();
147 $this->registerFilterGroup( new ChangesListStringOptionsFilterGroup( [
148 'name' => 'watchlistactivity',
149 'title' => 'rcfilters-filtergroup-watchlistactivity',
150 'class' => ChangesListStringOptionsFilterGroup
::class,
152 'isFullCoverage' => true,
156 'label' => 'rcfilters-filter-watchlistactivity-unseen-label',
157 'description' => 'rcfilters-filter-watchlistactivity-unseen-description',
158 'cssClassSuffix' => 'watchedunseen',
159 'isRowApplicableCallable' => function ( $ctx, $rc ) {
160 $changeTs = $rc->getAttribute( 'rc_timestamp' );
161 $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
162 return $lastVisitTs !== null && $changeTs >= $lastVisitTs;
167 'label' => 'rcfilters-filter-watchlistactivity-seen-label',
168 'description' => 'rcfilters-filter-watchlistactivity-seen-description',
169 'cssClassSuffix' => 'watchedseen',
170 'isRowApplicableCallable' => function ( $ctx, $rc ) {
171 $changeTs = $rc->getAttribute( 'rc_timestamp' );
172 $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
173 return $lastVisitTs === null ||
$changeTs < $lastVisitTs;
177 'default' => ChangesListStringOptionsFilterGroup
::NONE
,
178 'queryCallable' => function ( $specialPageClassName, $context, $dbr,
179 &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
180 if ( $selectedValues === [ 'seen' ] ) {
181 $conds[] = $dbr->makeList( [
182 'wl_notificationtimestamp IS NULL',
183 'rc_timestamp < wl_notificationtimestamp'
185 } elseif ( $selectedValues === [ 'unseen' ] ) {
186 $conds[] = $dbr->makeList( [
187 'wl_notificationtimestamp IS NOT NULL',
188 'rc_timestamp >= wl_notificationtimestamp'
194 $user = $this->getUser();
196 $significance = $this->getFilterGroup( 'significance' );
197 $hideMinor = $significance->getFilter( 'hideminor' );
198 $hideMinor->setDefault( $user->getBoolOption( 'watchlisthideminor' ) );
200 $automated = $this->getFilterGroup( 'automated' );
201 $hideBots = $automated->getFilter( 'hidebots' );
202 $hideBots->setDefault( $user->getBoolOption( 'watchlisthidebots' ) );
204 $registration = $this->getFilterGroup( 'registration' );
205 $hideAnons = $registration->getFilter( 'hideanons' );
206 $hideAnons->setDefault( $user->getBoolOption( 'watchlisthideanons' ) );
207 $hideLiu = $registration->getFilter( 'hideliu' );
208 $hideLiu->setDefault( $user->getBoolOption( 'watchlisthideliu' ) );
210 $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
211 if ( $reviewStatus !== null ) {
212 // Conditional on feature being available and rights
213 $hidePatrolled = $reviewStatus->getFilter( 'hidepatrolled' );
214 $hidePatrolled->setDefault( $user->getBoolOption( 'watchlisthidepatrolled' ) );
217 $authorship = $this->getFilterGroup( 'authorship' );
218 $hideMyself = $authorship->getFilter( 'hidemyself' );
219 $hideMyself->setDefault( $user->getBoolOption( 'watchlisthideown' ) );
221 $changeType = $this->getFilterGroup( 'changeType' );
222 $hideCategorization = $changeType->getFilter( 'hidecategorization' );
223 if ( $hideCategorization !== null ) {
224 // Conditional on feature being available
225 $hideCategorization->setDefault( $user->getBoolOption( 'watchlisthidecategorization' ) );
230 * Get a FormOptions object containing the default options
232 * @return FormOptions
234 public function getDefaultOptions() {
235 $opts = parent
::getDefaultOptions();
236 $user = $this->getUser();
238 $opts->add( 'days', $user->getOption( 'watchlistdays' ), FormOptions
::FLOAT );
239 $opts->add( 'extended', $user->getBoolOption( 'extendwatchlist' ) );
240 $opts->add( 'limit', $user->getIntOption( 'wllimit' ), FormOptions
::INT );
245 public function validateOptions( FormOptions
$opts ) {
246 $opts->validateBounds( 'days', 0, $this->maxDays
);
247 $opts->validateIntBounds( 'limit', 0, 5000 );
248 parent
::validateOptions( $opts );
252 * Get all custom filters
254 * @return array Map of filter URL param names to properties (msg/default)
256 protected function getCustomFilters() {
257 if ( $this->customFilters
=== null ) {
258 $this->customFilters
= parent
::getCustomFilters();
259 Hooks
::run( 'SpecialWatchlistFilters', [ $this, &$this->customFilters
], '1.23' );
262 return $this->customFilters
;
266 * Fetch values for a FormOptions object from the WebRequest associated with this instance.
268 * Maps old pre-1.23 request parameters Watchlist used to use (different from Recentchanges' ones)
269 * to the current ones.
271 * @param FormOptions $opts
272 * @return FormOptions
274 protected function fetchOptionsFromRequest( $opts ) {
275 static $compatibilityMap = [
276 'hideMinor' => 'hideminor',
277 'hideBots' => 'hidebots',
278 'hideAnons' => 'hideanons',
279 'hideLiu' => 'hideliu',
280 'hidePatrolled' => 'hidepatrolled',
281 'hideOwn' => 'hidemyself',
284 $params = $this->getRequest()->getValues();
285 foreach ( $compatibilityMap as $from => $to ) {
286 if ( isset( $params[$from] ) ) {
287 $params[$to] = $params[$from];
288 unset( $params[$from] );
292 if ( $this->getRequest()->getVal( 'action' ) == 'submit' ) {
293 $allBooleansFalse = [];
295 // If the user submitted the form, start with a baseline of "all
296 // booleans are false", then change the ones they checked. This
297 // means we ignore the defaults.
299 // This is how we handle the fact that HTML forms don't submit
301 foreach ( $this->filterGroups
as $filterGroup ) {
302 if ( $filterGroup instanceof ChangesListBooleanFilterGroup
) {
303 foreach ( $filterGroup->getFilters() as $filter ) {
304 $allBooleansFalse[$filter->getName()] = false;
309 $params = $params +
$allBooleansFalse;
312 // Not the prettiest way to achieve this… FormOptions internally depends on data sanitization
313 // methods defined on WebRequest and removing this dependency would cause some code duplication.
314 $request = new DerivativeRequest( $this->getRequest(), $params );
315 $opts->fetchValuesFromRequest( $request );
323 protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
324 &$join_conds, FormOptions
$opts
326 $dbr = $this->getDB();
327 parent
::buildQuery( $tables, $fields, $conds, $query_options, $join_conds,
331 if ( $opts['days'] > 0 ) {
332 $conds[] = 'rc_timestamp > ' .
333 $dbr->addQuotes( $dbr->timestamp( time() - $opts['days'] * 3600 * 24 ) );
340 protected function doMainQuery( $tables, $fields, $conds, $query_options,
341 $join_conds, FormOptions
$opts
343 $dbr = $this->getDB();
344 $user = $this->getUser();
346 # Toggle watchlist content (all recent edits or just the latest)
347 if ( !$opts['extended'] ) {
348 # Top log Ids for a page are not stored
349 $nonRevisionTypes = [ RC_LOG
];
350 Hooks
::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] );
351 if ( $nonRevisionTypes ) {
352 $conds[] = $dbr->makeList(
354 'rc_this_oldid=page_latest',
355 'rc_type' => $nonRevisionTypes,
362 $tables = array_merge( [ 'recentchanges', 'watchlist' ], $tables );
363 $fields = array_merge( RecentChange
::selectFields(), $fields );
365 $query_options = array_merge( [
366 'ORDER BY' => 'rc_timestamp DESC',
367 'LIMIT' => $opts['limit']
369 $join_conds = array_merge(
374 'wl_user' => $user->getId(),
375 'wl_namespace=rc_namespace',
384 $fields[] = 'page_latest';
385 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
387 $fields[] = 'wl_notificationtimestamp';
389 // Log entries with DELETED_ACTION must not show up unless the user has
390 // the necessary rights.
391 if ( !$user->isAllowed( 'deletedhistory' ) ) {
392 $bitmask = LogPage
::DELETED_ACTION
;
393 } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
394 $bitmask = LogPage
::DELETED_ACTION | LogPage
::DELETED_RESTRICTED
;
399 $conds[] = $dbr->makeList( [
400 'rc_type != ' . RC_LOG
,
401 $dbr->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
405 ChangeTags
::modifyDisplayQuery(
414 $this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts );
416 if ( $this->areFiltersInConflict() ) {
430 protected function runMainQueryHook( &$tables, &$fields, &$conds, &$query_options,
433 return parent
::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
435 'SpecialWatchlistQuery',
436 [ &$conds, &$tables, &$join_conds, &$fields, $opts ],
442 * Return a IDatabase object for reading
446 protected function getDB() {
447 return wfGetDB( DB_REPLICA
, 'watchlist' );
453 public function outputFeedLinks() {
454 $user = $this->getUser();
455 $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
457 $this->addFeedLinks( [
458 'action' => 'feedwatchlist',
460 'wlowner' => $user->getName(),
461 'wltoken' => $wlToken,
467 * Build and output the actual changes list.
469 * @param ResultWrapper $rows Database rows
470 * @param FormOptions $opts
472 public function outputChangesList( $rows, $opts ) {
473 $dbr = $this->getDB();
474 $user = $this->getUser();
475 $output = $this->getOutput();
477 # Show a message about replica DB lag, if applicable
478 $lag = wfGetLB()->safeGetLag( $dbr );
480 $output->showLagWarning( $lag );
483 # If no rows to display, show message before try to render the list
484 if ( $rows->numRows() == 0 ) {
485 $output->wrapWikiMsg(
486 "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
491 $dbr->dataSeek( $rows, 0 );
493 $list = ChangesList
::newFromContext( $this->getContext(), $this->filterGroups
);
494 $list->setWatchlistDivs();
495 $list->initChangesListRows( $rows );
496 if ( $user->getOption( 'watchlistunwatchlinks' ) ) {
497 $list->setChangeLinePrefixer( function ( RecentChange
$rc, ChangesList
$cl, $grouped ) {
498 // Don't show unwatch link if the line is a grouped log entry using EnhancedChangesList,
499 // since EnhancedChangesList groups log entries by performer rather than by target article
500 if ( $rc->mAttribs
['rc_type'] == RC_LOG
&& $cl instanceof EnhancedChangesList
&&
504 return $this->getLinkRenderer()
505 ->makeKnownLink( $rc->getTitle(),
506 $this->msg( 'watchlist-unwatch' )->text(), [
507 'class' => 'mw-unwatch-link',
508 'title' => $this->msg( 'tooltip-ca-unwatch' )->text()
509 ], [ 'action' => 'unwatch' ] ) . ' ';
513 $dbr->dataSeek( $rows, 0 );
515 if ( $this->getConfig()->get( 'RCShowWatchingUsers' )
516 && $user->getOption( 'shownumberswatching' )
518 $watchedItemStore = MediaWikiServices
::getInstance()->getWatchedItemStore();
521 $s = $list->beginRecentChangesList();
523 if ( $this->isStructuredFilterUiEnabled() ) {
524 $s .= $this->makeLegend();
527 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
529 foreach ( $rows as $obj ) {
531 $rc = RecentChange
::newFromRow( $obj );
533 # Skip CatWatch entries for hidden cats based on user preference
535 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE
&&
536 !$userShowHiddenCats &&
537 $rc->getParam( 'hidden-cat' )
542 $rc->counter
= $counter++
;
544 if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
545 $updated = $obj->wl_notificationtimestamp
;
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
::fieldset(
596 $this->msg( 'watchlist-options' )->text(),
598 [ 'id' => 'mw-watchlist-options', 'class' => 'cloptions' ]
601 if ( !$this->isStructuredFilterUiEnabled() ) {
602 $form .= $this->makeLegend();
605 $lang = $this->getLanguage();
606 if ( $opts['days'] > 0 ) {
607 $days = $opts['days'];
609 $days = $this->maxDays
;
611 $timestamp = wfTimestampNow();
612 $wlInfo = Html
::rawElement(
614 [ 'class' => 'wlinfo' ],
615 $this->msg( 'wlnote' )->numParams( $numRows, round( $days * 24 ) )->params(
616 $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
620 $nondefaults = $opts->getChangedValues();
621 $cutofflinks = Html
::rawElement(
623 [ 'class' => 'cldays cloption' ],
624 $this->msg( 'wlshowtime' ) . ' ' . $this->cutoffselector( $opts )
627 # Spit out some control panel links
629 $namesOfDisplayedFilters = [];
630 foreach ( $this->getFilterGroups() as $groupName => $group ) {
631 if ( !$group->isPerGroupRequestParameter() ) {
632 foreach ( $group->getFilters() as $filterName => $filter ) {
633 if ( $filter->displaysOnUnstructuredUi( $this ) ) {
634 $namesOfDisplayedFilters[] = $filterName;
635 $links[] = $this->showHideCheck(
637 $filter->getShowHide(),
640 $filter->isFeatureAvailableOnStructuredUi( $this )
647 $hiddenFields = $nondefaults;
648 $hiddenFields['action'] = 'submit';
649 unset( $hiddenFields['namespace'] );
650 unset( $hiddenFields['invert'] );
651 unset( $hiddenFields['associated'] );
652 unset( $hiddenFields['days'] );
653 foreach ( $namesOfDisplayedFilters as $filterName ) {
654 unset( $hiddenFields[$filterName] );
657 # Namespace filter and put the whole form together.
659 $form .= $cutofflinks;
660 $form .= Html
::rawElement(
662 [ 'class' => 'clshowhide' ],
663 $this->msg( 'watchlist-hide' ) .
664 $this->msg( 'colon-separator' )->escaped() .
665 implode( ' ', $links )
667 $form .= "\n<br />\n";
669 $namespaceForm = Html
::namespaceSelector(
671 'selected' => $opts['namespace'],
673 'label' => $this->msg( 'namespace' )->text()
675 'name' => 'namespace',
677 'class' => 'namespaceselector',
680 $namespaceForm .= '<span class="mw-input-with-label">' . Xml
::checkLabel(
681 $this->msg( 'invert' )->text(),
685 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
687 $namespaceForm .= '<span class="mw-input-with-label">' . Xml
::checkLabel(
688 $this->msg( 'namespace_association' )->text(),
692 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
694 $form .= Html
::rawElement(
696 [ 'class' => 'namespaceForm cloption' ],
700 $form .= Xml
::submitButton(
701 $this->msg( 'watchlist-submit' )->text(),
702 [ 'class' => 'cloption-submit' ]
704 foreach ( $hiddenFields as $key => $value ) {
705 $form .= Html
::hidden( $key, $value ) . "\n";
707 $form .= Xml
::closeElement( 'fieldset' ) . "\n";
708 $form .= Xml
::closeElement( 'form' ) . "\n";
710 // Insert a placeholder for RCFilters
711 if ( $this->isStructuredFilterUiEnabled() ) {
712 $rcfilterContainer = Html
::element(
714 [ 'class' => 'rcfilters-container' ]
717 $loadingContainer = Html
::rawElement(
719 [ 'class' => 'rcfilters-spinner' ],
722 [ 'class' => 'rcfilters-spinner-bounce' ]
726 // Wrap both with rcfilters-head
727 $this->getOutput()->addHTML(
730 [ 'class' => 'rcfilters-head' ],
731 $rcfilterContainer . $form
736 $this->getOutput()->addHTML( $loadingContainer );
738 $this->getOutput()->addHTML( $form );
741 $this->setBottomText( $opts );
744 function cutoffselector( $options ) {
745 // Cast everything to strings immediately, so that we know all of the values have the same
746 // precision, and can be compared with '==='. 2/24 has a few more decimal places than its
747 // default string representation, for example, and would confuse comparisons.
749 // Misleadingly, the 'days' option supports hours too.
750 $days = array_map( 'strval', [ 1 / 24, 2 / 24, 6 / 24, 12 / 24, 1, 3, 7 ] );
752 $userWatchlistOption = (string)$this->getUser()->getOption( 'watchlistdays' );
753 // add the user preference, if it isn't available already
754 if ( !in_array( $userWatchlistOption, $days ) && $userWatchlistOption !== '0' ) {
755 $days[] = $userWatchlistOption;
758 $maxDays = (string)$this->maxDays
;
759 // add the maximum possible value, if it isn't available already
760 if ( !in_array( $maxDays, $days ) ) {
764 $selected = (string)$options['days'];
765 if ( $selected <= 0 ) {
766 $selected = $maxDays;
769 // add the currently selected value, if it isn't available already
770 if ( !in_array( $selected, $days ) ) {
774 $select = new XmlSelect( 'days', 'days', $selected );
777 foreach ( $days as $value ) {
779 $name = $this->msg( 'hours' )->numParams( $value * 24 )->text();
781 $name = $this->msg( 'days' )->numParams( $value )->text();
783 $select->addOption( $name, $value );
786 return $select->getHTML() . "\n<br />\n";
789 function setTopText( FormOptions
$opts ) {
790 $nondefaults = $opts->getChangedValues();
792 $user = $this->getUser();
794 $numItems = $this->countItems();
795 $showUpdatedMarker = $this->getConfig()->get( 'ShowUpdatedMarker' );
797 // Show watchlist header
799 if ( $numItems == 0 ) {
800 $form .= $this->msg( 'nowatchlist' )->parse() . "\n";
802 $form .= $this->msg( 'watchlist-details' )->numParams( $numItems )->parse() . "\n";
803 if ( $this->getConfig()->get( 'EnotifWatchlist' )
804 && $user->getOption( 'enotifwatchlistpages' )
806 $form .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
808 if ( $showUpdatedMarker ) {
809 $form .= $this->msg( 'wlheader-showupdated' )->parse() . "\n";
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(
843 $this->msg( $message, '' )->text(),
852 * Count the number of paired items on a user's watchlist.
853 * The assumption made here is that when a subject page is watched a talk page is also watched.
854 * Hence the number of individual items is halved.
858 protected function countItems() {
859 $store = MediaWikiServices
::getInstance()->getWatchedItemStore();
860 $count = $store->countWatchedItems( $this->getUser() );
861 return floor( $count / 2 );