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();
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' ] );
135 return 'mw.widgets.DateInputWidget';
139 if ( $this->inputFormat !==
null ) {
142 if ( $this->displayFormat !==
null ) {
145 if ( $this->longDisplayFormat !==
null ) {
148 if ( $this->placeholderLabel !==
null ) {
151 if ( $this->placeholderDateFormat !==
null ) {
154 if ( $this->precision !==
null ) {
157 if ( $this->mustBeAfter !==
null ) {
160 if ( $this->mustBeBefore !==
null ) {
163 if ( $this->overlay !==
null ) {
166 return parent::getConfig(
$config );
171 return parent::getInputElement(
$config )
173 'type' => (
$config[
'precision'] ===
'month' ) ?
'month' :
'date'