wiki.techinc.nl/includes/widget/ComplexTitleInputWidget.php
Amir E. Aharoni 870dbf0659 Make lines short to pass phpcs in six files under includes/
Bug: T102614
Change-Id: I91a2d4f4bf86a22c8bb466da0e2f95ea27c571a3
2015-09-26 18:41:01 +00:00

70 lines
1.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* MediaWiki Widgets ComplexTitleInputWidget class.
*
* @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
namespace MediaWiki\Widget;
/**
* Complex title input widget.
*/
class ComplexTitleInputWidget extends \OOUI\Widget {
protected $namespace = null;
protected $title = null;
/**
* Like TitleInputWidget, but the namespace has to be input through a separate dropdown field.
*
* @param array $config Configuration options
* @param array $config['namespace'] Configuration for the NamespaceInputWidget dropdown
* with list of namespaces
* @param array $config['title'] Configuration for the TitleInputWidget text field
*/
public function __construct( array $config = array() ) {
// Configuration initialization
$config = array_merge(
array(
'namespace' => array(),
'title' => array(),
),
$config
);
// Parent constructor
parent::__construct( $config );
// Properties
$this->config = $config;
$this->namespace = new NamespaceInputWidget( $config['namespace'] );
$this->title = new TitleInputWidget( array_merge(
$config['title'],
array(
// The inner TitleInputWidget shouldn't be infusable,
// only the ComplexTitleInputWidget itself can be.
'infusable' => false,
'relative' => true,
'namespace' => isset( $config['namespace']['value'] ) ?
$config['namespace']['value'] :
null,
)
) );
// Initialization
$this
->addClasses( array( 'mw-widget-complexTitleInputWidget' ) )
->appendContent( $this->namespace, $this->title );
}
protected function getJavaScriptClassName() {
return 'mw.widgets.ComplexTitleInputWidget';
}
public function getConfig( &$config ) {
$config['namespace'] = $this->config['namespace'];
$config['title'] = $this->config['title'];
return parent::getConfig( $config );
}
}