Skip to content

Commit

Permalink
Render dates that don't parse as text, not as exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuck Hagenbuch committed Mar 3, 2014
1 parent 918da65 commit c92c763
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions framework/Core/lib/Horde/Core/Ui/VarRenderer/Html.php
Expand Up @@ -22,6 +22,17 @@ protected function _renderVarInputDefault($form, &$var, &$vars)
htmlspecialchars($var->getTypeName());
}

protected function _renderVarInput_basic($form, &$var, &$vars)
{
return sprintf('<input type="text" name="%s" id="%s" value="%s" %s%s />',
htmlspecialchars($var->getVarName()),
$this->_genID($var->getVarName(), false),
htmlspecialchars($var->getValue($vars)),
$var->isDisabled() ? ' disabled="disabled" ' : '',
$this->_getActionScripts($form, $var)
);
}

protected function _renderVarInput_number($form, &$var, &$vars)
{
$value = $var->getValue($vars);
Expand Down Expand Up @@ -468,6 +479,12 @@ protected function _renderVarInput_monthyear($form, &$var, &$vars)

protected function _renderVarInput_monthdayyear($form, &$var, &$vars)
{
try {
$date = $var->type->getDateParts($var->getValue($vars));
} catch (Horde_Date_Exception $e) {
return $this->_renderVarInput_basic($form, $var, $vars);
}

$GLOBALS['injector']->getInstance('Horde_PageOutput')->addInlineScript(
"document.observe('Horde_Calendar:select', " .
"function(e) {" .
Expand Down Expand Up @@ -510,7 +527,6 @@ protected function _renderVarInput_monthdayyear($form, &$var, &$vars)
$dates['year'][$i] = $i;
}
}
$date = $var->type->getDateParts($var->getValue($vars));

// TODO: use NLS to get the order right for the Rest Of The
// World.
Expand Down Expand Up @@ -1380,7 +1396,7 @@ protected function _renderVarDisplay_monthdayyear($form, &$var, &$vars)
try {
return $var->type->formatDate($date);
} catch (Horde_Date_Exception $e) {
return $e->getMessage();
return $date;
}
}
return '';
Expand All @@ -1392,8 +1408,9 @@ protected function _renderVarDisplay_datetime($form, &$var, &$vars)
try {
$html = htmlspecialchars($var->type->formatDate($value));
} catch (Horde_Date_Exception $e) {
return $e->getMessage();
return $value;
}

if (!$var->type->emptyDateArray($value)) {
$html .= Horde_Form_Type_date::getAgo($value);
}
Expand Down

0 comments on commit c92c763

Please sign in to comment.