Migrate remaining usages of Title::userCan() to PermissionManager
[lhc/web/wiklou.git] / includes / widget / TitlesMultiselectWidget.php
index 0a50fcd..ac34259 100644 (file)
@@ -2,66 +2,33 @@
 
 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;
+       protected $excludeDynamicNamespaces = null;
 
        /**
         * @param array $config Configuration options
-        *   - array $config['titles'] 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
+        *   - bool $config['excludeDynamicNamespaces'] Exclude pages in negative namespaces
         */
        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'];
+               if ( isset( $config['excludeDynamicNamespaces'] ) ) {
+                       $this->excludeDynamicNamespaces = $config['excludeDynamicNamespaces'];
                }
 
-               $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' ] );
        }
 
@@ -70,26 +37,13 @@ class TitlesMultiselectWidget extends \OOUI\Widget {
        }
 
        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;
+               if ( $this->excludeDynamicNamespaces !== null ) {
+                       $config['excludeDynamicNamespaces'] = $this->excludeDynamicNamespaces;
                }
 
-               $config['$overlay'] = true;
                return parent::getConfig( $config );
        }