MediaWiki REL1_33
SpecialWatchlist.php
Go to the documentation of this file.
1<?php
27
35 protected static $savedQueriesPreferenceName = 'rcfilters-wl-saved-queries';
36 protected static $daysPreferenceName = 'watchlistdays';
37 protected static $limitPreferenceName = 'wllimit';
38 protected static $collapsedPreferenceName = 'rcfilters-wl-collapsed';
39
41 private $maxDays;
43 private $watchStore;
44
45 public function __construct( $page = 'Watchlist', $restriction = 'viewmywatchlist' ) {
46 parent::__construct( $page, $restriction );
47
48 $this->maxDays = $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 );
49 $this->watchStore = MediaWikiServices::getInstance()->getWatchedItemStore();
50 }
51
52 public function doesWrites() {
53 return true;
54 }
55
61 function execute( $subpage ) {
62 // Anons don't get a watchlist
63 $this->requireLogin( 'watchlistanontext' );
64
65 $output = $this->getOutput();
66 $request = $this->getRequest();
67 $this->addHelpLink( 'Help:Watching pages' );
68 $output->addModuleStyles( [ 'mediawiki.special' ] );
69 $output->addModules( [
70 'mediawiki.special.recentchanges',
71 'mediawiki.special.watchlist',
72 ] );
73
74 $mode = SpecialEditWatchlist::getMode( $request, $subpage );
75 if ( $mode !== false ) {
76 if ( $mode === SpecialEditWatchlist::EDIT_RAW ) {
77 $title = SpecialPage::getTitleFor( 'EditWatchlist', 'raw' );
78 } elseif ( $mode === SpecialEditWatchlist::EDIT_CLEAR ) {
79 $title = SpecialPage::getTitleFor( 'EditWatchlist', 'clear' );
80 } else {
81 $title = SpecialPage::getTitleFor( 'EditWatchlist' );
82 }
83
84 $output->redirect( $title->getLocalURL() );
85
86 return;
87 }
88
89 $this->checkPermissions();
90
91 $user = $this->getUser();
92 $opts = $this->getOptions();
93
94 $config = $this->getConfig();
95 if ( ( $config->get( 'EnotifWatchlist' ) || $config->get( 'ShowUpdatedMarker' ) )
96 && $request->getVal( 'reset' )
97 && $request->wasPosted()
98 && $user->matchEditToken( $request->getVal( 'token' ) )
99 ) {
100 $user->clearAllNotifications();
101 $output->redirect( $this->getPageTitle()->getFullURL( $opts->getChangedValues() ) );
102
103 return;
104 }
105
106 parent::execute( $subpage );
107
108 if ( $this->isStructuredFilterUiEnabled() ) {
109 $output->addModuleStyles( [ 'mediawiki.rcfilters.highlightCircles.seenunseen.styles' ] );
110 }
111 }
112
113 public static function checkStructuredFilterUiEnabled( Config $config, User $user ) {
114 return !$user->getOption( 'wlenhancedfilters-disable' );
115 }
116
123 public function getSubpagesForPrefixSearch() {
124 return [
125 'clear',
126 'edit',
127 'raw',
128 ];
129 }
130
134 protected function transformFilterDefinition( array $filterDefinition ) {
135 if ( isset( $filterDefinition['showHideSuffix'] ) ) {
136 $filterDefinition['showHide'] = 'wl' . $filterDefinition['showHideSuffix'];
137 }
138
139 return $filterDefinition;
140 }
141
145 protected function registerFilters() {
146 parent::registerFilters();
147
148 // legacy 'extended' filter
150 'name' => 'extended-group',
151 'filters' => [
152 [
153 'name' => 'extended',
154 'isReplacedInStructuredUi' => true,
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(
163 [
164 'rc_this_oldid=page_latest',
165 'rc_type' => $nonRevisionTypes,
166 ],
167 LIST_OR
168 );
169 }
170 },
171 ]
172 ],
173
174 ] ) );
175
176 if ( $this->isStructuredFilterUiEnabled() ) {
177 $this->getFilterGroup( 'lastRevision' )
178 ->getFilter( 'hidepreviousrevisions' )
179 ->setDefault( !$this->getUser()->getBoolOption( 'extendwatchlist' ) );
180 }
181
183 'name' => 'watchlistactivity',
184 'title' => 'rcfilters-filtergroup-watchlistactivity',
185 'class' => ChangesListStringOptionsFilterGroup::class,
186 'priority' => 3,
187 'isFullCoverage' => true,
188 'filters' => [
189 [
190 'name' => 'unseen',
191 'label' => 'rcfilters-filter-watchlistactivity-unseen-label',
192 'description' => 'rcfilters-filter-watchlistactivity-unseen-description',
193 'cssClassSuffix' => 'watchedunseen',
194 'isRowApplicableCallable' => function ( $ctx, RecentChange $rc ) {
195 $changeTs = $rc->getAttribute( 'rc_timestamp' );
196 $lastVisitTs = $this->watchStore->getLatestNotificationTimestamp(
197 $rc->getAttribute( 'wl_notificationtimestamp' ),
198 $rc->getPerformer(),
199 $rc->getTitle()
200 );
201 return $lastVisitTs !== null && $changeTs >= $lastVisitTs;
202 },
203 ],
204 [
205 'name' => 'seen',
206 'label' => 'rcfilters-filter-watchlistactivity-seen-label',
207 'description' => 'rcfilters-filter-watchlistactivity-seen-description',
208 'cssClassSuffix' => 'watchedseen',
209 'isRowApplicableCallable' => function ( $ctx, $rc ) {
210 $changeTs = $rc->getAttribute( 'rc_timestamp' );
211 $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
212 return $lastVisitTs === null || $changeTs < $lastVisitTs;
213 }
214 ],
215 ],
217 'queryCallable' => function ( $specialPageClassName, $context, $dbr,
218 &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
219 if ( $selectedValues === [ 'seen' ] ) {
220 $conds[] = $dbr->makeList( [
221 'wl_notificationtimestamp IS NULL',
222 'rc_timestamp < wl_notificationtimestamp'
223 ], LIST_OR );
224 } elseif ( $selectedValues === [ 'unseen' ] ) {
225 $conds[] = $dbr->makeList( [
226 'wl_notificationtimestamp IS NOT NULL',
227 'rc_timestamp >= wl_notificationtimestamp'
228 ], LIST_AND );
229 }
230 }
231 ] ) );
232
233 $user = $this->getUser();
234
235 $significance = $this->getFilterGroup( 'significance' );
236 $hideMinor = $significance->getFilter( 'hideminor' );
237 $hideMinor->setDefault( $user->getBoolOption( 'watchlisthideminor' ) );
238
239 $automated = $this->getFilterGroup( 'automated' );
240 $hideBots = $automated->getFilter( 'hidebots' );
241 $hideBots->setDefault( $user->getBoolOption( 'watchlisthidebots' ) );
242
243 $registration = $this->getFilterGroup( 'registration' );
244 $hideAnons = $registration->getFilter( 'hideanons' );
245 $hideAnons->setDefault( $user->getBoolOption( 'watchlisthideanons' ) );
246 $hideLiu = $registration->getFilter( 'hideliu' );
247 $hideLiu->setDefault( $user->getBoolOption( 'watchlisthideliu' ) );
248
249 // Selecting both hideanons and hideliu on watchlist preferances
250 // gives mutually exclusive filters, so those are ignored
251 if ( $user->getBoolOption( 'watchlisthideanons' ) &&
252 !$user->getBoolOption( 'watchlisthideliu' )
253 ) {
254 $this->getFilterGroup( 'userExpLevel' )
255 ->setDefault( 'registered' );
256 }
257
258 if ( $user->getBoolOption( 'watchlisthideliu' ) &&
259 !$user->getBoolOption( 'watchlisthideanons' )
260 ) {
261 $this->getFilterGroup( 'userExpLevel' )
262 ->setDefault( 'unregistered' );
263 }
264
265 $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
266 if ( $reviewStatus !== null ) {
267 // Conditional on feature being available and rights
268 if ( $user->getBoolOption( 'watchlisthidepatrolled' ) ) {
269 $reviewStatus->setDefault( 'unpatrolled' );
270 $legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' );
271 $legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' );
272 $legacyHidePatrolled->setDefault( true );
273 }
274 }
275
276 $authorship = $this->getFilterGroup( 'authorship' );
277 $hideMyself = $authorship->getFilter( 'hidemyself' );
278 $hideMyself->setDefault( $user->getBoolOption( 'watchlisthideown' ) );
279
280 $changeType = $this->getFilterGroup( 'changeType' );
281 $hideCategorization = $changeType->getFilter( 'hidecategorization' );
282 if ( $hideCategorization !== null ) {
283 // Conditional on feature being available
284 $hideCategorization->setDefault( $user->getBoolOption( 'watchlisthidecategorization' ) );
285 }
286 }
287
297 protected function fetchOptionsFromRequest( $opts ) {
298 static $compatibilityMap = [
299 'hideMinor' => 'hideminor',
300 'hideBots' => 'hidebots',
301 'hideAnons' => 'hideanons',
302 'hideLiu' => 'hideliu',
303 'hidePatrolled' => 'hidepatrolled',
304 'hideOwn' => 'hidemyself',
305 ];
306
307 $params = $this->getRequest()->getValues();
308 foreach ( $compatibilityMap as $from => $to ) {
309 if ( isset( $params[$from] ) ) {
310 $params[$to] = $params[$from];
311 unset( $params[$from] );
312 }
313 }
314
315 if ( $this->getRequest()->getVal( 'action' ) == 'submit' ) {
316 $allBooleansFalse = [];
317
318 // If the user submitted the form, start with a baseline of "all
319 // booleans are false", then change the ones they checked. This
320 // means we ignore the defaults.
321
322 // This is how we handle the fact that HTML forms don't submit
323 // unchecked boxes.
324 foreach ( $this->getLegacyShowHideFilters() as $filter ) {
325 $allBooleansFalse[ $filter->getName() ] = false;
326 }
327
328 $params = $params + $allBooleansFalse;
329 }
330
331 // Not the prettiest way to achieve this… FormOptions internally depends on data sanitization
332 // methods defined on WebRequest and removing this dependency would cause some code duplication.
333 $request = new DerivativeRequest( $this->getRequest(), $params );
334 $opts->fetchValuesFromRequest( $request );
335
336 return $opts;
337 }
338
342 protected function doMainQuery( $tables, $fields, $conds, $query_options,
343 $join_conds, FormOptions $opts
344 ) {
345 $dbr = $this->getDB();
346 $user = $this->getUser();
347
348 $rcQuery = RecentChange::getQueryInfo();
349 $tables = array_merge( $tables, $rcQuery['tables'], [ 'watchlist' ] );
350 $fields = array_merge( $rcQuery['fields'], $fields );
351
352 $join_conds = array_merge(
353 [
354 'watchlist' => [
355 'JOIN',
356 [
357 'wl_user' => $user->getId(),
358 'wl_namespace=rc_namespace',
359 'wl_title=rc_title'
360 ],
361 ],
362 ],
363 $rcQuery['joins'],
364 $join_conds
365 );
366
367 $tables[] = 'page';
368 $fields[] = 'page_latest';
369 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
370
371 $fields[] = 'wl_notificationtimestamp';
372
373 // Log entries with DELETED_ACTION must not show up unless the user has
374 // the necessary rights.
375 if ( !$user->isAllowed( 'deletedhistory' ) ) {
376 $bitmask = LogPage::DELETED_ACTION;
377 } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
379 } else {
380 $bitmask = 0;
381 }
382 if ( $bitmask ) {
383 $conds[] = $dbr->makeList( [
384 'rc_type != ' . RC_LOG,
385 $dbr->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
386 ], LIST_OR );
387 }
388
389 $tagFilter = $opts['tagfilter'] ? explode( '|', $opts['tagfilter'] ) : [];
391 $tables,
392 $fields,
393 $conds,
394 $join_conds,
395 $query_options,
396 $tagFilter
397 );
398
399 $this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts );
400
401 if ( $this->areFiltersInConflict() ) {
402 return false;
403 }
404
405 $orderByAndLimit = [
406 'ORDER BY' => 'rc_timestamp DESC',
407 'LIMIT' => $opts['limit']
408 ];
409 if ( in_array( 'DISTINCT', $query_options ) ) {
410 // ChangeTags::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
411 // In order to prevent DISTINCT from causing query performance problems,
412 // we have to GROUP BY the primary key. This in turn requires us to add
413 // the primary key to the end of the ORDER BY, and the old ORDER BY to the
414 // start of the GROUP BY
415 $orderByAndLimit['ORDER BY'] = 'rc_timestamp DESC, rc_id DESC';
416 $orderByAndLimit['GROUP BY'] = 'rc_timestamp, rc_id';
417 }
418 // array_merge() is used intentionally here so that hooks can, should
419 // they so desire, override the ORDER BY / LIMIT condition(s)
420 $query_options = array_merge( $orderByAndLimit, $query_options );
421
422 return $dbr->select(
423 $tables,
424 $fields,
425 $conds,
426 __METHOD__,
427 $query_options,
428 $join_conds
429 );
430 }
431
437 protected function getDB() {
438 return wfGetDB( DB_REPLICA, 'watchlist' );
439 }
440
444 public function outputFeedLinks() {
445 $user = $this->getUser();
446 $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
447 if ( $wlToken ) {
448 $this->addFeedLinks( [
449 'action' => 'feedwatchlist',
450 'allrev' => 1,
451 'wlowner' => $user->getName(),
452 'wltoken' => $wlToken,
453 ] );
454 }
455 }
456
463 public function outputChangesList( $rows, $opts ) {
464 $dbr = $this->getDB();
465 $user = $this->getUser();
466 $output = $this->getOutput();
467 $services = MediaWikiServices::getInstance();
468
469 # Show a message about replica DB lag, if applicable
470 $lag = $dbr->getSessionLagStatus()['lag'];
471 if ( $lag > 0 ) {
472 $output->showLagWarning( $lag );
473 }
474
475 # If no rows to display, show message before try to render the list
476 if ( $rows->numRows() == 0 ) {
477 $output->wrapWikiMsg(
478 "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
479 );
480 return;
481 }
482
483 $dbr->dataSeek( $rows, 0 );
484
485 $list = ChangesList::newFromContext( $this->getContext(), $this->filterGroups );
486 $list->setWatchlistDivs();
487 $list->initChangesListRows( $rows );
488 if ( $user->getOption( 'watchlistunwatchlinks' ) ) {
489 $list->setChangeLinePrefixer( function ( RecentChange $rc, ChangesList $cl, $grouped ) {
490 // Don't show unwatch link if the line is a grouped log entry using EnhancedChangesList,
491 // since EnhancedChangesList groups log entries by performer rather than by target article
492 if ( $rc->mAttribs['rc_type'] == RC_LOG && $cl instanceof EnhancedChangesList &&
493 $grouped ) {
494 return '';
495 } else {
496 return $this->getLinkRenderer()
497 ->makeKnownLink( $rc->getTitle(),
498 $this->msg( 'watchlist-unwatch' )->text(), [
499 'class' => 'mw-unwatch-link',
500 'title' => $this->msg( 'tooltip-ca-unwatch' )->text()
501 ], [ 'action' => 'unwatch' ] ) . "\u{00A0}";
502 }
503 } );
504 }
505 $dbr->dataSeek( $rows, 0 );
506
507 if ( $this->getConfig()->get( 'RCShowWatchingUsers' )
508 && $user->getOption( 'shownumberswatching' )
509 ) {
510 $watchedItemStore = $services->getWatchedItemStore();
511 }
512
513 $s = $list->beginRecentChangesList();
514
515 if ( $this->isStructuredFilterUiEnabled() ) {
516 $s .= $this->makeLegend();
517 }
518
519 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
520 $counter = 1;
521 foreach ( $rows as $obj ) {
522 # Make RC entry
523 $rc = RecentChange::newFromRow( $obj );
524
525 # Skip CatWatch entries for hidden cats based on user preference
526 if (
527 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE &&
528 !$userShowHiddenCats &&
529 $rc->getParam( 'hidden-cat' )
530 ) {
531 continue;
532 }
533
534 $rc->counter = $counter++;
535
536 if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
537 $updated = $obj->wl_notificationtimestamp;
538 } else {
539 $updated = false;
540 }
541
542 if ( isset( $watchedItemStore ) ) {
543 $rcTitleValue = new TitleValue( (int)$obj->rc_namespace, $obj->rc_title );
544 $rc->numberofWatchingusers = $watchedItemStore->countWatchers( $rcTitleValue );
545 } else {
546 $rc->numberofWatchingusers = 0;
547 }
548
549 $changeLine = $list->recentChangesLine( $rc, $updated, $counter );
550 if ( $changeLine !== false ) {
551 $s .= $changeLine;
552 }
553 }
554 $s .= $list->endRecentChangesList();
555
556 $output->addHTML( $s );
557 }
558
565 public function doHeader( $opts, $numRows ) {
566 $user = $this->getUser();
567 $out = $this->getOutput();
568
569 $out->addSubtitle(
570 $this->msg( 'watchlistfor2', $user->getName() )
572 $this->getLanguage(),
573 $this->getLinkRenderer()
574 ) )
575 );
576
577 $this->setTopText( $opts );
578
579 $form = '';
580
581 $form .= Xml::openElement( 'form', [
582 'method' => 'get',
583 'action' => wfScript(),
584 'id' => 'mw-watchlist-form'
585 ] );
586 $form .= Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() );
587 $form .= Xml::openElement(
588 'fieldset',
589 [ 'id' => 'mw-watchlist-options', 'class' => 'cloptions' ]
590 );
591 $form .= Xml::element(
592 'legend', null, $this->msg( 'watchlist-options' )->text()
593 );
594
595 if ( !$this->isStructuredFilterUiEnabled() ) {
596 $form .= $this->makeLegend();
597 }
598
599 $lang = $this->getLanguage();
600 $timestamp = wfTimestampNow();
601 $wlInfo = Html::rawElement(
602 'span',
603 [
604 'class' => 'wlinfo',
605 'data-params' => json_encode( [ 'from' => $timestamp ] ),
606 ],
607 $this->msg( 'wlnote' )->numParams( $numRows, round( $opts['days'] * 24 ) )->params(
608 $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
609 )->parse()
610 ) . "<br />\n";
611
612 $nondefaults = $opts->getChangedValues();
613 $cutofflinks = Html::rawElement(
614 'span',
615 [ 'class' => 'cldays cloption' ],
616 $this->msg( 'wlshowtime' ) . ' ' . $this->cutoffselector( $opts )
617 );
618
619 # Spit out some control panel links
620 $links = [];
621 $namesOfDisplayedFilters = [];
622 foreach ( $this->getLegacyShowHideFilters() as $filterName => $filter ) {
623 $namesOfDisplayedFilters[] = $filterName;
624 $links[] = $this->showHideCheck(
625 $nondefaults,
626 $filter->getShowHide(),
627 $filterName,
628 $opts[ $filterName ],
629 $filter->isFeatureAvailableOnStructuredUi( $this )
630 );
631 }
632
633 $hiddenFields = $nondefaults;
634 $hiddenFields['action'] = 'submit';
635 unset( $hiddenFields['namespace'] );
636 unset( $hiddenFields['invert'] );
637 unset( $hiddenFields['associated'] );
638 unset( $hiddenFields['days'] );
639 foreach ( $namesOfDisplayedFilters as $filterName ) {
640 unset( $hiddenFields[$filterName] );
641 }
642
643 # Namespace filter and put the whole form together.
644 $form .= $wlInfo;
645 $form .= $cutofflinks;
646 $form .= Html::rawElement(
647 'span',
648 [ 'class' => 'clshowhide' ],
649 $this->msg( 'watchlist-hide' ) .
650 $this->msg( 'colon-separator' )->escaped() .
651 implode( ' ', $links )
652 );
653 $form .= "\n<br />\n";
654
655 $namespaceForm = Html::namespaceSelector(
656 [
657 'selected' => $opts['namespace'],
658 'all' => '',
659 'label' => $this->msg( 'namespace' )->text(),
660 'in-user-lang' => true,
661 ], [
662 'name' => 'namespace',
663 'id' => 'namespace',
664 'class' => 'namespaceselector',
665 ]
666 ) . "\n";
667 $hidden = $opts['namespace'] === '' ? ' mw-input-hidden' : '';
668 $namespaceForm .= '<span class="mw-input-with-label' . $hidden . '">' . Xml::checkLabel(
669 $this->msg( 'invert' )->text(),
670 'invert',
671 'nsinvert',
672 $opts['invert'],
673 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
674 ) . "</span>\n";
675 $namespaceForm .= '<span class="mw-input-with-label' . $hidden . '">' . Xml::checkLabel(
676 $this->msg( 'namespace_association' )->text(),
677 'associated',
678 'nsassociated',
679 $opts['associated'],
680 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
681 ) . "</span>\n";
682 $form .= Html::rawElement(
683 'span',
684 [ 'class' => 'namespaceForm cloption' ],
685 $namespaceForm
686 );
687
688 $form .= Xml::submitButton(
689 $this->msg( 'watchlist-submit' )->text(),
690 [ 'class' => 'cloption-submit' ]
691 ) . "\n";
692 foreach ( $hiddenFields as $key => $value ) {
693 $form .= Html::hidden( $key, $value ) . "\n";
694 }
695 $form .= Xml::closeElement( 'fieldset' ) . "\n";
696 $form .= Xml::closeElement( 'form' ) . "\n";
697
698 // Insert a placeholder for RCFilters
699 if ( $this->isStructuredFilterUiEnabled() ) {
700 $rcfilterContainer = Html::element(
701 'div',
702 [ 'class' => 'rcfilters-container' ]
703 );
704
705 $loadingContainer = Html::rawElement(
706 'div',
707 [ 'class' => 'rcfilters-spinner' ],
708 Html::element(
709 'div',
710 [ 'class' => 'rcfilters-spinner-bounce' ]
711 )
712 );
713
714 // Wrap both with rcfilters-head
715 $this->getOutput()->addHTML(
716 Html::rawElement(
717 'div',
718 [ 'class' => 'rcfilters-head' ],
719 $rcfilterContainer . $form
720 )
721 );
722
723 // Add spinner
724 $this->getOutput()->addHTML( $loadingContainer );
725 } else {
726 $this->getOutput()->addHTML( $form );
727 }
728
729 $this->setBottomText( $opts );
730 }
731
733 $selected = (float)$options['days'];
734 if ( $selected <= 0 ) {
735 $selected = $this->maxDays;
736 }
737
738 $selectedHours = round( $selected * 24 );
739
740 $hours = array_unique( array_filter( [
741 1,
742 2,
743 6,
744 12,
745 24,
746 72,
747 168,
748 24 * (float)$this->getUser()->getOption( 'watchlistdays', 0 ),
749 24 * $this->maxDays,
750 $selectedHours
751 ] ) );
752 asort( $hours );
753
754 $select = new XmlSelect( 'days', 'days', (float)( $selectedHours / 24 ) );
755
756 foreach ( $hours as $value ) {
757 if ( $value < 24 ) {
758 $name = $this->msg( 'hours' )->numParams( $value )->text();
759 } else {
760 $name = $this->msg( 'days' )->numParams( $value / 24 )->text();
761 }
762 $select->addOption( $name, (float)( $value / 24 ) );
763 }
764
765 return $select->getHTML() . "\n<br />\n";
766 }
767
768 function setTopText( FormOptions $opts ) {
769 $nondefaults = $opts->getChangedValues();
770 $form = '';
771 $user = $this->getUser();
772
773 $numItems = $this->countItems();
774 $showUpdatedMarker = $this->getConfig()->get( 'ShowUpdatedMarker' );
775
776 // Show watchlist header
777 $watchlistHeader = '';
778 if ( $numItems == 0 ) {
779 $watchlistHeader = $this->msg( 'nowatchlist' )->parse();
780 } else {
781 $watchlistHeader .= $this->msg( 'watchlist-details' )->numParams( $numItems )->parse() . "\n";
782 if ( $this->getConfig()->get( 'EnotifWatchlist' )
783 && $user->getOption( 'enotifwatchlistpages' )
784 ) {
785 $watchlistHeader .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
786 }
787 if ( $showUpdatedMarker ) {
788 $watchlistHeader .= $this->msg(
790 'rcfilters-watchlist-showupdated' :
791 'wlheader-showupdated'
792 )->parse() . "\n";
793 }
794 }
795 $form .= Html::rawElement(
796 'div',
797 [ 'class' => 'watchlistDetails' ],
798 $watchlistHeader
799 );
800
801 if ( $numItems > 0 && $showUpdatedMarker ) {
802 $form .= Xml::openElement( 'form', [ 'method' => 'post',
803 'action' => $this->getPageTitle()->getLocalURL(),
804 'id' => 'mw-watchlist-resetbutton' ] ) . "\n" .
805 Xml::submitButton( $this->msg( 'enotif_reset' )->text(),
806 [ 'name' => 'mw-watchlist-reset-submit' ] ) . "\n" .
807 Html::hidden( 'token', $user->getEditToken() ) . "\n" .
808 Html::hidden( 'reset', 'all' ) . "\n";
809 foreach ( $nondefaults as $key => $value ) {
810 $form .= Html::hidden( $key, $value ) . "\n";
811 }
812 $form .= Xml::closeElement( 'form' ) . "\n";
813 }
814
815 $this->getOutput()->addHTML( $form );
816 }
817
818 protected function showHideCheck( $options, $message, $name, $value, $inStructuredUi ) {
819 $options[$name] = 1 - (int)$value;
820
821 $attribs = [ 'class' => 'mw-input-with-label clshowhideoption cloption' ];
822 if ( $inStructuredUi ) {
823 $attribs[ 'data-feature-in-structured-ui' ] = true;
824 }
825
826 return Html::rawElement(
827 'span',
828 $attribs,
829 // not using Html::checkLabel because that would escape the contents
830 Html::check( $name, (int)$value, [ 'id' => $name ] ) . Html::rawElement(
831 'label',
832 $attribs + [ 'for' => $name ],
833 // <nowiki/> at beginning to avoid messages with "$1 ..." being parsed as pre tags
834 $this->msg( $message, '<nowiki/>' )->parse()
835 )
836 );
837 }
838
846 protected function countItems() {
847 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
848 $count = $store->countWatchedItems( $this->getUser() );
849 return floor( $count / 2 );
850 }
851}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='')
Applies all tags-related changes to a query.
If the group is active, any unchecked filters will translate to hide parameters in the URL.
Special page which uses a ChangesList to show query results.
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
getFilterGroup( $groupName)
Gets a specified ChangesListFilterGroup by name.
isStructuredFilterUiEnabled()
Check whether the structured filter UI is enabled.
areFiltersInConflict()
Check if filters are in conflict and guaranteed to return no results.
registerFilterGroup(ChangesListFilterGroup $group)
Register a structured changes list filter group.
getOptions()
Get the current FormOptions for this request.
setBottomText(FormOptions $opts)
Send the text to be displayed after the options.
makeLegend()
Return the legend displayed within the fieldset.
Represents a filter group with multiple string options.
const NONE
Signifies that no options in the group are selected, meaning the group has no effect.
static newFromContext(IContextSource $context, array $groups=[])
Fetch an appropriate changes list class for the specified context Some users might want to use an enh...
Similar to FauxRequest, but only fakes URL parameters and method (POST or GET) and use the base reque...
Helper class to keep track of options when mixing links and form elements.
getChangedValues()
Return options modified as an array ( name => value )
const DELETED_RESTRICTED
Definition LogPage.php:37
const DELETED_ACTION
Definition LogPage.php:34
MediaWikiServices is the service locator for the application scope of MediaWiki.
Utility class for creating new RC entries.
getPerformer()
Get the User object of the person who performed this change.
getAttribute( $name)
Get an attribute value.
static buildTools( $lang, LinkRenderer $linkRenderer=null)
Build a set of links for convenient navigation between watchlist viewing and editing modes.
const EDIT_CLEAR
Editing modes.
static getMode( $request, $par)
Determine whether we are editing the watchlist, and if so, what kind of editing operation.
getOutput()
Get the OutputPage being used for this instance.
requireLogin( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin')
If the user is not logged in, throws UserNotLoggedIn error.
getUser()
Shortcut to get the User executing this instance.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
addFeedLinks( $params)
Adds RSS/atom links.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
A special page that lists last changes made to the wiki, limited to user-defined list of titles.
__construct( $page='Watchlist', $restriction='viewmywatchlist')
outputFeedLinks()
Output feed links.
$watchStore
WatchedItemStore.
doHeader( $opts, $numRows)
Set the text to be displayed above the changes.
showHideCheck( $options, $message, $name, $value, $inStructuredUi)
getSubpagesForPrefixSearch()
Return an array of subpages that this special page will accept.
fetchOptionsFromRequest( $opts)
Fetch values for a FormOptions object from the WebRequest associated with this instance.
doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, FormOptions $opts)
@inheritDoc
static $savedQueriesPreferenceName
getDB()
Return a IDatabase object for reading.
transformFilterDefinition(array $filterDefinition)
@inheritDoc
countItems()
Count the number of paired items on a user's watchlist.
static checkStructuredFilterUiEnabled(Config $config, User $user)
Static method to check whether StructuredFilter UI is enabled for the given user.
setTopText(FormOptions $opts)
Send the text to be displayed before the options.
execute( $subpage)
Main execution point.
registerFilters()
@inheritDoc
outputChangesList( $rows, $opts)
Build and output the actual changes list.
doesWrites()
Indicates whether this special page may perform database writes.
Represents a page (or page fragment) title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:48
Class for generating HTML <select> or <datalist> elements.
Definition XmlSelect.php:26
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
const LIST_OR
Definition Defines.php:55
const RC_LOG
Definition Defines.php:153
const LIST_AND
Definition Defines.php:52
const RC_CATEGORIZE
Definition Defines.php:155
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
Definition hooks.txt:2818
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Definition hooks.txt:2843
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition hooks.txt:855
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:1999
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition hooks.txt:2848
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:955
this hook is for auditing only RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition hooks.txt:996
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
Definition hooks.txt:2290
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:271
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition hooks.txt:2012
return true to allow those checks to and false if checking is done & $user
Definition hooks.txt:1510
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
Definition hooks.txt:2272
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
Interface for configuration instances.
Definition Config.php:28
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
Result wrapper for grabbing data queried from an IDatabase object.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
$filter
const DB_REPLICA
Definition defines.php:25
$params
if(!isset( $args[0])) $lang