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