MediaWiki REL1_39
TagMultiselectWidget.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Widget;
4
5use OOUI\MultilineTextInputWidget;
6
14class TagMultiselectWidget extends \OOUI\Widget {
16 protected $selectedArray;
18 protected $inputName;
22 protected $input;
24 protected $tagLimit;
26 protected $allowArbitrary;
28 protected $allowedValues;
29
40 public function __construct( array $config = [] ) {
41 parent::__construct( $config );
42
43 // Properties
44 $this->selectedArray = $config['default'] ?? [];
45 $this->inputName = $config['name'] ?? null;
46 $this->inputPlaceholder = $config['placeholder'] ?? null;
47 $this->input = $config['input'] ?? [];
48 $this->tagLimit = $config['tagLimit'] ?? null;
49 $this->allowArbitrary = $config['allowArbitrary'] ?? false;
50 $this->allowedValues = $config['allowedValues'] ?? null;
51
52 $textarea = new MultilineTextInputWidget( array_merge( [
53 'name' => $this->inputName,
54 'value' => implode( "\n", $this->selectedArray ),
55 'rows' => 10,
56 'classes' => [
57 'mw-widgets-tagMultiselectWidget-multilineTextInputWidget'
58 ],
59 ], $this->input ) );
60
61 $pending = new PendingTextInputWidget();
62
63 $this->appendContent( $textarea, $pending );
64 $this->addClasses( [ 'mw-widgets-tagMultiselectWidget' ] );
65 }
66
67 public function getConfig( &$config ) {
68 if ( $this->selectedArray !== null ) {
69 $config['selected'] = $this->selectedArray;
70 }
71 if ( $this->inputName !== null ) {
72 $config['name'] = $this->inputName;
73 }
74 if ( $this->inputPlaceholder !== null ) {
75 $config['placeholder'] = $this->inputPlaceholder;
76 }
77 if ( $this->input !== null ) {
78 $config['input'] = $this->input;
79 }
80 if ( $this->tagLimit !== null ) {
81 $config['tagLimit'] = $this->tagLimit;
82 }
83 if ( $this->allowArbitrary !== null ) {
84 $config['allowArbitrary'] = $this->allowArbitrary;
85 }
86 if ( $this->allowedValues !== null ) {
87 $config['allowedValues'] = $this->allowedValues;
88 }
89
90 $config['$overlay'] = true;
91 return parent::getConfig( $config );
92 }
93
94 protected function getJavaScriptClassName() {
95 return 'mw.widgets.TagMultiselectWidget';
96 }
97}
Text input widget that displays pending animation.
Base class for widgets to select multiple users, titles, namespaces, etc.