X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fchanges%2FChangesListBooleanFilter.php;h=913bd3832f8af576d5d562e8f46a37f78c92ad39;hb=e5ffb82fabc3411ac3f23f5ac7ebd49c923dc1cf;hp=73c0fb01efc5522b22dde7a9bd6e2b0a790e4724;hpb=d2c91eb0af7127ad3bf559c9eaca5045fae9de80;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/changes/ChangesListBooleanFilter.php b/includes/changes/ChangesListBooleanFilter.php index 73c0fb01ef..913bd3832f 100644 --- a/includes/changes/ChangesListBooleanFilter.php +++ b/includes/changes/ChangesListBooleanFilter.php @@ -66,6 +66,13 @@ class ChangesListBooleanFilter extends ChangesListFilter { */ protected $queryCallable; + /** + * Value that defined when this filter is considered active + * + * @var bool $activeValue + */ + protected $activeValue; + /** * Create a new filter with the specified configuration. * @@ -90,6 +97,8 @@ class ChangesListBooleanFilter extends ChangesListFilter { * to true. It does not need to be set if the exact same filter is simply visible * on both. * * $filterDefinition['default'] bool Default + * * $filterDefinition['activeValue'] bool This filter is considered active when + * its value is equal to its activeValue. Default is true. * * $filterDefinition['priority'] int Priority integer. Higher value means higher * up in the group's filter list. * * $filterDefinition['queryCallable'] callable Callable accepting parameters, used @@ -126,6 +135,12 @@ class ChangesListBooleanFilter extends ChangesListFilter { if ( isset( $filterDefinition['queryCallable'] ) ) { $this->queryCallable = $filterDefinition['queryCallable']; } + + if ( isset( $filterDefinition['activeValue'] ) ) { + $this->activeValue = $filterDefinition['activeValue']; + } else { + $this->activeValue = true; + } } /** @@ -136,7 +151,7 @@ class ChangesListBooleanFilter extends ChangesListFilter { */ public function getDefault( $structuredUI = false ) { return $this->isReplacedInStructuredUi && $structuredUI ? - false : + !$this->activeValue : $this->defaultValue; } @@ -157,14 +172,14 @@ class ChangesListBooleanFilter extends ChangesListFilter { } /** - * @inheritdoc + * @inheritDoc */ public function displaysOnUnstructuredUi() { return !!$this->showHide; } /** - * @inheritdoc + * @inheritDoc */ public function isFeatureAvailableOnStructuredUi() { return $this->isReplacedInStructuredUi || @@ -184,8 +199,8 @@ class ChangesListBooleanFilter extends ChangesListFilter { * @param array &$join_conds Array of join conditions; see IDatabase::select $join_conds */ public function modifyQuery( IDatabase $dbr, ChangesListSpecialPage $specialPage, - &$tables, &$fields, &$conds, &$query_options, &$join_conds ) { - + &$tables, &$fields, &$conds, &$query_options, &$join_conds + ) { if ( $this->queryCallable === null ) { return; } @@ -206,7 +221,7 @@ class ChangesListBooleanFilter extends ChangesListFilter { } /** - * @inheritdoc + * @inheritDoc */ public function getJsData() { $output = parent::getJsData(); @@ -217,7 +232,7 @@ class ChangesListBooleanFilter extends ChangesListFilter { } /** - * @inheritdoc + * @inheritDoc */ public function isSelected( FormOptions $opts ) { return !$opts[ $this->getName() ] && @@ -225,4 +240,17 @@ class ChangesListBooleanFilter extends ChangesListFilter { return $opts[ $sibling->getName() ]; } ); } + + /** + * @param FormOptions $opts Query parameters merged with defaults + * @param bool $isStructuredUI Whether the structured UI is currently enabled + * @return bool Whether this filter should be considered active + */ + public function isActive( FormOptions $opts, $isStructuredUI ) { + if ( $this->isReplacedInStructuredUi && $isStructuredUI ) { + return false; + } + + return $opts[ $this->getName() ] === $this->activeValue; + } }