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 = [] ) {
34 array_merge( [ 'maxLength' => 255 ], $config )
37 // Properties, which are ignored in PHP and just shipped back to JS
38 if ( isset( $config['namespace'] ) ) {
39 $this->namespace = $config['namespace'];
41 if ( isset( $config['relative'] ) ) {
42 $this->relative
= $config['relative'];
44 if ( isset( $config['suggestions'] ) ) {
45 $this->suggestions
= $config['suggestions'];
47 if ( isset( $config['highlightFirst'] ) ) {
48 $this->highlightFirst
= $config['highlightFirst'];
50 if ( isset( $config['validateTitle'] ) ) {
51 $this->validateTitle
= $config['validateTitle'];
55 $this->addClasses( [ 'mw-widget-titleInputWidget' ] );
58 protected function getJavaScriptClassName() {
59 return 'mw.widgets.TitleInputWidget';
62 public function getConfig( &$config ) {
63 if ( $this->namespace !== null ) {
64 $config['namespace'] = $this->namespace;
66 if ( $this->relative
!== null ) {
67 $config['relative'] = $this->relative
;
69 if ( $this->suggestions
!== null ) {
70 $config['suggestions'] = $this->suggestions
;
72 if ( $this->highlightFirst
!== null ) {
73 $config['highlightFirst'] = $this->highlightFirst
;
75 if ( $this->validateTitle
!== null ) {
76 $config['validateTitle'] = $this->validateTitle
;
78 $config['$overlay'] = true;
79 return parent
::getConfig( $config );