MediaWiki master
HTMLExpiryField.php
Go to the documentation of this file.
1<?php
2
4
8
16
20 protected $relativeField;
21
28 public function __construct( array $params = [] ) {
29 parent::__construct( $params );
30
31 $type = !empty( $params['options'] ) ? 'selectorother' : 'text';
32 $this->relativeField = $this->getFieldByType( $type );
33 }
34
40 public function getInputHTML( $value ) {
41 return $this->relativeField->getInputHTML( $value );
42 }
43
44 protected function shouldInfuseOOUI() {
45 return true;
46 }
47
51 protected function getOOUIModules() {
52 return array_merge(
53 [
54 'mediawiki.widgets.expiry',
55 ],
56 $this->relativeField->getOOUIModules()
57 );
58 }
59
63 public function getInputOOUI( $value ) {
64 return new ExpiryInputWidget(
65 $this->relativeField->getInputOOUI( $value ),
66 [
67 'id' => $this->mID,
68 'required' => $this->mParams['required'] ?? false,
69 ]
70 );
71 }
72
73 public function getInputCodex( $value, $hasErrors ) {
74 return $this->relativeField->getInputCodex( $value, $hasErrors );
75 }
76
80 public function loadDataFromRequest( $request ) {
81 return $this->relativeField->loadDataFromRequest( $request );
82 }
83
90 protected function getFieldByType( $type ) {
91 $class = HTMLForm::$typeMappings[$type];
93 $params['type'] = $type;
94 $params['class'] = $class;
95
96 // Remove Parameters that are being used on the parent.
97 unset( $params['label-message'] );
98 return new $class( $params );
99 }
100
101}
102
104class_alias( HTMLExpiryField::class, 'HTMLExpiryField' );
array $params
The job parameters.
Expiry Field that allows the user to specify a precise date or a relative date string.
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
__construct(array $params=[])
Relative Date Time Field.
getInputCodex( $value, $hasErrors)
Same as getInputHTML, but for Codex.
getFieldByType( $type)
Get the HTMLForm field by the type string.
loadDataFromRequest( $request)
Get the value that this input has been set to from a posted form, or the input's default value if it ...
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
shouldInfuseOOUI()
Whether the field should be automatically infused.
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.Defaults to false, which getOOUI will interpret as "...
The parent class to generate form fields.
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:206
static string[] $typeMappings
A mapping of 'type' inputs onto standard HTMLFormField subclasses.
Definition HTMLForm.php:210