MediaWiki  master
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 ) {
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 }
HTMLForm\$typeMappings
static $typeMappings
Definition: HTMLForm.php:139
HTMLExpiryField\getInputHTML
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
Definition: HTMLExpiryField.php:36
MediaWiki\Widget\ExpiryInputWidget
Expiry widget.
Definition: ExpiryInputWidget.php:16
HTMLExpiryField\getInputOOUI
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.Defaults to false, which getOOUI will interpret as "...
Definition: HTMLExpiryField.php:59
HTMLExpiryField\shouldInfuseOOUI
shouldInfuseOOUI()
Whether the field should be automatically infused.
Definition: HTMLExpiryField.php:40
HTMLExpiryField\loadDataFromRequest
loadDataFromRequest( $request)
Get the value that this input has been set to from a posted form, or the input's default value if it ...
Definition: HTMLExpiryField.php:72
HTMLFormField
The parent class to generate form fields.
Definition: HTMLFormField.php:9
HTMLExpiryField\$relativeField
HTMLFormField $relativeField
Definition: HTMLExpiryField.php:16
HTMLExpiryField\getFieldByType
getFieldByType( $type)
Get the HTMLForm field by the type string.
Definition: HTMLExpiryField.php:82
HTMLFormField\$mParams
array array[] $mParams
Definition: HTMLFormField.php:11
HTMLExpiryField
Expiry Field that allows the user to specify a precise date or a relative date string.
Definition: HTMLExpiryField.php:11
HTMLExpiryField\getOOUIModules
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
Definition: HTMLExpiryField.php:47
HTMLExpiryField\__construct
__construct(array $params=[])
Relative Date Time Field.
Definition: HTMLExpiryField.php:24
$type
$type
Definition: testCompression.php:52