57 $config = array_merge( [
60 'longDisplayFormat' =>
false,
64 if ( isset( $config[
'inputFormat'] ) ) {
65 $this->inputFormat = $config[
'inputFormat'];
67 if ( isset( $config[
'placeholderDateFormat'] ) ) {
68 $this->placeholderDateFormat = $config[
'placeholderDateFormat'];
70 $this->precision = $config[
'precision'];
71 if ( isset( $config[
'mustBeAfter'] ) ) {
72 $this->mustBeAfter = $config[
'mustBeAfter'];
73 } elseif ( isset( $config[
'min'] ) ) {
74 $this->mustBeAfter = $this->modifyDate( $config[
'min'],
'-1 day' );
76 if ( isset( $config[
'mustBeBefore'] ) ) {
77 $this->mustBeBefore = $config[
'mustBeBefore'];
78 } elseif ( isset( $config[
'max'] ) ) {
79 $this->mustBeBefore = $this->modifyDate( $config[
'max'],
'+1 day' );
83 if ( isset( $config[
'displayFormat'] ) ) {
84 $this->displayFormat = $config[
'displayFormat'];
86 if ( isset( $config[
'longDisplayFormat'] ) ) {
87 $this->longDisplayFormat = $config[
'longDisplayFormat'];
89 if ( isset( $config[
'placeholderLabel'] ) ) {
90 $this->placeholderLabel = $config[
'placeholderLabel'];
94 if ( $this->placeholderDateFormat !==
null ) {
96 } elseif ( $this->inputFormat !==
null ) {
100 $placeholder =
wfMessage(
"mw-widgets-dateinput-placeholder-$this->precision" )->text();
103 $config = array_merge( [
105 'placeholder' => $placeholder,
108 parent::__construct( $config );
112 if ( $this->mustBeAfter !==
null ) {
113 $this->input->setAttributes( [
'min' => $this->modifyDate( $this->mustBeAfter,
'+1 day' ) ] );
115 if ( $this->mustBeBefore !==
null ) {
116 $this->input->setAttributes( [
'max' => $this->modifyDate( $this->mustBeBefore,
'-1 day' ) ] );
120 $this->addClasses( [
'mw-widget-dateInputWidget' ] );