MediaWiki  master
HTMLSizeFilterField.php
Go to the documentation of this file.
1 <?php
2 
4 
17 
18  protected bool $mSelectMin = true;
19 
20  public function getSize() {
21  return $this->mParams['size'] ?? 9;
22  }
23 
24  public function getInputHTML( $value ) {
25  $attribs = [];
26  if ( !empty( $this->mParams['disabled'] ) ) {
27  $attribs['disabled'] = 'disabled';
28  }
29 
30  $html = Xml::radioLabel(
31  $this->msg( 'minimum-size' )->text(),
32  $this->mName . '-mode',
33  'min',
34  $this->mID . '-mode-min',
35  $this->mSelectMin,
36  $attribs
37  );
38  $html .= "\u{00A0}" . Xml::radioLabel(
39  $this->msg( 'maximum-size' )->text(),
40  $this->mName . '-mode',
41  'max',
42  $this->mID . '-mode-max',
43  !$this->mSelectMin,
44  $attribs
45  );
46  $html .= "\u{00A0}" . parent::getInputHTML( $value ? abs( $value ) : '' );
47  $html .= "\u{00A0}" . $this->msg( 'pagesize' )->parse();
48 
49  return $html;
50  }
51 
56  protected function getInputWidget( $params ) {
57  $this->mParent->getOutput()->addModuleStyles( 'mediawiki.widgets.SizeFilterWidget.styles' );
58 
59  // negative numbers represent "max", positive numbers represent "min"
60  $value = $params['value'];
61  $params['value'] = $value ? abs( $value ) : '';
62 
64  'selectMin' => $this->mSelectMin,
65  'textinput' => $params,
66  'radioselectinput' => [
67  'name' => $this->mName . '-mode',
68  'disabled' => !empty( $this->mParams['disabled'] ),
69  ],
70  ] );
71  }
72 
73  protected function getOOUIModules() {
74  return [ 'mediawiki.widgets.SizeFilterWidget' ];
75  }
76 
82  public function loadDataFromRequest( $request ) {
83  $size = abs( $request->getInt( $this->mName, $this->getDefault() ) );
84 
85  // negative numbers represent "max", positive numbers represent "min"
86  if ( $request->getVal( $this->mName . '-mode' ) === 'max' ) {
87  $this->mSelectMin = false;
88  return -$size;
89  } else {
90  return $size;
91  }
92  }
93 
94  protected function needsLabel() {
95  return false;
96  }
97 }
msg( $key,... $params)
Get a translated interface message.
A field that must contain a number.
Definition: HTMLIntField.php:8
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)
Stability: stableto overrideWidgetStability: stableto override
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Definition: WebRequest.php:50
static radioLabel( $label, $name, $value, $id, $checked=false, $attribs=[])
Convenience function to build an HTML radio button with a label.
Definition: Xml.php:458