From 0b74074b2c96e11164e999128cbdb8a7862d07a9 Mon Sep 17 00:00:00 2001 From: "chencongzhi520@gmail.com" Date: Tue, 12 Jun 2012 07:11:47 +0000 Subject: [PATCH] * finish task#633. --- module/bug/control.php | 5 ++++ module/bug/view/view.html.php | 8 ++++++ module/common/model.php | 40 ++++++++++++++++++++++++++++++ module/story/control.php | 5 ++++ module/story/view/view.html.php | 8 ++++++ module/task/control.php | 5 ++++ module/task/view/view.html.php | 8 ++++++ module/testcase/control.php | 5 ++++ module/testcase/view/view.html.php | 8 ++++++ www/theme/default/style.css | 4 +-- 10 files changed, 94 insertions(+), 2 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 2e0d2450ba..3b46381c51 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -347,6 +347,11 @@ class bug extends control /* Get product info. */ $productID = $bug->product; $productName = $this->products[$productID]; + + /* Get the previous and next bug. */ + $tmpBugIDs = $this->dao->select('id')->from(TABLE_BUG)->where($this->session->storyReport)->fetchPairs('id'); + $bugIDs = ',' . implode(',', $tmpBugIDs) . ','; + $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('bug', $bugIDs, $bugID); /* Header and positon. */ $this->view->header->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->view; diff --git a/module/bug/view/view.html.php b/module/bug/view/view.html.php index 7f56306b65..eeff8135e6 100644 --- a/module/bug/view/view.html.php +++ b/module/bug/view/view.html.php @@ -41,6 +41,14 @@ common::printLink('bug', 'delete', $params, $lang->delete, 'hiddenwin'); } echo html::a($browseLink, $lang->goback); + if($preAndNext->pre) + { + echo "" . html::a($this->inLink('view', "storyID={$preAndNext->pre->id}"), '<') . "  "; + } + if($preAndNext->next) + { + echo "next->id}{$lang->colon}{$preAndNext->pre->title}>" . html::a($this->inLink('view', "storyID={$preAndNext->next->id}"), '>') . ""; + } ?> diff --git a/module/common/model.php b/module/common/model.php index dd0394ec6b..0ed31ca037 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -429,4 +429,44 @@ class commonModel extends model return false; } + + /** + * Get the previous and next object. + * + * @param string $type story|task|bug|case + * @param string $objectIDs + * @param string $objectID + * @access public + * @return void + */ + public function getPreAndNextObject($type, $objectIDs, $objectID) + { + $table = ''; + switch($type) + { + case 'story' : $table = TABLE_STORY; break; + case 'task' : $table = TABLE_TASK; break; + case 'bug' : $table = TABLE_BUG; break; + case 'case' : $table = TABLE_CASE; break; + default:break; + } + + $currentStart = strpos($objectIDs, ',' . $objectID . ',') + 1; + $currentEnd = $currentStart + strlen($objectID) - 1; + + /* Get the previous object. */ + $tmp = substr($objectIDs, 0, $currentStart - 1); + $preStart = strrpos($tmp, ',', 0) + 1; + $preEnd = $currentStart - 2; + $preID = substr($objectIDs, $preStart, $preEnd - $preStart + 1); + $preAndNextObject->pre = $this->dao->select('*')->from($table)->where('id')->eq($preID)->fetch(); + + /* Get the next object. */ + $nextStart = $currentEnd + 2; + $nextEnd = strpos($objectIDs, ',', $nextStart) - 1; + $nextID = substr($objectIDs, $nextStart, $nextEnd - $nextStart + 1); + $preAndNextObject->next = $this->dao->select('*')->from($table)->where('id')->eq($nextID)->fetch(); + + return $preAndNextObject; + } } diff --git a/module/story/control.php b/module/story/control.php index 597467b20c..6a00fc2ac6 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -367,6 +367,11 @@ class story extends control /* Set the menu. */ $this->product->setMenu($this->product->getPairs(), $product->id); + /* Get the previous and next story. */ + $tmpStoryIDs = $this->dao->select('id')->from(TABLE_STORY)->where($this->session->storyReport)->fetchPairs('id'); + $storyIDs = ',' . implode(',', $tmpStoryIDs) . ','; + $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('story', $storyIDs, $storyID); + $header['title'] = $product->name . $this->lang->colon . $this->lang->story->view . $this->lang->colon . $story->title; $position[] = html::a($this->createLink('product', 'browse', "product=$product->id"), $product->name); $position[] = $this->lang->story->view; diff --git a/module/story/view/view.html.php b/module/story/view/view.html.php index 67d19b0a7c..26c1cdfb2e 100644 --- a/module/story/view/view.html.php +++ b/module/story/view/view.html.php @@ -29,6 +29,14 @@ common::printLink('story', 'delete', "storyID=$story->id", $lang->delete, 'hiddenwin'); } echo html::a($browseLink, $lang->goback); + if($preAndNext->pre) + { + echo "" . html::a($this->inLink('view', "storyID={$preAndNext->pre->id}&version={$preAndNext->pre->version}"), '<') . "  "; + } + if($preAndNext->next) + { + echo "next->id}{$lang->colon}{$preAndNext->pre->title}>" . html::a($this->inLink('view', "storyID={$preAndNext->next->id}&version={$preAndNext->next->version}"), '>') . ""; + } ?> diff --git a/module/task/control.php b/module/task/control.php index c46f948437..75bd03488b 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -343,6 +343,11 @@ class task extends control $project = $this->project->getById($task->project); $this->project->setMenu($this->project->getPairs(), $project->id); + /* Get the previous and next task. */ + $tmpTaskIDs = $this->dao->select('id')->from(TABLE_TASK)->alias('t1')->where($this->session->taskReportCondition)->fetchPairs('id'); + $taskIDs = ',' . implode(',', $tmpTaskIDs) . ','; + $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('task', $taskIDs, $taskID); + $header['title'] = $project->name . $this->lang->colon . $this->lang->task->view; $position[] = html::a($this->createLink('project', 'browse', "projectID=$task->project"), $project->name); $position[] = $this->lang->task->view; diff --git a/module/task/view/view.html.php b/module/task/view/view.html.php index 4bb0d0d6bf..3a4cbbc391 100644 --- a/module/task/view/view.html.php +++ b/module/task/view/view.html.php @@ -34,6 +34,14 @@ if(!common::printLink('task', 'delete',"projectID=$task->project&taskID=$task->id", $lang->task->buttonDelete, 'hiddenwin')) echo $lang->task->buttonDelete . ' '; } echo html::a($browseLink, $lang->goback); + if($preAndNext->pre) + { + echo "" . html::a($this->inLink('view', "taskID={$preAndNext->pre->id}"), '<') . "  "; + } + if($preAndNext->next) + { + echo "next->id}{$lang->colon}{$preAndNext->pre->name}>" . html::a($this->inLink('view', "taskID={$preAndNext->next->id}"), '>') . ""; + } ?> diff --git a/module/testcase/control.php b/module/testcase/control.php index 4457c5303a..f18a6df7a2 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -320,6 +320,11 @@ class testcase extends control $productID = $case->product; $this->testcase->setMenu($this->products, $productID); + /* Get the previous and next testcase. */ + $tmpCaseIDs = $this->dao->select('id')->from(TABLE_CASE)->where($this->session->testcaseReport)->fetchPairs('id'); + $caseIDs = ',' . implode(',', $tmpCaseIDs) . ','; + $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('case', $caseIDs, $caseID); + $this->view->header['title'] = $this->products[$productID] . $this->lang->colon . $this->lang->testcase->view; $this->view->position[] = html::a($this->createLink('testcase', 'browse', "productID=$productID"), $this->products[$productID]); $this->view->position[] = $this->lang->testcase->view; diff --git a/module/testcase/view/view.html.php b/module/testcase/view/view.html.php index 95e41c9a75..df45ed4d1b 100644 --- a/module/testcase/view/view.html.php +++ b/module/testcase/view/view.html.php @@ -28,6 +28,14 @@ common::printLink('testcase', 'delete', "caseID=$case->id", $lang->delete, 'hiddenwin'); } echo html::a($browseLink, $lang->goback); + if($preAndNext->pre) + { + echo "" . html::a($this->inLink('view', "storyID={$preAndNext->pre->id}&version={$preAndNext->pre->version}"), '<') . "  "; + } + if($preAndNext->next) + { + echo "next->id}{$lang->colon}{$preAndNext->pre->title}>" . html::a($this->inLink('view', "storyID={$preAndNext->next->id}&version={$preAndNext->next->version}"), '>') . ""; + } ?> diff --git a/www/theme/default/style.css b/www/theme/default/style.css index 140aa8a1ba..694bb36ea4 100644 --- a/www/theme/default/style.css +++ b/www/theme/default/style.css @@ -321,8 +321,8 @@ table.tablesorter thead tr .headerSortDown {background-image: url(./images/table /* Title bar. */ #titlebar {font-size:14px; font-weight:bold; background-color:#efefef; padding:0px 5px; margin:10px 0; height:30px; line-height:30px;} -#titlebar #main {float:left; width:70%; clear:none; text-align:left} -#titlebar div {float:right; width:30%; clear:none; text-align:right} +#titlebar #main {float:left; width:65%; clear:none; text-align:left} +#titlebar div {float:right; width:35%; clear:none; text-align:right} #titlebar #main input {font-size:14px; margin-top:5px} #titlebar .text-1 {width:80%}