43 public const TYPE =
'string_options';
53 public const ALL =
'all';
114 if ( !isset( $groupDefinition[
'isFullCoverage'] ) ) {
115 throw new InvalidArgumentException(
'You must specify isFullCoverage' );
118 $groupDefinition[
'type'] = self::TYPE;
120 parent::__construct( $groupDefinition );
122 $this->queryCallable = $groupDefinition[
'queryCallable'];
124 if ( isset( $groupDefinition[
'default'] ) ) {
125 $this->
setDefault( $groupDefinition[
'default'] );
127 throw new InvalidArgumentException(
'You must specify a default' );
146 return $this->defaultValue;
163 $this->filters[$filter->
getName()] = $filter;
170 &$tables, &$fields, &$conds, &$query_options, &$join_conds,
174 if ( !$isStructuredFiltersEnabled ) {
178 $value = $opts[ $this->
getName() ];
179 $allowedFilterNames = [];
180 foreach ( $this->filters as $filter ) {
181 $allowedFilterNames[] = $filter->getName();
184 if ( $value === self::ALL ) {
185 $selectedValues = $allowedFilterNames;
187 $selectedValues = explode( self::SEPARATOR, strtolower( $value ) );
190 $selectedValues = array_intersect(
201 if ( count( $selectedValues ) === 0 ) {
205 sort( $selectedValues );
207 ( $this->queryCallable )(
208 get_class( $specialPage ),
224 $output = parent::getJsData();
226 $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.