Merge "Align "What's this" vertically"
[lhc/web/wiklou.git] / includes / specials / SpecialRecentchanges.php
index 41007e2..547a1b0 100644 (file)
@@ -164,94 +164,12 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                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;
        }
 
        /**
@@ -323,7 +241,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
 
                $opts->add( 'categories', '' );
                $opts->add( 'categories_any', false );
-               $opts->add( 'tagfilter', '' );
 
                return $opts;
        }
@@ -540,8 +457,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        && $this->getUser()->getOption( 'shownumberswatching' );
                $watcherCache = [];
 
-               $dbr = $this->getDB();
-
                $counter = 1;
                $list = ChangesList::newFromContext( $this->getContext(), $this->filterGroups );
                $list->initChangesListRows( $rows );
@@ -636,7 +551,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        ++$count;
                        $addSubmit = ( $count === $extraOptsCount ) ? $submit : '';
 
-                       $out .= Xml::openElement( 'tr' );
+                       $out .= Xml::openElement( 'tr', [ 'class' => $name . 'Form' ] );
                        if ( is_array( $optionRow ) ) {
                                $out .= Xml::tags(
                                        'td',
@@ -673,11 +588,11 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                $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' ]
@@ -720,7 +635,21 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
 
                $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(),
@@ -729,7 +658,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
 
                        $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()
@@ -785,17 +714,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                return $extraOpts;
        }
 
-       /**
-        * Check whether the structured filter UI is enabled
-        *
-        * @return bool
-        */
-       protected function isStructuredFilterUiEnabled() {
-               return $this->getUser()->getOption(
-                       'rcenhancedfilters'
-               );
-       }
-
        /**
         * Add page-specific modules.
         */
@@ -803,10 +721,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                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' );
-               }
        }
 
        /**
@@ -868,7 +782,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
        /**
         * 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 ) {
@@ -1030,7 +944,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
 
                $filterGroups = $this->getFilterGroups();
 
-               $context = $this->getContext();
                foreach ( $filterGroups as $groupName => $group ) {
                        if ( !$group->isPerGroupRequestParameter() ) {
                                foreach ( $group->getFilters() as $key => $filter ) {
@@ -1047,7 +960,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                                                        [ $key => 1 - $options[$key] ], $nondefaults );
 
                                                $attribs = [
-                                                       'class' => "$msg rcshowhideoption",
+                                                       'class' => "$msg rcshowhideoption clshowhideoption",
                                                        'data-filter-name' => $filter->getName(),
                                                ];
 
@@ -1091,4 +1004,12 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
        protected function getCacheTTL() {
                return 60 * 5;
        }
+
+       function getDefaultLimit() {
+               return $this->getUser()->getIntOption( 'rclimit' );
+       }
+
+       function getDefaultDays() {
+               return $this->getUser()->getIntOption( 'rcdays' );
+       }
 }