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 // legacy 'extended' filter
148 $this->registerFilterGroup( new ChangesListBooleanFilterGroup( [
149 'name' => 'extended-group',
152 'name' => 'extended',
153 'isReplacedInStructuredUi' => true,
154 'isVisible' => false,
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, $rc ) {
195 $changeTs = $rc->getAttribute( 'rc_timestamp' );
196 $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
197 return $lastVisitTs !== null && $changeTs >= $lastVisitTs;
202 'label' => 'rcfilters-filter-watchlistactivity-seen-label',
203 'description' => 'rcfilters-filter-watchlistactivity-seen-description',
204 'cssClassSuffix' => 'watchedseen',
205 'isRowApplicableCallable' => function ( $ctx, $rc ) {
206 $changeTs = $rc->getAttribute( 'rc_timestamp' );
207 $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
208 return $lastVisitTs === null ||
$changeTs < $lastVisitTs;
212 'default' => ChangesListStringOptionsFilterGroup
::NONE
,
213 'queryCallable' => function ( $specialPageClassName, $context, $dbr,
214 &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
215 if ( $selectedValues === [ 'seen' ] ) {
216 $conds[] = $dbr->makeList( [
217 'wl_notificationtimestamp IS NULL',
218 'rc_timestamp < wl_notificationtimestamp'
220 } elseif ( $selectedValues === [ 'unseen' ] ) {
221 $conds[] = $dbr->makeList( [
222 'wl_notificationtimestamp IS NOT NULL',
223 'rc_timestamp >= wl_notificationtimestamp'
229 $user = $this->getUser();
231 $significance = $this->getFilterGroup( 'significance' );
232 $hideMinor = $significance->getFilter( 'hideminor' );
233 $hideMinor->setDefault( $user->getBoolOption( 'watchlisthideminor' ) );
235 $automated = $this->getFilterGroup( 'automated' );
236 $hideBots = $automated->getFilter( 'hidebots' );
237 $hideBots->setDefault( $user->getBoolOption( 'watchlisthidebots' ) );
239 $registration = $this->getFilterGroup( 'registration' );
240 $hideAnons = $registration->getFilter( 'hideanons' );
241 $hideAnons->setDefault( $user->getBoolOption( 'watchlisthideanons' ) );
242 $hideLiu = $registration->getFilter( 'hideliu' );
243 $hideLiu->setDefault( $user->getBoolOption( 'watchlisthideliu' ) );
245 $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
246 if ( $reviewStatus !== null ) {
247 // Conditional on feature being available and rights
248 $hidePatrolled = $reviewStatus->getFilter( 'hidepatrolled' );
249 $hidePatrolled->setDefault( $user->getBoolOption( 'watchlisthidepatrolled' ) );
252 $authorship = $this->getFilterGroup( 'authorship' );
253 $hideMyself = $authorship->getFilter( 'hidemyself' );
254 $hideMyself->setDefault( $user->getBoolOption( 'watchlisthideown' ) );
256 $changeType = $this->getFilterGroup( 'changeType' );
257 $hideCategorization = $changeType->getFilter( 'hidecategorization' );
258 if ( $hideCategorization !== null ) {
259 // Conditional on feature being available
260 $hideCategorization->setDefault( $user->getBoolOption( 'watchlisthidecategorization' ) );
265 * Get a FormOptions object containing the default options
267 * @return FormOptions
269 public function getDefaultOptions() {
270 $opts = parent
::getDefaultOptions();
271 $user = $this->getUser();
273 $opts->add( 'days', $user->getOption( 'watchlistdays' ), FormOptions
::FLOAT );
274 $opts->add( 'limit', $user->getIntOption( 'wllimit' ), FormOptions
::INT );
279 public function validateOptions( FormOptions
$opts ) {
280 $opts->validateBounds( 'days', 0, $this->maxDays
);
281 $opts->validateIntBounds( 'limit', 0, 5000 );
282 parent
::validateOptions( $opts );
286 * Get all custom filters
288 * @return array Map of filter URL param names to properties (msg/default)
290 protected function getCustomFilters() {
291 if ( $this->customFilters
=== null ) {
292 $this->customFilters
= parent
::getCustomFilters();
293 Hooks
::run( 'SpecialWatchlistFilters', [ $this, &$this->customFilters
], '1.23' );
296 return $this->customFilters
;
300 * Fetch values for a FormOptions object from the WebRequest associated with this instance.
302 * Maps old pre-1.23 request parameters Watchlist used to use (different from Recentchanges' ones)
303 * to the current ones.
305 * @param FormOptions $opts
306 * @return FormOptions
308 protected function fetchOptionsFromRequest( $opts ) {
309 static $compatibilityMap = [
310 'hideMinor' => 'hideminor',
311 'hideBots' => 'hidebots',
312 'hideAnons' => 'hideanons',
313 'hideLiu' => 'hideliu',
314 'hidePatrolled' => 'hidepatrolled',
315 'hideOwn' => 'hidemyself',
318 $params = $this->getRequest()->getValues();
319 foreach ( $compatibilityMap as $from => $to ) {
320 if ( isset( $params[$from] ) ) {
321 $params[$to] = $params[$from];
322 unset( $params[$from] );
326 if ( $this->getRequest()->getVal( 'action' ) == 'submit' ) {
327 $allBooleansFalse = [];
329 // If the user submitted the form, start with a baseline of "all
330 // booleans are false", then change the ones they checked. This
331 // means we ignore the defaults.
333 // This is how we handle the fact that HTML forms don't submit
335 foreach ( $this->filterGroups
as $filterGroup ) {
336 if ( $filterGroup instanceof ChangesListBooleanFilterGroup
) {
337 foreach ( $filterGroup->getFilters() as $filter ) {
338 if ( $filter->isVisible() ) {
339 $allBooleansFalse[$filter->getName()] = false;
345 $params = $params +
$allBooleansFalse;
348 // Not the prettiest way to achieve this… FormOptions internally depends on data sanitization
349 // methods defined on WebRequest and removing this dependency would cause some code duplication.
350 $request = new DerivativeRequest( $this->getRequest(), $params );
351 $opts->fetchValuesFromRequest( $request );
359 protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
360 &$join_conds, FormOptions
$opts
362 $dbr = $this->getDB();
363 parent
::buildQuery( $tables, $fields, $conds, $query_options, $join_conds,
367 if ( $opts['days'] > 0 ) {
368 $conds[] = 'rc_timestamp > ' .
369 $dbr->addQuotes( $dbr->timestamp( time() - $opts['days'] * 3600 * 24 ) );
376 protected function doMainQuery( $tables, $fields, $conds, $query_options,
377 $join_conds, FormOptions
$opts
379 $dbr = $this->getDB();
380 $user = $this->getUser();
382 $tables = array_merge( [ 'recentchanges', 'watchlist' ], $tables );
383 $fields = array_merge( RecentChange
::selectFields(), $fields );
385 $query_options = array_merge( [
386 'ORDER BY' => 'rc_timestamp DESC',
387 'LIMIT' => $opts['limit']
389 $join_conds = array_merge(
394 'wl_user' => $user->getId(),
395 'wl_namespace=rc_namespace',
404 $fields[] = 'page_latest';
405 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
407 $fields[] = 'wl_notificationtimestamp';
409 // Log entries with DELETED_ACTION must not show up unless the user has
410 // the necessary rights.
411 if ( !$user->isAllowed( 'deletedhistory' ) ) {
412 $bitmask = LogPage
::DELETED_ACTION
;
413 } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
414 $bitmask = LogPage
::DELETED_ACTION | LogPage
::DELETED_RESTRICTED
;
419 $conds[] = $dbr->makeList( [
420 'rc_type != ' . RC_LOG
,
421 $dbr->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
425 ChangeTags
::modifyDisplayQuery(
434 $this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts );
436 if ( $this->areFiltersInConflict() ) {
450 protected function runMainQueryHook( &$tables, &$fields, &$conds, &$query_options,
453 return parent
::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
455 'SpecialWatchlistQuery',
456 [ &$conds, &$tables, &$join_conds, &$fields, $opts ],
462 * Return a IDatabase object for reading
466 protected function getDB() {
467 return wfGetDB( DB_REPLICA
, 'watchlist' );
473 public function outputFeedLinks() {
474 $user = $this->getUser();
475 $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
477 $this->addFeedLinks( [
478 'action' => 'feedwatchlist',
480 'wlowner' => $user->getName(),
481 'wltoken' => $wlToken,
487 * Build and output the actual changes list.
489 * @param ResultWrapper $rows Database rows
490 * @param FormOptions $opts
492 public function outputChangesList( $rows, $opts ) {
493 $dbr = $this->getDB();
494 $user = $this->getUser();
495 $output = $this->getOutput();
497 # Show a message about replica DB lag, if applicable
498 $lag = wfGetLB()->safeGetLag( $dbr );
500 $output->showLagWarning( $lag );
503 # If no rows to display, show message before try to render the list
504 if ( $rows->numRows() == 0 ) {
505 $output->wrapWikiMsg(
506 "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
511 $dbr->dataSeek( $rows, 0 );
513 $list = ChangesList
::newFromContext( $this->getContext(), $this->filterGroups
);
514 $list->setWatchlistDivs();
515 $list->initChangesListRows( $rows );
516 if ( $user->getOption( 'watchlistunwatchlinks' ) ) {
517 $list->setChangeLinePrefixer( function ( RecentChange
$rc, ChangesList
$cl, $grouped ) {
518 // Don't show unwatch link if the line is a grouped log entry using EnhancedChangesList,
519 // since EnhancedChangesList groups log entries by performer rather than by target article
520 if ( $rc->mAttribs
['rc_type'] == RC_LOG
&& $cl instanceof EnhancedChangesList
&&
524 return $this->getLinkRenderer()
525 ->makeKnownLink( $rc->getTitle(),
526 $this->msg( 'watchlist-unwatch' )->text(), [
527 'class' => 'mw-unwatch-link',
528 'title' => $this->msg( 'tooltip-ca-unwatch' )->text()
529 ], [ 'action' => 'unwatch' ] ) . ' ';
533 $dbr->dataSeek( $rows, 0 );
535 if ( $this->getConfig()->get( 'RCShowWatchingUsers' )
536 && $user->getOption( 'shownumberswatching' )
538 $watchedItemStore = MediaWikiServices
::getInstance()->getWatchedItemStore();
541 $s = $list->beginRecentChangesList();
543 if ( $this->isStructuredFilterUiEnabled() ) {
544 $s .= $this->makeLegend();
547 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
549 foreach ( $rows as $obj ) {
551 $rc = RecentChange
::newFromRow( $obj );
553 # Skip CatWatch entries for hidden cats based on user preference
555 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE
&&
556 !$userShowHiddenCats &&
557 $rc->getParam( 'hidden-cat' )
562 $rc->counter
= $counter++
;
564 if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
565 $updated = $obj->wl_notificationtimestamp
;
570 if ( isset( $watchedItemStore ) ) {
571 $rcTitleValue = new TitleValue( (int)$obj->rc_namespace
, $obj->rc_title
);
572 $rc->numberofWatchingusers
= $watchedItemStore->countWatchers( $rcTitleValue );
574 $rc->numberofWatchingusers
= 0;
577 $changeLine = $list->recentChangesLine( $rc, $updated, $counter );
578 if ( $changeLine !== false ) {
582 $s .= $list->endRecentChangesList();
584 $output->addHTML( $s );
588 * Set the text to be displayed above the changes
590 * @param FormOptions $opts
591 * @param int $numRows Number of rows in the result to show after this header
593 public function doHeader( $opts, $numRows ) {
594 $user = $this->getUser();
595 $out = $this->getOutput();
598 $this->msg( 'watchlistfor2', $user->getName() )
599 ->rawParams( SpecialEditWatchlist
::buildTools(
600 $this->getLanguage(),
601 $this->getLinkRenderer()
605 $this->setTopText( $opts );
609 $form .= Xml
::openElement( 'form', [
611 'action' => wfScript(),
612 'id' => 'mw-watchlist-form'
614 $form .= Html
::hidden( 'title', $this->getPageTitle()->getPrefixedText() );
615 $form .= Xml
::fieldset(
616 $this->msg( 'watchlist-options' )->text(),
618 [ 'id' => 'mw-watchlist-options', 'class' => 'cloptions' ]
621 if ( !$this->isStructuredFilterUiEnabled() ) {
622 $form .= $this->makeLegend();
625 $lang = $this->getLanguage();
626 if ( $opts['days'] > 0 ) {
627 $days = $opts['days'];
629 $days = $this->maxDays
;
631 $timestamp = wfTimestampNow();
632 $wlInfo = Html
::rawElement(
634 [ 'class' => 'wlinfo' ],
635 $this->msg( 'wlnote' )->numParams( $numRows, round( $days * 24 ) )->params(
636 $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
640 $nondefaults = $opts->getChangedValues();
641 $cutofflinks = Html
::rawElement(
643 [ 'class' => 'cldays cloption' ],
644 $this->msg( 'wlshowtime' ) . ' ' . $this->cutoffselector( $opts )
647 # Spit out some control panel links
649 $namesOfDisplayedFilters = [];
650 foreach ( $this->getFilterGroups() as $groupName => $group ) {
651 if ( !$group->isPerGroupRequestParameter() ) {
652 foreach ( $group->getFilters() as $filterName => $filter ) {
653 if ( $filter->displaysOnUnstructuredUi( $this ) ) {
654 $namesOfDisplayedFilters[] = $filterName;
655 $links[] = $this->showHideCheck(
657 $filter->getShowHide(),
660 $filter->isFeatureAvailableOnStructuredUi( $this )
667 $hiddenFields = $nondefaults;
668 $hiddenFields['action'] = 'submit';
669 unset( $hiddenFields['namespace'] );
670 unset( $hiddenFields['invert'] );
671 unset( $hiddenFields['associated'] );
672 unset( $hiddenFields['days'] );
673 foreach ( $namesOfDisplayedFilters as $filterName ) {
674 unset( $hiddenFields[$filterName] );
677 # Namespace filter and put the whole form together.
679 $form .= $cutofflinks;
680 $form .= Html
::rawElement(
682 [ 'class' => 'clshowhide' ],
683 $this->msg( 'watchlist-hide' ) .
684 $this->msg( 'colon-separator' )->escaped() .
685 implode( ' ', $links )
687 $form .= "\n<br />\n";
689 $namespaceForm = Html
::namespaceSelector(
691 'selected' => $opts['namespace'],
693 'label' => $this->msg( 'namespace' )->text()
695 'name' => 'namespace',
697 'class' => 'namespaceselector',
700 $namespaceForm .= '<span class="mw-input-with-label">' . Xml
::checkLabel(
701 $this->msg( 'invert' )->text(),
705 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
707 $namespaceForm .= '<span class="mw-input-with-label">' . Xml
::checkLabel(
708 $this->msg( 'namespace_association' )->text(),
712 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
714 $form .= Html
::rawElement(
716 [ 'class' => 'namespaceForm cloption' ],
720 $form .= Xml
::submitButton(
721 $this->msg( 'watchlist-submit' )->text(),
722 [ 'class' => 'cloption-submit' ]
724 foreach ( $hiddenFields as $key => $value ) {
725 $form .= Html
::hidden( $key, $value ) . "\n";
727 $form .= Xml
::closeElement( 'fieldset' ) . "\n";
728 $form .= Xml
::closeElement( 'form' ) . "\n";
730 // Insert a placeholder for RCFilters
731 if ( $this->isStructuredFilterUiEnabled() ) {
732 $rcfilterContainer = Html
::element(
734 [ 'class' => 'rcfilters-container' ]
737 $loadingContainer = Html
::rawElement(
739 [ 'class' => 'rcfilters-spinner' ],
742 [ 'class' => 'rcfilters-spinner-bounce' ]
746 // Wrap both with rcfilters-head
747 $this->getOutput()->addHTML(
750 [ 'class' => 'rcfilters-head' ],
751 $rcfilterContainer . $form
756 $this->getOutput()->addHTML( $loadingContainer );
758 $this->getOutput()->addHTML( $form );
761 $this->setBottomText( $opts );
764 function cutoffselector( $options ) {
765 // Cast everything to strings immediately, so that we know all of the values have the same
766 // precision, and can be compared with '==='. 2/24 has a few more decimal places than its
767 // default string representation, for example, and would confuse comparisons.
769 // Misleadingly, the 'days' option supports hours too.
770 $days = array_map( 'strval', [ 1 / 24, 2 / 24, 6 / 24, 12 / 24, 1, 3, 7 ] );
772 $userWatchlistOption = (string)$this->getUser()->getOption( 'watchlistdays' );
773 // add the user preference, if it isn't available already
774 if ( !in_array( $userWatchlistOption, $days ) && $userWatchlistOption !== '0' ) {
775 $days[] = $userWatchlistOption;
778 $maxDays = (string)$this->maxDays
;
779 // add the maximum possible value, if it isn't available already
780 if ( !in_array( $maxDays, $days ) ) {
784 $selected = (string)$options['days'];
785 if ( $selected <= 0 ) {
786 $selected = $maxDays;
789 // add the currently selected value, if it isn't available already
790 if ( !in_array( $selected, $days ) ) {
794 $select = new XmlSelect( 'days', 'days', $selected );
797 foreach ( $days as $value ) {
799 $name = $this->msg( 'hours' )->numParams( $value * 24 )->text();
801 $name = $this->msg( 'days' )->numParams( $value )->text();
803 $select->addOption( $name, $value );
806 return $select->getHTML() . "\n<br />\n";
809 function setTopText( FormOptions
$opts ) {
810 $nondefaults = $opts->getChangedValues();
812 $user = $this->getUser();
814 $numItems = $this->countItems();
815 $showUpdatedMarker = $this->getConfig()->get( 'ShowUpdatedMarker' );
817 // Show watchlist header
819 if ( $numItems == 0 ) {
820 $form .= $this->msg( 'nowatchlist' )->parse() . "\n";
822 $form .= $this->msg( 'watchlist-details' )->numParams( $numItems )->parse() . "\n";
823 if ( $this->getConfig()->get( 'EnotifWatchlist' )
824 && $user->getOption( 'enotifwatchlistpages' )
826 $form .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
828 if ( $showUpdatedMarker ) {
829 $form .= $this->msg( 'wlheader-showupdated' )->parse() . "\n";
834 if ( $numItems > 0 && $showUpdatedMarker ) {
835 $form .= Xml
::openElement( 'form', [ 'method' => 'post',
836 'action' => $this->getPageTitle()->getLocalURL(),
837 'id' => 'mw-watchlist-resetbutton' ] ) . "\n" .
838 Xml
::submitButton( $this->msg( 'enotif_reset' )->text(),
839 [ 'name' => 'mw-watchlist-reset-submit' ] ) . "\n" .
840 Html
::hidden( 'token', $user->getEditToken() ) . "\n" .
841 Html
::hidden( 'reset', 'all' ) . "\n";
842 foreach ( $nondefaults as $key => $value ) {
843 $form .= Html
::hidden( $key, $value ) . "\n";
845 $form .= Xml
::closeElement( 'form' ) . "\n";
848 $this->getOutput()->addHTML( $form );
851 protected function showHideCheck( $options, $message, $name, $value, $inStructuredUi ) {
852 $options[$name] = 1 - (int)$value;
854 $attribs = [ 'class' => 'mw-input-with-label clshowhideoption cloption' ];
855 if ( $inStructuredUi ) {
856 $attribs[ 'data-feature-in-structured-ui' ] = true;
859 return Html
::rawElement(
863 $this->msg( $message, '' )->text(),
872 * Count the number of paired items on a user's watchlist.
873 * The assumption made here is that when a subject page is watched a talk page is also watched.
874 * Hence the number of individual items is halved.
878 protected function countItems() {
879 $store = MediaWikiServices
::getInstance()->getWatchedItemStore();
880 $count = $store->countWatchedItems( $this->getUser() );
881 return floor( $count / 2 );
884 function getDefaultLimit() {
885 return $this->getUser()->getIntOption( 'wllimit' );
888 function getDefaultDays() {
889 return $this->getUser()->getIntOption( 'watchlistdays' );