X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fchanges%2FChangesListStringOptionsFilterGroup.php;h=8cd7ba8dea53bfbd375639266b320fb5f4e763a9;hp=59efd82bcab8c547fbc5fd0fcbc3ce229af87905;hb=11ee7f78da9776db26098642a151a288f98bea14;hpb=802c199d0bd80ff0f4d730c61fd58cbf08a52d8d diff --git a/includes/changes/ChangesListStringOptionsFilterGroup.php b/includes/changes/ChangesListStringOptionsFilterGroup.php index 59efd82bca..8cd7ba8dea 100644 --- a/includes/changes/ChangesListStringOptionsFilterGroup.php +++ b/includes/changes/ChangesListStringOptionsFilterGroup.php @@ -18,7 +18,6 @@ * http://www.gnu.org/copyleft/gpl.html * * @file - * @license GPL 2+ * @author Matthew Flaschen */ @@ -35,7 +34,6 @@ use Wikimedia\Rdbms\IDatabase; * * @since 1.29 */ - class ChangesListStringOptionsFilterGroup extends ChangesListFilterGroup { /** * Type marker, used by JavaScript @@ -128,13 +126,6 @@ class ChangesListStringOptionsFilterGroup extends ChangesListFilterGroup { } } - /** - * @inheritDoc - */ - public function isPerGroupRequestParameter() { - return true; - } - /** * Sets default of filter group. * @@ -163,30 +154,24 @@ class ChangesListStringOptionsFilterGroup extends ChangesListFilterGroup { /** * Registers a filter in this group * - * @param ChangesListStringOptionsFilter $filter ChangesListStringOptionsFilter + * @param ChangesListStringOptionsFilter $filter */ public function registerFilter( ChangesListStringOptionsFilter $filter ) { $this->filters[$filter->getName()] = $filter; } /** - * 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(); @@ -242,4 +227,22 @@ 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 bool $isStructuredUI Is structured filters UI current enabled + * @return bool + */ + private function isActive( $isStructuredUI ) { + // STRING_OPTIONS filter groups are exclusively active on Structured UI + return $isStructuredUI; + } }