MediaWiki REL1_34
SizeFilterWidget.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Widget;
4
5use \OOUI\RadioSelectInputWidget;
6use \OOUI\TextInputWidget;
7use \OOUI\LabelWidget;
8
15class SizeFilterWidget extends \OOUI\Widget {
17 protected $config;
19 protected $label;
23 protected $textinput;
24
33 public function __construct( array $config = [] ) {
34 // Configuration initialization
35 $config = array_merge( [
36 'selectMin' => true,
37 'textinput' => [],
38 'radioselectinput' => []
39 ], $config );
40 $config['textinput'] = array_merge( [
41 'type' => 'number'
42 ], $config['textinput'] );
43 $config['radioselectinput'] = array_merge( [ 'options' => [
44 [
45 'data' => 'min',
46 'label' => wfMessage( 'minimum-size' )->text()
47 ],
48 [
49 'data' => 'max',
50 'label' => wfMessage( 'maximum-size' )->text()
51 ]
52 ] ], $config['radioselectinput'] );
53
54 // Parent constructor
55 parent::__construct( $config );
56
57 // Properties
58 $this->config = $config;
59 $this->radioselectinput = new RadioSelectInputWidget( $config[ 'radioselectinput'] );
60 $this->textinput = new TextInputWidget( $config[ 'textinput' ] );
61 $this->label = new LabelWidget( [ 'label' => wfMessage( 'pagesize' )->text() ] );
62
63 // Initialization
64 $this->radioselectinput->setValue( $config[ 'selectMin' ] ? 'min' : 'max' );
65 $this
66 ->addClasses( [ 'mw-widget-sizeFilterWidget' ] )
67 ->appendContent( $this->radioselectinput, $this->textinput, $this->label );
68 }
69
70 protected function getJavaScriptClassName() {
71 return 'mw.widgets.SizeFilterWidget';
72 }
73
74 public function getConfig( &$config ) {
75 $config['textinput'] = $this->config['textinput'];
76 $config['radioselectinput'] = $this->config['radioselectinput'];
77 $config['selectMin'] = $this->config['selectMin'];
78 return parent::getConfig( $config );
79 }
80}
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
__construct(array $config=[])
RadioSelectInputWidget and a TextInputWidget to set minimum or maximum byte size.
RadioSelectInputWidget $radioselectinput