MediaWiki  1.30.2
DateTimeInputWidget.php
Go to the documentation of this file.
1 <?php
8 namespace MediaWiki\Widget;
9 
10 use OOUI\Tag;
11 
15 class DateTimeInputWidget extends \OOUI\InputWidget {
16 
17  protected $type = null;
18  protected $min = null;
19  protected $max = null;
20  protected $clearable = null;
21 
29  public function __construct( array $config = [] ) {
30  // We need $this->type set before calling the parent constructor
31  if ( isset( $config['type'] ) ) {
32  $this->type = $config['type'];
33  } else {
34  throw new \InvalidArgumentException( '$config[\'type\'] must be specified' );
35  }
36 
37  // Parent constructor
38  parent::__construct( $config );
39 
40  // Properties, which are ignored in PHP and just shipped back to JS
41  if ( isset( $config['min'] ) ) {
42  $this->min = $config['min'];
43  }
44  if ( isset( $config['max'] ) ) {
45  $this->max = $config['max'];
46  }
47  if ( isset( $config['clearable'] ) ) {
48  $this->clearable = $config['clearable'];
49  }
50 
51  // Initialization
52  $this->addClasses( [ 'mw-widgets-datetime-dateTimeInputWidget' ] );
53  }
54 
55  protected function getJavaScriptClassName() {
56  return 'mw.widgets.datetime.DateTimeInputWidget';
57  }
58 
59  public function getConfig( &$config ) {
60  $config['type'] = $this->type;
61  if ( $this->min !== null ) {
62  $config['min'] = $this->min;
63  }
64  if ( $this->max !== null ) {
65  $config['max'] = $this->max;
66  }
67  if ( $this->clearable !== null ) {
68  $config['clearable'] = $this->clearable;
69  }
70  return parent::getConfig( $config );
71  }
72 
73  protected function getInputElement( $config ) {
74  return ( new Tag( 'input' ) )->setAttributes( [ 'type' => $this->type ] );
75  }
76 }
type
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
Definition: postgres.txt:22
MediaWiki\Widget\DateTimeInputWidget\$min
$min
Definition: DateTimeInputWidget.php:18
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
MediaWiki\Widget\DateTimeInputWidget\getInputElement
getInputElement( $config)
Definition: DateTimeInputWidget.php:73
MediaWiki\Widget\DateTimeInputWidget\$type
$type
Definition: DateTimeInputWidget.php:17
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
MediaWiki\Widget\DateTimeInputWidget\$clearable
$clearable
Definition: DateTimeInputWidget.php:20
MediaWiki\Widget\DateTimeInputWidget\__construct
__construct(array $config=[])
Definition: DateTimeInputWidget.php:29
MediaWiki\Widget\DateTimeInputWidget\getConfig
getConfig(&$config)
Definition: DateTimeInputWidget.php:59
MediaWiki\Widget\DateTimeInputWidget\$max
$max
Definition: DateTimeInputWidget.php:19
MediaWiki\Widget
MediaWiki Widgets – ComplexNamespaceInputWidget class.
Definition: ComplexNamespaceInputWidget.php:8
MediaWiki\Widget\DateTimeInputWidget\getJavaScriptClassName
getJavaScriptClassName()
Definition: DateTimeInputWidget.php:55
MediaWiki\$config
Config $config
Definition: MediaWiki.php:42
MediaWiki\Widget\DateTimeInputWidget
Date-time input widget.
Definition: DateTimeInputWidget.php:15
array
the array() calling protocol came about after MediaWiki 1.4rc1.