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
{
35 protected static $savedQueriesPreferenceName = 'rcfilters-wl-saved-queries';
39 public function __construct( $page = 'Watchlist', $restriction = 'viewmywatchlist' ) {
40 parent
::__construct( $page, $restriction );
42 $this->maxDays
= $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 );
45 public function doesWrites() {
50 * Main execution point
52 * @param string $subpage
54 function execute( $subpage ) {
55 // Anons don't get a watchlist
56 $this->requireLogin( 'watchlistanontext' );
58 $output = $this->getOutput();
59 $request = $this->getRequest();
60 $this->addHelpLink( 'Help:Watching pages' );
61 $output->addModules( [
62 'mediawiki.special.changeslist.visitedstatus',
63 'mediawiki.special.watchlist',
65 $output->addModuleStyles( [ 'mediawiki.special.watchlist.styles' ] );
67 $mode = SpecialEditWatchlist
::getMode( $request, $subpage );
68 if ( $mode !== false ) {
69 if ( $mode === SpecialEditWatchlist
::EDIT_RAW
) {
70 $title = SpecialPage
::getTitleFor( 'EditWatchlist', 'raw' );
71 } elseif ( $mode === SpecialEditWatchlist
::EDIT_CLEAR
) {
72 $title = SpecialPage
::getTitleFor( 'EditWatchlist', 'clear' );
74 $title = SpecialPage
::getTitleFor( 'EditWatchlist' );
77 $output->redirect( $title->getLocalURL() );
82 $this->checkPermissions();
84 $user = $this->getUser();
85 $opts = $this->getOptions();
87 $config = $this->getConfig();
88 if ( ( $config->get( 'EnotifWatchlist' ) ||
$config->get( 'ShowUpdatedMarker' ) )
89 && $request->getVal( 'reset' )
90 && $request->wasPosted()
91 && $user->matchEditToken( $request->getVal( 'token' ) )
93 $user->clearAllNotifications();
94 $output->redirect( $this->getPageTitle()->getFullURL( $opts->getChangedValues() ) );
99 parent
::execute( $subpage );
101 if ( $this->isStructuredFilterUiEnabled() ) {
102 $output->addModuleStyles( [ 'mediawiki.rcfilters.highlightCircles.seenunseen.styles' ] );
104 $output->addJsConfigVars(
105 'wgStructuredChangeFiltersEditWatchlistUrl',
106 SpecialPage
::getTitleFor( 'EditWatchlist' )->getLocalURL()
111 public function isStructuredFilterUiEnabled() {
112 return $this->getRequest()->getBool( 'rcfilters' ) ||
(
113 $this->getConfig()->get( 'StructuredChangeFiltersOnWatchlist' ) &&
114 $this->getUser()->getOption( 'rcenhancedfilters' )
118 public function isStructuredFilterUiEnabledByDefault() {
119 return $this->getConfig()->get( 'StructuredChangeFiltersOnWatchlist' ) &&
120 $this->getUser()->getDefaultOption( 'rcenhancedfilters' );
124 * Return an array of subpages that this special page will accept.
126 * @see also SpecialEditWatchlist::getSubpagesForPrefixSearch
127 * @return string[] subpages
129 public function getSubpagesForPrefixSearch() {
140 protected function transformFilterDefinition( array $filterDefinition ) {
141 if ( isset( $filterDefinition['showHideSuffix'] ) ) {
142 $filterDefinition['showHide'] = 'wl' . $filterDefinition['showHideSuffix'];
145 return $filterDefinition;
151 protected function registerFilters() {
152 parent
::registerFilters();
154 // legacy 'extended' filter
155 $this->registerFilterGroup( new ChangesListBooleanFilterGroup( [
156 'name' => 'extended-group',
159 'name' => 'extended',
160 'isReplacedInStructuredUi' => true,
161 'activeValue' => false,
162 'default' => $this->getUser()->getBoolOption( 'extendwatchlist' ),
163 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables,
164 &$fields, &$conds, &$query_options, &$join_conds ) {
165 $nonRevisionTypes = [ RC_LOG
];
166 Hooks
::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] );
167 if ( $nonRevisionTypes ) {
168 $conds[] = $dbr->makeList(
170 'rc_this_oldid=page_latest',
171 'rc_type' => $nonRevisionTypes,
182 if ( $this->isStructuredFilterUiEnabled() ) {
183 $this->getFilterGroup( 'lastRevision' )
184 ->getFilter( 'hidepreviousrevisions' )
185 ->setDefault( !$this->getUser()->getBoolOption( 'extendwatchlist' ) );
188 $this->registerFilterGroup( new ChangesListStringOptionsFilterGroup( [
189 'name' => 'watchlistactivity',
190 'title' => 'rcfilters-filtergroup-watchlistactivity',
191 'class' => ChangesListStringOptionsFilterGroup
::class,
193 'isFullCoverage' => true,
197 'label' => 'rcfilters-filter-watchlistactivity-unseen-label',
198 'description' => 'rcfilters-filter-watchlistactivity-unseen-description',
199 'cssClassSuffix' => 'watchedunseen',
200 'isRowApplicableCallable' => function ( $ctx, $rc ) {
201 $changeTs = $rc->getAttribute( 'rc_timestamp' );
202 $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
203 return $lastVisitTs !== null && $changeTs >= $lastVisitTs;
208 'label' => 'rcfilters-filter-watchlistactivity-seen-label',
209 'description' => 'rcfilters-filter-watchlistactivity-seen-description',
210 'cssClassSuffix' => 'watchedseen',
211 'isRowApplicableCallable' => function ( $ctx, $rc ) {
212 $changeTs = $rc->getAttribute( 'rc_timestamp' );
213 $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
214 return $lastVisitTs === null ||
$changeTs < $lastVisitTs;
218 'default' => ChangesListStringOptionsFilterGroup
::NONE
,
219 'queryCallable' => function ( $specialPageClassName, $context, $dbr,
220 &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
221 if ( $selectedValues === [ 'seen' ] ) {
222 $conds[] = $dbr->makeList( [
223 'wl_notificationtimestamp IS NULL',
224 'rc_timestamp < wl_notificationtimestamp'
226 } elseif ( $selectedValues === [ 'unseen' ] ) {
227 $conds[] = $dbr->makeList( [
228 'wl_notificationtimestamp IS NOT NULL',
229 'rc_timestamp >= wl_notificationtimestamp'
235 $user = $this->getUser();
237 $significance = $this->getFilterGroup( 'significance' );
238 $hideMinor = $significance->getFilter( 'hideminor' );
239 $hideMinor->setDefault( $user->getBoolOption( 'watchlisthideminor' ) );
241 $automated = $this->getFilterGroup( 'automated' );
242 $hideBots = $automated->getFilter( 'hidebots' );
243 $hideBots->setDefault( $user->getBoolOption( 'watchlisthidebots' ) );
245 $registration = $this->getFilterGroup( 'registration' );
246 $hideAnons = $registration->getFilter( 'hideanons' );
247 $hideAnons->setDefault( $user->getBoolOption( 'watchlisthideanons' ) );
248 $hideLiu = $registration->getFilter( 'hideliu' );
249 $hideLiu->setDefault( $user->getBoolOption( 'watchlisthideliu' ) );
251 $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
252 if ( $reviewStatus !== null ) {
253 // Conditional on feature being available and rights
254 $hidePatrolled = $reviewStatus->getFilter( 'hidepatrolled' );
255 $hidePatrolled->setDefault( $user->getBoolOption( 'watchlisthidepatrolled' ) );
258 $authorship = $this->getFilterGroup( 'authorship' );
259 $hideMyself = $authorship->getFilter( 'hidemyself' );
260 $hideMyself->setDefault( $user->getBoolOption( 'watchlisthideown' ) );
262 $changeType = $this->getFilterGroup( 'changeType' );
263 $hideCategorization = $changeType->getFilter( 'hidecategorization' );
264 if ( $hideCategorization !== null ) {
265 // Conditional on feature being available
266 $hideCategorization->setDefault( $user->getBoolOption( 'watchlisthidecategorization' ) );
271 * Get all custom filters
273 * @return array Map of filter URL param names to properties (msg/default)
275 protected function getCustomFilters() {
276 if ( $this->customFilters
=== null ) {
277 $this->customFilters
= parent
::getCustomFilters();
278 Hooks
::run( 'SpecialWatchlistFilters', [ $this, &$this->customFilters
], '1.23' );
281 return $this->customFilters
;
285 * Fetch values for a FormOptions object from the WebRequest associated with this instance.
287 * Maps old pre-1.23 request parameters Watchlist used to use (different from Recentchanges' ones)
288 * to the current ones.
290 * @param FormOptions $opts
291 * @return FormOptions
293 protected function fetchOptionsFromRequest( $opts ) {
294 static $compatibilityMap = [
295 'hideMinor' => 'hideminor',
296 'hideBots' => 'hidebots',
297 'hideAnons' => 'hideanons',
298 'hideLiu' => 'hideliu',
299 'hidePatrolled' => 'hidepatrolled',
300 'hideOwn' => 'hidemyself',
303 $params = $this->getRequest()->getValues();
304 foreach ( $compatibilityMap as $from => $to ) {
305 if ( isset( $params[$from] ) ) {
306 $params[$to] = $params[$from];
307 unset( $params[$from] );
311 if ( $this->getRequest()->getVal( 'action' ) == 'submit' ) {
312 $allBooleansFalse = [];
314 // If the user submitted the form, start with a baseline of "all
315 // booleans are false", then change the ones they checked. This
316 // means we ignore the defaults.
318 // This is how we handle the fact that HTML forms don't submit
320 foreach ( $this->filterGroups
as $filterGroup ) {
321 if ( $filterGroup instanceof ChangesListBooleanFilterGroup
) {
322 /** @var ChangesListBooleanFilter $filter */
323 foreach ( $filterGroup->getFilters() as $filter ) {
324 if ( $filter->displaysOnUnstructuredUi() ) {
325 $allBooleansFalse[$filter->getName()] = false;
331 $params = $params +
$allBooleansFalse;
334 // Not the prettiest way to achieve this… FormOptions internally depends on data sanitization
335 // methods defined on WebRequest and removing this dependency would cause some code duplication.
336 $request = new DerivativeRequest( $this->getRequest(), $params );
337 $opts->fetchValuesFromRequest( $request );
345 protected function doMainQuery( $tables, $fields, $conds, $query_options,
346 $join_conds, FormOptions
$opts
348 $dbr = $this->getDB();
349 $user = $this->getUser();
351 $tables = array_merge( [ 'recentchanges', 'watchlist' ], $tables );
352 $fields = array_merge( RecentChange
::selectFields(), $fields );
354 $join_conds = array_merge(
359 'wl_user' => $user->getId(),
360 'wl_namespace=rc_namespace',
369 $fields[] = 'page_latest';
370 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
372 $fields[] = 'wl_notificationtimestamp';
374 // Log entries with DELETED_ACTION must not show up unless the user has
375 // the necessary rights.
376 if ( !$user->isAllowed( 'deletedhistory' ) ) {
377 $bitmask = LogPage
::DELETED_ACTION
;
378 } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
379 $bitmask = LogPage
::DELETED_ACTION | LogPage
::DELETED_RESTRICTED
;
384 $conds[] = $dbr->makeList( [
385 'rc_type != ' . RC_LOG
,
386 $dbr->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
390 $tagFilter = $opts['tagfilter'] ?
explode( '|', $opts['tagfilter'] ) : [];
391 ChangeTags
::modifyDisplayQuery(
400 $this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts );
402 if ( $this->areFiltersInConflict() ) {
407 'ORDER BY' => 'rc_timestamp DESC',
408 'LIMIT' => $opts['limit']
410 if ( in_array( 'DISTINCT', $query_options ) ) {
411 // ChangeTags::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
412 // In order to prevent DISTINCT from causing query performance problems,
413 // we have to GROUP BY the primary key. This in turn requires us to add
414 // the primary key to the end of the ORDER BY, and the old ORDER BY to the
415 // start of the GROUP BY
416 $orderByAndLimit['ORDER BY'] = 'rc_timestamp DESC, rc_id DESC';
417 $orderByAndLimit['GROUP BY'] = 'rc_timestamp, rc_id';
419 // array_merge() is used intentionally here so that hooks can, should
420 // they so desire, override the ORDER BY / LIMIT condition(s)
421 $query_options = array_merge( $orderByAndLimit, $query_options );
433 protected function runMainQueryHook( &$tables, &$fields, &$conds, &$query_options,
436 return parent
::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
438 'SpecialWatchlistQuery',
439 [ &$conds, &$tables, &$join_conds, &$fields, $opts ],
445 * Return a IDatabase object for reading
449 protected function getDB() {
450 return wfGetDB( DB_REPLICA
, 'watchlist' );
456 public function outputFeedLinks() {
457 $user = $this->getUser();
458 $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
460 $this->addFeedLinks( [
461 'action' => 'feedwatchlist',
463 'wlowner' => $user->getName(),
464 'wltoken' => $wlToken,
470 * Build and output the actual changes list.
472 * @param ResultWrapper $rows Database rows
473 * @param FormOptions $opts
475 public function outputChangesList( $rows, $opts ) {
476 $dbr = $this->getDB();
477 $user = $this->getUser();
478 $output = $this->getOutput();
480 # Show a message about replica DB lag, if applicable
481 $lag = wfGetLB()->safeGetLag( $dbr );
483 $output->showLagWarning( $lag );
486 # If no rows to display, show message before try to render the list
487 if ( $rows->numRows() == 0 ) {
488 $output->wrapWikiMsg(
489 "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
494 $dbr->dataSeek( $rows, 0 );
496 $list = ChangesList
::newFromContext( $this->getContext(), $this->filterGroups
);
497 $list->setWatchlistDivs();
498 $list->initChangesListRows( $rows );
499 if ( $user->getOption( 'watchlistunwatchlinks' ) ) {
500 $list->setChangeLinePrefixer( function ( RecentChange
$rc, ChangesList
$cl, $grouped ) {
501 // Don't show unwatch link if the line is a grouped log entry using EnhancedChangesList,
502 // since EnhancedChangesList groups log entries by performer rather than by target article
503 if ( $rc->mAttribs
['rc_type'] == RC_LOG
&& $cl instanceof EnhancedChangesList
&&
507 return $this->getLinkRenderer()
508 ->makeKnownLink( $rc->getTitle(),
509 $this->msg( 'watchlist-unwatch' )->text(), [
510 'class' => 'mw-unwatch-link',
511 'title' => $this->msg( 'tooltip-ca-unwatch' )->text()
512 ], [ 'action' => 'unwatch' ] ) . ' ';
516 $dbr->dataSeek( $rows, 0 );
518 if ( $this->getConfig()->get( 'RCShowWatchingUsers' )
519 && $user->getOption( 'shownumberswatching' )
521 $watchedItemStore = MediaWikiServices
::getInstance()->getWatchedItemStore();
524 $s = $list->beginRecentChangesList();
526 if ( $this->isStructuredFilterUiEnabled() ) {
527 $s .= $this->makeLegend();
530 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
532 foreach ( $rows as $obj ) {
534 $rc = RecentChange
::newFromRow( $obj );
536 # Skip CatWatch entries for hidden cats based on user preference
538 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE
&&
539 !$userShowHiddenCats &&
540 $rc->getParam( 'hidden-cat' )
545 $rc->counter
= $counter++
;
547 if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
548 $updated = $obj->wl_notificationtimestamp
;
553 if ( isset( $watchedItemStore ) ) {
554 $rcTitleValue = new TitleValue( (int)$obj->rc_namespace
, $obj->rc_title
);
555 $rc->numberofWatchingusers
= $watchedItemStore->countWatchers( $rcTitleValue );
557 $rc->numberofWatchingusers
= 0;
560 $changeLine = $list->recentChangesLine( $rc, $updated, $counter );
561 if ( $changeLine !== false ) {
565 $s .= $list->endRecentChangesList();
567 $output->addHTML( $s );
571 * Set the text to be displayed above the changes
573 * @param FormOptions $opts
574 * @param int $numRows Number of rows in the result to show after this header
576 public function doHeader( $opts, $numRows ) {
577 $user = $this->getUser();
578 $out = $this->getOutput();
581 $this->msg( 'watchlistfor2', $user->getName() )
582 ->rawParams( SpecialEditWatchlist
::buildTools(
583 $this->getLanguage(),
584 $this->getLinkRenderer()
588 $this->setTopText( $opts );
592 $form .= Xml
::openElement( 'form', [
594 'action' => wfScript(),
595 'id' => 'mw-watchlist-form'
597 $form .= Html
::hidden( 'title', $this->getPageTitle()->getPrefixedText() );
598 $form .= Xml
::openElement(
600 [ 'id' => 'mw-watchlist-options', 'class' => 'cloptions' ]
602 $form .= Xml
::element(
603 'legend', null, $this->msg( 'watchlist-options' )->text()
606 if ( !$this->isStructuredFilterUiEnabled() ) {
607 $form .= $this->makeLegend();
610 $lang = $this->getLanguage();
611 $timestamp = wfTimestampNow();
612 $wlInfo = Html
::rawElement(
616 'data-params' => json_encode( [ 'from' => $timestamp ] ),
618 $this->msg( 'wlnote' )->numParams( $numRows, round( $opts['days'] * 24 ) )->params(
619 $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
623 $nondefaults = $opts->getChangedValues();
624 $cutofflinks = Html
::rawElement(
626 [ 'class' => 'cldays cloption' ],
627 $this->msg( 'wlshowtime' ) . ' ' . $this->cutoffselector( $opts )
630 # Spit out some control panel links
632 $namesOfDisplayedFilters = [];
633 foreach ( $this->getFilterGroups() as $groupName => $group ) {
634 if ( !$group->isPerGroupRequestParameter() ) {
635 foreach ( $group->getFilters() as $filterName => $filter ) {
636 if ( $filter->displaysOnUnstructuredUi( $this ) ) {
637 $namesOfDisplayedFilters[] = $filterName;
638 $links[] = $this->showHideCheck(
640 $filter->getShowHide(),
643 $filter->isFeatureAvailableOnStructuredUi( $this )
650 $hiddenFields = $nondefaults;
651 $hiddenFields['action'] = 'submit';
652 unset( $hiddenFields['namespace'] );
653 unset( $hiddenFields['invert'] );
654 unset( $hiddenFields['associated'] );
655 unset( $hiddenFields['days'] );
656 foreach ( $namesOfDisplayedFilters as $filterName ) {
657 unset( $hiddenFields[$filterName] );
660 # Namespace filter and put the whole form together.
662 $form .= $cutofflinks;
663 $form .= Html
::rawElement(
665 [ 'class' => 'clshowhide' ],
666 $this->msg( 'watchlist-hide' ) .
667 $this->msg( 'colon-separator' )->escaped() .
668 implode( ' ', $links )
670 $form .= "\n<br />\n";
672 $namespaceForm = Html
::namespaceSelector(
674 'selected' => $opts['namespace'],
676 'label' => $this->msg( 'namespace' )->text()
678 'name' => 'namespace',
680 'class' => 'namespaceselector',
683 $namespaceForm .= '<span class="mw-input-with-label">' . Xml
::checkLabel(
684 $this->msg( 'invert' )->text(),
688 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
690 $namespaceForm .= '<span class="mw-input-with-label">' . Xml
::checkLabel(
691 $this->msg( 'namespace_association' )->text(),
695 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
697 $form .= Html
::rawElement(
699 [ 'class' => 'namespaceForm cloption' ],
703 $form .= Xml
::submitButton(
704 $this->msg( 'watchlist-submit' )->text(),
705 [ 'class' => 'cloption-submit' ]
707 foreach ( $hiddenFields as $key => $value ) {
708 $form .= Html
::hidden( $key, $value ) . "\n";
710 $form .= Xml
::closeElement( 'fieldset' ) . "\n";
711 $form .= Xml
::closeElement( 'form' ) . "\n";
713 // Insert a placeholder for RCFilters
714 if ( $this->isStructuredFilterUiEnabled() ) {
715 $rcfilterContainer = Html
::element(
717 [ 'class' => 'rcfilters-container' ]
720 $loadingContainer = Html
::rawElement(
722 [ 'class' => 'rcfilters-spinner' ],
725 [ 'class' => 'rcfilters-spinner-bounce' ]
729 // Wrap both with rcfilters-head
730 $this->getOutput()->addHTML(
733 [ 'class' => 'rcfilters-head' ],
734 $rcfilterContainer . $form
739 $this->getOutput()->addHTML( $loadingContainer );
741 $this->getOutput()->addHTML( $form );
744 $this->setBottomText( $opts );
747 function cutoffselector( $options ) {
748 // Cast everything to strings immediately, so that we know all of the values have the same
749 // precision, and can be compared with '==='. 2/24 has a few more decimal places than its
750 // default string representation, for example, and would confuse comparisons.
752 // Misleadingly, the 'days' option supports hours too.
753 $days = array_map( 'strval', [ 1 / 24, 2 / 24, 6 / 24, 12 / 24, 1, 3, 7 ] );
755 $userWatchlistOption = (string)$this->getUser()->getOption( 'watchlistdays' );
756 // add the user preference, if it isn't available already
757 if ( !in_array( $userWatchlistOption, $days ) && $userWatchlistOption !== '0' ) {
758 $days[] = $userWatchlistOption;
761 $maxDays = (string)$this->maxDays
;
762 // add the maximum possible value, if it isn't available already
763 if ( !in_array( $maxDays, $days ) ) {
767 $selected = (string)$options['days'];
768 if ( $selected <= 0 ) {
769 $selected = $maxDays;
772 // add the currently selected value, if it isn't available already
773 if ( !in_array( $selected, $days ) ) {
777 $select = new XmlSelect( 'days', 'days', $selected );
780 foreach ( $days as $value ) {
782 $name = $this->msg( 'hours' )->numParams( $value * 24 )->text();
784 $name = $this->msg( 'days' )->numParams( $value )->text();
786 $select->addOption( $name, $value );
789 return $select->getHTML() . "\n<br />\n";
792 function setTopText( FormOptions
$opts ) {
793 $nondefaults = $opts->getChangedValues();
795 $user = $this->getUser();
797 $numItems = $this->countItems();
798 $showUpdatedMarker = $this->getConfig()->get( 'ShowUpdatedMarker' );
800 // Show watchlist header
801 $watchlistHeader = '';
802 if ( $numItems == 0 ) {
803 $watchlistHeader = $this->msg( 'nowatchlist' )->parse();
805 $watchlistHeader .= $this->msg( 'watchlist-details' )->numParams( $numItems )->parse() . "\n";
806 if ( $this->getConfig()->get( 'EnotifWatchlist' )
807 && $user->getOption( 'enotifwatchlistpages' )
809 $watchlistHeader .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
811 if ( $showUpdatedMarker ) {
812 $watchlistHeader .= $this->msg(
813 $this->isStructuredFilterUiEnabled() ?
814 'rcfilters-watchlist-showupdated' :
815 'wlheader-showupdated'
819 $form .= Html
::rawElement(
821 [ 'class' => 'watchlistDetails' ],
825 if ( $numItems > 0 && $showUpdatedMarker ) {
826 $form .= Xml
::openElement( 'form', [ 'method' => 'post',
827 'action' => $this->getPageTitle()->getLocalURL(),
828 'id' => 'mw-watchlist-resetbutton' ] ) . "\n" .
829 Xml
::submitButton( $this->msg( 'enotif_reset' )->text(),
830 [ 'name' => 'mw-watchlist-reset-submit' ] ) . "\n" .
831 Html
::hidden( 'token', $user->getEditToken() ) . "\n" .
832 Html
::hidden( 'reset', 'all' ) . "\n";
833 foreach ( $nondefaults as $key => $value ) {
834 $form .= Html
::hidden( $key, $value ) . "\n";
836 $form .= Xml
::closeElement( 'form' ) . "\n";
839 $this->getOutput()->addHTML( $form );
842 protected function showHideCheck( $options, $message, $name, $value, $inStructuredUi ) {
843 $options[$name] = 1 - (int)$value;
845 $attribs = [ 'class' => 'mw-input-with-label clshowhideoption cloption' ];
846 if ( $inStructuredUi ) {
847 $attribs[ 'data-feature-in-structured-ui' ] = true;
850 return Html
::rawElement(
854 $this->msg( $message, '' )->text(),
863 * Count the number of paired items on a user's watchlist.
864 * The assumption made here is that when a subject page is watched a talk page is also watched.
865 * Hence the number of individual items is halved.
869 protected function countItems() {
870 $store = MediaWikiServices
::getInstance()->getWatchedItemStore();
871 $count = $store->countWatchedItems( $this->getUser() );
872 return floor( $count / 2 );
875 function getDefaultLimit() {
876 return $this->getUser()->getIntOption( 'wllimit' );
879 function getDefaultDays() {
880 return floatval( $this->getUser()->getOption( 'watchlistdays' ) );