MediaWiki  master
HTMLSizeFilterField.php
Go to the documentation of this file.
1 <?php
2 
12  public function getSize() {
13  return $this->mParams['size'] ?? 9;
14  }
15 
16  public function getInputHTML( $value ) {
17  $attribs = [];
18  if ( !empty( $this->mParams['disabled'] ) ) {
19  $attribs['disabled'] = 'disabled';
20  }
21 
22  $html = Xml::radioLabel(
23  $this->msg( 'minimum-size' )->text(),
24  $this->mName . '-mode',
25  'min',
26  $this->mID . '-mode-min',
27  $value >= 0,
28  $attribs
29  );
30  $html .= "\u{00A0}" . Xml::radioLabel(
31  $this->msg( 'maximum-size' )->text(),
32  $this->mName . '-mode',
33  'max',
34  $this->mID . '-mode-max',
35  $value < 0,
36  $attribs
37  );
38  $html .= "\u{00A0}" . parent::getInputHTML( $value ? abs( $value ) : '' );
39  $html .= "\u{00A0}" . $this->msg( 'pagesize' )->parse();
40 
41  return $html;
42  }
43 
44  protected function getInputWidget( $params ) {
45  $this->mParent->getOutput()->addModuleStyles( 'mediawiki.widgets.SizeFilterWidget.styles' );
46 
47  // negative numbers represent "max", positive numbers represent "min"
48  $value = $params['value'];
49 
50  $params['value'] = $value ? abs( $value ) : '';
51 
53  'selectMin' => $value >= 0,
54  'textinput' => $params,
55  'radioselectinput' => [
56  'name' => $this->mName . '-mode',
57  'disabled' => !empty( $this->mParams['disabled'] ),
58  ],
59  ] );
60  }
61 
62  protected function getOOUIModules() {
63  return [ 'mediawiki.widgets.SizeFilterWidget' ];
64  }
65 
71  public function loadDataFromRequest( $request ) {
72  $size = $request->getInt( $this->mName );
73  if ( !$size ) {
74  return $this->getDefault();
75  }
76  $size = abs( $size );
77 
78  // negative numbers represent "max", positive numbers represent "min"
79  if ( $request->getVal( $this->mName . '-mode' ) === 'max' ) {
80  return -$size;
81  } else {
82  return $size;
83  }
84  }
85 
86  protected function needsLabel() {
87  return false;
88  }
89 }
A size filter field for use on query-type special pages.
static radioLabel( $label, $name, $value, $id, $checked=false, $attribs=[])
Convenience function to build an HTML radio button with a label.
Definition: Xml.php:444
msg( $key,... $params)
Get a translated interface message.
A field that must contain a number.
Definition: HTMLIntField.php:6