3 use Wikimedia\Rdbms\IDatabase
;
6 * If the group is active, any unchecked filters will
7 * translate to hide parameters in the URL. E.g. if 'Human (not bot)' is checked,
8 * but 'Bot' is unchecked, hidebots=1 will be sent.
11 * @method ChangesListBooleanFilter[] getFilters()
13 class ChangesListBooleanFilterGroup
extends ChangesListFilterGroup
{
15 * Type marker, used by JavaScript
17 const TYPE
= 'send_unselected_if_any';
20 * Create a new filter group with the specified configuration
22 * @param array $groupDefinition Configuration of group
23 * * $groupDefinition['name'] string Group name
24 * * $groupDefinition['title'] string i18n key for title (optional, can be omitted
25 * only if none of the filters in the group display in the structured UI)
26 * * $groupDefinition['priority'] int Priority integer. Higher means higher in the
28 * * $groupDefinition['filters'] array Numeric array of filter definitions, each of which
29 * is an associative array to be passed to the filter constructor. However,
30 * 'priority' is optional for the filters. Any filter that has priority unset
31 * will be put to the bottom, in the order given.
32 * * $groupDefinition['whatsThisHeader'] string i18n key for header of "What's
33 * This" popup (optional).
34 * * $groupDefinition['whatsThisBody'] string i18n key for body of "What's This"
36 * * $groupDefinition['whatsThisUrl'] string URL for main link of "What's This"
38 * * $groupDefinition['whatsThisLinkText'] string i18n key of text for main link of
39 * "What's This" popup (optional).
41 public function __construct( array $groupDefinition ) {
42 $groupDefinition['isFullCoverage'] = true;
43 $groupDefinition['type'] = self
::TYPE
;
45 parent
::__construct( $groupDefinition );
51 protected function createFilter( array $filterDefinition ) {
52 return new ChangesListBooleanFilter( $filterDefinition );
56 * Registers a filter in this group
58 * @param ChangesListBooleanFilter $filter
59 * @suppress PhanParamSignaturePHPDocMismatchHasParamType,PhanParamSignatureMismatch
61 public function registerFilter( ChangesListBooleanFilter
$filter ) {
62 $this->filters
[$filter->getName()] = $filter;
68 public function modifyQuery( IDatabase
$dbr, ChangesListSpecialPage
$specialPage,
69 &$tables, &$fields, &$conds, &$query_options, &$join_conds,
70 FormOptions
$opts, $isStructuredFiltersEnabled
72 /** @var ChangesListBooleanFilter $filter */
73 foreach ( $this->getFilters() as $filter ) {
74 if ( $filter->isActive( $opts, $isStructuredFiltersEnabled ) ) {
75 $filter->modifyQuery( $dbr, $specialPage, $tables, $fields, $conds,
76 $query_options, $join_conds );
84 public function addOptions( FormOptions
$opts, $allowDefaults, $isStructuredFiltersEnabled ) {
85 /** @var ChangesListBooleanFilter $filter */
86 foreach ( $this->getFilters() as $filter ) {
87 $defaultValue = $allowDefaults ?
$filter->getDefault( $isStructuredFiltersEnabled ) : false;
88 $opts->add( $filter->getName(), $defaultValue );