Preview example date/time results in configuration views

refs #4609
This commit is contained in:
Johannes Meyer 2013-08-28 10:50:10 +02:00 committed by Marius Hein
parent 32abb20a60
commit 74241258f5
3 changed files with 23 additions and 9 deletions

View File

@ -209,25 +209,29 @@ class GeneralForm extends Form
$phpUrl = '<a href="http://php.net/manual/en/function.date.php" target="_new">'
. 'the official PHP documentation</a>';
$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());

View File

@ -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());

View File

@ -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);