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