* adjust the action dynamic logs in index page.

This commit is contained in:
wangchunsheng
2010-02-10 09:26:38 +00:00
parent c7cdb125ae
commit fe116ecc2e
5 changed files with 72 additions and 31 deletions

View File

@@ -21,14 +21,27 @@
* @version $Id$
* @link http://www.zentao.cn
*/
$lang->action->label->common = '$date, <strong>$action</strong> by <strong>$actor</strong>';
$lang->action->label->extra = '$date, <strong>$action</strong> as <strong>$extra</strong> by <strong>$actor</strong>';
$lang->action->label->opened = '$date, 由 <strong>$actor</strong> 创建。';
$lang->action->label->changed = '$date, 由 <strong>$actor</strong> 变更。';
$lang->action->label->edited = '$date, 由 <strong>$actor</strong> 编辑。';
$lang->action->label->closed = '$date, 由 <strong>$actor</strong> 关闭。';
$lang->action->label->commented = '$date, 由 <strong>$actor</strong> 发表评论。';
$lang->action->label->activated = '$date, 由 <strong>$actor</strong> 激活。';
$lang->action->label->diff1 = '修改了 <strong><i>%s</i></strong>,旧值为 "%s",新值为 "%s"。<br />';
$lang->action->label->diff2 = '修改了 <strong><i>%s</i></strong>,区别为:<blockquote>%s</blockquote>';
$lang->action->desc->common = '$date, <strong>$action</strong> by <strong>$actor</strong>';
$lang->action->desc->extra = '$date, <strong>$action</strong> as <strong>$extra</strong> by <strong>$actor</strong>';
$lang->action->desc->opened = '$date, 由 <strong>$actor</strong> 创建。';
$lang->action->desc->changed = '$date, 由 <strong>$actor</strong> 变更。';
$lang->action->desc->edited = '$date, 由 <strong>$actor</strong> 编辑。';
$lang->action->desc->closed = '$date, 由 <strong>$actor</strong> 关闭。';
$lang->action->desc->commented = '$date, 由 <strong>$actor</strong> 发表评论。';
$lang->action->desc->activated = '$date, 由 <strong>$actor</strong> 激活。';
$lang->action->desc->diff1 = '修改了 <strong><i>%s</i></strong>,旧值为 "%s",新值为 "%s"。<br />';
$lang->action->desc->diff2 = '修改了 <strong><i>%s</i></strong>,区别为:<blockquote>%s</blockquote>';
$lang->action->label->opened = '创建了';
$lang->action->label->changed = '变更了';
$lang->action->label->edited = '编辑了';
$lang->action->label->closed = '关闭了';
$lang->action->label->commented = '评论了';
$lang->action->label->activated = '激活了';
$lang->action->label->resolved = '解决了';
$lang->action->label->reviewed = '评审了';
$lang->action->label->story = '需求|story|view|storyID=%s';
$lang->action->label->task = '任务|task|view|taskID=%s';
$lang->action->label->bug = 'Bug|bug|view|bugID=%s';
$lang->action->label->testcase = '用例|testcase|view|caseID=%s';
$lang->action->label->space = ' ';

View File

@@ -91,48 +91,74 @@ class actionModel extends model
$actionType = strtolower($action->action);
if(isset($this->lang->$objectType->action->$actionType))
{
$label = $this->lang->$objectType->action->$actionType;
$desc = $this->lang->$objectType->action->$actionType;
}
elseif(isset($this->lang->action->label->$actionType))
elseif(isset($this->lang->action->desc->$actionType))
{
$label = $this->lang->action->label->$actionType;
$desc = $this->lang->action->desc->$actionType;
}
else
{
$label = $action->extra ? $this->lang->action->label->extra : $this->lang->action->label->common;
$desc = $action->extra ? $this->lang->action->desc->extra : $this->lang->action->desc->common;
}
foreach($action as $key => $value)
{
if($key == 'history') continue;
if(is_array($label))
if(is_array($desc))
{
if($key == 'extra') continue;
$label['main'] = str_replace('$' . $key, $value, $label['main']);
$desc['main'] = str_replace('$' . $key, $value, $desc['main']);
}
else
{
$label = str_replace('$' . $key, $value, $label);
$desc = str_replace('$' . $key, $value, $desc);
}
}
if(is_array($label))
if(is_array($desc))
{
$extra = strtolower($action->extra);
if(isset($label['extra'][$extra]))
if(isset($desc['extra'][$extra]))
{
echo str_replace('$extra', $label['extra'][$extra], $label['main']);
echo str_replace('$extra', $desc['extra'][$extra], $desc['main']);
}
else
{
echo str_replace('$extra', $action->extra, $label['main']);
echo str_replace('$extra', $action->extra, $desc['main']);
}
}
else
{
echo $label;
echo $desc;
}
}
/* 打印动态信息。*/
public function getDynamic($objectType = 'all', $count = 30)
{
$actions = $this->dao->select('*')->from(TABLE_ACTION)->onCaseOf($objectType != 'all')->where('objectType')->eq($objectType)->endCase()->orderBy('id desc')->limit($count)->fetchAll();
if(!$actions) return array();
foreach($actions as $action)
{
$actionType = strtolower($action->action);
$objectType = strtolower($action->objectType);
$action->date = date('H:i', $action->date);
$action->actionLabel = isset($this->lang->action->label->$actionType) ? $this->lang->action->label->$actionType : $action->action;
$action->objectLabel = isset($this->lang->action->label->$objectType) ? $this->lang->action->label->$objectType : $objectType;
if(strpos($action->objectLabel, '|') !== false)
{
list($objectLabel, $moduleName, $methodName, $vars) = explode('|', $action->objectLabel);
$action->objectLink = html::a(helper::createLink($moduleName, $methodName, sprintf($vars, $action->objectID)), '#' . $action->objectID);
$action->objectLabel = $objectLabel;
}
else
{
$action->objectLink = '#' . $action->objectID;
}
}
return $actions;
}
/* 打印修改记录。*/
public function printChanges($objectType, $histories)
{
@@ -148,11 +174,11 @@ class actionModel extends model
$history->fieldLabel = str_pad($history->fieldLabel, $maxLength, $this->lang->action->label->space);
if($history->diff != '')
{
printf($this->lang->action->label->diff2, $history->fieldLabel, nl2br($history->diff));
printf($this->lang->action->desc->diff2, $history->fieldLabel, nl2br($history->diff));
}
else
{
printf($this->lang->action->label->diff1, $history->fieldLabel, $history->old, $history->new);
printf($this->lang->action->desc->diff1, $history->fieldLabel, $history->old, $history->new);
}
}
}

View File

@@ -50,7 +50,7 @@ class index extends control
$this->view->projectGroups = $projectGroups;
$this->view->burns = $burns;
$this->view->counts = count($projects);
$this->view->actions = $this->dao->select('*')->from(TABLE_ACTION)->orderBy('id desc')->limit(30)->fetchAll();
$this->view->actions = $this->loadModel('action')->getDynamic('all', 25);
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->display();
}

View File

@@ -27,3 +27,4 @@ $lang->index->common = '首页';
$lang->index->index = '首页';
$lang->index->ping = '接口:同步session';
$lang->index->latest = '最新动态';
$lang->index->action = '%s, %s <i>%s</i> %s <strong>%s</strong>';

View File

@@ -22,6 +22,7 @@
*/
?>
<?php include '../../common/header.html.php';?>
<?php include '../../common/colorize.html.php';?>
<div class="yui-d0 yui-t6">
<div class='yui-main'>
<div class='yui-b'>
@@ -53,17 +54,17 @@
</div>
</div>
<div class='yui-b'>
<div class='box-title'><?php echo $lang->index->latest;?></div>
<div class='box-content'>
<table class='table-1 colored'>
<caption><?php echo $lang->index->latest;?></caption>
<?php
foreach($actions as $action)
{
if($action->objectType == 'case') $action->objectType = 'testcase';
echo date('H:i', $action->date) . ' ' . html::a($this->createLink('user', 'view', "account=$action->actor"), $users[$action->actor]) . ' ' . $action->action . ' ' . $action->objectType . ' ' . html::a($this->createLink($action->objectType, 'view', "id=$action->objectID"), '#' . $action->objectID);
echo "<br />";
echo "<tr><td>";
printf($lang->index->action, $action->date, $users[$action->actor], $action->actionLabel, $action->objectLabel, $action->objectLink);
echo "</td></tr>";
}
?>
</div>
</table>
</div>
</div>
<script language='Javascript'><?php for($i = 1; $i <= $counts; $i ++) echo "createChart$i();"; ?></script>