Merge "Add attributes parameter to ShowSearchHitTitle"
[lhc/web/wiklou.git] / includes / changes / ChangesListStringOptionsFilterGroup.php
index 86b4a8b..653344a 100644 (file)
@@ -35,7 +35,6 @@ use Wikimedia\Rdbms\IDatabase;
  *
  * @since 1.29
  */
-
 class ChangesListStringOptionsFilterGroup extends ChangesListFilterGroup {
        /**
         * Type marker, used by JavaScript
@@ -128,13 +127,6 @@ class ChangesListStringOptionsFilterGroup extends ChangesListFilterGroup {
                }
        }
 
-       /**
-        * @inheritdoc
-        */
-       public function isPerGroupRequestParameter() {
-               return true;
-       }
-
        /**
         * Sets default of filter group.
         *
@@ -154,7 +146,7 @@ class ChangesListStringOptionsFilterGroup extends ChangesListFilterGroup {
        }
 
        /**
-        * @inheritdoc
+        * @inheritDoc
         */
        protected function createFilter( array $filterDefinition ) {
                return new ChangesListStringOptionsFilter( $filterDefinition );
@@ -170,23 +162,17 @@ class ChangesListStringOptionsFilterGroup extends ChangesListFilterGroup {
        }
 
        /**
-        * Modifies the query to include the filter group.
-        *
-        * The modification is only done if the filter group is in effect.  This means that
-        * one or more valid and allowed filters were selected.
-        *
-        * @param IDatabase $dbr Database, for addQuotes, makeList, and similar
-        * @param ChangesListSpecialPage $specialPage Current special page
-        * @param array &$tables Array of tables; see IDatabase::select $table
-        * @param array &$fields Array of fields; see IDatabase::select $vars
-        * @param array &$conds Array of conditions; see IDatabase::select $conds
-        * @param array &$query_options Array of query options; see IDatabase::select $options
-        * @param array &$join_conds Array of join conditions; see IDatabase::select $join_conds
-        * @param string $value URL parameter value
+        * @inheritDoc
         */
        public function modifyQuery( IDatabase $dbr, ChangesListSpecialPage $specialPage,
-               &$tables, &$fields, &$conds, &$query_options, &$join_conds, $value ) {
+               &$tables, &$fields, &$conds, &$query_options, &$join_conds,
+               FormOptions $opts, $isStructuredFiltersEnabled
+       ) {
+               if ( !$this->isActive( $isStructuredFiltersEnabled ) ) {
+                       return;
+               }
 
+               $value = $opts[ $this->getName() ];
                $allowedFilterNames = [];
                foreach ( $this->filters as $filter ) {
                        $allowedFilterNames[] = $filter->getName();
@@ -232,7 +218,7 @@ class ChangesListStringOptionsFilterGroup extends ChangesListFilterGroup {
        }
 
        /**
-        * @inheritdoc
+        * @inheritDoc
         */
        public function getJsData() {
                $output = parent::getJsData();
@@ -242,4 +228,21 @@ class ChangesListStringOptionsFilterGroup extends ChangesListFilterGroup {
 
                return $output;
        }
+
+       /**
+        * @inheritDoc
+        */
+       public function addOptions( FormOptions $opts, $allowDefaults, $isStructuredFiltersEnabled ) {
+               $opts->add( $this->getName(), $allowDefaults ? $this->getDefault() : '' );
+       }
+
+       /**
+        * Check if this filter group is currently active
+        *
+        * @param {boolean} $isStructuredUI Is structured filters UI current enabled
+        */
+       private function isActive( $isStructuredUI ) {
+               // STRING_OPTIONS filter groups are exclusively active on Structured UI
+               return $isStructuredUI;
+       }
 }