MediaWiki REL1_31
UsersMultiselectWidget.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Widget;
4
5use OOUI\MultilineTextInputWidget;
6
13class UsersMultiselectWidget extends \OOUI\Widget {
14
15 protected $usersArray = [];
16 protected $inputName = null;
17 protected $inputPlaceholder = null;
18
25 public function __construct( array $config = [] ) {
26 parent::__construct( $config );
27
28 // Properties
29 if ( isset( $config['default'] ) ) {
30 $this->usersArray = $config['default'];
31 }
32 if ( isset( $config['name'] ) ) {
33 $this->inputName = $config['name'];
34 }
35 if ( isset( $config['placeholder'] ) ) {
36 $this->inputPlaceholder = $config['placeholder'];
37 }
38
39 $textarea = new MultilineTextInputWidget( [
40 'name' => $this->inputName,
41 'value' => implode( "\n", $this->usersArray ),
42 'rows' => 25,
43 ] );
44 $this->prependContent( $textarea );
45 }
46
47 protected function getJavaScriptClassName() {
48 return 'mw.widgets.UsersMultiselectWidget';
49 }
50
51 public function getConfig( &$config ) {
52 if ( $this->usersArray !== null ) {
53 $config['selected'] = $this->usersArray;
54 }
55 if ( $this->inputName !== null ) {
56 $config['name'] = $this->inputName;
57 }
58 if ( $this->inputPlaceholder !== null ) {
59 $config['placeholder'] = $this->inputPlaceholder;
60 }
61
62 $config['$overlay'] = true;
63 return parent::getConfig( $config );
64 }
65
66}