TitlesMultiselectWidget.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace MediaWiki\Widget;
  3. /**
  4. * Widget to select multiple titles.
  5. *
  6. * @copyright 2017 MediaWiki Widgets Team and others; see AUTHORS.txt
  7. * @license MIT
  8. */
  9. class TitlesMultiselectWidget extends TagMultiselectWidget {
  10. protected $showMissing = null;
  11. protected $excludeDynamicNamespaces = null;
  12. /**
  13. * @param array $config Configuration options
  14. * - bool $config['showMissing'] Show missing pages
  15. * - bool $config['excludeDynamicNamespaces'] Exclude pages in negative namespaces
  16. */
  17. public function __construct( array $config = [] ) {
  18. parent::__construct( $config );
  19. // Properties
  20. if ( isset( $config['showMissing'] ) ) {
  21. $this->showMissing = $config['showMissing'];
  22. }
  23. if ( isset( $config['excludeDynamicNamespaces'] ) ) {
  24. $this->excludeDynamicNamespaces = $config['excludeDynamicNamespaces'];
  25. }
  26. $this->addClasses( [ 'mw-widgets-titlesMultiselectWidget' ] );
  27. }
  28. protected function getJavaScriptClassName() {
  29. return 'mw.widgets.TitlesMultiselectWidget';
  30. }
  31. public function getConfig( &$config ) {
  32. if ( $this->showMissing !== null ) {
  33. $config['showMissing'] = $this->showMissing;
  34. }
  35. if ( $this->excludeDynamicNamespaces !== null ) {
  36. $config['excludeDynamicNamespaces'] = $this->excludeDynamicNamespaces;
  37. }
  38. return parent::getConfig( $config );
  39. }
  40. }