MediaWiki master
HTMLTagFilter.php
Go to the documentation of this file.
1<?php
2
4
8
16 protected $tagFilter;
17
19 protected $activeOnly = ChangeTags::TAG_SET_ACTIVE_ONLY;
20
22 protected $useAllTags = ChangeTags::USE_ALL_TAGS;
23
31 public function __construct( $params ) {
32 parent::__construct( $params );
33
34 if ( array_key_exists( 'activeOnly', $params ) ) {
35 $this->activeOnly = $params['activeOnly'];
36 }
37 if ( array_key_exists( 'useAllTags', $params ) ) {
38 $this->useAllTags = $params['useAllTags'];
39 }
40 }
41
42 private function buildTagFilter( string $value, string $format ): bool {
43 $this->tagFilter = MediaWikiServices::getInstance()->getChangeTagsFormatter()->buildTagFilter(
44 $value,
45 $format,
46 $this->mParent->getContext(),
47 $this->activeOnly,
48 $this->useAllTags
49 );
50 return (bool)$this->tagFilter;
51 }
52
54 public function getTableRow( $value ) {
55 if ( $this->buildTagFilter( $value, 'other' ) ) {
56 return parent::getTableRow( $value );
57 }
58 return '';
59 }
60
62 public function getDiv( $value ) {
63 if ( $this->buildTagFilter( $value, 'other' ) ) {
64 return parent::getDiv( $value );
65 }
66 return '';
67 }
68
70 public function getOOUI( $value ) {
71 if ( $this->buildTagFilter( $value, 'ooui' ) ) {
72 return parent::getOOUI( $value );
73 }
74 return new \OOUI\FieldLayout( new \OOUI\Widget() );
75 }
76
78 public function getCodex( $value ) {
79 if ( $this->buildTagFilter( $value, 'codex' ) ) {
80 return parent::getCodex( $value );
81 }
82 return '';
83 }
84
86 public function getInputHTML( $value ) {
87 if ( $this->tagFilter ) {
88 // we only need the select field, HTMLForm should handle the label
89 return $this->tagFilter[1];
90 }
91 return '';
92 }
93
95 public function getInputOOUI( $value ) {
96 if ( $this->tagFilter ) {
97 // we only need the select field, HTMLForm should handle the label
98 return $this->tagFilter[1];
99 }
100 return '';
101 }
102
104 protected function shouldInfuseOOUI() {
105 return true;
106 }
107}
108
110class_alias( HTMLTagFilter::class, 'HTMLTagFilter' );
Recent changes tagging.
Wrapper for ChangeTags::buildTagFilterSelector to use in HTMLForm.
getOOUI( $value)
Get the OOUI version of the div.Falls back to getDiv by default. to override 1.26\OOUI\FieldLayout
getCodex( $value)
Get the Codex version of the div.1.42string HTML
getDiv( $value)
Get the complete div for the input, including help text, labels, and whatever.to override 1....
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.Defaults to false, which getOOUI will interpret as "...
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
getTableRow( $value)
Get the complete table row for the input, including help text, labels, and whatever....
__construct( $params)
Initialise the object.to call 1.22 The 'label' attribute no longer accepts raw HTML,...
shouldInfuseOOUI()
Whether the field should be automatically infused.Note that all OOUI HTMLForm fields are infusable (y...
The parent class to generate form fields.
Service locator for MediaWiki core services.