MediaWiki  master
TagMultiselectWidget.php
Go to the documentation of this file.
1 <?php
2 
3 namespace MediaWiki\Widget;
4 
6 
14 abstract class TagMultiselectWidget extends \OOUI\Widget {
16  protected $selectedArray;
18  protected $inputName;
20  protected $inputPlaceholder;
22  protected $input;
24  protected $tagLimit;
25 
34  public function __construct( array $config = [] ) {
35  parent::__construct( $config );
36 
37  // Properties
38  $this->selectedArray = $config['default'] ?? [];
39  $this->inputName = $config['name'] ?? null;
40  $this->inputPlaceholder = $config['placeholder'] ?? null;
41  $this->input = $config['input'] ?? [];
42  $this->tagLimit = $config['tagLimit'] ?? null;
43 
44  $textarea = new MultilineTextInputWidget( array_merge( [
45  'name' => $this->inputName,
46  'value' => implode( "\n", $this->selectedArray ),
47  'rows' => 10,
48  'classes' => [
49  'mw-widgets-tagMultiselectWidget-multilineTextInputWidget'
50  ],
51  ], $this->input ) );
52 
53  $pending = new PendingTextInputWidget();
54 
55  $this->appendContent( $textarea, $pending );
56  $this->addClasses( [ 'mw-widgets-tagMultiselectWidget' ] );
57  }
58 
59  public function getConfig( &$config ) {
60  if ( $this->selectedArray !== null ) {
61  $config['selected'] = $this->selectedArray;
62  }
63  if ( $this->inputName !== null ) {
64  $config['name'] = $this->inputName;
65  }
66  if ( $this->inputPlaceholder !== null ) {
67  $config['placeholder'] = $this->inputPlaceholder;
68  }
69  if ( $this->input !== null ) {
70  $config['input'] = $this->input;
71  }
72  if ( $this->tagLimit !== null ) {
73  $config['tagLimit'] = $this->tagLimit;
74  }
75 
76  $config['$overlay'] = true;
77  return parent::getConfig( $config );
78  }
79 
80 }
Config $config
Definition: MediaWiki.php:43
Text input widget that displays pending animation.
Abstract base class for widgets to select multiple users, titles, namespaces, etc.