MediaWiki REL1_39
HTMLSizeFilterField.php
Go to the documentation of this file.
1<?php
2
15 public function getSize() {
16 return $this->mParams['size'] ?? 9;
17 }
18
19 public function getInputHTML( $value ) {
20 $attribs = [];
21 if ( !empty( $this->mParams['disabled'] ) ) {
22 $attribs['disabled'] = 'disabled';
23 }
24
25 $html = Xml::radioLabel(
26 $this->msg( 'minimum-size' )->text(),
27 $this->mName . '-mode',
28 'min',
29 $this->mID . '-mode-min',
30 $value >= 0,
31 $attribs
32 );
33 $html .= "\u{00A0}" . Xml::radioLabel(
34 $this->msg( 'maximum-size' )->text(),
35 $this->mName . '-mode',
36 'max',
37 $this->mID . '-mode-max',
38 $value < 0,
39 $attribs
40 );
41 $html .= "\u{00A0}" . parent::getInputHTML( $value ? abs( $value ) : '' );
42 $html .= "\u{00A0}" . $this->msg( 'pagesize' )->parse();
43
44 return $html;
45 }
46
51 protected function getInputWidget( $params ) {
52 $this->mParent->getOutput()->addModuleStyles( 'mediawiki.widgets.SizeFilterWidget.styles' );
53
54 // negative numbers represent "max", positive numbers represent "min"
55 $value = $params['value'];
56
57 $params['value'] = $value ? abs( $value ) : '';
58
60 'selectMin' => $value >= 0,
61 'textinput' => $params,
62 'radioselectinput' => [
63 'name' => $this->mName . '-mode',
64 'disabled' => !empty( $this->mParams['disabled'] ),
65 ],
66 ] );
67 }
68
69 protected function getOOUIModules() {
70 return [ 'mediawiki.widgets.SizeFilterWidget' ];
71 }
72
78 public function loadDataFromRequest( $request ) {
79 $size = $request->getInt( $this->mName );
80 if ( !$size ) {
81 return $this->getDefault();
82 }
83 $size = abs( $size );
84
85 // negative numbers represent "max", positive numbers represent "min"
86 if ( $request->getVal( $this->mName . '-mode' ) === 'max' ) {
87 return -$size;
88 } else {
89 return $size;
90 }
91 }
92
93 protected function needsLabel() {
94 return false;
95 }
96}
msg( $key,... $params)
Get a translated interface message.
A field that must contain a number.
A size filter field for use on query-type special pages.
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
needsLabel()
Should this field have a label, or is there no input element with the appropriate id for the label to...
getInputWidget( $params)
to overrideWidgetto override
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...