X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fspecials%2FSpecialRecentchanges.php;h=2fe56f989a24a415abacd0db96431526534c24e4;hb=2632183a49f6f8845fdbd77bceaccb6aafe4003f;hp=acfc1c0e7bd62db8cb4b2d327666008215bb43bb;hpb=967ead16680077f4734ba668cd4104c789a3b9ff;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index acfc1c0e7b..2fe56f989a 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -138,8 +138,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage { * @param string $subpage */ public function execute( $subpage ) { - global $wgStructuredChangeFiltersEnableSaving; - // Backwards-compatibility: redirect to new feed URLs $feedFormat = $this->getRequest()->getVal( 'feed' ); if ( !$this->including() && $feedFormat ) { @@ -179,14 +177,72 @@ class SpecialRecentChanges extends ChangesListSpecialPage { ) ); + $experimentalStructuredChangeFilters = + $this->getConfig()->get( 'StructuredChangeFiltersEnableExperimentalViews' ); + $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] ); $out->addJsConfigVars( 'wgStructuredChangeFiltersEnableSaving', - $wgStructuredChangeFiltersEnableSaving + $this->getConfig()->get( 'StructuredChangeFiltersEnableSaving' ) + ); + $out->addJsConfigVars( + 'wgStructuredChangeFiltersEnableExperimentalViews', + $experimentalStructuredChangeFilters ); + $out->addJsConfigVars( + 'wgStructuredChangeFiltersEnableLiveUpdate', + $this->getConfig()->get( 'StructuredChangeFiltersEnableLiveUpdate' ) + ); + if ( $experimentalStructuredChangeFilters ) { + $out->addJsConfigVars( + 'wgRCFiltersChangeTags', + $this->buildChangeTagList() + ); + } } } + /** + * 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 ); + $tagStats = ChangeTags::tagUsageStatistics(); + + $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats ); + + // Sort by hits + arsort( $tagHitCounts ); + + // 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, + ]; + } + } + + return $result; + } + /** * @inheritdoc */ @@ -315,8 +371,8 @@ class SpecialRecentChanges extends ChangesListSpecialPage { * @inheritdoc */ protected function buildQuery( &$tables, &$fields, &$conds, - &$query_options, &$join_conds, FormOptions $opts ) { - + &$query_options, &$join_conds, FormOptions $opts + ) { $dbr = $this->getDB(); parent::buildQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts ); @@ -340,8 +396,8 @@ class SpecialRecentChanges extends ChangesListSpecialPage { * @inheritdoc */ protected function doMainQuery( $tables, $fields, $conds, $query_options, - $join_conds, FormOptions $opts ) { - + $join_conds, FormOptions $opts + ) { $dbr = $this->getDB(); $user = $this->getUser(); @@ -469,6 +525,10 @@ class SpecialRecentChanges extends ChangesListSpecialPage { $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' ); $rclistOutput = $list->beginRecentChangesList(); + if ( $this->isStructuredFilterUiEnabled() ) { + $rclistOutput .= $this->makeLegend(); + } + foreach ( $rows as $obj ) { if ( $limit == 0 ) { break; @@ -536,7 +596,9 @@ class SpecialRecentChanges extends ChangesListSpecialPage { $nondefaults = $opts->getChangedValues(); $panel = []; - $panel[] = $this->makeLegend(); + if ( !$this->isStructuredFilterUiEnabled() ) { + $panel[] = $this->makeLegend(); + } $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows ); $panel[] = '
';