90661485642781da872f7c839db9acb995493dac
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
1 <?php
2 /**
3 * Implements Special:Watchlist
4 *
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.
9 *
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.
14 *
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
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 use MediaWiki\MediaWikiServices;
25 use Wikimedia\Rdbms\ResultWrapper;
26 use Wikimedia\Rdbms\IDatabase;
27
28 /**
29 * A special page that lists last changes made to the wiki,
30 * limited to user-defined list of titles.
31 *
32 * @ingroup SpecialPage
33 */
34 class SpecialWatchlist extends ChangesListSpecialPage {
35 public function __construct( $page = 'Watchlist', $restriction = 'viewmywatchlist' ) {
36 parent::__construct( $page, $restriction );
37 }
38
39 public function doesWrites() {
40 return true;
41 }
42
43 /**
44 * Main execution point
45 *
46 * @param string $subpage
47 */
48 function execute( $subpage ) {
49 // Anons don't get a watchlist
50 $this->requireLogin( 'watchlistanontext' );
51
52 $output = $this->getOutput();
53 $request = $this->getRequest();
54 $this->addHelpLink( 'Help:Watching pages' );
55 $output->addModules( [
56 'mediawiki.special.changeslist.visitedstatus',
57 'mediawiki.special.watchlist',
58 ] );
59
60 $mode = SpecialEditWatchlist::getMode( $request, $subpage );
61 if ( $mode !== false ) {
62 if ( $mode === SpecialEditWatchlist::EDIT_RAW ) {
63 $title = SpecialPage::getTitleFor( 'EditWatchlist', 'raw' );
64 } elseif ( $mode === SpecialEditWatchlist::EDIT_CLEAR ) {
65 $title = SpecialPage::getTitleFor( 'EditWatchlist', 'clear' );
66 } else {
67 $title = SpecialPage::getTitleFor( 'EditWatchlist' );
68 }
69
70 $output->redirect( $title->getLocalURL() );
71
72 return;
73 }
74
75 $this->checkPermissions();
76
77 $user = $this->getUser();
78 $opts = $this->getOptions();
79
80 $config = $this->getConfig();
81 if ( ( $config->get( 'EnotifWatchlist' ) || $config->get( 'ShowUpdatedMarker' ) )
82 && $request->getVal( 'reset' )
83 && $request->wasPosted()
84 ) {
85 $user->clearAllNotifications();
86 $output->redirect( $this->getPageTitle()->getFullURL( $opts->getChangedValues() ) );
87
88 return;
89 }
90
91 parent::execute( $subpage );
92 }
93
94 /**
95 * Return an array of subpages that this special page will accept.
96 *
97 * @see also SpecialEditWatchlist::getSubpagesForPrefixSearch
98 * @return string[] subpages
99 */
100 public function getSubpagesForPrefixSearch() {
101 return [
102 'clear',
103 'edit',
104 'raw',
105 ];
106 }
107
108 /**
109 * @inheritdoc
110 */
111 protected function registerFiltersFromDefinitions( array $definition ) {
112 foreach ( $definition as $groupName => &$groupDefinition ) {
113 foreach ( $groupDefinition['filters'] as &$filterDefinition ) {
114 if ( isset( $filterDefinition['showHideSuffix'] ) ) {
115 $filterDefinition['showHide'] = 'wl' . $filterDefinition['showHideSuffix'];
116 }
117 }
118 }
119
120 parent::registerFiltersFromDefinitions( $definition );
121 }
122
123 /**
124 * @inheritdoc
125 */
126 protected function registerFilters() {
127 parent::registerFilters();
128
129 $user = $this->getUser();
130
131 $significance = $this->getFilterGroup( 'significance' );
132 $hideMinor = $significance->getFilter( 'hideminor' );
133 $hideMinor->setDefault( $user->getBoolOption( 'watchlisthideminor' ) );
134
135 $automated = $this->getFilterGroup( 'automated' );
136 $hideBots = $automated->getFilter( 'hidebots' );
137 $hideBots->setDefault( $user->getBoolOption( 'watchlisthidebots' ) );
138
139 $registration = $this->getFilterGroup( 'registration' );
140 $hideAnons = $registration->getFilter( 'hideanons' );
141 $hideAnons->setDefault( $user->getBoolOption( 'watchlisthideanons' ) );
142 $hideLiu = $registration->getFilter( 'hideliu' );
143 $hideLiu->setDefault( $user->getBoolOption( 'watchlisthideliu' ) );
144
145 $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
146 $hidePatrolled = $reviewStatus->getFilter( 'hidepatrolled' );
147 $hidePatrolled->setDefault( $user->getBoolOption( 'watchlisthidepatrolled' ) );
148
149 $authorship = $this->getFilterGroup( 'authorship' );
150 $hideMyself = $authorship->getFilter( 'hidemyself' );
151 $hideMyself->setDefault( $user->getBoolOption( 'watchlisthideown' ) );
152
153 $changeType = $this->getFilterGroup( 'changeType' );
154 $hideCategorization = $changeType->getFilter( 'hidecategorization' );
155 $hideCategorization->setDefault( $user->getBoolOption( 'watchlisthidecategorization' ) );
156 }
157
158 /**
159 * Get a FormOptions object containing the default options
160 *
161 * @return FormOptions
162 */
163 public function getDefaultOptions() {
164 $opts = parent::getDefaultOptions();
165 $user = $this->getUser();
166
167 $opts->add( 'days', $user->getOption( 'watchlistdays' ), FormOptions::FLOAT );
168 $opts->add( 'extended', $user->getBoolOption( 'extendwatchlist' ) );
169
170 return $opts;
171 }
172
173 /**
174 * Get all custom filters
175 *
176 * @return array Map of filter URL param names to properties (msg/default)
177 */
178 protected function getCustomFilters() {
179 if ( $this->customFilters === null ) {
180 $this->customFilters = parent::getCustomFilters();
181 Hooks::run( 'SpecialWatchlistFilters', [ $this, &$this->customFilters ], '1.23' );
182 }
183
184 return $this->customFilters;
185 }
186
187 /**
188 * Fetch values for a FormOptions object from the WebRequest associated with this instance.
189 *
190 * Maps old pre-1.23 request parameters Watchlist used to use (different from Recentchanges' ones)
191 * to the current ones.
192 *
193 * @param FormOptions $opts
194 * @return FormOptions
195 */
196 protected function fetchOptionsFromRequest( $opts ) {
197 static $compatibilityMap = [
198 'hideMinor' => 'hideminor',
199 'hideBots' => 'hidebots',
200 'hideAnons' => 'hideanons',
201 'hideLiu' => 'hideliu',
202 'hidePatrolled' => 'hidepatrolled',
203 'hideOwn' => 'hidemyself',
204 ];
205
206 $params = $this->getRequest()->getValues();
207 foreach ( $compatibilityMap as $from => $to ) {
208 if ( isset( $params[$from] ) ) {
209 $params[$to] = $params[$from];
210 unset( $params[$from] );
211 }
212 }
213
214 if ( $this->getRequest()->getVal( 'action' ) == 'submit' ) {
215 $allBooleansFalse = [];
216
217 // If the user submitted the form, start with a baseline of "all
218 // booleans are false", then change the ones they checked. This
219 // means we ignore the defaults.
220
221 // This is how we handle the fact that HTML forms don't submit
222 // unchecked boxes.
223 foreach ( $this->filterGroups as $filterGroup ) {
224 if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
225 foreach ( $filterGroup->getFilters() as $filter ) {
226 $allBooleansFalse[$filter->getName()] = false;
227 }
228 }
229 }
230
231 $params = $params + $allBooleansFalse;
232 }
233
234 // Not the prettiest way to achieve this… FormOptions internally depends on data sanitization
235 // methods defined on WebRequest and removing this dependency would cause some code duplication.
236 $request = new DerivativeRequest( $this->getRequest(), $params );
237 $opts->fetchValuesFromRequest( $request );
238
239 return $opts;
240 }
241
242 /**
243 * @inheritdoc
244 */
245 protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
246 &$join_conds, FormOptions $opts ) {
247
248 $dbr = $this->getDB();
249 parent::buildQuery( $tables, $fields, $conds, $query_options, $join_conds,
250 $opts );
251
252 // Calculate cutoff
253 if ( $opts['days'] > 0 ) {
254 $conds[] = 'rc_timestamp > ' .
255 $dbr->addQuotes( $dbr->timestamp( time() - intval( $opts['days'] * 86400 ) ) );
256 }
257 }
258
259 /**
260 * @inheritdoc
261 */
262 protected function doMainQuery( $tables, $fields, $conds, $query_options,
263 $join_conds, FormOptions $opts ) {
264
265 $dbr = $this->getDB();
266 $user = $this->getUser();
267
268 # Toggle watchlist content (all recent edits or just the latest)
269 if ( $opts['extended'] ) {
270 $limitWatchlist = $user->getIntOption( 'wllimit' );
271 $usePage = false;
272 } else {
273 # Top log Ids for a page are not stored
274 $nonRevisionTypes = [ RC_LOG ];
275 Hooks::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] );
276 if ( $nonRevisionTypes ) {
277 $conds[] = $dbr->makeList(
278 [
279 'rc_this_oldid=page_latest',
280 'rc_type' => $nonRevisionTypes,
281 ],
282 LIST_OR
283 );
284 }
285 $limitWatchlist = 0;
286 $usePage = true;
287 }
288
289 $tables = array_merge( [ 'recentchanges', 'watchlist' ], $tables );
290 $fields = array_merge( RecentChange::selectFields(), $fields );
291
292 $query_options = array_merge( [ 'ORDER BY' => 'rc_timestamp DESC' ], $query_options );
293 $join_conds = array_merge(
294 [
295 'watchlist' => [
296 'INNER JOIN',
297 [
298 'wl_user' => $user->getId(),
299 'wl_namespace=rc_namespace',
300 'wl_title=rc_title'
301 ],
302 ],
303 ],
304 $join_conds
305 );
306
307 if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
308 $fields[] = 'wl_notificationtimestamp';
309 }
310 if ( $limitWatchlist ) {
311 $query_options['LIMIT'] = $limitWatchlist;
312 }
313
314 $rollbacker = $user->isAllowed( 'rollback' );
315 if ( $usePage || $rollbacker ) {
316 $tables[] = 'page';
317 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
318 if ( $rollbacker ) {
319 $fields[] = 'page_latest';
320 }
321 }
322
323 // Log entries with DELETED_ACTION must not show up unless the user has
324 // the necessary rights.
325 if ( !$user->isAllowed( 'deletedhistory' ) ) {
326 $bitmask = LogPage::DELETED_ACTION;
327 } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
328 $bitmask = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED;
329 } else {
330 $bitmask = 0;
331 }
332 if ( $bitmask ) {
333 $conds[] = $dbr->makeList( [
334 'rc_type != ' . RC_LOG,
335 $dbr->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
336 ], LIST_OR );
337 }
338
339 ChangeTags::modifyDisplayQuery(
340 $tables,
341 $fields,
342 $conds,
343 $join_conds,
344 $query_options,
345 ''
346 );
347
348 $this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts );
349
350 return $dbr->select(
351 $tables,
352 $fields,
353 $conds,
354 __METHOD__,
355 $query_options,
356 $join_conds
357 );
358 }
359
360 protected function runMainQueryHook( &$tables, &$fields, &$conds, &$query_options,
361 &$join_conds, $opts
362 ) {
363 return parent::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
364 && Hooks::run(
365 'SpecialWatchlistQuery',
366 [ &$conds, &$tables, &$join_conds, &$fields, $opts ],
367 '1.23'
368 );
369 }
370
371 /**
372 * Return a IDatabase object for reading
373 *
374 * @return IDatabase
375 */
376 protected function getDB() {
377 return wfGetDB( DB_REPLICA, 'watchlist' );
378 }
379
380 /**
381 * Output feed links.
382 */
383 public function outputFeedLinks() {
384 $user = $this->getUser();
385 $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
386 if ( $wlToken ) {
387 $this->addFeedLinks( [
388 'action' => 'feedwatchlist',
389 'allrev' => 1,
390 'wlowner' => $user->getName(),
391 'wltoken' => $wlToken,
392 ] );
393 }
394 }
395
396 /**
397 * Build and output the actual changes list.
398 *
399 * @param ResultWrapper $rows Database rows
400 * @param FormOptions $opts
401 */
402 public function outputChangesList( $rows, $opts ) {
403 $dbr = $this->getDB();
404 $user = $this->getUser();
405 $output = $this->getOutput();
406
407 # Show a message about replica DB lag, if applicable
408 $lag = wfGetLB()->safeGetLag( $dbr );
409 if ( $lag > 0 ) {
410 $output->showLagWarning( $lag );
411 }
412
413 # If no rows to display, show message before try to render the list
414 if ( $rows->numRows() == 0 ) {
415 $output->wrapWikiMsg(
416 "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
417 );
418 return;
419 }
420
421 $dbr->dataSeek( $rows, 0 );
422
423 $list = ChangesList::newFromContext( $this->getContext(), $this->filterGroups );
424 $list->setWatchlistDivs();
425 $list->initChangesListRows( $rows );
426 $dbr->dataSeek( $rows, 0 );
427
428 if ( $this->getConfig()->get( 'RCShowWatchingUsers' )
429 && $user->getOption( 'shownumberswatching' )
430 ) {
431 $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
432 }
433
434 $s = $list->beginRecentChangesList();
435 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
436 $counter = 1;
437 foreach ( $rows as $obj ) {
438 # Make RC entry
439 $rc = RecentChange::newFromRow( $obj );
440
441 # Skip CatWatch entries for hidden cats based on user preference
442 if (
443 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE &&
444 !$userShowHiddenCats &&
445 $rc->getParam( 'hidden-cat' )
446 ) {
447 continue;
448 }
449
450 $rc->counter = $counter++;
451
452 if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
453 $updated = $obj->wl_notificationtimestamp;
454 } else {
455 $updated = false;
456 }
457
458 if ( isset( $watchedItemStore ) ) {
459 $rcTitleValue = new TitleValue( (int)$obj->rc_namespace, $obj->rc_title );
460 $rc->numberofWatchingusers = $watchedItemStore->countWatchers( $rcTitleValue );
461 } else {
462 $rc->numberofWatchingusers = 0;
463 }
464
465 $changeLine = $list->recentChangesLine( $rc, $updated, $counter );
466 if ( $changeLine !== false ) {
467 $s .= $changeLine;
468 }
469 }
470 $s .= $list->endRecentChangesList();
471
472 $output->addHTML( $s );
473 }
474
475 /**
476 * Set the text to be displayed above the changes
477 *
478 * @param FormOptions $opts
479 * @param int $numRows Number of rows in the result to show after this header
480 */
481 public function doHeader( $opts, $numRows ) {
482 $user = $this->getUser();
483 $out = $this->getOutput();
484
485 $out->addSubtitle(
486 $this->msg( 'watchlistfor2', $user->getName() )
487 ->rawParams( SpecialEditWatchlist::buildTools(
488 $this->getLanguage(),
489 $this->getLinkRenderer()
490 ) )
491 );
492
493 $this->setTopText( $opts );
494
495 $lang = $this->getLanguage();
496 if ( $opts['days'] > 0 ) {
497 $days = $opts['days'];
498 } else {
499 $days = $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 );
500 }
501 $timestamp = wfTimestampNow();
502 $wlInfo = $this->msg( 'wlnote' )->numParams( $numRows, round( $days * 24 ) )->params(
503 $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
504 )->parse() . "<br />\n";
505
506 $nondefaults = $opts->getChangedValues();
507 $cutofflinks = $this->msg( 'wlshowtime' ) . ' ' . $this->cutoffselector( $opts );
508
509 # Spit out some control panel links
510 $links = [];
511 $context = $this->getContext();
512 $namesOfDisplayedFilters = [];
513 foreach ( $this->getFilterGroups() as $groupName => $group ) {
514 if ( !$group->isPerGroupRequestParameter() ) {
515 foreach ( $group->getFilters() as $filterName => $filter ) {
516 if ( $filter->displaysOnUnstructuredUi( $this ) ) {
517 $namesOfDisplayedFilters[] = $filterName;
518 $links[] = $this->showHideCheck(
519 $nondefaults,
520 $filter->getShowHide(),
521 $filterName,
522 $opts[$filterName]
523 );
524 }
525 }
526 }
527 }
528
529 $hiddenFields = $nondefaults;
530 $hiddenFields['action'] = 'submit';
531 unset( $hiddenFields['namespace'] );
532 unset( $hiddenFields['invert'] );
533 unset( $hiddenFields['associated'] );
534 unset( $hiddenFields['days'] );
535 foreach ( $namesOfDisplayedFilters as $filterName ) {
536 unset( $hiddenFields[$filterName] );
537 }
538
539 # Create output
540 $form = '';
541
542 # Namespace filter and put the whole form together.
543 $form .= $wlInfo;
544 $form .= $cutofflinks;
545 $form .= $this->msg( 'watchlist-hide' ) .
546 $this->msg( 'colon-separator' )->escaped() .
547 implode( ' ', $links );
548 $form .= "\n<br />\n";
549 $form .= Html::namespaceSelector(
550 [
551 'selected' => $opts['namespace'],
552 'all' => '',
553 'label' => $this->msg( 'namespace' )->text()
554 ], [
555 'name' => 'namespace',
556 'id' => 'namespace',
557 'class' => 'namespaceselector',
558 ]
559 ) . "\n";
560 $form .= '<span class="mw-input-with-label">' . Xml::checkLabel(
561 $this->msg( 'invert' )->text(),
562 'invert',
563 'nsinvert',
564 $opts['invert'],
565 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
566 ) . "</span>\n";
567 $form .= '<span class="mw-input-with-label">' . Xml::checkLabel(
568 $this->msg( 'namespace_association' )->text(),
569 'associated',
570 'nsassociated',
571 $opts['associated'],
572 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
573 ) . "</span>\n";
574 $form .= Xml::submitButton( $this->msg( 'watchlist-submit' )->text() ) . "\n";
575 foreach ( $hiddenFields as $key => $value ) {
576 $form .= Html::hidden( $key, $value ) . "\n";
577 }
578 $form .= Xml::closeElement( 'fieldset' ) . "\n";
579 $form .= Xml::closeElement( 'form' ) . "\n";
580 $this->getOutput()->addHTML( $form );
581
582 $this->setBottomText( $opts );
583 }
584
585 function cutoffselector( $options ) {
586 // Cast everything to strings immediately, so that we know all of the values have the same
587 // precision, and can be compared with '==='. 2/24 has a few more decimal places than its
588 // default string representation, for example, and would confuse comparisons.
589
590 // Misleadingly, the 'days' option supports hours too.
591 $days = array_map( 'strval', [ 1/24, 2/24, 6/24, 12/24, 1, 3, 7 ] );
592
593 $userWatchlistOption = (string)$this->getUser()->getOption( 'watchlistdays' );
594 // add the user preference, if it isn't available already
595 if ( !in_array( $userWatchlistOption, $days ) && $userWatchlistOption !== '0' ) {
596 $days[] = $userWatchlistOption;
597 }
598
599 $maxDays = (string)( $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
600 // add the maximum possible value, if it isn't available already
601 if ( !in_array( $maxDays, $days ) ) {
602 $days[] = $maxDays;
603 }
604
605 $selected = (string)$options['days'];
606 if ( $selected <= 0 ) {
607 $selected = $maxDays;
608 }
609
610 // add the currently selected value, if it isn't available already
611 if ( !in_array( $selected, $days ) ) {
612 $days[] = $selected;
613 }
614
615 $select = new XmlSelect( 'days', 'days', $selected );
616
617 asort( $days );
618 foreach ( $days as $value ) {
619 if ( $value < 1 ) {
620 $name = $this->msg( 'hours' )->numParams( $value * 24 )->text();
621 } else {
622 $name = $this->msg( 'days' )->numParams( $value )->text();
623 }
624 $select->addOption( $name, $value );
625 }
626
627 return $select->getHTML() . "\n<br />\n";
628 }
629
630 function setTopText( FormOptions $opts ) {
631 $nondefaults = $opts->getChangedValues();
632 $form = "";
633 $user = $this->getUser();
634
635 $numItems = $this->countItems();
636 $showUpdatedMarker = $this->getConfig()->get( 'ShowUpdatedMarker' );
637
638 // Show watchlist header
639 $form .= "<p>";
640 if ( $numItems == 0 ) {
641 $form .= $this->msg( 'nowatchlist' )->parse() . "\n";
642 } else {
643 $form .= $this->msg( 'watchlist-details' )->numParams( $numItems )->parse() . "\n";
644 if ( $this->getConfig()->get( 'EnotifWatchlist' )
645 && $user->getOption( 'enotifwatchlistpages' )
646 ) {
647 $form .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
648 }
649 if ( $showUpdatedMarker ) {
650 $form .= $this->msg( 'wlheader-showupdated' )->parse() . "\n";
651 }
652 }
653 $form .= "</p>";
654
655 if ( $numItems > 0 && $showUpdatedMarker ) {
656 $form .= Xml::openElement( 'form', [ 'method' => 'post',
657 'action' => $this->getPageTitle()->getLocalURL(),
658 'id' => 'mw-watchlist-resetbutton' ] ) . "\n" .
659 Xml::submitButton( $this->msg( 'enotif_reset' )->text(),
660 [ 'name' => 'mw-watchlist-reset-submit' ] ) . "\n" .
661 Html::hidden( 'reset', 'all' ) . "\n";
662 foreach ( $nondefaults as $key => $value ) {
663 $form .= Html::hidden( $key, $value ) . "\n";
664 }
665 $form .= Xml::closeElement( 'form' ) . "\n";
666 }
667
668 $form .= Xml::openElement( 'form', [
669 'method' => 'get',
670 'action' => wfScript(),
671 'id' => 'mw-watchlist-form'
672 ] );
673 $form .= Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() );
674 $form .= Xml::fieldset(
675 $this->msg( 'watchlist-options' )->text(),
676 false,
677 [ 'id' => 'mw-watchlist-options' ]
678 );
679
680 $form .= $this->makeLegend();
681
682 $this->getOutput()->addHTML( $form );
683 }
684
685 protected function showHideCheck( $options, $message, $name, $value ) {
686 $options[$name] = 1 - (int)$value;
687
688 return '<span class="mw-input-with-label">' . Xml::checkLabel(
689 $this->msg( $message, '' )->text(),
690 $name,
691 $name,
692 (int)$value
693 ) . '</span>';
694 }
695
696 /**
697 * Count the number of paired items on a user's watchlist.
698 * The assumption made here is that when a subject page is watched a talk page is also watched.
699 * Hence the number of individual items is halved.
700 *
701 * @return int
702 */
703 protected function countItems() {
704 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
705 $count = $store->countWatchedItems( $this->getUser() );
706 return floor( $count / 2 );
707 }
708 }