Skip to content

Commit

Permalink
Merge pull request #211 from garyee/Branch_3.3.5
Browse files Browse the repository at this point in the history
fixed Dateformat FE php error
  • Loading branch information
davidmaack authored Dec 21, 2016
2 parents 959d7cc + 3019bf9 commit 8a25af9
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions system/modules/multicolumnwizard/MultiColumnWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ protected function validator($varInput)

// Convert date formats into timestamps (check the eval setting first -> #3063)
$rgxp = $arrField['eval']['rgxp'];
if (($rgxp == 'date' || $rgxp == 'time' || $rgxp == 'datim') && $varValue != '')
if (!$objWidget->hasErrors() && ($rgxp == 'date' || $rgxp == 'time' || $rgxp == 'datim') && $varValue != '')
{
$objDate = new Date($varValue, $GLOBALS['TL_CONFIG'][$rgxp . 'Format']);
$objDate = new Date($varValue,$this->getNumericDateFormat($rgxp));
$varValue = $objDate->tstamp;
}

Expand Down Expand Up @@ -526,7 +526,7 @@ public function generate()
if ($arrField['eval']['datepicker'])
{
$rgxp = $arrField['eval']['rgxp'];
$format = $GLOBALS['TL_CONFIG'][$rgxp . 'Format'];
$format = $this->getNumericDateFormat($rgxp);

switch ($rgxp)
{
Expand Down Expand Up @@ -673,7 +673,7 @@ protected function getMcWDatePickerString($strId, $strKey, $rgxp)
{
if (version_compare(VERSION, '2.11', '<'))
{
$format = $GLOBALS['TL_CONFIG'][$rgxp . 'Format'];
$format = $this->getNumericDateFormat($rgxp);
switch ($rgxp)
{
case 'datim':
Expand Down Expand Up @@ -711,7 +711,7 @@ protected function getMcWDatePickerString($strId, $strKey, $rgxp)

elseif (version_compare(VERSION,'3.3','<')) {

$format = Date::formatToJs($GLOBALS['TL_CONFIG'][$rgxp . 'Format']);
$format = Date::formatToJs($this->getNumericDateFormat($rgxp));
switch ($rgxp)
{
case 'datim':
Expand Down Expand Up @@ -747,7 +747,7 @@ protected function getMcWDatePickerString($strId, $strKey, $rgxp)

else
{
$format = Date::formatToJs($GLOBALS['TL_CONFIG'][$rgxp . 'Format']);
$format = Date::formatToJs($this->getNumericDateFormat($rgxp));
switch ($rgxp)
{
case 'datim':
Expand Down Expand Up @@ -949,9 +949,15 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue)

// Convert date formats into timestamps (check the eval setting first -> #3063)
$rgxp = $arrField['eval']['rgxp'];
$dateFormatErrorMsg="";
if (($rgxp == 'date' || $rgxp == 'time' || $rgxp == 'datim') && $varValue != '')
{
$objDate = new Date($varValue, $GLOBALS['TL_CONFIG'][$rgxp . 'Format']);
try{
$objDate = new Date($varValue, $this->getNumericDateFormat($rgxp));
}catch(\Exception $e){
$dateFormatErrorMsg=$e->getMessage();
}

$varValue = $objDate->tstamp;
}

Expand All @@ -973,6 +979,9 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue)
$objWidget->storeValues = true;
$objWidget->xlabel = $xlabel;
$objWidget->currentRecord = $this->currentRecord;
if(!empty($dateFormatErrorMsg)){
$objWidget->addError($e->getMessage());
}

return $objWidget;
}
Expand Down Expand Up @@ -1234,4 +1243,15 @@ protected function generateButtonString($level = 0)
return $return;
}

/**
* Get Time/Date-format from global config (BE) or Page settings (FE)
* @param $rgxp
*
* @return mixed
*/
private function getNumericDateFormat($rgxp){
return call_user_func(array("\Contao\Date","getNumeric".ucfirst($rgxp)."Format" ));
}


}

0 comments on commit 8a25af9

Please sign in to comment.