42 public const TYPE =
'string_options';
52 public const ALL =
'all';
113 if ( !isset( $groupDefinition[
'isFullCoverage'] ) ) {
114 throw new InvalidArgumentException(
'You must specify isFullCoverage' );
117 $groupDefinition[
'type'] = self::TYPE;
119 parent::__construct( $groupDefinition );
121 $this->queryCallable = $groupDefinition[
'queryCallable'];
123 if ( isset( $groupDefinition[
'default'] ) ) {
124 $this->
setDefault( $groupDefinition[
'default'] );
126 throw new InvalidArgumentException(
'You must specify a default' );
145 return $this->defaultValue;
162 $this->filters[$filter->
getName()] = $filter;
169 &$tables, &$fields, &$conds, &$query_options, &$join_conds,
173 if ( !$isStructuredFiltersEnabled ) {
177 $value = $opts[ $this->
getName() ];
178 $allowedFilterNames = [];
179 foreach ( $this->filters as $filter ) {
180 $allowedFilterNames[] = $filter->getName();
183 if ( $value === self::ALL ) {
184 $selectedValues = $allowedFilterNames;
186 $selectedValues = explode( self::SEPARATOR, strtolower( $value ) );
189 $selectedValues = array_intersect(
200 if ( count( $selectedValues ) === 0 ) {
204 sort( $selectedValues );
206 ( $this->queryCallable )(
207 get_class( $specialPage ),
223 $output = parent::getJsData();
225 $output[
'separator'] = self::SEPARATOR;
Represents a filter group (used on ChangesListSpecialPage and descendants)
Represents a filter group with multiple string options.
addOptions(FormOptions $opts, $allowDefaults, $isStructuredFiltersEnabled)
All the options represented by this filter group to $opts.
getDefault()
Gets default of filter group.
__construct(array $groupDefinition)
Create a new filter group with the specified configuration.
string $defaultValue
Default parameter value.
registerFilter(ChangesListStringOptionsFilter $filter)
Registers a filter in this group.
const ALL
Signifies that all options in the group are selected.
const TYPE
Type marker, used by JavaScript.
callable $queryCallable
Callable used to do the actual query modification; see constructor.
const SEPARATOR
Delimiter.
createFilter(array $filterDefinition)
Creates a filter of the appropriate type for this group, from the definition.ChangesListFilter Filter
setDefault( $defaultValue)
Sets default of filter group.
modifyQuery(IReadableDatabase $dbr, ChangesListSpecialPage $specialPage, &$tables, &$fields, &$conds, &$query_options, &$join_conds, FormOptions $opts, $isStructuredFiltersEnabled)
Modifies the query to include the filter group.The modification is only done if the filter group is i...
getJsData()
Gets the JS data in the format required by the front-end of the structured UI.array|null Associative ...
const NONE
Signifies that no options in the group are selected, meaning the group has no effect.
An individual filter in a ChangesListStringOptionsFilterGroup.
Special page which uses a ChangesList to show query results.
getContext()
Gets the context this SpecialPage is executed in.