class TitleInputWidget extends TextInputWidget {
protected $namespace = null;
+ protected $relative = null;
/**
* @param array $config Configuration options
- * @param number|null $config['namespace'] Namespace to prepend to queries
+ * @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)
*/
public function __construct( array $config = array() ) {
// Parent constructor
parent::__construct( array_merge( $config, array( 'infusable' => true ) ) );
- // Properties
+ // Properties, which are ignored in PHP and just shipped back to JS
if ( isset( $config['namespace'] ) ) {
- // Actually ignored in PHP, we just ship it back to JS
$this->namespace = $config['namespace'];
}
+ if ( isset( $config['relative'] ) ) {
+ $this->relative = $config['relative'];
+ }
+
// Initialization
$this->addClasses( array( 'mw-widget-TitleInputWidget' ) );
}
if ( $this->namespace !== null ) {
$config['namespace'] = $this->namespace;
}
+ if ( $this->relative !== null ) {
+ $config['relative'] = $this->relative;
+ }
return parent::getConfig( $config );
}
}
* @param {Object} [config] Configuration options
* @cfg {number} [limit=10] Number of results to show
* @cfg {number} [namespace] Namespace to prepend to queries
+ * @cfg {boolean} [relative=true] If a namespace is set, return a title relative to it
* @cfg {boolean} [showRedirectTargets=true] Show the targets of redirects
* @cfg {boolean} [showRedlink] Show red link to exact match if it doesn't exist
* @cfg {boolean} [showImages] Show page images
// Properties
this.limit = config.limit || 10;
this.namespace = config.namespace || null;
+ this.relative = config.relative !== undefined ? config.relative : true;
this.showRedirectTargets = config.showRedirectTargets !== false;
this.showRedlink = !!config.showRedlink;
this.showImages = !!config.showImages;
mw.widgets.TitleInputWidget.prototype.getOptionWidgetData = function ( title, data ) {
var mwTitle = new mw.Title( title );
return {
- data: this.namespace !== null ? mwTitle.getRelativeText( this.namespace ) : title,
+ data: this.namespace !== null && this.relative
+ ? mwTitle.getRelativeText( this.namespace )
+ : title,
imageUrl: this.showImages ? data.imageUrl : null,
description: this.showDescriptions ? data.description : null,
missing: data.missing,