From e251dc84fbb19f46800307eeb37c08bfd4db1ef5 Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Sat, 27 Feb 2010 01:26:40 +0000 Subject: [PATCH] * adjust the display of history, keep the diffs at bottom. --- trunk/module/action/model.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/trunk/module/action/model.php b/trunk/module/action/model.php index 2939561b5c..a67aa5dc99 100644 --- a/trunk/module/action/model.php +++ b/trunk/module/action/model.php @@ -154,13 +154,20 @@ class actionModel extends model public function printChanges($objectType, $histories) { if(empty($histories)) return; - $maxLength = 0; + + /* 计算字段的最大长度,并将历史记录根据是否有diff分开,以保证含有diff的字段显示在最后面。*/ + $maxLength = 0; + $historiesWithDiff = array(); + $historiesWithoutDiff = array(); foreach($histories as $history) { - $fieldName = $history->field; + $fieldName = $history->field; $history->fieldLabel = isset($this->lang->$objectType->$fieldName) ? $this->lang->$objectType->$fieldName : $fieldName; if(($length = strlen($history->fieldLabel)) > $maxLength) $maxLength = $length; + $history->diff ? $historiesWithDiff[] = $history : $historiesWithoutDiff[] = $history; } + $histories = array_merge($historiesWithoutDiff, $historiesWithDiff); + foreach($histories as $history) { $history->fieldLabel = str_pad($history->fieldLabel, $maxLength, $this->lang->action->label->space);