rdbms: Avoid selectDB() call in LoadMonitor new connections
[mediawiki.git] / includes / widget / UsersMultiselectWidget.php
blob999cb6ab3254d0027faf96b43686bbf99f53b70a
1 <?php
2 /**
3 * MediaWiki Widgets – UsersMultiselectWidget class.
5 * @copyright 2017 MediaWiki Widgets Team and others; see AUTHORS.txt
6 * @license The MIT License (MIT); see LICENSE.txt
7 */
8 namespace MediaWiki\Widget;
10 use \OOUI\TextInputWidget;
12 /**
13 * Widget to select multiple users.
15 class UsersMultiselectWidget extends \OOUI\Widget {
17 protected $usersArray = [];
18 protected $inputName = null;
19 protected $inputPlaceholder = null;
21 /**
22 * @param array $config Configuration options
23 * @param array $config['users'] Array of usernames to use as preset data
24 * @param array $config['placeholder'] Placeholder message for input
25 * @param array $config['name'] Name attribute (used in forms)
27 public function __construct( array $config = [] ) {
28 parent::__construct( $config );
30 // Properties
31 if ( isset( $config['default'] ) ) {
32 $this->usersArray = $config['default'];
34 if ( isset( $config['name'] ) ) {
35 $this->inputName = $config['name'];
37 if ( isset( $config['placeholder'] ) ) {
38 $this->inputPlaceholder = $config['placeholder'];
41 $textarea = new TextInputWidget( [
42 'name' => $this->inputName,
43 'multiline' => true,
44 'value' => implode( "\n", $this->usersArray ),
45 'rows' => 25,
46 ] );
47 $this->prependContent( $textarea );
50 protected function getJavaScriptClassName() {
51 return 'mw.widgets.UsersMultiselectWidget';
54 public function getConfig( &$config ) {
55 if ( $this->usersArray !== null ) {
56 $config['selected'] = $this->usersArray;
58 if ( $this->inputName !== null ) {
59 $config['name'] = $this->inputName;
61 if ( $this->inputPlaceholder !== null ) {
62 $config['placeholder'] = $this->inputPlaceholder;
65 return parent::getConfig( $config );