From 74241258f55f7c4dc4ec134f106a4a3c43c25bb3 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 28 Aug 2013 10:50:10 +0200 Subject: [PATCH] Preview example date/time results in configuration views refs #4609 --- application/forms/Config/GeneralForm.php | 12 ++++++++---- application/forms/Preference/GeneralForm.php | 18 ++++++++++++++---- application/views/helpers/DateFormat.php | 2 +- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/application/forms/Config/GeneralForm.php b/application/forms/Config/GeneralForm.php index f80a12c65..78f0fb33a 100644 --- a/application/forms/Config/GeneralForm.php +++ b/application/forms/Config/GeneralForm.php @@ -209,25 +209,29 @@ class GeneralForm extends Form $phpUrl = '' . 'the official PHP documentation'; + $dateFormatValue = $this->getRequest()->getParam('date_format', $cfg->get('dateFormat', 'd/m/Y')); $txtDefaultDateFormat = new Zend_Form_Element_Text( array( 'name' => 'date_format', 'label' => 'Date Format', - 'helptext' => 'Display dates according to this format. See ' . $phpUrl . ' for possible values', + 'helptext' => 'Display dates according to this format. (See ' . $phpUrl . ' for possible values.) ' + . 'Example result: ' . $this->getView()->dateFormat()->format(time(), $dateFormatValue), 'required' => true, - 'value' => $cfg->get('dateFormat', 'd/m/Y') + 'value' => $dateFormatValue ) ); $this->addElement($txtDefaultDateFormat); $txtDefaultDateFormat->addValidator(new DateFormatValidator()); + $timeFormatValue = $this->getRequest()->getParam('time_format', $cfg->get('timeFormat', 'g:i A')); $txtDefaultTimeFormat = new Zend_Form_Element_Text( array( 'name' => 'time_format', 'label' => 'Time Format', 'required' => true, - 'helptext' => 'Display times according to this format. See ' . $phpUrl . ' for possible values', - 'value' => $cfg->get('timeFormat', 'g:i A') + 'helptext' => 'Display times according to this format. (See ' . $phpUrl . ' for possible values.) ' + . 'Example result: ' . $this->getView()->dateFormat()->format(time(), $timeFormatValue), + 'value' => $timeFormatValue ) ); $txtDefaultTimeFormat->addValidator(new TimeFormatValidator()); diff --git a/application/forms/Preference/GeneralForm.php b/application/forms/Preference/GeneralForm.php index 9c43a2bbc..213c788ae 100644 --- a/application/forms/Preference/GeneralForm.php +++ b/application/forms/Preference/GeneralForm.php @@ -161,13 +161,18 @@ class GeneralForm extends Form 'required' => true ) ); + $dateFormatValue = $this->getRequest()->getParam( + 'date_format', + $prefs->get('app.dateFormat', $cfg->get('dateFormat', 'd/m/Y')) + ); $txtDefaultDateFormat = new Zend_Form_Element_Text( array( 'name' => 'date_format', 'label' => 'Preferred Date Format', - 'helptext' => 'Display dates according to this format. See ' . $phpUrl . ' for possible values', + 'helptext' => 'Display dates according to this format. (See ' . $phpUrl . ' for possible values.) ' + . 'Example result: ' . $this->getView()->dateFormat()->format(time(), $dateFormatValue), 'required' => !$useGlobalDateFormat, - 'value' => $prefs->get('app.dateFormat', $cfg->get('dateFormat', 'd/m/Y')) + 'value' => $dateFormatValue ) ); @@ -186,13 +191,18 @@ class GeneralForm extends Form 'required' => !$useGlobalTimeFormat ) ); + $timeFormatValue = $this->getRequest()->getParam( + 'time_format', + $prefs->get('app.timeFormat', $cfg->get('timeFormat', 'g:i A')) + ); $txtDefaultTimeFormat = new Zend_Form_Element_Text( array( 'name' => 'time_format', 'label' => 'Preferred Time Format', 'required' => !$useGlobalTimeFormat, - 'helptext' => 'Display times according to this format. See ' . $phpUrl . ' for possible values', - 'value' => $prefs->get('app.timeFormat', $cfg->get('timeFormat', 'g:i A')) + 'helptext' => 'Display times according to this format. (See ' . $phpUrl . ' for possible values.) ' + . 'Example result: ' . $this->getView()->dateFormat()->format(time(), $timeFormatValue), + 'value' => $timeFormatValue ) ); $txtDefaultTimeFormat->addValidator(new TimeFormatValidator()); diff --git a/application/views/helpers/DateFormat.php b/application/views/helpers/DateFormat.php index be71a2c10..5dcb29c01 100644 --- a/application/views/helpers/DateFormat.php +++ b/application/views/helpers/DateFormat.php @@ -50,7 +50,7 @@ class Zend_View_Helper_DateFormat extends Zend_View_Helper_Abstract * @param string $format * @return string */ - private function format($timestamp, $format) + public function format($timestamp, $format) { $dt = DateTimeFactory::create(); $dt->setTimestamp($timestamp);