浏览代码

- New configuration parameter deadline_format to specify how to display Deadlines (date or time difference or a mix of the two)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1424 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 14 年之前
父节点
当前提交
40a79d05a0
共有 2 个文件被更改,包括 16 次插入4 次删除
  1. 7 4
      core/attributedef.class.inc.php
  2. 9 0
      core/config.class.inc.php

+ 7 - 4
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;
 	}

+ 9 - 0
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)