MediaWiki REL1_39
HTMLExpiryField.php
Go to the documentation of this file.
1<?php
2
4
12
16 protected $relativeField;
17
24 public function __construct( array $params = [] ) {
25 parent::__construct( $params );
26
27 $type = !empty( $params['options'] ) ? 'selectorother' : 'text';
28 $this->relativeField = $this->getFieldByType( $type );
29 }
30
36 public function getInputHTML( $value ) {
37 return $this->relativeField->getInputHTML( $value );
38 }
39
40 protected function shouldInfuseOOUI() {
41 return true;
42 }
43
47 protected function getOOUIModules() {
48 return array_merge(
49 [
50 'mediawiki.widgets.expiry',
51 ],
52 $this->relativeField->getOOUIModules()
53 );
54 }
55
59 public function getInputOOUI( $value ) {
60 return new ExpiryInputWidget(
61 $this->relativeField->getInputOOUI( $value ),
62 [
63 'id' => $this->mID,
64 'required' => $this->mParams['required'] ?? false,
65 ]
66 );
67 }
68
72 public function loadDataFromRequest( $request ) {
73 return $this->relativeField->loadDataFromRequest( $request );
74 }
75
82 protected function getFieldByType( $type ) {
83 $class = HTMLForm::$typeMappings[$type];
84 $params = $this->mParams;
85 $params['type'] = $type;
86 $params['class'] = $class;
87
88 // Remove Parameters that are being used on the parent.
89 unset( $params['label-message'] );
90 return new $class( $params );
91 }
92
93}
Expiry Field that allows the user to specify a precise date or a relative date string.
shouldInfuseOOUI()
Whether the field should be automatically infused.
__construct(array $params=[])
Relative Date Time Field.
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.Defaults to false, which getOOUI will interpret as "...
HTMLFormField $relativeField
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
getFieldByType( $type)
Get the HTMLForm field by the type string.
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
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 parent class to generate form fields.
array array[] $mParams