diff --git a/module/repo/control.php b/module/repo/control.php index f5704205d0..292cc57d83 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -1,4 +1,7 @@ repo->getByID($repoID); @@ -1165,7 +1169,7 @@ class repo extends control $this->scm->setEngine($repo); $this->repo->setRepoBranch($branch); - helper::setcookie("syncBranch", $branch, 0, $this->config->webRoot, '', $this->config->cookieSecure, true); + helper::setcookie("syncBranch", $branch); $latestInDB = $this->dao->select('t1.*')->from(TABLE_REPOHISTORY)->alias('t1') ->leftJoin(TABLE_REPOBRANCH)->alias('t2')->on('t1.id=t2.revision') @@ -1196,47 +1200,15 @@ class repo extends control } /** - * Ajax show side logs. - * - * @param int $repoID - * @param string $path - * @param int $objectID - * @param string $type - * @param int $recTotal - * @param int $recPerPage - * @param int $pageID - * @access public - * @return void - */ - public function ajaxSideCommits($repoID, $path, $objectID = 0, $type = 'dir', $recTotal = 0, $recPerPage = 10, $pageID = 1) - { - if($this->get->repoPath) $path = $this->get->repoPath; - $this->app->loadClass('pager', true); - $pager = new pager($recTotal, $recPerPage, $pageID); - - $repo = $this->repo->getByID($repoID); - $path = $this->repo->decodePath($path); - $revisions = $this->repo->getCommits($repo, $path, 'HEAD', $type, $pager); - - $this->view->repo = $this->repo->getByID($repoID); - $this->view->revisions = $revisions; - $this->view->pager = $pager; - $this->view->repoID = $repoID; - $this->view->objectID = $objectID; - $this->view->logType = $type; - $this->view->path = urldecode($path); - $this->display(); - } - - /** - * Ajax get svn tags + * 获取SVN目录。 + * Ajax get svn dir. * * @param int $repoID * @param string $path * @access public - * @return void + * @return object */ - public function ajaxGetSVNDirs($repoID, $path = '') + public function ajaxGetSVNDirs(int $repoID, string $path = '') { $repo = $this->repo->getByID($repoID); if($repo->SCM != 'Subversion') return print(json_encode(array())); @@ -1256,10 +1228,11 @@ class repo extends control foreach($tags as $dirPath => $dirName) $dirs[$dirPath] = $this->repo->encodePath($dirPath); } - return print(json_encode($dirs)); + echo json_encode($dirs); } /** + * 获取1.5级导航数据。 * Ajax get drop menu. * * @param int $repoID @@ -1295,31 +1268,7 @@ class repo extends control } /** - * Create new product select options by remove shadow products if remove project. - * - * @access public - * @return void - */ - public function ajaxFilterShadowProducts() - { - $postData = fixer::input('post') - ->setDefault('products', array()) - ->setDefault('projectID', 0) - ->setDefault('objectID', 0) - ->get(); - - $shadowProduct = $this->loadModel('product')->getShadowProductByProject($postData->projectID); - $selectedProducts = array_diff($postData->products, array($shadowProduct->id)); // Remove shadow product. - - $products = $postData->objectID ? $this->loadModel('product')->getProductPairsByProject($objectID) : $this->loadModel('product')->getPairs(); - $linkedProducts = $this->loadModel('product')->getByIdList($postData->products); - $linkedProductPairs = array_combine(array_keys($linkedProducts), helper::arrayColumn($linkedProducts, 'name')); - $products = $products + $linkedProductPairs; - - return print (html::select('product[]', $products, $selectedProducts, "class='form-control chosen' multiple")); - } - - /** + * 根据产品ID获取项目列表。 * Get projects list by product id list by ajax. * * @access public @@ -1327,13 +1276,7 @@ class repo extends control */ public function ajaxProjectsOfProducts() { - $postData = fixer::input('post') - ->setDefault('products', array()) - ->setDefault('projects', array()) - ->get(); - $productIds = $postData->products ? explode(',', $postData->products) : array(); - $projectIds = $postData->projects ? explode(',', $postData->projects) : array(); - + $productIds = $this->post->products ? explode(',', $this->post->products) : array(); if(empty($productIds)) { $products = $this->loadModel('product')->getPairs('', 0, '', 'all'); @@ -1342,19 +1285,16 @@ class repo extends control /* Get all projects that can be accessed. */ $accessProjects = $this->loadModel('product')->getProjectPairsByProductIDList($productIds); - $selectedProjects = array_intersect(array_keys($accessProjects), $projectIds); - $options = array(); foreach($accessProjects as $projectID => $project) { $options[] = array('text' => $project, 'value' => $projectID); } return print(json_encode($options)); - $name = isset($postData->number) ? "projects[{$postData->number}][]" : 'projects[]'; - return print (html::select($name, $accessProjects, $selectedProjects, "class='form-control chosen' multiple")); } /** + * 获取服务器下拉列表数据。 * Ajax get hosts. * * @param int $scm @@ -1363,8 +1303,7 @@ class repo extends control */ public function ajaxGetHosts($scm) { - $scm = strtolower($scm); - $hosts = $this->loadModel($scm)->getPairs(); + $hosts = $this->loadModel(strtolower($scm))->getPairs(); $options = array(); foreach($hosts as $hostID => $host) @@ -1375,6 +1314,7 @@ class repo extends control } /** + * 获取各个服务器下的项目。 * Ajax get projects by server. * * @param int $serverID @@ -1390,6 +1330,7 @@ class repo extends control } /** + * 获取Gitea项目。 * Ajax get gitea projects. * * @param string $gitlabID @@ -1411,6 +1352,7 @@ class repo extends control } /** + * 获取Gogs项目。 * Ajax get gogs projects. * * @param string $gitlabID @@ -1432,6 +1374,7 @@ class repo extends control } /** + * 获取Gitlab项目。 * Ajax get gitlab projects. * * @param string $gitlabID @@ -1457,6 +1400,7 @@ class repo extends control } /** + * 根据服务器ID获取分组。 * Ajax get groups by server. * * @param int $serverID @@ -1476,39 +1420,14 @@ class repo extends control } /** - * Ajax get branch drop menu. - * - * @param int $repoID - * @param string $branchID - * @param int $objectID - * @access public - * @return void - */ - public function ajaxGetBranchDropMenu($repoID, $branchID, $objectID) - { - $repo = $this->repo->getByID($repoID); - $branches = $this->repo->getBranches($repo); - if($branchID) $branchID = base64_decode($branchID); - - $branchesHtml = "