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
{
18 /** @var LabelWidget */
20 /** @var RadioSelectInputWidget */
21 protected $radioselectinput;
22 /** @var TextInputWidget */
26 * RadioSelectInputWidget and a TextInputWidget to set minimum or maximum byte size
28 * @param array $config Configuration options
29 * - array $config['textinput'] Configuration for the TextInputWidget
30 * - array $config['radioselectinput'] Configuration for the RadioSelectWidget
31 * - bool $congif['selectMin'] Whether to select 'min', false would select 'max'
33 public function __construct( array $config = [] ) {
34 // Configuration initialization
35 $config = array_merge( [
38 'radioselectinput' => []
40 $config['textinput'] = array_merge( [
42 ], $config['textinput'] );
43 $config['radioselectinput'] = array_merge( [ 'options' => [
46 'label' => wfMessage( 'minimum-size' )->text()
50 'label' => wfMessage( 'maximum-size' )->text()
52 ] ], $config['radioselectinput'] );
55 parent
::__construct( $config );
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() ] );
64 $this->radioselectinput
->setValue( $config[ 'selectMin' ] ?
'min' : 'max' );
66 ->addClasses( [ 'mw-widget-sizeFilterWidget' ] )
67 ->appendContent( $this->radioselectinput
, $this->textinput
, $this->label
);
70 protected function getJavaScriptClassName() {
71 return 'mw.widgets.SizeFilterWidget';
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 );