143 if ( isset( $filterDefinition[
'group'] ) ) {
144 $this->group = $filterDefinition[
'group'];
146 throw new MWException(
'You must use \'group\' to specify the ' .
147 'ChangesListFilterGroup this filter belongs to' );
150 if ( strpos( $filterDefinition[
'name'], self::RESERVED_NAME_CHAR ) !==
false ) {
151 throw new MWException(
'Filter names may not contain \'' .
152 self::RESERVED_NAME_CHAR .
153 '\'. Use the naming convention: \
'lowercase\''
157 if ( $this->group->getFilter( $filterDefinition[
'name'] ) ) {
158 throw new MWException(
'Two filters in a group cannot have the ' .
159 "same name: '{$filterDefinition['name']}'" );
162 $this->name = $filterDefinition[
'name'];
164 if ( isset( $filterDefinition[
'cssClassSuffix'] ) ) {
165 $this->cssClassSuffix = $filterDefinition[
'cssClassSuffix'];
166 $this->isRowApplicableCallable = $filterDefinition[
'isRowApplicableCallable'];
169 if ( isset( $filterDefinition[
'label'] ) ) {
170 $this->label = $filterDefinition[
'label'];
171 $this->description = $filterDefinition[
'description'];
174 $this->priority = $filterDefinition[
'priority'];
176 $this->group->registerFilter( $this );
193 public function conflictsWith( $other, $globalKey, $forwardKey, $backwardKey ) {
194 if ( $globalKey ===
null || $forwardKey ===
null || $backwardKey ===
null ) {
195 throw new MWException(
'All messages must be specified' );
204 $other->setUnidirectionalConflict(
224 $this->conflictingGroups[] = [
225 'group' => $other->getName(),
226 'groupObject' => $other,
227 'globalDescription' => $globalDescription,
228 'contextDescription' => $contextDescription,
231 $this->conflictingFilters[] = [
232 'group' => $other->getGroup()->getName(),
233 'filter' => $other->getName(),
234 'filterObject' => $other,
235 'globalDescription' => $globalDescription,
236 'contextDescription' => $contextDescription,
239 throw new MWException(
'You can only pass in a ChangesListFilterGroup or a ChangesListFilter' );
253 if ( $other->
getGroup() !== $this->getGroup() ) {
254 throw new MWException(
'Supersets can only be defined for filters in the same group' );
257 $this->subsetFilters[] = [
260 'group' => $other->
getGroup()->getName(),
307 return $this->label !==
null;
334 if ( $this->cssClassSuffix !==
null ) {
349 if ( $this->isRowApplicableCallable ===
null ) {
353 if ( call_user_func( $this->isRowApplicableCallable, $ctx, $rc ) ) {
377 $output[
'messageKeys'] = [
382 $conflicts = array_merge(
383 $this->conflictingGroups,
384 $this->conflictingFilters
387 foreach ( $conflicts as $conflictInfo ) {
388 unset( $conflictInfo[
'filterObject'] );
389 unset( $conflictInfo[
'groupObject'] );
390 $output[
'conflicts'][] = $conflictInfo;
392 $output[
'messageKeys'],
393 $conflictInfo[
'globalDescription'],
394 $conflictInfo[
'contextDescription']
416 function ( $conflictDesc ) {
417 return $conflictDesc[
'groupObject' ];
430 function ( $conflictDesc ) {
431 return $conflictDesc[
'filterObject' ];
445 if (
$group->anySelected( $opts ) && $this->isSelected( $opts ) ) {
447 foreach ( $this->
getSiblings() as $siblingFilter ) {
448 if ( $siblingFilter->isSelected( $opts ) && !$siblingFilter->hasConflictWithGroup(
$group ) ) {
471 foreach ( $this->
getSiblings() as $siblingFilter ) {
473 $siblingFilter->isSelected( $opts ) &&
474 !$siblingFilter->hasConflictWithFilter(
$filter )
Represents a filter group (used on ChangesListSpecialPage and descendants)
Represents a filter (used on ChangesListSpecialPage and descendants)
displaysOnUnstructuredUi()
Checks whether the filter should display on the unstructured UI.
$cssClassSuffix
CSS class suffix used for attribution, e.g.
getConflictingFilters()
Get filters conflicting with this filter.
getJsData()
Gets the JS data required by the front-end of the structured UI.
activelyInConflictWithGroup(ChangesListFilterGroup $group, FormOptions $opts)
Check if the conflict with a group is currently "active".
$conflictingGroups
Array of associative arrays with conflict information.
$conflictingFilters
Array of associative arrays with conflict information.
displaysOnStructuredUi()
Checks whether the filter should display on the structured UI This refers to the exact filter.
$label
i18n key of label for structured UI
setUnidirectionalConflict( $other, $globalDescription, $contextDescription)
Marks that the given ChangesListFilterGroup or ChangesListFilter conflicts with this object.
isFeatureAvailableOnStructuredUi()
Checks whether an equivalent feature for this filter is available on the structured UI.
applyCssClassIfNeeded(IContextSource $ctx, RecentChange $rc, array &$classes)
Add CSS class if needed.
setAsSupersetOf(ChangesListFilter $other)
Marks that the current instance is (also) a superset of the filter passed in.
$priority
Priority integer.
__construct(array $filterDefinition)
Creates a new filter with the specified configuration, and registers it to the specified group.
hasConflictWithGroup(ChangesListFilterGroup $group)
$subsetFilters
Array of associative arrays with subset information.
isSelected(FormOptions $opts)
Checks whether this filter is selected in the provided options.
setDefaultHighlightColor( $defaultHighlightColor)
$description
i18n key of description for structured UI
getConflictingGroups()
Get groups conflicting with this filter.
hasConflictWithFilter(ChangesListFilter $filter)
getCssClass()
Gets the CSS class.
getSiblings()
Get filters in the same group.
activelyInConflictWithFilter(ChangesListFilter $filter, FormOptions $opts)
Check if the conflict with a filter is currently "active".
$isRowApplicableCallable
Callable that returns true if and only if a row is attributed to this filter.
conflictsWith( $other, $globalKey, $forwardKey, $backwardKey)
Marks that the given ChangesListFilterGroup or ChangesListFilter conflicts with this object.
Utility class for creating new RC entries.
Interface for objects which can provide a MediaWiki context on request.