From cb8bf4cba75e387c0b48c0fb98588de8230fd85c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 29 Aug 2013 14:10:48 +0200 Subject: [PATCH] GeneralForm: Code fixes Made that the user's last configuration is previewed in case the input is invalid. refs #4609 --- application/forms/Config/GeneralForm.php | 12 +++++++++--- application/forms/Preference/GeneralForm.php | 16 ++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/application/forms/Config/GeneralForm.php b/application/forms/Config/GeneralForm.php index 749ee6dd1..d1bed4125 100644 --- a/application/forms/Config/GeneralForm.php +++ b/application/forms/Config/GeneralForm.php @@ -66,7 +66,7 @@ class GeneralForm extends Form * * @var null */ - private $resources = null; + private $resources; /** * The view helper to format date/time strings @@ -239,7 +239,10 @@ class GeneralForm extends Form $phpUrl = '' . 'the official PHP documentation'; - $dateFormatValue = $this->getRequest()->getParam('date_format', $cfg->get('dateFormat', 'd/m/Y')); + $dateFormatValue = $this->getRequest()->getParam('date_format', ''); + if (empty($dateFormatValue)) { + $dateFormatValue = $cfg->get('dateFormat', 'd/m/Y'); + } $txtDefaultDateFormat = new Zend_Form_Element_Text( array( 'name' => 'date_format', @@ -253,7 +256,10 @@ class GeneralForm extends Form $this->addElement($txtDefaultDateFormat); $txtDefaultDateFormat->addValidator(new DateFormatValidator()); - $timeFormatValue = $this->getRequest()->getParam('time_format', $cfg->get('timeFormat', 'g:i A')); + $timeFormatValue = $this->getRequest()->getParam('time_format', ''); + if (empty($timeFormatValue)) { + $timeFormatValue = $cfg->get('timeFormat', 'g:i A'); + } $txtDefaultTimeFormat = new Zend_Form_Element_Text( array( 'name' => 'time_format', diff --git a/application/forms/Preference/GeneralForm.php b/application/forms/Preference/GeneralForm.php index 6ff51f6a9..08ad13dfc 100644 --- a/application/forms/Preference/GeneralForm.php +++ b/application/forms/Preference/GeneralForm.php @@ -192,10 +192,10 @@ class GeneralForm extends Form 'required' => true ) ); - $dateFormatValue = $this->getRequest()->getParam( - 'date_format', - $prefs->get('app.dateFormat', $cfg->get('dateFormat', 'd/m/Y')) - ); + $dateFormatValue = $this->getRequest()->getParam('date_format', ''); + if (empty($dateFormatValue)) { + $dateFormatValue = $prefs->get('app.dateFormat', $cfg->get('dateFormat', 'd/m/Y')); + } $txtDefaultDateFormat = new Zend_Form_Element_Text( array( 'name' => 'date_format', @@ -222,10 +222,10 @@ class GeneralForm extends Form 'required' => !$useGlobalTimeFormat ) ); - $timeFormatValue = $this->getRequest()->getParam( - 'time_format', - $prefs->get('app.timeFormat', $cfg->get('timeFormat', 'g:i A')) - ); + $timeFormatValue = $this->getRequest()->getParam('time_format', ''); + if (empty($timeFormatValue)) { + $timeFormatValue = $prefs->get('app.timeFormat', $cfg->get('timeFormat', 'g:i A')); + } $txtDefaultTimeFormat = new Zend_Form_Element_Text( array( 'name' => 'time_format',