886afa6fee1c87c318b1bfa26bb14808521447b6
3 * MediaWiki Widgets – TitleInputWidget class.
5 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
6 * @license The MIT License (MIT); see LICENSE.txt
8 namespace MediaWiki\Widget
;
13 class TitleInputWidget
extends \OOUI\TextInputWidget
{
15 protected $namespace = null;
16 protected $relative = null;
17 protected $suggestions = null;
18 protected $highlightFirst = null;
19 protected $validateTitle = null;
22 * @param array $config Configuration options
23 * @param int|null $config['namespace'] Namespace to prepend to queries
24 * @param bool|null $config['relative'] If a namespace is set,
25 * return a title relative to it (default: true)
26 * @param bool|null $config['suggestions'] Display search suggestions (default: true)
27 * @param bool|null $config['highlightFirst'] Automatically highlight
28 * the first result (default: true)
29 * @param bool|null $config['validateTitle'] Whether the input must
30 * be a valid title (default: true)
32 public function __construct( array $config = [] ) {
35 array_merge( [ 'infusable' => true, 'maxLength' => 255 ], $config )
38 // Properties, which are ignored in PHP and just shipped back to JS
39 if ( isset( $config['namespace'] ) ) {
40 $this->namespace = $config['namespace'];
42 if ( isset( $config['relative'] ) ) {
43 $this->relative
= $config['relative'];
45 if ( isset( $config['suggestions'] ) ) {
46 $this->suggestions
= $config['suggestions'];
48 if ( isset( $config['highlightFirst'] ) ) {
49 $this->highlightFirst
= $config['highlightFirst'];
51 if ( isset( $config['validateTitle'] ) ) {
52 $this->validateTitle
= $config['validateTitle'];
56 $this->addClasses( [ 'mw-widget-titleInputWidget' ] );
59 protected function getJavaScriptClassName() {
60 return 'mw.widgets.TitleInputWidget';
63 public function getConfig( &$config ) {
64 if ( $this->namespace !== null ) {
65 $config['namespace'] = $this->namespace;
67 if ( $this->relative
!== null ) {
68 $config['relative'] = $this->relative
;
70 if ( $this->suggestions
!== null ) {
71 $config['suggestions'] = $this->suggestions
;
73 if ( $this->highlightFirst
!== null ) {
74 $config['highlightFirst'] = $this->highlightFirst
;
76 if ( $this->validateTitle
!== null ) {
77 $config['validateTitle'] = $this->validateTitle
;
79 return parent
::getConfig( $config );