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
45 protected function shouldInfuseOOUI() {
46 return true;
47 }
48
52 protected function getOOUIModules() {
53 return [ 'mediawiki.widgets.expiry', ...$this->relativeField->getOOUIModules() ];
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
70 public function getInputCodex( $value, $hasErrors ) {
71 return $this->relativeField->getInputCodex( $value, $hasErrors );
72 }
73
77 public function loadDataFromRequest( $request ) {
78 return $this->relativeField->loadDataFromRequest( $request );
79 }
80
87 protected function getFieldByType( $type ) {
88 $class = HTMLForm::$typeMappings[$type];
89 $params = $this->mParams;
90 $params['type'] = $type;
91 $params['class'] = $class;
92
93 // Remove Parameters that are being used on the parent.
94 unset( $params['label-message'] );
95 return new $class( $params );
96 }
97
98}
99
101class_alias( HTMLExpiryField::class, 'HTMLExpiryField' );
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.This is called by CodexHTMLForm.If not overridden,...
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.Note that all OOUI HTMLForm fields are infusable (y...
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:195
static string[] $typeMappings
A mapping of 'type' inputs onto standard HTMLFormField subclasses.
Definition HTMLForm.php:199