MediaWiki master
HTMLSizeFilterField.php
Go to the documentation of this file.
1<?php
2
4
8
20
21 protected bool $mSelectMin = true;
22
24 public function getSize() {
25 return $this->mParams['size'] ?? 9;
26 }
27
29 public function getInputHTML( $value ) {
30 $attribs = [];
31 if ( !empty( $this->mParams['disabled'] ) ) {
32 $attribs['disabled'] = 'disabled';
33 }
34
35 $html = '';
36
37 $minId = $this->mID . '-mode-min';
38 $html .= Html::radio(
39 $this->mName . '-mode',
40 $this->mSelectMin,
41 [ 'id' => $minId, 'value' => 'min' ] + $attribs
42 );
43 $html .= "\u{00A0}" . Html::label( $this->msg( 'minimum-size' )->text(), $minId, $attribs );
44
45 $html .= "\u{00A0}";
46
47 $maxId = $this->mID . '-mode-max';
48 $html .= Html::radio(
49 $this->mName . '-mode',
50 !$this->mSelectMin,
51 [ 'id' => $maxId, 'value' => 'max' ] + $attribs
52 );
53 $html .= "\u{00A0}" . Html::label( $this->msg( 'maximum-size' )->text(), $maxId, $attribs );
54
55 $html .= "\u{00A0}" . parent::getInputHTML( $value ? abs( $value ) : '' );
56 $html .= "\u{00A0}" . $this->msg( 'pagesize' )->parse();
57
58 return $html;
59 }
60
65 protected function getInputWidget( $params ) {
66 $this->mParent->getOutput()->addModuleStyles( 'mediawiki.widgets.SizeFilterWidget.styles' );
67
68 // negative numbers represent "max", positive numbers represent "min"
69 $value = $params['value'];
70 $params['value'] = $value ? abs( $value ) : '';
71
72 return new SizeFilterWidget( [
73 'selectMin' => $this->mSelectMin,
74 'textinput' => $params,
75 'radioselectinput' => [
76 'name' => $this->mName . '-mode',
77 'disabled' => !empty( $this->mParams['disabled'] ),
78 ],
79 ] );
80 }
81
83 protected function getOOUIModules() {
84 return [ 'mediawiki.widgets.SizeFilterWidget' ];
85 }
86
92 public function loadDataFromRequest( $request ) {
93 $size = abs( $request->getInt( $this->mName, $this->getDefault() ) );
94
95 // negative numbers represent "max", positive numbers represent "min"
96 if ( $request->getRawVal( $this->mName . '-mode' ) === 'max' ) {
97 $this->mSelectMin = false;
98 return -$size;
99 } else {
100 return $size;
101 }
102 }
103
105 protected function needsLabel() {
106 return false;
107 }
108}
109
111class_alias( HTMLSizeFilterField::class, 'HTMLSizeFilterField' );
A field that must contain a number.
A size filter field for use on query-type special pages.
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
getInputWidget( $params)
to overrideWidgetto override
needsLabel()
Should this field have a label, or is there no input element with the appropriate id for the label to...
msg( $key,... $params)
Get a translated interface message.
This class is a collection of static functions that serve two purposes:
Definition Html.php:43
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...