aboutsummaryrefslogtreecommitdiffstats
path: root/includes/widget/UserInputWidget.php
blob: 874f05f668693e197d9cfa70a7803ea01616d46d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php

namespace MediaWiki\Widget;

use OOUI\TextInputWidget;

/**
 * User input widget.
 *
 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
 * @license MIT
 */
class UserInputWidget extends TextInputWidget {
	/** @var bool */
	protected $excludeNamed;

	/** @var bool */
	protected $excludeTemp;

	/**
	 * @param array $config Configuration options
	 */
	public function __construct( array $config = [] ) {
		parent::__construct( $config );

		if ( isset( $config['excludenamed'] ) ) {
			$this->excludeNamed = $config['excludenamed'];
		}

		if ( isset( $config['excludetemp'] ) ) {
			$this->excludeTemp = $config['excludetemp'];
		}

		// Initialization
		$this->addClasses( [ 'mw-widget-userInputWidget' ] );
	}

	protected function getJavaScriptClassName() {
		return 'mw.widgets.UserInputWidget';
	}

	public function getConfig( &$config ) {
		$config['$overlay'] = true;

		if ( $this->excludeNamed !== null ) {
			$config['excludenamed'] = $this->excludeNamed;
		}

		if ( $this->excludeTemp !== null ) {
			$config['excludetemp'] = $this->excludeTemp;
		}

		return parent::getConfig( $config );
	}
}