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;
20 * @param array $config Configuration options
21 * @param int|null $config['namespace'] Namespace to prepend to queries
22 * @param bool|null $config['relative'] If a namespace is set, return a title relative to it (default: true)
23 * @param bool|null $config['suggestions'] Display search suggestions (default: true)
25 public function __construct( array $config = array() ) {
27 parent
::__construct( array_merge( $config, array( 'infusable' => true ) ) );
29 // Properties, which are ignored in PHP and just shipped back to JS
30 if ( isset( $config['namespace'] ) ) {
31 $this->namespace = $config['namespace'];
33 if ( isset( $config['relative'] ) ) {
34 $this->relative
= $config['relative'];
36 if ( isset( $config['suggestions'] ) ) {
37 $this->suggestions
= $config['suggestions'];
41 $this->addClasses( array( 'mw-widget-titleInputWidget' ) );
44 protected function getJavaScriptClassName() {
45 return 'mw.widgets.TitleInputWidget';
48 public function getConfig( &$config ) {
49 if ( $this->namespace !== null ) {
50 $config['namespace'] = $this->namespace;
52 if ( $this->relative
!== null ) {
53 $config['relative'] = $this->relative
;
55 if ( $this->suggestions
!== null ) {
56 $config['suggestions'] = $this->suggestions
;
58 return parent
::getConfig( $config );