55 'longDisplayFormat' =>
false,
59 if ( isset(
$config[
'inputFormat'] ) ) {
60 $this->inputFormat =
$config[
'inputFormat'];
62 if ( isset(
$config[
'placeholderDateFormat'] ) ) {
63 $this->placeholderDateFormat =
$config[
'placeholderDateFormat'];
65 $this->precision =
$config[
'precision'];
66 if ( isset(
$config[
'mustBeAfter'] ) ) {
67 $this->mustBeAfter =
$config[
'mustBeAfter'];
69 if ( isset(
$config[
'mustBeBefore'] ) ) {
70 $this->mustBeBefore =
$config[
'mustBeBefore'];
74 if ( isset(
$config[
'displayFormat'] ) ) {
75 $this->displayFormat =
$config[
'displayFormat'];
77 if ( isset(
$config[
'longDisplayFormat'] ) ) {
78 $this->longDisplayFormat =
$config[
'longDisplayFormat'];
80 if ( isset(
$config[
'placeholderLabel'] ) ) {
81 $this->placeholderLabel =
$config[
'placeholderLabel'];
85 if ( $this->placeholderDateFormat !==
null ) {
87 } elseif ( $this->inputFormat !==
null ) {
91 $placeholder =
wfMessage(
"mw-widgets-dateinput-placeholder-$this->precision" )->text();
96 'placeholder' => $placeholder,
103 if ( $this->mustBeAfter !==
null ) {
104 $min =
new DateTime( $this->mustBeAfter );
105 $min = $min->modify(
'+1 day' );
106 $min = $min->format(
'Y-m-d' );
107 $this->input->setAttributes( [
'min' => $min ] );
109 if ( $this->mustBeBefore !==
null ) {
110 $max =
new DateTime( $this->mustBeBefore );
111 $max = $max->modify(
'-1 day' );
112 $max = $max->format(
'Y-m-d' );
113 $this->input->setAttributes( [
'max' => $max ] );
117 $this->addClasses( [
'mw-widget-dateInputWidget' ] );
121 return 'mw.widgets.DateInputWidget';
125 if ( $this->inputFormat !==
null ) {
128 if ( $this->displayFormat !==
null ) {
131 if ( $this->longDisplayFormat !==
null ) {
134 if ( $this->placeholderLabel !==
null ) {
137 if ( $this->placeholderDateFormat !==
null ) {
140 if ( $this->precision !==
null ) {
143 if ( $this->mustBeAfter !==
null ) {
146 if ( $this->mustBeBefore !==
null ) {
150 return parent::getConfig(
$config );
155 return parent::getInputElement(
$config )
157 'type' => (
$config[
'precision'] ===
'month' ) ?
'month' :
'date'