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(
- 'wgRCFiltersChangeTags',
- $this->buildChangeTagList()
- );
+ $out->addJsConfigVars( 'wgStructuredChangeFiltersLiveUpdateSupported', true );
$out->addJsConfigVars(
- 'StructuredChangeFiltersDisplayConfig',
- [
- 'maxDays' => (int)$this->getConfig()->get( 'RCMaxAge' ) / ( 24 * 3600 ), // Translate to days
- 'limitArray' => $this->getConfig()->get( 'RCLinkLimits' ),
- 'daysArray' => $this->getConfig()->get( 'RCLinkDays' ),
- ]
+ 'wgStructuredChangeFiltersSavedQueriesPreferenceName',
+ 'rcfilters-saved-queries'
);
}
}
/**
- * 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;
- }
-
- /**
- * @inheritdoc
+ * @inheritDoc
*/
protected function transformFilterDefinition( array $filterDefinition ) {
if ( isset( $filterDefinition['showHideSuffix'] ) ) {
}
/**
- * @inheritdoc
+ * @inheritDoc
*/
protected function registerFilters() {
parent::registerFilters();
}
/**
- * @inheritdoc
+ * @inheritDoc
*/
protected function buildQuery( &$tables, &$fields, &$conds,
&$query_options, &$join_conds, FormOptions $opts
}
/**
- * @inheritdoc
+ * @inheritDoc
*/
protected function doMainQuery( $tables, $fields, $conds, $query_options,
$join_conds, FormOptions $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' ]
$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' );
- }
}
/**
/**
* Filter $rows by categories set in $opts
*
- * @param ResultWrapper $rows Database rows
+ * @param ResultWrapper &$rows Database rows
* @param FormOptions $opts
*/
function filterByCategories( &$rows, FormOptions $opts ) {
$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(),
];