MediaWiki  master
TagMultiselectWidget.php
Go to the documentation of this file.
1 <?php
2 
3 namespace MediaWiki\Widget;
4 
5 use OOUI\MultilineTextInputWidget;
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 }
MediaWiki\Widget\PendingTextInputWidget
Text input widget that displays pending animation.
Definition: PendingTextInputWidget.php:10
MediaWiki\Widget\TagMultiselectWidget
Abstract base class for widgets to select multiple users, titles, namespaces, etc.
Definition: TagMultiselectWidget.php:14
MediaWiki\Widget\TagMultiselectWidget\$inputPlaceholder
string null $inputPlaceholder
Definition: TagMultiselectWidget.php:20
MediaWiki\Widget\TagMultiselectWidget\$input
array $input
Definition: TagMultiselectWidget.php:22
MediaWiki\Widget\TagMultiselectWidget\$inputName
string null $inputName
Definition: TagMultiselectWidget.php:18
MediaWiki\Widget\TagMultiselectWidget\$selectedArray
array $selectedArray
Definition: TagMultiselectWidget.php:16
MediaWiki\Widget\TagMultiselectWidget\$tagLimit
int null $tagLimit
Definition: TagMultiselectWidget.php:24
MediaWiki\Widget\TagMultiselectWidget\__construct
__construct(array $config=[])
Definition: TagMultiselectWidget.php:34
MediaWiki\Widget\TagMultiselectWidget\getConfig
getConfig(&$config)
Definition: TagMultiselectWidget.php:59
MediaWiki\Widget
Definition: CheckMatrixWidget.php:3
MediaWiki\$config
Config $config
Definition: MediaWiki.php:42