Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| ExpiryInputWidget | |
0.00% |
0 / 15 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
| getJavaScriptClassName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getConfig | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Widget; |
| 4 | |
| 5 | use OOUI\Widget; |
| 6 | |
| 7 | /** |
| 8 | * Expiry widget. |
| 9 | * |
| 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. |
| 12 | * |
| 13 | * @copyright 2018 MediaWiki Widgets Team and others; see AUTHORS.txt |
| 14 | * @license MIT |
| 15 | */ |
| 16 | class ExpiryInputWidget extends Widget { |
| 17 | |
| 18 | /** |
| 19 | * @var Widget |
| 20 | */ |
| 21 | protected $relativeInput; |
| 22 | |
| 23 | /** |
| 24 | * @var bool |
| 25 | */ |
| 26 | protected $required; |
| 27 | |
| 28 | /** |
| 29 | * @param Widget $relativeInput |
| 30 | * @param array $options Configuration options |
| 31 | */ |
| 32 | public function __construct( Widget $relativeInput, array $options = [] ) { |
| 33 | parent::__construct( $options ); |
| 34 | |
| 35 | $this->required = $options['required'] ?? false; |
| 36 | |
| 37 | // Properties |
| 38 | $this->relativeInput = $relativeInput; |
| 39 | $this->relativeInput->addClasses( [ 'mw-widget-ExpiryWidget-relative' ] ); |
| 40 | |
| 41 | // Initialization |
| 42 | $this |
| 43 | ->addClasses( [ |
| 44 | 'mw-widget-ExpiryWidget', |
| 45 | 'mw-widget-ExpiryWidget-hasDatePicker' |
| 46 | ] ) |
| 47 | ->appendContent( $this->relativeInput ); |
| 48 | } |
| 49 | |
| 50 | /** @inheritDoc */ |
| 51 | protected function getJavaScriptClassName() { |
| 52 | return 'mw.widgets.ExpiryWidget'; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * @inheritDoc |
| 57 | */ |
| 58 | public function getConfig( &$config ) { |
| 59 | $config['required'] = $this->required; |
| 60 | $config['relativeInput'] = []; |
| 61 | $this->relativeInput->getConfig( $config['relativeInput'] ); |
| 62 | return parent::getConfig( $config ); |
| 63 | } |
| 64 | } |