| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Widget; |
| 4 |
|
| 5 |
use OOUI\TextInputWidget; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
class TitleInputWidget extends TextInputWidget { |
| 14 |
|
| 15 |
|
| 16 |
protected $namespace = null; |
| 17 |
|
| 18 |
protected $relative = null; |
| 19 |
|
| 20 |
protected $suggestions = null; |
| 21 |
|
| 22 |
protected $highlightFirst = null; |
| 23 |
|
| 24 |
protected $validateTitle = null; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public function __construct( array $config = [] ) { |
| 38 |
parent::__construct( |
| 39 |
array_merge( [ 'maxLength' => 255 ], $config ) |
| 40 |
); |
| 41 |
|
| 42 |
|
| 43 |
if ( isset( $config['namespace'] ) ) { |
| 44 |
$this->namespace = $config['namespace']; |
| 45 |
} |
| 46 |
if ( isset( $config['relative'] ) ) { |
| 47 |
$this->relative = $config['relative']; |
| 48 |
} |
| 49 |
if ( isset( $config['suggestions'] ) ) { |
| 50 |
$this->suggestions = $config['suggestions']; |
| 51 |
} |
| 52 |
if ( isset( $config['highlightFirst'] ) ) { |
| 53 |
$this->highlightFirst = $config['highlightFirst']; |
| 54 |
} |
| 55 |
if ( isset( $config['validateTitle'] ) ) { |
| 56 |
$this->validateTitle = $config['validateTitle']; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
$this->addClasses( [ 'mw-widget-titleInputWidget' ] ); |
| 61 |
} |
| 62 |
|
| 63 |
protected function getJavaScriptClassName() { |
| 64 |
return 'mw.widgets.TitleInputWidget'; |
| 65 |
} |
| 66 |
|
| 67 |
public function getConfig( &$config ) { |
| 68 |
if ( $this->namespace !== null ) { |
| 69 |
$config['namespace'] = $this->namespace; |
| 70 |
} |
| 71 |
if ( $this->relative !== null ) { |
| 72 |
$config['relative'] = $this->relative; |
| 73 |
} |
| 74 |
if ( $this->suggestions !== null ) { |
| 75 |
$config['suggestions'] = $this->suggestions; |
| 76 |
} |
| 77 |
if ( $this->highlightFirst !== null ) { |
| 78 |
$config['highlightFirst'] = $this->highlightFirst; |
| 79 |
} |
| 80 |
if ( $this->validateTitle !== null ) { |
| 81 |
$config['validateTitle'] = $this->validateTitle; |
| 82 |
} |
| 83 |
$config['$overlay'] = true; |
| 84 |
return parent::getConfig( $config ); |
| 85 |
} |
| 86 |
} |