MediaWiki master
HTMLSizeFilterField.php
Go to the documentation of this file.
1<?php
2
4
8
21
22 protected bool $mSelectMin = true;
23
24 public function getSize() {
25 return $this->mParams['size'] ?? 9;
26 }
27
28 public function getInputHTML( $value ) {
29 $attribs = [];
30 if ( !empty( $this->mParams['disabled'] ) ) {
31 $attribs['disabled'] = 'disabled';
32 }
33
34 $html = '';
35
36 $minId = $this->mID . '-mode-min';
37 $html .= Html::radio(
38 $this->mName . '-mode',
39 $this->mSelectMin,
40 [ 'id' => $minId, 'value' => 'min' ] + $attribs
41 );
42 $html .= "\u{00A0}" . Html::label( $this->msg( 'minimum-size' )->text(), $minId, $attribs );
43
44 $html .= "\u{00A0}";
45
46 $maxId = $this->mID . '-mode-max';
47 $html .= Html::radio(
48 $this->mName . '-mode',
49 !$this->mSelectMin,
50 [ 'id' => $maxId, 'value' => 'max' ] + $attribs
51 );
52 $html .= "\u{00A0}" . Html::label( $this->msg( 'maximum-size' )->text(), $maxId, $attribs );
53
54 $html .= "\u{00A0}" . parent::getInputHTML( $value ? abs( $value ) : '' );
55 $html .= "\u{00A0}" . $this->msg( 'pagesize' )->parse();
56
57 return $html;
58 }
59
64 protected function getInputWidget( $params ) {
65 $this->mParent->getOutput()->addModuleStyles( 'mediawiki.widgets.SizeFilterWidget.styles' );
66
67 // negative numbers represent "max", positive numbers represent "min"
68 $value = $params['value'];
69 $params['value'] = $value ? abs( $value ) : '';
70
71 return new SizeFilterWidget( [
72 'selectMin' => $this->mSelectMin,
73 'textinput' => $params,
74 'radioselectinput' => [
75 'name' => $this->mName . '-mode',
76 'disabled' => !empty( $this->mParams['disabled'] ),
77 ],
78 ] );
79 }
80
81 protected function getOOUIModules() {
82 return [ 'mediawiki.widgets.SizeFilterWidget' ];
83 }
84
90 public function loadDataFromRequest( $request ) {
91 $size = abs( $request->getInt( $this->mName, $this->getDefault() ) );
92
93 // negative numbers represent "max", positive numbers represent "min"
94 if ( $request->getRawVal( $this->mName . '-mode' ) === 'max' ) {
95 $this->mSelectMin = false;
96 return -$size;
97 } else {
98 return $size;
99 }
100 }
101
102 protected function needsLabel() {
103 return false;
104 }
105}
106
108class_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:57
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...