parent::execute( $subpage );
if ( $this->isStructuredFilterUiEnabled() ) {
- $jsData = $this->getStructuredFilterJsData();
-
- $messages = [];
- foreach ( $jsData['messageKeys'] as $key ) {
- $messages[$key] = $this->msg( $key )->plain();
- }
-
- $out->addHTML(
- ResourceLoader::makeInlineScript(
- ResourceLoader::makeMessageSetScript( $messages )
- )
- );
-
- $experimentalStructuredChangeFilters =
- $this->getConfig()->get( 'StructuredChangeFiltersEnableExperimentalViews' );
-
- $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
- $out->addJsConfigVars(
- 'wgStructuredChangeFiltersEnableExperimentalViews',
- $experimentalStructuredChangeFilters
- );
- $out->addJsConfigVars(
- 'wgStructuredChangeFiltersEnableLiveUpdate',
- $this->getConfig()->get( 'StructuredChangeFiltersEnableLiveUpdate' )
- );
+ $out->addJsConfigVars( 'wgStructuredChangeFiltersLiveUpdateSupported', true );
$out->addJsConfigVars(
- 'wgRCFiltersChangeTags',
- $this->buildChangeTagList()
+ 'wgStructuredChangeFiltersSavedQueriesPreferenceName',
+ 'rcfilters-saved-queries'
);
- $out->addJsConfigVars(
- 'StructuredChangeFiltersDisplayConfig',
- [
- 'maxDays' => (int)$this->getConfig()->get( 'RCMaxAge' ) / ( 24 * 3600 ), // Translate to days
- 'limitArray' => $this->getConfig()->get( 'RCLinkLimits' ),
- 'daysArray' => $this->getConfig()->get( 'RCLinkDays' ),
- ]
- );
- }
- }
-
- /**
- * Fetch the change tags list for the front end
- *
- * @return Array Tag data
- */
- protected function buildChangeTagList() {
- $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
- $softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
-
- // Hit counts disabled for perf reasons, see T169997
- /*
- $tagStats = ChangeTags::tagUsageStatistics();
- $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats );
-
- // Sort by hits
- arsort( $tagHitCounts );
- */
- $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags );
-
- // Build the list and data
- $result = [];
- foreach ( $tagHitCounts as $tagName => $hits ) {
- if (
- // Only get active tags
- isset( $explicitlyDefinedTags[ $tagName ] ) ||
- isset( $softwareActivatedTags[ $tagName ] )
- ) {
- // Parse description
- $desc = ChangeTags::tagLongDescriptionMessage( $tagName, $this->getContext() );
-
- $result[] = [
- 'name' => $tagName,
- 'label' => Sanitizer::stripAllTags(
- ChangeTags::tagDescription( $tagName, $this->getContext() )
- ),
- 'description' => $desc ? Sanitizer::stripAllTags( $desc->parse() ) : '',
- 'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
- 'hits' => $hits,
- ];
- }
}
-
- // Instead of sorting by hit count (disabled, see above), sort by display name
- usort( $result, function ( $a, $b ) {
- return strcasecmp( $a['label'], $b['label'] );
- } );
-
- return $result;
}
/**
*/
public function getDefaultOptions() {
$opts = parent::getDefaultOptions();
- $user = $this->getUser();
- $opts->add( 'days', $user->getIntOption( 'rcdays' ), FormOptions::FLOAT );
- $opts->add( 'limit', $user->getIntOption( 'rclimit' ) );
+ $opts->add( 'days', $this->getDefaultDays(), FormOptions::FLOAT );
+ $opts->add( 'limit', $this->getDefaultLimit() );
$opts->add( 'from', '' );
$opts->add( 'categories', '' );
$opts->add( 'categories_any', false );
- $opts->add( 'tagfilter', '' );
return $opts;
}
&& $this->getUser()->getOption( 'shownumberswatching' );
$watcherCache = [];
- $dbr = $this->getDB();
-
$counter = 1;
$list = ChangesList::newFromContext( $this->getContext(), $this->filterGroups );
$list->initChangesListRows( $rows );
++$count;
$addSubmit = ( $count === $extraOptsCount ) ? $submit : '';
- $out .= Xml::openElement( 'tr' );
+ $out .= Xml::openElement( 'tr', [ 'class' => $name . 'Form' ] );
if ( is_array( $optionRow ) ) {
$out .= Xml::tags(
'td',
$rcoptions = Xml::fieldset(
$this->msg( 'recentchanges-legend' )->text(),
$panelString,
- [ 'class' => 'rcoptions' ]
+ [ 'class' => 'rcoptions cloptions' ]
);
// Insert a placeholder for RCFilters
- if ( $this->getUser()->getOption( 'rcenhancedfilters' ) ) {
+ if ( $this->isStructuredFilterUiEnabled() ) {
$rcfilterContainer = Html::element(
'div',
[ 'class' => 'rcfilters-container' ]
$message = $this->msg( 'recentchangestext' )->inContentLanguage();
if ( !$message->isDisabled() ) {
- $content = $message->parse();
+ // Parse the message in this weird ugly way to preserve the ability to include interlanguage
+ // links in it (T172461). In the future when T66969 is resolved, perhaps we can just use
+ // $message->parse() instead. This code is copied from Message::parseText().
+ $parserOutput = MessageCache::singleton()->parse(
+ $message->plain(),
+ $this->getPageTitle(),
+ /*linestart*/true,
+ // Message class sets the interface flag to false when parsing in a language different than
+ // user language, and this is wiki content language
+ /*interface*/false,
+ $wgContLang
+ );
+ $content = $parserOutput->getText();
+ // Add only metadata here (including the language links), text is added below
+ $this->getOutput()->addParserOutputMetadata( $parserOutput );
$langAttributes = [
'lang' => $wgContLang->getHtmlCode(),
$topLinksAttributes = [ 'class' => 'mw-recentchanges-toplinks' ];
- if ( $this->getUser()->getOption( 'rcenhancedfilters' ) ) {
+ if ( $this->isStructuredFilterUiEnabled() ) {
$contentTitle = Html::rawElement( 'div',
[ 'class' => 'mw-recentchanges-toplinks-title' ],
$this->msg( 'rcfilters-other-review-tools' )->parse()
return $extraOpts;
}
- /**
- * Check whether the structured filter UI is enabled
- *
- * @return bool
- */
- protected function isStructuredFilterUiEnabled() {
- return $this->getUser()->getOption(
- 'rcenhancedfilters'
- );
- }
-
/**
* Add page-specific modules.
*/
parent::addModules();
$out = $this->getOutput();
$out->addModules( 'mediawiki.special.recentchanges' );
- if ( $this->isStructuredFilterUiEnabled() ) {
- $out->addModules( 'mediawiki.rcfilters.filters.ui' );
- $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
- }
}
/**
$filterGroups = $this->getFilterGroups();
- $context = $this->getContext();
foreach ( $filterGroups as $groupName => $group ) {
if ( !$group->isPerGroupRequestParameter() ) {
foreach ( $group->getFilters() as $key => $filter ) {
[ $key => 1 - $options[$key] ], $nondefaults );
$attribs = [
- 'class' => "$msg rcshowhideoption",
+ 'class' => "$msg rcshowhideoption clshowhideoption",
'data-filter-name' => $filter->getName(),
];
protected function getCacheTTL() {
return 60 * 5;
}
+
+ function getDefaultLimit() {
+ return $this->getUser()->getIntOption( 'rclimit' );
+ }
+
+ function getDefaultDays() {
+ return floatval( $this->getUser()->getOption( 'rcdays' ) );
+ }
}