Simplify documentation headers of includes/widgets/…Widget.php files
[lhc/web/wiklou.git] / includes / widget / TitleInputWidget.php
1 <?php
2
3 namespace MediaWiki\Widget;
4
5 /**
6 * Title input widget.
7 *
8 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
9 * @license MIT
10 */
11 class TitleInputWidget extends \OOUI\TextInputWidget {
12
13 protected $namespace = null;
14 protected $relative = null;
15 protected $suggestions = null;
16 protected $highlightFirst = null;
17 protected $validateTitle = null;
18
19 /**
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)
29 */
30 public function __construct( array $config = [] ) {
31 parent::__construct(
32 array_merge( [ 'maxLength' => 255 ], $config )
33 );
34
35 // Properties, which are ignored in PHP and just shipped back to JS
36 if ( isset( $config['namespace'] ) ) {
37 $this->namespace = $config['namespace'];
38 }
39 if ( isset( $config['relative'] ) ) {
40 $this->relative = $config['relative'];
41 }
42 if ( isset( $config['suggestions'] ) ) {
43 $this->suggestions = $config['suggestions'];
44 }
45 if ( isset( $config['highlightFirst'] ) ) {
46 $this->highlightFirst = $config['highlightFirst'];
47 }
48 if ( isset( $config['validateTitle'] ) ) {
49 $this->validateTitle = $config['validateTitle'];
50 }
51
52 // Initialization
53 $this->addClasses( [ 'mw-widget-titleInputWidget' ] );
54 }
55
56 protected function getJavaScriptClassName() {
57 return 'mw.widgets.TitleInputWidget';
58 }
59
60 public function getConfig( &$config ) {
61 if ( $this->namespace !== null ) {
62 $config['namespace'] = $this->namespace;
63 }
64 if ( $this->relative !== null ) {
65 $config['relative'] = $this->relative;
66 }
67 if ( $this->suggestions !== null ) {
68 $config['suggestions'] = $this->suggestions;
69 }
70 if ( $this->highlightFirst !== null ) {
71 $config['highlightFirst'] = $this->highlightFirst;
72 }
73 if ( $this->validateTitle !== null ) {
74 $config['validateTitle'] = $this->validateTitle;
75 }
76 $config['$overlay'] = true;
77 return parent::getConfig( $config );
78 }
79 }