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