* [refac bug #55463] Fetch release export in projectrelease.
This commit is contained in:
@@ -275,19 +275,7 @@ class projectrelease extends control
|
||||
*/
|
||||
public function export(int $releaseID)
|
||||
{
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$release = $this->release->getByID($releaseID);
|
||||
$type = $this->post->type;
|
||||
|
||||
$html = '';
|
||||
if($type == 'story' || $type == 'all') $html .= $this->projectreleaseZen->generateStoryHtml($release);
|
||||
if($type == 'bug' || $type == 'all') $html .= $this->projectreleaseZen->generateBugHtml($release);
|
||||
if($type == 'leftbug' || $type == 'all') $html .= $this->projectreleaseZen->generateBugHtml($release, 'left');
|
||||
$html = "<html><head><meta charset='utf-8'><title>{$this->post->fileName}</title><style>table, th, td{font-size:12px; border:1px solid gray; border-collapse:collapse;}</style></head><body>$html</body></html>";
|
||||
|
||||
return print($this->fetch('file', 'sendDownHeader', array('fileName' => $this->post->fileName, 'html', $html)));
|
||||
}
|
||||
if(!empty($_POST)) return $this->fetch('release', 'export', "releaseID={$releaseID}");
|
||||
|
||||
$this->display('release', 'export');
|
||||
}
|
||||
|
||||
@@ -30,79 +30,4 @@ class projectreleaseZen extends projectrelease
|
||||
$this->view->branch = $branch;
|
||||
$this->view->project = $this->project->getByID($projectID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成关联的需求的 html。
|
||||
* Generate story html.
|
||||
*
|
||||
* @param object $release
|
||||
* @access protected
|
||||
* @return string
|
||||
*/
|
||||
protected function generateStoryHtml(object $release): string
|
||||
{
|
||||
$this->loadModel('story');
|
||||
|
||||
$html = "<h3>{$this->lang->release->stories}</h3>";
|
||||
if(empty($release->stories)) return $html;
|
||||
|
||||
/* 生成表头。*/
|
||||
/* Generate thead.*/
|
||||
$fields = array('id' => $this->lang->story->id, 'title' => $this->lang->story->title);
|
||||
$html .= '<table><tr>';
|
||||
foreach($fields as $fieldLabel) $html .= "<th><nobr>$fieldLabel</nobr></th>\n";
|
||||
$html .= '</tr>';
|
||||
|
||||
$stories = $this->dbh->query($this->session->storyQueryCondition . " ORDER BY " . strtr($this->session->storyOrderBy, '_', ' '))->fetchAll();
|
||||
foreach($stories as $story)
|
||||
{
|
||||
$story->title = "<a href='" . common::getSysURL() . $this->createLink('story', 'view', "storyID=$story->id") . "' target='_blank'>$story->title</a>";
|
||||
|
||||
$html .= "<tr valign='top'>\n";
|
||||
foreach($fields as $fieldName => $fieldLabel) $html .= '<td><nobr>' . zget($story, $fieldName, '') . "</nobr></td>\n";
|
||||
$html .= "</tr>\n";
|
||||
}
|
||||
$html .= '</table>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 bug 的 html。
|
||||
* Generate bug html.
|
||||
*
|
||||
* @param object $release
|
||||
* @param string $type linked|left
|
||||
* @access protected
|
||||
* @return string
|
||||
*/
|
||||
protected function generateBugHtml(object $release, string $type = 'linked'): string
|
||||
{
|
||||
$this->loadModel('bug');
|
||||
|
||||
$html = '<h3>' . ($type == 'linked' ? $this->lang->release->bugs : $this->lang->release->generatedBugs) . '</h3>';
|
||||
|
||||
$bugIdList = $type == 'linked' ? $release->bugs : $release->leftBugs;
|
||||
if(empty($bugIdList)) return $html;
|
||||
|
||||
$fields = array('id' => $this->lang->bug->id, 'title' => $this->lang->bug->title);
|
||||
$html .= '<table><tr>';
|
||||
foreach($fields as $fieldLabel) $html .= "<th><nobr>$fieldLabel</nobr></th>\n";
|
||||
$html .= '</tr>';
|
||||
|
||||
$bugs = array();
|
||||
$queryConditionName = $type == 'linked' ? 'linkedBugQueryCondition' : 'leftBugsQueryCondition';
|
||||
if($this->session->$queryConditionName !== false) $bugs = $this->dao->select('id, title')->from(TABLE_BUG)->where($this->session->$queryConditionName)->beginIF($this->session->bugOrderBy !== false)->orderBy($this->session->bugOrderBy)->fi()->fetchAll('id');
|
||||
foreach($bugs as $bug)
|
||||
{
|
||||
$bug->title = "<a href='" . common::getSysURL() . $this->createLink('bug', 'view', "bugID=$bug->id") . "' target='_blank'>$bug->title</a>";
|
||||
|
||||
$html .= "<tr valign='top'>\n";
|
||||
foreach($fields as $fieldName => $fieldLabel) $html .= "<td><nobr>" . zget($bug, $fieldName, '') . "</nobr></td>\n";
|
||||
$html .= "</tr>\n";
|
||||
}
|
||||
$html .= '</table>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,13 +326,12 @@ class release extends control
|
||||
{
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$release = $this->release->getByID($releaseID);
|
||||
$release = $this->release->getByID($releaseID, true);
|
||||
$type = $this->post->type;
|
||||
$fileName = $this->post->fileName;
|
||||
if(empty($fileName)) return $this->sendError(sprintf($this->lang->error->notempty, $this->lang->release->fileName));
|
||||
|
||||
$html = '';
|
||||
$release = $this->release->getByID($releaseID, true);
|
||||
$html = '';
|
||||
if($type == 'story' || $type == 'all') $html .= $this->releaseZen->buildStoryDataForExport($release);
|
||||
if($type == 'bug' || $type == 'all') $html .= $this->releaseZen->buildBugDataForExport($release, 'bug');
|
||||
if($type == 'leftbug' || $type == 'all') $html .= $this->releaseZen->buildBugDataForExport($release, 'leftbug');
|
||||
|
||||
Reference in New Issue
Block a user