MediaWiki  master
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 }
MediaWiki\Widget\SizeFilterWidget
Select and input widget.
Definition: SizeFilterWidget.php:15
HTMLIntField
A field that must contain a number.
Definition: HTMLIntField.php:8
HTMLSizeFilterField\getInputHTML
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
Definition: HTMLSizeFilterField.php:19
HTMLSizeFilterField
A size filter field for use on query-type special pages.
Definition: HTMLSizeFilterField.php:14
HTMLSizeFilterField\loadDataFromRequest
loadDataFromRequest( $request)
Definition: HTMLSizeFilterField.php:78
HTMLFormField\getDefault
getDefault()
Stable to override.
Definition: HTMLFormField.php:999
HTMLSizeFilterField\getSize
getSize()
Stable to override.
Definition: HTMLSizeFilterField.php:15
HTMLSizeFilterField\getInputWidget
getInputWidget( $params)
Stable to override.Widget Stable to override Stable to override
Definition: HTMLSizeFilterField.php:51
Xml\radioLabel
static radioLabel( $label, $name, $value, $id, $checked=false, $attribs=[])
Convenience function to build an HTML radio button with a label.
Definition: Xml.php:448
HTMLSizeFilterField\needsLabel
needsLabel()
Should this field have a label, or is there no input element with the appropriate id for the label to...
Definition: HTMLSizeFilterField.php:93
HTMLSizeFilterField\getOOUIModules
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
Definition: HTMLSizeFilterField.php:69
HTMLFormField\msg
msg( $key,... $params)
Get a translated interface message.
Definition: HTMLFormField.php:87