3 namespace MediaWiki\Widget
;
5 use OOUI\TextInputWidget
;
10 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
13 class TitleInputWidget
extends TextInputWidget
{
16 protected $namespace = null;
18 protected $relative = null;
20 protected $suggestions = null;
22 protected $highlightFirst = null;
24 protected $validateTitle = null;
27 * @param array $config Configuration options
28 * - int|null $config['namespace'] Namespace to prepend to queries
29 * - bool|null $config['relative'] If a namespace is set,
30 * return a title relative to it (default: true)
31 * - bool|null $config['suggestions'] Display search suggestions (default: true)
32 * - bool|null $config['highlightFirst'] Automatically highlight
33 * the first result (default: true)
34 * - bool|null $config['validateTitle'] Whether the input must
35 * be a valid title (default: true)
37 public function __construct( array $config = [] ) {
39 array_merge( [ 'maxLength' => 255 ], $config )
42 // Properties, which are ignored in PHP and just shipped back to JS
43 if ( isset( $config['namespace'] ) ) {
44 $this->namespace = $config['namespace'];
46 if ( isset( $config['relative'] ) ) {
47 $this->relative
= $config['relative'];
49 if ( isset( $config['suggestions'] ) ) {
50 $this->suggestions
= $config['suggestions'];
52 if ( isset( $config['highlightFirst'] ) ) {
53 $this->highlightFirst
= $config['highlightFirst'];
55 if ( isset( $config['validateTitle'] ) ) {
56 $this->validateTitle
= $config['validateTitle'];
60 $this->addClasses( [ 'mw-widget-titleInputWidget' ] );
63 protected function getJavaScriptClassName() {
64 return 'mw.widgets.TitleInputWidget';
67 public function getConfig( &$config ) {
68 if ( $this->namespace !== null ) {
69 $config['namespace'] = $this->namespace;
71 if ( $this->relative
!== null ) {
72 $config['relative'] = $this->relative
;
74 if ( $this->suggestions
!== null ) {
75 $config['suggestions'] = $this->suggestions
;
77 if ( $this->highlightFirst
!== null ) {
78 $config['highlightFirst'] = $this->highlightFirst
;
80 if ( $this->validateTitle
!== null ) {
81 $config['validateTitle'] = $this->validateTitle
;
83 $config['$overlay'] = true;
84 return parent
::getConfig( $config );