3 namespace MediaWiki\Widget
;
10 * Allows the user to toggle between a precise time or enter a relative time,
11 * regardless, the value comes in as a relative time.
13 * @copyright 2018 MediaWiki Widgets Team and others; see AUTHORS.txt
16 class ExpiryInputWidget
extends Widget
{
21 protected $relativeInput;
26 protected $noDatePicker;
34 * @param Widget $relativeInput
35 * @param array $options Configuration options
37 public function __construct( Widget
$relativeInput, array $options = [] ) {
38 $config = \RequestContext
::getMain()->getConfig();
40 $options['noDatePicker'] = $config->get( 'ExpiryWidgetNoDatePicker' );
42 parent
::__construct( $options );
44 $this->noDatePicker
= $options['noDatePicker'];
45 $this->required
= $options['required'] ??
false;
48 $this->relativeInput
= $relativeInput;
49 $this->relativeInput
->addClasses( [ 'mw-widget-ExpiryWidget-relative' ] );
53 'mw-widget-ExpiryWidget',
55 if ( $options['noDatePicker'] === false ) {
56 $classes[] = 'mw-widget-ExpiryWidget-hasDatePicker';
59 ->addClasses( $classes )
60 ->appendContent( $this->relativeInput
);
63 protected function getJavaScriptClassName() {
64 return 'mw.widgets.ExpiryWidget';
70 public function getConfig( &$config ) {
71 $config['noDatePicker'] = $this->noDatePicker
;
72 $config['required'] = $this->required
;
73 $config['relativeInput'] = [];
74 $this->relativeInput
->getConfig( $config['relativeInput'] );
75 return parent
::getConfig( $config );