X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialRecentchanges.php;h=d856d4b20e66b924af45954f8dbac1066b6d0f25;hp=acfc1c0e7bd62db8cb4b2d327666008215bb43bb;hb=dc58db74645913fcdc8019f06c5143e404b4b30c;hpb=3c97f1b788a1e31f71760dbcc1e9e68b6c561bac diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index acfc1c0e7b..d856d4b20e 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -138,7 +138,8 @@ class SpecialRecentChanges extends ChangesListSpecialPage { * @param string $subpage */ public function execute( $subpage ) { - global $wgStructuredChangeFiltersEnableSaving; + global $wgStructuredChangeFiltersEnableSaving, + $wgStructuredChangeFiltersEnableExperimentalViews; // Backwards-compatibility: redirect to new feed URLs $feedFormat = $this->getRequest()->getVal( 'feed' ); @@ -184,9 +185,60 @@ class SpecialRecentChanges extends ChangesListSpecialPage { 'wgStructuredChangeFiltersEnableSaving', $wgStructuredChangeFiltersEnableSaving ); + $out->addJsConfigVars( + 'wgStructuredChangeFiltersEnableExperimentalViews', + $wgStructuredChangeFiltersEnableExperimentalViews + ); + $out->addJsConfigVars( + 'wgRCFiltersChangeTags', + $this->buildChangeTagList() + ); } } + /** + * Fetch the change tags list for the front end + * + * @return Array Tag data + */ + protected function buildChangeTagList() { + function stripAllHtml( $input ) { + return trim( html_entity_decode( strip_tags( $input ) ) ); + } + + $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' => stripAllHtml( ChangeTags::tagDescription( $tagName, $this->getContext() ) ), + 'description' => $desc ? stripAllHtml( $desc->parse() ) : '', + 'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ), + 'hits' => $hits, + ]; + } + } + + return $result; + } + /** * @inheritdoc */ @@ -315,8 +367,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 +392,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 +521,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 +592,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[] = '
';