Go to the documentation of this file.
21 'date' =>
'[0-9]{4}-[01][0-9]-[0-3][0-9]',
22 'time' =>
'[0-2][0-9]:[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?',
23 'datetime' =>
'[0-9]{4}-[01][0-9]-[0-3][0-9][T ][0-2][0-9]:[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?Z?',
31 $this->mType = array_key_exists(
'type',
$params )
35 if ( !in_array( $this->mType, [
'date',
'time',
'datetime' ] ) ) {
36 throw new InvalidArgumentException(
"Invalid type '$this->mType'" );
39 if ( $this->mPlaceholder ===
'' ) {
41 $this->mPlaceholder = $this->
msg(
"htmlform-{$this->mType}-placeholder" )->text();
44 $this->mClass .=
' mw-htmlform-datetime-field';
48 $parentList = array_diff( $list, [
'min',
'max' ] );
49 $ret = parent::getAttributes( $parentList );
51 if ( in_array(
'min', $list ) && isset( $this->mParams[
'min'] ) ) {
52 $min = $this->
parseDate( $this->mParams[
'min'] );
57 if ( in_array(
'max', $list ) && isset( $this->mParams[
'max'] ) ) {
58 $max = $this->
parseDate( $this->mParams[
'max'] );
73 if ( !
$request->getCheck( $this->mName ) ) {
83 $p = parent::validate(
$value, $alldata );
97 return $this->
msg(
"htmlform-{$this->mType}-invalid" );
100 if ( isset( $this->mParams[
'min'] ) ) {
101 $min = $this->
parseDate( $this->mParams[
'min'] );
102 if ( $min && $date < $min ) {
104 return $this->
msg(
"htmlform-{$this->mType}-toolow", $this->
formatDate( $min ) );
108 if ( isset( $this->mParams[
'max'] ) ) {
109 $max = $this->
parseDate( $this->mParams[
'max'] );
110 if ( $max && $date > $max ) {
112 return $this->
msg(
"htmlform-{$this->mType}-toohigh", $this->
formatDate( $max ) );
125 if ( $this->mType ===
'date' ) {
126 $value .=
' T00:00:00+0000';
128 if ( $this->mType ===
'time' ) {
133 $date =
new DateTime(
$value,
new DateTimeZone(
'GMT' ) );
134 return $date->getTimestamp();
135 }
catch ( Exception $ex ) {
141 switch ( $this->mType ) {
143 return gmdate(
'Y-m-d',
$value );
146 return gmdate(
'H:i:s',
$value );
149 return gmdate(
'Y-m-d\\TH:i:s\\Z',
$value );
161 if ( isset( $this->mParams[
'min'] ) ) {
162 $min = $this->
parseDate( $this->mParams[
'min'] );
167 if ( isset( $this->mParams[
'max'] ) ) {
168 $max = $this->
parseDate( $this->mParams[
'max'] );
178 return [
'mediawiki.widgets.datetime' ];
shouldInfuseOOUI()
Whether the field should be automatically infused.
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.
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
A field that will contain a date and/or time.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
validate( $value, $alldata)
Override this function to add specific validation checks on the field input.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
getAttributes(array $list)
Returns the given attributes from the parameters.
loadDataFromRequest( $request)
Get the value that this input has been set to from a posted form, or the input's default value if it ...
the array() calling protocol came about after MediaWiki 1.4rc1.