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 = Xml::radioLabel(
35 $this->msg( 'minimum-size' )->text(),
36 $this->mName . '-mode',
37 'min',
38 $this->mID . '-mode-min',
39 $this->mSelectMin,
40 $attribs
41 );
42 $html .= "\u{00A0}" . Xml::radioLabel(
43 $this->msg( 'maximum-size' )->text(),
44 $this->mName . '-mode',
45 'max',
46 $this->mID . '-mode-max',
47 !$this->mSelectMin,
48 $attribs
49 );
50 $html .= "\u{00A0}" . parent::getInputHTML( $value ? abs( $value ) : '' );
51 $html .= "\u{00A0}" . $this->msg( 'pagesize' )->parse();
52
53 return $html;
54 }
55
60 protected function getInputWidget( $params ) {
61 $this->mParent->getOutput()->addModuleStyles( 'mediawiki.widgets.SizeFilterWidget.styles' );
62
63 // negative numbers represent "max", positive numbers represent "min"
64 $value = $params['value'];
65 $params['value'] = $value ? abs( $value ) : '';
66
67 return new SizeFilterWidget( [
68 'selectMin' => $this->mSelectMin,
69 'textinput' => $params,
70 'radioselectinput' => [
71 'name' => $this->mName . '-mode',
72 'disabled' => !empty( $this->mParams['disabled'] ),
73 ],
74 ] );
75 }
76
77 protected function getOOUIModules() {
78 return [ 'mediawiki.widgets.SizeFilterWidget' ];
79 }
80
86 public function loadDataFromRequest( $request ) {
87 $size = abs( $request->getInt( $this->mName, $this->getDefault() ) );
88
89 // negative numbers represent "max", positive numbers represent "min"
90 if ( $request->getVal( $this->mName . '-mode' ) === 'max' ) {
91 $this->mSelectMin = false;
92 return -$size;
93 } else {
94 return $size;
95 }
96 }
97
98 protected function needsLabel() {
99 return false;
100 }
101}
102
104class_alias( HTMLSizeFilterField::class, 'HTMLSizeFilterField' );
array $params
The job parameters.
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.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...
Module of static functions for generating XML.
Definition Xml.php:37