Merge "Simplify HTMLTitleTextField::validate"
[lhc/web/wiklou.git] / includes / specialpage / ChangesListSpecialPage.php
index 58944b4..43b4e98 100644 (file)
@@ -69,9 +69,6 @@ abstract class ChangesListSpecialPage extends SpecialPage {
        /** @var FormOptions */
        protected $rcOptions;
 
-       /** @var array */
-       protected $customFilters;
-
        // Order of both groups and filters is significant; first is top-most priority,
        // descending from there.
        // 'showHideSuffix' is a shortcut to and avoid spelling out
@@ -84,8 +81,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
         *
         * Groups are displayed to the user in the structured UI.  However, if necessary,
         * all of the filters in a group can be configured to only display on the
-        * unstuctured UI, in which case you don't need a group title.  This is done in
-        * getFilterGroupDefinitionFromLegacyCustomFilters, for example.
+        * unstuctured UI, in which case you don't need a group title.
         *
         * @var array $filterGroupDefinitions
         */
@@ -780,26 +776,20 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                $out = $this->getOutput();
                if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
                        $jsData = $this->getStructuredFilterJsData();
-
                        $messages = [];
                        foreach ( $jsData['messageKeys'] as $key ) {
                                $messages[$key] = $this->msg( $key )->plain();
                        }
-                       $out->addBodyClasses( 'mw-rcfilters-enabled' );
 
+                       $out->addBodyClasses( 'mw-rcfilters-enabled' );
                        $collapsed = $this->getUser()->getBoolOption( static::$collapsedPreferenceName );
                        if ( $collapsed ) {
                                $out->addBodyClasses( 'mw-rcfilters-collapsed' );
                        }
 
-                       $out->addHTML(
-                               ResourceLoader::makeInlineScript(
-                                       ResourceLoader::makeMessageSetScript( $messages ),
-                                       $out->getCSPNonce()
-                               )
-                       );
-
+                       // These config and message exports should be moved into a ResourceLoader data module (T201574)
                        $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
+                       $out->addJsConfigVars( 'wgStructuredChangeFiltersMessages', $messages );
                        $out->addJsConfigVars( 'wgStructuredChangeFiltersCollapsedState', $collapsed );
 
                        $out->addJsConfigVars(
@@ -993,11 +983,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
 
                Hooks::run( 'ChangesListSpecialPageStructuredFilters', [ $this ] );
 
-               $unstructuredGroupDefinition =
-                       $this->getFilterGroupDefinitionFromLegacyCustomFilters(
-                               $this->getCustomFilters()
-                       );
-               $this->registerFiltersFromDefinitions( [ $unstructuredGroupDefinition ] );
+               $this->registerFiltersFromDefinitions( [] );
 
                $userExperienceLevel = $this->getFilterGroup( 'userExpLevel' );
                $registered = $userExperienceLevel->getFilter( 'registered' );
@@ -1080,32 +1066,6 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                }
        }
 
-       /**
-        * Get filter group definition from legacy custom filters
-        *
-        * @param array $customFilters Custom filters from legacy hooks
-        * @return array Group definition
-        */
-       protected function getFilterGroupDefinitionFromLegacyCustomFilters( array $customFilters ) {
-               // Special internal unstructured group
-               $unstructuredGroupDefinition = [
-                       'name' => 'unstructured',
-                       'class' => ChangesListBooleanFilterGroup::class,
-                       'priority' => -1, // Won't display in structured
-                       'filters' => [],
-               ];
-
-               foreach ( $customFilters as $name => $params ) {
-                       $unstructuredGroupDefinition['filters'][] = [
-                               'name' => $name,
-                               'showHide' => $params['msg'],
-                               'default' => $params['default'],
-                       ];
-               }
-
-               return $unstructuredGroupDefinition;
-       }
-
        /**
         * @return array The legacy show/hide toggle filters
         */
@@ -1251,21 +1211,6 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                return $output;
        }
 
-       /**
-        * Get custom show/hide filters using deprecated ChangesListSpecialPageFilters
-        * hook.
-        *
-        * @return array Map of filter URL param names to properties (msg/default)
-        */
-       protected function getCustomFilters() {
-               if ( $this->customFilters === null ) {
-                       $this->customFilters = [];
-                       Hooks::run( 'ChangesListSpecialPageFilters', [ $this, &$this->customFilters ], '1.29' );
-               }
-
-               return $this->customFilters;
-       }
-
        /**
         * Fetch values for a FormOptions object from the WebRequest associated with this instance.
         *