41 public function __construct( $page =
'Watchlist', $restriction =
'viewmywatchlist' ) {
42 parent::__construct( $page, $restriction );
44 $this->maxDays = $this->
getConfig()->get(
'RCMaxAge' ) / ( 3600 * 24 );
64 'mediawiki.special.changeslist.visitedstatus',
65 'mediawiki.special.watchlist',
67 $output->addModuleStyles( [
'mediawiki.special.watchlist.styles' ] );
70 if ( $mode !==
false ) {
79 $output->redirect( $title->getLocalURL() );
90 if ( ( $config->get(
'EnotifWatchlist' ) || $config->get(
'ShowUpdatedMarker' ) )
93 && $user->matchEditToken(
$request->getVal(
'token' ) )
95 $user->clearAllNotifications();
101 parent::execute( $subpage );
104 $output->addModuleStyles( [
'mediawiki.rcfilters.highlightCircles.seenunseen.styles' ] );
107 'wgStructuredChangeFiltersEditWatchlistUrl',
115 $config->
get(
'StructuredChangeFiltersOnWatchlist' ) &&
116 $user->getOption(
'rcenhancedfilters' )
138 if ( isset( $filterDefinition[
'showHideSuffix'] ) ) {
139 $filterDefinition[
'showHide'] =
'wl' . $filterDefinition[
'showHideSuffix'];
142 return $filterDefinition;
149 parent::registerFilters();
153 'name' =>
'extended-group',
156 'name' =>
'extended',
157 'isReplacedInStructuredUi' =>
true,
158 'activeValue' =>
false,
159 'default' => $this->
getUser()->getBoolOption(
'extendwatchlist' ),
160 'queryCallable' =>
function ( $specialClassName, $ctx,
$dbr, &
$tables,
161 &$fields, &$conds, &$query_options, &$join_conds ) {
162 $nonRevisionTypes = [
RC_LOG ];
163 Hooks::run(
'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] );
164 if ( $nonRevisionTypes ) {
165 $conds[] =
$dbr->makeList(
167 'rc_this_oldid=page_latest',
168 'rc_type' => $nonRevisionTypes,
181 ->getFilter(
'hidepreviousrevisions' )
182 ->setDefault( !$this->
getUser()->getBoolOption(
'extendwatchlist' ) );
186 'name' =>
'watchlistactivity',
187 'title' =>
'rcfilters-filtergroup-watchlistactivity',
188 'class' => ChangesListStringOptionsFilterGroup::class,
190 'isFullCoverage' =>
true,
194 'label' =>
'rcfilters-filter-watchlistactivity-unseen-label',
195 'description' =>
'rcfilters-filter-watchlistactivity-unseen-description',
196 'cssClassSuffix' =>
'watchedunseen',
197 'isRowApplicableCallable' =>
function ( $ctx, $rc ) {
198 $changeTs = $rc->getAttribute(
'rc_timestamp' );
199 $lastVisitTs = $rc->getAttribute(
'wl_notificationtimestamp' );
200 return $lastVisitTs !==
null && $changeTs >= $lastVisitTs;
205 'label' =>
'rcfilters-filter-watchlistactivity-seen-label',
206 'description' =>
'rcfilters-filter-watchlistactivity-seen-description',
207 'cssClassSuffix' =>
'watchedseen',
208 'isRowApplicableCallable' =>
function ( $ctx, $rc ) {
209 $changeTs = $rc->getAttribute(
'rc_timestamp' );
210 $lastVisitTs = $rc->getAttribute(
'wl_notificationtimestamp' );
211 return $lastVisitTs ===
null || $changeTs < $lastVisitTs;
217 &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
218 if ( $selectedValues === [
'seen' ] ) {
219 $conds[] =
$dbr->makeList( [
220 'wl_notificationtimestamp IS NULL',
221 'rc_timestamp < wl_notificationtimestamp'
223 } elseif ( $selectedValues === [
'unseen' ] ) {
224 $conds[] =
$dbr->makeList( [
225 'wl_notificationtimestamp IS NOT NULL',
226 'rc_timestamp >= wl_notificationtimestamp'
235 $hideMinor = $significance->getFilter(
'hideminor' );
236 $hideMinor->setDefault( $user->getBoolOption(
'watchlisthideminor' ) );
239 $hideBots = $automated->getFilter(
'hidebots' );
240 $hideBots->setDefault( $user->getBoolOption(
'watchlisthidebots' ) );
243 $hideAnons = $registration->getFilter(
'hideanons' );
244 $hideAnons->setDefault( $user->getBoolOption(
'watchlisthideanons' ) );
245 $hideLiu = $registration->getFilter(
'hideliu' );
246 $hideLiu->setDefault( $user->getBoolOption(
'watchlisthideliu' ) );
250 if ( $user->getBoolOption(
'watchlisthideanons' ) &&
251 !$user->getBoolOption(
'watchlisthideliu' )
254 ->setDefault(
'registered' );
257 if ( $user->getBoolOption(
'watchlisthideliu' ) &&
258 !$user->getBoolOption(
'watchlisthideanons' )
261 ->setDefault(
'unregistered' );
265 if ( $reviewStatus !==
null ) {
267 if ( $user->getBoolOption(
'watchlisthidepatrolled' ) ) {
268 $reviewStatus->setDefault(
'unpatrolled' );
269 $legacyReviewStatus = $this->
getFilterGroup(
'legacyReviewStatus' );
270 $legacyHidePatrolled = $legacyReviewStatus->getFilter(
'hidepatrolled' );
271 $legacyHidePatrolled->setDefault(
true );
276 $hideMyself = $authorship->getFilter(
'hidemyself' );
277 $hideMyself->setDefault( $user->getBoolOption(
'watchlisthideown' ) );
280 $hideCategorization = $changeType->getFilter(
'hidecategorization' );
281 if ( $hideCategorization !==
null ) {
283 $hideCategorization->setDefault( $user->getBoolOption(
'watchlisthidecategorization' ) );
293 if ( $this->customFilters ===
null ) {
294 $this->customFilters = parent::getCustomFilters();
295 Hooks::run(
'SpecialWatchlistFilters', [ $this, &$this->customFilters ],
'1.23' );
311 static $compatibilityMap = [
312 'hideMinor' =>
'hideminor',
313 'hideBots' =>
'hidebots',
314 'hideAnons' =>
'hideanons',
315 'hideLiu' =>
'hideliu',
316 'hidePatrolled' =>
'hidepatrolled',
317 'hideOwn' =>
'hidemyself',
321 foreach ( $compatibilityMap as $from => $to ) {
322 if ( isset(
$params[$from] ) ) {
328 if ( $this->
getRequest()->getVal(
'action' ) ==
'submit' ) {
329 $allBooleansFalse = [];
338 $allBooleansFalse[ $filter->getName() ] =
false;
347 $opts->fetchValuesFromRequest(
$request );
361 $rcQuery = RecentChange::getQueryInfo();
362 $tables = array_merge(
$tables, $rcQuery[
'tables'], [
'watchlist' ] );
363 $fields = array_merge( $rcQuery[
'fields'], $fields );
365 $join_conds = array_merge(
370 'wl_user' => $user->getId(),
371 'wl_namespace=rc_namespace',
381 $fields[] =
'page_latest';
382 $join_conds[
'page'] = [
'LEFT JOIN',
'rc_cur_id=page_id' ];
384 $fields[] =
'wl_notificationtimestamp';
388 if ( !$user->isAllowed(
'deletedhistory' ) ) {
390 } elseif ( !$user->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
396 $conds[] =
$dbr->makeList( [
398 $dbr->bitAnd(
'rc_deleted', $bitmask ) .
" != $bitmask",
402 $tagFilter = $opts[
'tagfilter'] ? explode(
'|', $opts[
'tagfilter'] ) : [];
419 'ORDER BY' =>
'rc_timestamp DESC',
420 'LIMIT' => $opts[
'limit']
422 if ( in_array(
'DISTINCT', $query_options ) ) {
428 $orderByAndLimit[
'ORDER BY'] =
'rc_timestamp DESC, rc_id DESC';
429 $orderByAndLimit[
'GROUP BY'] =
'rc_timestamp, rc_id';
433 $query_options = array_merge( $orderByAndLimit, $query_options );
448 return parent::runMainQueryHook(
$tables, $fields, $conds, $query_options, $join_conds, $opts )
450 'SpecialWatchlistQuery',
451 [ &$conds, &
$tables, &$join_conds, &$fields, $opts ],
470 $wlToken = $user->getTokenFromOption(
'watchlisttoken' );
473 'action' =>
'feedwatchlist',
475 'wlowner' => $user->getName(),
476 'wltoken' => $wlToken,
492 # Show a message about replica DB lag, if applicable
493 $lag = MediaWikiServices::getInstance()->getDBLoadBalancer()->safeGetLag(
$dbr );
495 $output->showLagWarning( $lag );
498 # If no rows to display, show message before try to render the list
499 if (
$rows->numRows() == 0 ) {
501 "<div class='mw-changeslist-empty'>\n$1\n</div>",
'recentchanges-noresult'
509 $list->setWatchlistDivs();
510 $list->initChangesListRows(
$rows );
511 if ( $user->getOption(
'watchlistunwatchlinks' ) ) {
519 return $this->getLinkRenderer()
520 ->makeKnownLink( $rc->getTitle(),
521 $this->msg(
'watchlist-unwatch' )->text(), [
522 'class' =>
'mw-unwatch-link',
523 'title' => $this->msg(
'tooltip-ca-unwatch' )->text()
524 ], [
'action' =>
'unwatch' ] ) .
' ';
530 if ( $this->
getConfig()->
get(
'RCShowWatchingUsers' )
531 && $user->getOption(
'shownumberswatching' )
533 $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
536 $s = $list->beginRecentChangesList();
542 $userShowHiddenCats = $this->
getUser()->getBoolOption(
'showhiddencats' );
544 foreach (
$rows as $obj ) {
546 $rc = RecentChange::newFromRow( $obj );
548 # Skip CatWatch entries for hidden cats based on user preference
551 !$userShowHiddenCats &&
552 $rc->getParam(
'hidden-cat' )
557 $rc->counter = $counter++;
559 if ( $this->
getConfig()->
get(
'ShowUpdatedMarker' ) ) {
560 $updated = $obj->wl_notificationtimestamp;
565 if ( isset( $watchedItemStore ) ) {
566 $rcTitleValue =
new TitleValue( (
int)$obj->rc_namespace, $obj->rc_title );
567 $rc->numberofWatchingusers = $watchedItemStore->countWatchers( $rcTitleValue );
569 $rc->numberofWatchingusers = 0;
572 $changeLine = $list->recentChangesLine( $rc, $updated, $counter );
573 if ( $changeLine !==
false ) {
577 $s .= $list->endRecentChangesList();
593 $this->
msg(
'watchlistfor2', $user->getName() )
595 $this->getLanguage(),
596 $this->getLinkRenderer()
604 $form .= Xml::openElement(
'form', [
607 'id' =>
'mw-watchlist-form'
609 $form .= Html::hidden(
'title', $this->
getPageTitle()->getPrefixedText() );
610 $form .= Xml::openElement(
612 [
'id' =>
'mw-watchlist-options',
'class' =>
'cloptions' ]
614 $form .= Xml::element(
615 'legend',
null, $this->
msg(
'watchlist-options' )->
text()
624 $wlInfo = Html::rawElement(
628 'data-params' => json_encode( [
'from' => $timestamp ] ),
630 $this->
msg(
'wlnote' )->numParams( $numRows, round( $opts[
'days'] * 24 ) )->params(
631 $lang->userDate( $timestamp, $user ),
$lang->userTime( $timestamp, $user )
635 $nondefaults = $opts->getChangedValues();
636 $cutofflinks = Html::rawElement(
638 [
'class' =>
'cldays cloption' ],
642 # Spit out some control panel links
644 $namesOfDisplayedFilters = [];
646 $namesOfDisplayedFilters[] = $filterName;
649 $filter->getShowHide(),
651 $opts[ $filterName ],
652 $filter->isFeatureAvailableOnStructuredUi( $this )
656 $hiddenFields = $nondefaults;
657 $hiddenFields[
'action'] =
'submit';
658 unset( $hiddenFields[
'namespace'] );
659 unset( $hiddenFields[
'invert'] );
660 unset( $hiddenFields[
'associated'] );
661 unset( $hiddenFields[
'days'] );
662 foreach ( $namesOfDisplayedFilters as $filterName ) {
663 unset( $hiddenFields[$filterName] );
666 # Namespace filter and put the whole form together.
668 $form .= $cutofflinks;
669 $form .= Html::rawElement(
671 [
'class' =>
'clshowhide' ],
672 $this->
msg(
'watchlist-hide' ) .
673 $this->
msg(
'colon-separator' )->escaped() .
674 implode(
' ', $links )
676 $form .=
"\n<br />\n";
678 $namespaceForm = Html::namespaceSelector(
680 'selected' => $opts[
'namespace'],
682 'label' => $this->
msg(
'namespace' )->
text()
684 'name' =>
'namespace',
686 'class' =>
'namespaceselector',
689 $namespaceForm .=
'<span class="mw-input-with-label">' . Xml::checkLabel(
690 $this->
msg(
'invert' )->
text(),
694 [
'title' => $this->
msg(
'tooltip-invert' )->
text() ]
696 $namespaceForm .=
'<span class="mw-input-with-label">' . Xml::checkLabel(
697 $this->
msg(
'namespace_association' )->
text(),
701 [
'title' => $this->
msg(
'tooltip-namespace_association' )->
text() ]
703 $form .= Html::rawElement(
705 [
'class' =>
'namespaceForm cloption' ],
709 $form .= Xml::submitButton(
710 $this->
msg(
'watchlist-submit' )->
text(),
711 [
'class' =>
'cloption-submit' ]
713 foreach ( $hiddenFields as $key =>
$value ) {
714 $form .= Html::hidden( $key,
$value ) .
"\n";
716 $form .= Xml::closeElement(
'fieldset' ) .
"\n";
717 $form .= Xml::closeElement(
'form' ) .
"\n";
721 $rcfilterContainer = Html::element(
723 [
'class' =>
'rcfilters-container' ]
726 $loadingContainer = Html::rawElement(
728 [
'class' =>
'rcfilters-spinner' ],
731 [
'class' =>
'rcfilters-spinner-bounce' ]
739 [
'class' =>
'rcfilters-head' ],
740 $rcfilterContainer . $form
745 $this->
getOutput()->addHTML( $loadingContainer );
754 $selected = (float)
$options[
'days'];
755 if ( $selected <= 0 ) {
759 $selectedHours = round( $selected * 24 );
761 $hours = array_unique( array_filter( [
769 24 * (
float)$this->
getUser()->getOption(
'watchlistdays', 0 ),
775 $select =
new XmlSelect(
'days',
'days', (
float)( $selectedHours / 24 ) );
777 foreach ( $hours as
$value ) {
779 $name = $this->
msg(
'hours' )->numParams( $value )->text();
781 $name = $this->
msg(
'days' )->numParams( $value / 24 )->text();
783 $select->addOption( $name, (
float)(
$value / 24 ) );
786 return $select->getHTML() .
"\n<br />\n";
795 $showUpdatedMarker = $this->
getConfig()->get(
'ShowUpdatedMarker' );
798 $watchlistHeader =
'';
799 if ( $numItems == 0 ) {
800 $watchlistHeader = $this->
msg(
'nowatchlist' )->parse();
802 $watchlistHeader .= $this->
msg(
'watchlist-details' )->numParams( $numItems )->parse() .
"\n";
803 if ( $this->
getConfig()->
get(
'EnotifWatchlist' )
804 && $user->getOption(
'enotifwatchlistpages' )
806 $watchlistHeader .= $this->
msg(
'wlheader-enotif' )->parse() .
"\n";
808 if ( $showUpdatedMarker ) {
809 $watchlistHeader .= $this->
msg(
811 'rcfilters-watchlist-showupdated' :
812 'wlheader-showupdated'
816 $form .= Html::rawElement(
818 [
'class' =>
'watchlistDetails' ],
822 if ( $numItems > 0 && $showUpdatedMarker ) {
823 $form .= Xml::openElement(
'form', [
'method' =>
'post',
825 'id' =>
'mw-watchlist-resetbutton' ] ) .
"\n" .
826 Xml::submitButton( $this->
msg(
'enotif_reset' )->
text(),
827 [
'name' =>
'mw-watchlist-reset-submit' ] ) .
"\n" .
828 Html::hidden(
'token', $user->getEditToken() ) .
"\n" .
829 Html::hidden(
'reset',
'all' ) .
"\n";
830 foreach ( $nondefaults as $key =>
$value ) {
831 $form .= Html::hidden( $key,
$value ) .
"\n";
833 $form .= Xml::closeElement(
'form' ) .
"\n";
842 $attribs = [
'class' =>
'mw-input-with-label clshowhideoption cloption' ];
843 if ( $inStructuredUi ) {
844 $attribs[
'data-feature-in-structured-ui' ] =
true;
847 return Html::rawElement(
851 Html::check( $name, (
int)
$value, [
'id' => $name ] ) . Html::rawElement(
855 $this->
msg( $message,
'<nowiki/>' )->parse()
868 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
869 $count = $store->countWatchedItems( $this->
getUser() );
870 return floor( $count / 2 );
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...
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.
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.
getLegacyShowHideFilters()
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...
Utility class for creating new RC entries.
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')
getCustomFilters()
Get all custom filters.
outputFeedLinks()
Output feed links.
doHeader( $opts, $numRows)
Set the text to be displayed above the changes.
static $limitPreferenceName
showHideCheck( $options, $message, $name, $value, $inStructuredUi)
getSubpagesForPrefixSearch()
Return an array of subpages that this special page will accept.
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
static $daysPreferenceName
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.
cutoffselector( $options)
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,...
Class for generating HTML <select> or <datalist> elements.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
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
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
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
this hook is for auditing only RecentChangesLinked and Watchlist 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
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
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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
Allows to change the fields on the form that will be generated $name
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
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
if(!isset( $args[0])) $lang