'MediaWiki\\Widget\\Search\\SimpleSearchResultWidget' => __DIR__ . '/includes/widget/search/SimpleSearchResultWidget.php',
'MediaWiki\\Widget\\SelectWithInputWidget' => __DIR__ . '/includes/widget/SelectWithInputWidget.php',
'MediaWiki\\Widget\\SizeFilterWidget' => __DIR__ . '/includes/widget/SizeFilterWidget.php',
+ 'MediaWiki\\Widget\\TagMultiselectWidget' => __DIR__ . '/includes/widget/TagMultiselectWidget.php',
'MediaWiki\\Widget\\TitleInputWidget' => __DIR__ . '/includes/widget/TitleInputWidget.php',
'MediaWiki\\Widget\\TitlesMultiselectWidget' => __DIR__ . '/includes/widget/TitlesMultiselectWidget.php',
'MediaWiki\\Widget\\UserInputWidget' => __DIR__ . '/includes/widget/UserInputWidget.php',
* @return string
*/
protected function preText() {
- $this->getOutput()->addModuleStyles( 'mediawiki.widgets.TitlesMultiselectWidget.styles' );
+ $this->getOutput()->addModuleStyles( 'mediawiki.widgets.TagMultiselectWidget.styles' );
$this->getOutput()->addModules( [ 'mediawiki.special.block' ] );
$blockCIDRLimit = $this->getConfig()->get( 'BlockCIDRLimit' );
}
$out->addModules( 'mediawiki.special.preferences.ooui' );
- $out->addModuleStyles( 'mediawiki.special.preferences.styles.ooui' );
+ $out->addModuleStyles( [
+ 'mediawiki.special.preferences.styles.ooui',
+ 'mediawiki.widgets.TagMultiselectWidget.styles',
+ ] );
$out->addModuleStyles( 'oojs-ui-widgets.styles' );
$session = $this->getRequest()->getSession();
--- /dev/null
+<?php
+
+namespace MediaWiki\Widget;
+
+use OOUI\MultilineTextInputWidget;
+
+/**
+ * Abstract base class for widgets to select multiple users, titles,
+ * namespaces, etc.
+ *
+ * @copyright 2017 MediaWiki Widgets Team and others; see AUTHORS.txt
+ * @license MIT
+ */
+abstract class TagMultiselectWidget extends \OOUI\Widget {
+
+ protected $selectedArray = [];
+ protected $inputName = null;
+ protected $inputPlaceholder = null;
+ protected $tagLimit = null;
+
+ /**
+ * @param array $config Configuration options
+ * - array $config['default'] Array of items to use as preset data
+ * - array $config['name'] Name attribute (used in forms)
+ * - array $config['placeholder'] Placeholder message for input
+ * - array $config['input'] Config options for the input widget
+ * - number $config['tagLimit'] Maximum number of selected items
+ */
+ public function __construct( array $config = [] ) {
+ parent::__construct( $config );
+
+ // Properties
+ if ( isset( $config['default'] ) ) {
+ $this->selectedArray = $config['default'];
+ }
+ if ( isset( $config['name'] ) ) {
+ $this->inputName = $config['name'];
+ }
+ if ( isset( $config['placeholder'] ) ) {
+ $this->inputPlaceholder = $config['placeholder'];
+ }
+ if ( isset( $config['input'] ) ) {
+ $this->input = $config['input'];
+ } else {
+ $this->input = [];
+ }
+ if ( isset( $config['tagLimit'] ) ) {
+ $this->tagLimit = $config['tagLimit'];
+ }
+
+ $textarea = new MultilineTextInputWidget( array_merge( [
+ 'name' => $this->inputName,
+ 'value' => implode( "\n", $this->selectedArray ),
+ 'rows' => 10,
+ 'classes' => [
+ 'mw-widgets-tagMultiselectWidget-multilineTextInputWidget'
+ ],
+ ], $this->input ) );
+
+ $pending = new PendingTextInputWidget();
+
+ $this->appendContent( $textarea, $pending );
+ $this->addClasses( [ 'mw-widgets-tagMultiselectWidget' ] );
+ }
+
+ public function getConfig( &$config ) {
+ if ( $this->selectedArray !== null ) {
+ $config['selected'] = $this->selectedArray;
+ }
+ if ( $this->inputName !== null ) {
+ $config['name'] = $this->inputName;
+ }
+ if ( $this->inputPlaceholder !== null ) {
+ $config['placeholder'] = $this->inputPlaceholder;
+ }
+ if ( $this->input !== null ) {
+ $config['input'] = $this->input;
+ }
+ if ( $this->tagLimit !== null ) {
+ $config['tagLimit'] = $this->tagLimit;
+ }
+
+ $config['$overlay'] = true;
+ return parent::getConfig( $config );
+ }
+
+}
namespace MediaWiki\Widget;
-use OOUI\MultilineTextInputWidget;
-
/**
* Widget to select multiple titles.
*
* @copyright 2017 MediaWiki Widgets Team and others; see AUTHORS.txt
* @license MIT
*/
-class TitlesMultiselectWidget extends \OOUI\Widget {
+class TitlesMultiselectWidget extends TagMultiselectWidget {
- protected $titlesArray = [];
- protected $inputName = null;
- protected $inputPlaceholder = null;
- protected $tagLimit = null;
protected $showMissing = null;
/**
* @param array $config Configuration options
- * - array $config['default'] Array of titles to use as preset data
- * - array $config['placeholder'] Placeholder message for input
- * - array $config['name'] Name attribute (used in forms)
- * - number $config['tagLimit'] Maximum number of selected titles
* - bool $config['showMissing'] Show missing pages
- * - array $config['input'] Config options for the input widget
*/
public function __construct( array $config = [] ) {
parent::__construct( $config );
// Properties
- if ( isset( $config['default'] ) ) {
- $this->titlesArray = $config['default'];
- }
- if ( isset( $config['name'] ) ) {
- $this->inputName = $config['name'];
- }
- if ( isset( $config['placeholder'] ) ) {
- $this->inputPlaceholder = $config['placeholder'];
- }
- if ( isset( $config['tagLimit'] ) ) {
- $this->tagLimit = $config['tagLimit'];
- }
if ( isset( $config['showMissing'] ) ) {
$this->showMissing = $config['showMissing'];
}
- if ( isset( $config['input'] ) ) {
- $this->input = $config['input'];
- }
-
- $textarea = new MultilineTextInputWidget( array_merge( [
- 'name' => $this->inputName,
- 'value' => implode( "\n", $this->titlesArray ),
- 'rows' => 10,
- 'classes' => [
- 'mw-widgets-titlesMultiselectWidget-multilineTextInputWidget'
- ],
- ], $this->input ) );
- $pending = new PendingTextInputWidget();
-
- $this->appendContent( $textarea, $pending );
$this->addClasses( [ 'mw-widgets-titlesMultiselectWidget' ] );
}
}
public function getConfig( &$config ) {
- if ( $this->titlesArray !== null ) {
- $config['selected'] = $this->titlesArray;
- }
- if ( $this->inputName !== null ) {
- $config['name'] = $this->inputName;
- }
- if ( $this->inputPlaceholder !== null ) {
- $config['placeholder'] = $this->inputPlaceholder;
- }
- if ( $this->tagLimit !== null ) {
- $config['tagLimit'] = $this->tagLimit;
- }
if ( $this->showMissing !== null ) {
$config['showMissing'] = $this->showMissing;
}
- if ( $this->input !== null ) {
- $config['input'] = $this->input;
- }
- $config['$overlay'] = true;
return parent::getConfig( $config );
}
namespace MediaWiki\Widget;
-use OOUI\MultilineTextInputWidget;
-
/**
* Widget to select multiple users.
*
* @copyright 2017 MediaWiki Widgets Team and others; see AUTHORS.txt
* @license MIT
*/
-class UsersMultiselectWidget extends \OOUI\Widget {
-
- protected $usersArray = [];
- protected $inputName = null;
- protected $inputPlaceholder = null;
+class UsersMultiselectWidget extends TagMultiselectWidget {
/**
* @param array $config Configuration options
- * - array $config['users'] Array of usernames to use as preset data
- * - array $config['placeholder'] Placeholder message for input
- * - array $config['name'] Name attribute (used in forms)
*/
public function __construct( array $config = [] ) {
parent::__construct( $config );
-
- // Properties
- if ( isset( $config['default'] ) ) {
- $this->usersArray = $config['default'];
- }
- if ( isset( $config['name'] ) ) {
- $this->inputName = $config['name'];
- }
- if ( isset( $config['placeholder'] ) ) {
- $this->inputPlaceholder = $config['placeholder'];
- }
-
- $textarea = new MultilineTextInputWidget( [
- 'name' => $this->inputName,
- 'value' => implode( "\n", $this->usersArray ),
- 'rows' => 10,
- ] );
- $this->prependContent( $textarea );
}
protected function getJavaScriptClassName() {
}
public function getConfig( &$config ) {
- if ( $this->usersArray !== null ) {
- $config['selected'] = $this->usersArray;
- }
- if ( $this->inputName !== null ) {
- $config['name'] = $this->inputName;
- }
- if ( $this->inputPlaceholder !== null ) {
- $config['placeholder'] = $this->inputPlaceholder;
- }
-
- $config['$overlay'] = true;
return parent::getConfig( $config );
}
],
'targets' => [ 'desktop', 'mobile' ],
],
- 'mediawiki.widgets.TitlesMultiselectWidget.styles' => [
- 'styles' => 'resources/src/mediawiki.widgets/mw.widgets.TitlesMultiselectWidget.base.css',
+ 'mediawiki.widgets.TagMultiselectWidget.styles' => [
+ 'styles' => 'resources/src/mediawiki.widgets/mw.widgets.TagMultiselectWidget.base.css',
],
'mediawiki.widgets.SearchInputWidget' => [
'scripts' => [
--- /dev/null
+/*!
+ * MediaWiki Widgets - base TagMultiselectWidget styles.
+ *
+ * @copyright 2011-2018 MediaWiki Widgets Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+.client-nojs .mw-widgets-tagMultiselectWidget .mw-widgets-pendingTextInputWidget,
+.client-js .mw-widgets-tagMultiselectWidget .mw-widgets-tagMultiselectWidget-multilineTextInputWidget {
+ display: none;
+}
+++ /dev/null
-/*!
- * MediaWiki Widgets - base TitlesMultiselectWidget styles.
- *
- * @copyright 2011-2018 MediaWiki Widgets Team and others; see AUTHORS.txt
- * @license The MIT License (MIT); see LICENSE.txt
- */
-
-.client-nojs .mw-widgets-titlesMultiselectWidget .mw-widgets-pendingTextInputWidget,
-.client-js .mw-widgets-titlesMultiselectWidget .mw-widgets-titlesMultiselectWidget-multilineTextInputWidget {
- display: none;
-}