From 8cfebdf7237150387db2a51b4a7ff1fbeaaade5b Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Fri, 5 Aug 2011 13:08:56 +0000 Subject: [PATCH] - New configuration parameter deadline_format to specify how to display Deadlines (date or time difference or a mix of the two) SVN:trunk[1424] --- core/attributedef.class.inc.php | 11 +++++++---- core/config.class.inc.php | 9 +++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index 81c26ede3..a33b11ee7 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -2280,17 +2280,20 @@ class AttributeDeadline extends AttributeDateTime $sResult = ''; if ($value !== null) { - $value = AttributeDateTime::GetAsUnixSeconds($value); - $difference = $value - time(); + $iValue = AttributeDateTime::GetAsUnixSeconds($value); + $sDate = parent::GetAsHTML($value, $oHostObject); + $difference = $iValue - time(); if ($difference >= 0) { - $sResult = self::FormatDuration($difference); + $sDifference = self::FormatDuration($difference); } else { - $sResult = Dict::Format('UI:DeadlineMissedBy_duration', self::FormatDuration(-$difference)); + $sDifference = Dict::Format('UI:DeadlineMissedBy_duration', self::FormatDuration(-$difference)); } + $sFormat = MetaModel::GetConfig()->Get('deadline_format', '$difference$'); + $sResult = str_replace(array('$date$', '$difference$'), array($sDate, $sDifference), $sFormat); } return $sResult; } diff --git a/core/config.class.inc.php b/core/config.class.inc.php index a07273daf..b52b21d26 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -392,6 +392,15 @@ class Config 'source_of_value' => '', 'show_in_conf_sample' => true, ), + 'deadline_format' => array( + 'type' => 'string', + 'description' => 'The format used for displaying "deadline" attributes: any string with the following placeholders: $date$, $difference$', + // examples... $date$ ($deadline$) + 'default' => '$difference$', + 'value' => '$difference$', + 'source_of_value' => '', + 'show_in_conf_sample' => true, + ), ); public function IsProperty($sPropCode)