Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 25
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
TitlesMultiselectWidget
0.00% covered (danger)
0.00%
0 / 25
0.00% covered (danger)
0.00%
0 / 3
182
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
42
 getJavaScriptClassName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getConfig
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
42
1<?php
2
3namespace MediaWiki\Widget;
4
5/**
6 * Widget to select multiple titles.
7 *
8 * @copyright 2017 MediaWiki Widgets Team and others; see AUTHORS.txt
9 * @license MIT
10 */
11class TitlesMultiselectWidget extends TagMultiselectWidget {
12
13    /** @var bool|null */
14    protected $showMissing = null;
15    /** @var bool|null */
16    protected $excludeDynamicNamespaces = null;
17    /** @var int|null */
18    protected $namespace = null;
19    /** @var bool|null */
20    protected $relative = null;
21    /** @var bool|null */
22    protected $allowEditTags = null;
23
24    /**
25     * @param array $config Configuration options
26     *   - bool $config['showMissing'] Show missing pages in the typeahead dropdown
27     *     (ie. allow adding pages that don't exist)
28     *   - bool $config['excludeDynamicNamespaces'] Exclude pages in negative namespaces
29     *   - bool $config['namespace'] Shows pages only from the specified namespace
30     *   - bool $config['relative'] Include namespace names in form data, if 'namespace' config is used
31     *   - bool $config['allowEditTags'] Allow editing of the tags by clicking them
32     */
33    public function __construct( array $config = [] ) {
34        parent::__construct( $config );
35
36        // Properties
37        if ( isset( $config['showMissing'] ) ) {
38            $this->showMissing = $config['showMissing'];
39        }
40        if ( isset( $config['excludeDynamicNamespaces'] ) ) {
41            $this->excludeDynamicNamespaces = $config['excludeDynamicNamespaces'];
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['allowEditTags'] ) ) {
50            $this->allowEditTags = $config['allowEditTags'];
51        }
52
53        $this->addClasses( [ 'mw-widgets-titlesMultiselectWidget' ] );
54    }
55
56    /** @inheritDoc */
57    protected function getJavaScriptClassName() {
58        return 'mw.widgets.TitlesMultiselectWidget';
59    }
60
61    /** @inheritDoc */
62    public function getConfig( &$config ) {
63        if ( $this->showMissing !== null ) {
64            $config['showMissing'] = $this->showMissing;
65        }
66        if ( $this->excludeDynamicNamespaces !== null ) {
67            $config['excludeDynamicNamespaces'] = $this->excludeDynamicNamespaces;
68        }
69        if ( $this->namespace !== null ) {
70            $config['namespace'] = $this->namespace;
71        }
72        if ( $this->relative !== null ) {
73            $config['relative'] = $this->relative;
74        }
75        if ( $this->allowEditTags !== null ) {
76            $config['allowEditTags'] = $this->allowEditTags;
77        }
78
79        return parent::getConfig( $config );
80    }
81
82}