MediaWiki  1.34.0
HTMLExpiryField.php
Go to the documentation of this file.
1 <?php
2 
4 
10 
14  protected $relativeField;
15 
20  public function __construct( array $params = [] ) {
21  parent::__construct( $params );
22 
23  $type = !empty( $params['options'] ) ? 'selectorother' : 'text';
24  $this->relativeField = $this->getFieldByType( $type );
25  }
26 
32  public function getInputHTML( $value ) {
33  return $this->relativeField->getInputHTML( $value );
34  }
35 
36  protected function shouldInfuseOOUI() {
37  return true;
38  }
39 
43  protected function getOOUIModules() {
44  return array_merge(
45  [
46  'mediawiki.widgets.expiry',
47  ],
48  $this->relativeField->getOOUIModules()
49  );
50  }
51 
55  public function getInputOOUI( $value ) {
56  return new ExpiryInputWidget(
57  $this->relativeField->getInputOOUI( $value ),
58  [
59  'id' => $this->mID,
60  'required' => $this->mParams['required'] ?? false,
61  ]
62  );
63  }
64 
68  public function loadDataFromRequest( $request ) {
69  return $this->relativeField->loadDataFromRequest( $request );
70  }
71 
78  protected function getFieldByType( $type ) {
80  $params = $this->mParams;
81  $params['type'] = $type;
82  $params['class'] = $class;
83 
84  // Remove Parameters that are being used on the parent.
85  unset( $params['label-message'] );
86  return new $class( $params );
87  }
88 
89 }
HTMLForm\$typeMappings
static $typeMappings
Definition: HTMLForm.php:133
HTMLExpiryField\getInputHTML
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
Definition: HTMLExpiryField.php:32
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:55
HTMLExpiryField\shouldInfuseOOUI
shouldInfuseOOUI()
Whether the field should be automatically infused.
Definition: HTMLExpiryField.php:36
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:68
HTMLFormField
The parent class to generate form fields.
Definition: HTMLFormField.php:7
HTMLFormField\$mID
$mID
Definition: HTMLFormField.php:16
HTMLExpiryField\$relativeField
HTMLFormField $relativeField
Definition: HTMLExpiryField.php:14
HTMLExpiryField\getFieldByType
getFieldByType( $type)
Get the HTMLForm field by the type string.
Definition: HTMLExpiryField.php:78
HTMLFormField\$mParams
array array[] $mParams
Definition: HTMLFormField.php:9
HTMLExpiryField
Expiry Field that allows the user to specify a precise date or a relative date string.
Definition: HTMLExpiryField.php:9
HTMLExpiryField\getOOUIModules
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
Definition: HTMLExpiryField.php:43
HTMLExpiryField\__construct
__construct(array $params=[])
Relative Date Time Field.
Definition: HTMLExpiryField.php:20
$type
$type
Definition: testCompression.php:48