Merge "Use $foo.msg( 'bar' ) rather than $foo.html( mw.message( 'bar' ).parse() )"
[lhc/web/wiklou.git] / includes / widget / TitleInputWidget.php
index 8ac7014..8226148 100644 (file)
@@ -15,16 +15,24 @@ class TitleInputWidget extends \OOUI\TextInputWidget {
        protected $namespace = null;
        protected $relative = null;
        protected $suggestions = null;
+       protected $highlightFirst = null;
+       protected $validate = null;
 
        /**
         * @param array $config Configuration options
         * @param int|null $config['namespace'] Namespace to prepend to queries
-        * @param bool|null $config['relative'] If a namespace is set, return a title relative to it (default: true)
+        * @param bool|null $config['relative'] If a namespace is set,
+        *  return a title relative to it (default: true)
         * @param bool|null $config['suggestions'] Display search suggestions (default: true)
+        * @param bool|null $config['highlightFirst'] Automatically highlight
+        *  the first result (default: true)
+        * @param bool|null $config['validate'] Whether the input must be a valid title (default: true)
         */
        public function __construct( array $config = array() ) {
                // Parent constructor
-               parent::__construct( array_merge( array( 'infusable' => true, 'maxLength' => 255 ), $config ) );
+               parent::__construct(
+                       array_merge( array( 'infusable' => true, 'maxLength' => 255 ), $config )
+               );
 
                // Properties, which are ignored in PHP and just shipped back to JS
                if ( isset( $config['namespace'] ) ) {
@@ -36,6 +44,12 @@ class TitleInputWidget extends \OOUI\TextInputWidget {
                if ( isset( $config['suggestions'] ) ) {
                        $this->suggestions = $config['suggestions'];
                }
+               if ( isset( $config['highlightFirst'] ) ) {
+                       $this->highlightFirst = $config['highlightFirst'];
+               }
+               if ( isset( $config['validate'] ) ) {
+                       $this->validate = $config['validate'];
+               }
 
                // Initialization
                $this->addClasses( array( 'mw-widget-titleInputWidget' ) );
@@ -55,6 +69,12 @@ class TitleInputWidget extends \OOUI\TextInputWidget {
                if ( $this->suggestions !== null ) {
                        $config['suggestions'] = $this->suggestions;
                }
+               if ( $this->highlightFirst !== null ) {
+                       $config['highlightFirst'] = $this->highlightFirst;
+               }
+               if ( $this->validate !== null ) {
+                       $config['validate'] = $this->validate;
+               }
                return parent::getConfig( $config );
        }
 }