62 $config = array_merge( [
65 'longDisplayFormat' =>
false,
69 if ( isset( $config[
'inputFormat'] ) ) {
70 $this->inputFormat = $config[
'inputFormat'];
72 if ( isset( $config[
'placeholderDateFormat'] ) ) {
73 $this->placeholderDateFormat = $config[
'placeholderDateFormat'];
75 $this->precision = $config[
'precision'];
76 if ( isset( $config[
'mustBeAfter'] ) ) {
77 $this->mustBeAfter = $config[
'mustBeAfter'];
79 if ( isset( $config[
'mustBeBefore'] ) ) {
80 $this->mustBeBefore = $config[
'mustBeBefore'];
84 if ( isset( $config[
'displayFormat'] ) ) {
85 $this->displayFormat = $config[
'displayFormat'];
87 if ( isset( $config[
'longDisplayFormat'] ) ) {
88 $this->longDisplayFormat = $config[
'longDisplayFormat'];
90 if ( isset( $config[
'placeholderLabel'] ) ) {
91 $this->placeholderLabel = $config[
'placeholderLabel'];
93 if ( isset( $config[
'overlay'] ) ) {
94 $this->overlay = $config[
'overlay'];
98 if ( $this->placeholderDateFormat !==
null ) {
100 } elseif ( $this->inputFormat !==
null ) {
104 $placeholder =
wfMessage(
"mw-widgets-dateinput-placeholder-$this->precision" )->text();
107 $config = array_merge( [
109 'placeholder' => $placeholder,
113 parent::__construct( $config );
117 if ( $this->mustBeAfter !==
null ) {
118 $min =
new DateTime( $this->mustBeAfter );
119 $min = $min->modify(
'+1 day' );
120 $min = $min->format(
'Y-m-d' );
121 $this->input->setAttributes( [
'min' => $min ] );
123 if ( $this->mustBeBefore !==
null ) {
124 $max =
new DateTime( $this->mustBeBefore );
125 $max = $max->modify(
'-1 day' );
126 $max = $max->format(
'Y-m-d' );
127 $this->input->setAttributes( [
'max' => $max ] );
131 $this->addClasses( [
'mw-widget-dateInputWidget' ] );