* Adjust code
This commit is contained in:
@@ -747,6 +747,7 @@ CREATE TABLE IF NOT EXISTS `zt_mr` (
|
||||
`jobID` mediumint(8) unsigned NOT NULL,
|
||||
`compileID` mediumint(8) unsigned NOT NULL,
|
||||
`compileStatus` char(30) NOT NULL,
|
||||
`removeSourceBranch` enum('0','1') NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
-- DROP TABLE IF EXISTS `zt_mrapproval`;
|
||||
|
||||
@@ -945,8 +945,12 @@ class gitlab extends control
|
||||
$this->session->set('gitlabTagList', $this->app->getURI(true));
|
||||
$keyword = fixer::input('post')->setDefault('keyword', '')->get('keyword');
|
||||
|
||||
/* Pager. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
|
||||
$tagList = array();
|
||||
$result = $this->gitlab->apiGetTags($gitlabID, $projectID, $orderBy, $keyword);
|
||||
$result = $this->gitlab->apiGetTags($gitlabID, $projectID, $orderBy, $keyword, $pager);
|
||||
foreach($result as $gitlabTag)
|
||||
{
|
||||
$tag = new stdClass();
|
||||
@@ -957,12 +961,6 @@ class gitlab extends control
|
||||
$tagList[] = $tag;
|
||||
}
|
||||
|
||||
/* Pager. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$recTotal = count($tagList);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
$tagList = array_chunk($tagList, $pager->recPerPage);
|
||||
|
||||
$this->view->gitlab = $this->gitlab->getByID($gitlabID);
|
||||
$this->view->pager = $pager;
|
||||
$this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->browseTag;
|
||||
@@ -970,7 +968,7 @@ class gitlab extends control
|
||||
$this->view->projectID = $projectID;
|
||||
$this->view->keyword = $keyword;
|
||||
$this->view->project = $this->gitlab->apiGetSingleProject($gitlabID, $projectID);
|
||||
$this->view->gitlabTagList = empty($tagList) ? $tagList: $tagList[$pageID - 1];
|
||||
$this->view->gitlabTagList = $tagList;
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
+20
-3
@@ -1466,10 +1466,11 @@ class gitlabModel extends model
|
||||
* @param int $projectID
|
||||
* @param string $orderBy
|
||||
* @param string $keyword
|
||||
* @param object $pager
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function apiGetTags($gitlabID, $projectID, $orderBy = '', $keyword = '')
|
||||
public function apiGetTags($gitlabID, $projectID, $orderBy = '', $keyword = '', $pager = null)
|
||||
{
|
||||
$apiRoot = $this->getApiRoot($gitlabID);
|
||||
|
||||
@@ -1482,8 +1483,24 @@ class gitlabModel extends model
|
||||
|
||||
if($keyword) $apiRoot .= "&search={$keyword}";
|
||||
|
||||
$url = sprintf($apiRoot, "/projects/{$projectID}/repository/tags");
|
||||
return json_decode(commonModel::http($url));
|
||||
if(!$pager)
|
||||
{
|
||||
$url = sprintf($apiRoot, "/projects/{$projectID}/repository/tags");
|
||||
return json_decode(commonModel::http($url));
|
||||
}
|
||||
else
|
||||
{
|
||||
$apiRoot .= "&per_page={$pager->recPerPage}&page={$pager->pageID}";
|
||||
$url = sprintf($apiRoot, "/projects/{$projectID}/repository/tags");
|
||||
$result = commonModel::httpWithHeader($url);
|
||||
|
||||
$header = $result['header'];
|
||||
$pager->setRecTotal($header['X-Total']);
|
||||
$pager->setPageTotal();
|
||||
if($pager->pageID > $pager->pageTotal) $pager->setPageID($pager->pageTotal);
|
||||
|
||||
return json_decode($result['body']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user