138 if ( isset( $filterDefinition[
'group'] ) ) {
139 $this->
group = $filterDefinition[
'group'];
141 throw new MWException(
'You must use \'group\' to specify the ' .
142 'ChangesListFilterGroup this filter belongs to' );
145 if ( strpos( $filterDefinition[
'name'], self::RESERVED_NAME_CHAR ) !==
false ) {
146 throw new MWException(
'Filter names may not contain \'' .
147 self::RESERVED_NAME_CHAR .
148 '\'. Use the naming convention: \
'lowercase\''
152 if ( $this->
group->getFilter( $filterDefinition[
'name'] ) ) {
153 throw new MWException(
'Two filters in a group cannot have the ' .
154 "same name: '{$filterDefinition['name']}'" );
157 $this->name = $filterDefinition[
'name'];
159 if ( isset( $filterDefinition[
'cssClassSuffix'] ) ) {
160 $this->cssClassSuffix = $filterDefinition[
'cssClassSuffix'];
161 $this->isRowApplicableCallable = $filterDefinition[
'isRowApplicableCallable'];
164 if ( isset( $filterDefinition[
'label'] ) ) {
165 $this->label = $filterDefinition[
'label'];
166 $this->description = $filterDefinition[
'description'];
169 $this->priority = $filterDefinition[
'priority'];
171 $this->
group->registerFilter( $this );
189 public function conflictsWith( $other, $globalKey, $forwardKey, $backwardKey ) {
190 if ( $globalKey ===
null || $forwardKey ===
null || $backwardKey ===
null ) {
191 throw new MWException(
'All messages must be specified' );
200 $other->setUnidirectionalConflict(
221 $this->conflictingGroups[] = [
222 'group' => $other->getName(),
223 'groupObject' => $other,
224 'globalDescription' => $globalDescription,
225 'contextDescription' => $contextDescription,
228 $this->conflictingFilters[] = [
229 'group' => $other->getGroup()->getName(),
230 'filter' => $other->getName(),
231 'filterObject' => $other,
232 'globalDescription' => $globalDescription,
233 'contextDescription' => $contextDescription,
236 throw new MWException(
'You can only pass in a ChangesListFilterGroup or a ChangesListFilter' );
250 if ( $other->getGroup() !== $this->getGroup() ) {
251 throw new MWException(
'Supersets can only be defined for filters in the same group' );
254 $this->subsetFilters[] = [
257 'group' => $other->getGroup()->getName(),
258 'filter' => $other->getName(),
304 return $this->label !==
null;
331 if ( $this->cssClassSuffix !==
null ) {
346 if ( $this->isRowApplicableCallable ===
null ) {
350 if ( call_user_func( $this->isRowApplicableCallable, $ctx, $rc ) ) {
378 $conflicts = array_merge(
379 $this->conflictingGroups,
380 $this->conflictingFilters
383 foreach ( $conflicts as $conflictInfo ) {
384 unset( $conflictInfo[
'filterObject'] );
385 unset( $conflictInfo[
'groupObject'] );
386 $output[
'conflicts'][] = $conflictInfo;
389 $conflictInfo[
'globalDescription'],
390 $conflictInfo[
'contextDescription']
412 function ( $conflictDesc ) {
413 return $conflictDesc[
'groupObject' ];
426 function ( $conflictDesc ) {
427 return $conflictDesc[
'filterObject' ];
441 if (
$group->anySelected( $opts ) && $this->isSelected( $opts ) ) {
443 foreach ( $this->
getSiblings() as $siblingFilter ) {
444 if ( $siblingFilter->isSelected( $opts ) && !$siblingFilter->hasConflictWithGroup(
$group ) ) {
465 if ( $this->
isSelected( $opts ) && $filter->isSelected( $opts ) ) {
467 foreach ( $this->
getSiblings() as $siblingFilter ) {
469 $siblingFilter->isSelected( $opts ) &&
470 !$siblingFilter->hasConflictWithFilter( $filter )
492 function ( $filter ) {
493 return $filter !== $this;
no text was provided for refs named< code > blankwithnoreference</code ></span ></li ></ol ></div > !end !test with< references/> in group !wikitext Wikipedia rocks< ref > Proceeds of vol XXI</ref > Wikipedia rocks< ref group=note > Proceeds of vol XXI</ref >< references/>< references group=note/> ! html< p > Wikipedia rocks< sup id="cite_ref-1" class="reference">< a href="#cite_note-1"> &Wikipedia rocks< sup id="cite_ref-2" class="reference">< a href="#cite_note-2"> &</p >< div class="mw-references-wrap">< ol class="references">< li id="cite_note-1">< span class="mw-cite-backlink">< a href="#cite_ref-1"> ↑</a ></span >< span class="reference-text"> Proceeds of vol XXI</span ></li ></ol ></div >< div class="mw-references-wrap">< ol class="references">< li id="cite_note-2">< span class="mw-cite-backlink">< a href="#cite_ref-2"> ↑</a ></span >< span class="reference-text"> Proceeds of vol XXI</span ></li ></ol ></div > !end !test with< references/> in group
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.
activelyInConflictWithFilter(ChangeslistFilter $filter, FormOptions $opts)
Check if the conflict with a filter is currently "active".
$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.
$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.
$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.
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
Interface for objects which can provide a MediaWiki context on request.