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.
12 class ChangesListBooleanFilterGroup
extends ChangesListFilterGroup
{
14 * Type marker, used by JavaScript
16 const TYPE
= 'send_unselected_if_any';
19 * Create a new filter group with the specified configuration
21 * @param array $groupDefinition Configuration of group
22 * * $groupDefinition['name'] string Group name
23 * * $groupDefinition['title'] string i18n key for title (optional, can be omitted
24 * only if none of the filters in the group display in the structured UI)
25 * * $groupDefinition['priority'] int Priority integer. Higher means higher in the
27 * * $groupDefinition['filters'] array Numeric array of filter definitions, each of which
28 * is an associative array to be passed to the filter constructor. However,
29 * 'priority' is optional for the filters. Any filter that has priority unset
30 * will be put to the bottom, in the order given.
31 * * $groupDefinition['whatsThisHeader'] string i18n key for header of "What's
32 * This" popup (optional).
33 * * $groupDefinition['whatsThisBody'] string i18n key for body of "What's This"
35 * * $groupDefinition['whatsThisUrl'] string URL for main link of "What's This"
37 * * $groupDefinition['whatsThisLinkText'] string i18n key of text for main link of
38 * "What's This" popup (optional).
40 public function __construct( array $groupDefinition ) {
41 $groupDefinition['isFullCoverage'] = true;
42 $groupDefinition['type'] = self
::TYPE
;
44 parent
::__construct( $groupDefinition );
50 protected function createFilter( array $filterDefinition ) {
51 return new ChangesListBooleanFilter( $filterDefinition );
55 * Registers a filter in this group
57 * @param ChangesListBooleanFilter $filter
59 public function registerFilter( ChangesListBooleanFilter
$filter ) {
60 $this->filters
[$filter->getName()] = $filter;
66 public function modifyQuery( IDatabase
$dbr, ChangesListSpecialPage
$specialPage,
67 &$tables, &$fields, &$conds, &$query_options, &$join_conds,
68 FormOptions
$opts, $isStructuredFiltersEnabled
70 /** @var ChangesListBooleanFilter $filter */
71 foreach ( $this->getFilters() as $filter ) {
72 if ( $filter->isActive( $opts, $isStructuredFiltersEnabled ) ) {
73 $filter->modifyQuery( $dbr, $specialPage, $tables, $fields, $conds,
74 $query_options, $join_conds );
82 public function addOptions( FormOptions
$opts, $allowDefaults, $isStructuredFiltersEnabled ) {
83 /** @var ChangesListBooleanFilter $filter */
84 foreach ( $this->getFilters() as $filter ) {
85 $defaultValue = $allowDefaults ?
$filter->getDefault( $isStructuredFiltersEnabled ) : false;
86 $opts->add( $filter->getName(), $defaultValue );