3 namespace MediaWiki\Widget
;
5 use \OOUI\RadioSelectInputWidget
;
6 use \OOUI\TextInputWidget
;
10 * Select and input widget.
12 * @copyright 2011-2018 MediaWiki Widgets Team and others; see AUTHORS.txt
15 class SizeFilterWidget
extends \OOUI\Widget
{
17 protected $radioselectinput = null;
18 protected $textinput = null;
21 * RadioSelectInputWidget and a TextInputWidget to set minimum or maximum byte size
23 * @param array $config Configuration options
24 * - array $config['textinput'] Configuration for the TextInputWidget
25 * - array $config['radioselectinput'] Configuration for the RadioSelectWidget
26 * - bool $congif['selectMin'] Whether to select 'min', false would select 'max'
28 public function __construct( array $config = [] ) {
29 // Configuration initialization
30 $config = array_merge( [
33 'radioselectinput' => []
35 $config['textinput'] = array_merge( [
37 ], $config['textinput'] );
38 $config['radioselectinput'] = array_merge( [ 'options' => [
41 'label' => wfMessage( 'minimum-size' )->text()
45 'label' => wfMessage( 'maximum-size' )->text()
47 ] ], $config['radioselectinput'] );
50 parent
::__construct( $config );
53 $this->config
= $config;
54 $this->radioselectinput
= new RadioSelectInputWidget( $config[ 'radioselectinput'] );
55 $this->textinput
= new TextInputWidget( $config[ 'textinput' ] );
56 $this->label
= new LabelWidget( [ 'label' => wfMessage( 'pagesize' )->text() ] );
59 $this->radioselectinput
->setValue( $config[ 'selectMin' ] ?
'min' : 'max' );
61 ->addClasses( [ 'mw-widget-sizeFilterWidget' ] )
62 ->appendContent( $this->radioselectinput
, $this->textinput
, $this->label
);
65 protected function getJavaScriptClassName() {
66 return 'mw.widgets.SizeFilterWidget';
69 public function getConfig( &$config ) {
70 $config['textinput'] = $this->config
['textinput'];
71 $config['radioselectinput'] = $this->config
['radioselectinput'];
72 $config['selectMin'] = $this->config
['selectMin'];
73 return parent
::getConfig( $config );