From e9efc87cc7fe724b862c659d7fc789c2978c6ccf Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Thu, 15 Jun 2023 10:35:14 +0800 Subject: [PATCH] * Change third nav items get. --- lib/zin/wg/mainnavbar/v1.php | 3 ++- module/common/model.php | 48 ++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/lib/zin/wg/mainnavbar/v1.php b/lib/zin/wg/mainnavbar/v1.php index d83d3df87a..9321bd1db6 100644 --- a/lib/zin/wg/mainnavbar/v1.php +++ b/lib/zin/wg/mainnavbar/v1.php @@ -42,7 +42,8 @@ class mainNavbar extends nav $currentMethod = $app->getMethodName(); commonModel::setMainMenu(); - $items = \customModel::getModuleMenu($app->rawMethod); + $activeMenu = commonModel::printMainMenu(false); + $items = \customModel::getModuleMenu($activeMenu); if($items) { $items = json_decode(json_encode($items), true); diff --git a/module/common/model.php b/module/common/model.php index a0fdde3ede..1a7371ebee 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1131,11 +1131,12 @@ class commonModel extends model /** * Print the main menu. * + * @param bool $printHtml * @static * @access public * @return string */ - public static function printMainMenu() + public static function printMainMenu(bool $printHtml = true): string { global $app, $lang, $config; @@ -1157,12 +1158,12 @@ class commonModel extends model /* Print all main menus. */ $menu = customModel::getMainMenu(); - echo "\n"; + if($printHtml) echo $menuHtml; return $activeMenu; } @@ -1798,18 +1800,19 @@ EOF; * Build more executions button. * * @param int $executionID + * @param bool $printHtml * @static * @access public - * @return void + * @return bool */ - public static function buildMoreButton($executionID) + public static function buildMoreButton(int $executionID, bool $printHtml = true): bool { - if(defined('TUTORIAL')) return; + if(defined('TUTORIAL')) return false; global $lang, $app; $object = $app->dbh->query('SELECT project,`type` FROM ' . TABLE_EXECUTION . " WHERE `id` = '$executionID'")->fetch(); - if(empty($object)) return; + if(empty($object)) return false; $executionPairs = array(); $userCondition = !$app->user->admin ? " AND `id` " . helper::dbIN($app->user->view->sprints) : ''; @@ -1827,7 +1830,7 @@ EOF; $executionPairs[$execution->id] = $execution->name; } - if(empty($executionPairs)) return; + if(empty($executionPairs)) return false; $html = "
  • \n"; - echo $html; + if($printHtml) echo $html; + return true; } /** * Build devops app button. * + * @param bool $printHtml * @static * @access public - * @return void + * @return bool */ - public static function buildAppButton() + public static function buildAppButton(bool $printHtml = true): bool { - if(defined('TUTORIAL')) return; + if(defined('TUTORIAL')) return false; global $app, $config, $lang; $condition = ''; @@ -1868,11 +1873,11 @@ EOF; { if(commonModel::hasPriv($pipelineType, 'browse')) $types .= "'$pipelineType',"; } - if(empty($types)) return; + if(empty($types)) return false; $condition .= ' AND `type` in (' . trim($types, ',') . ')'; } $pipelineList = $app->dbh->query("SELECT `type`,name,url FROM " . TABLE_PIPELINE . " WHERE `deleted` = '0' $condition order by type")->fetchAll(); - if(empty($pipelineList)) return; + if(empty($pipelineList)) return false; $appCommon = isset($lang->db->custom['devopsMenu']['menu']['app']) ? $lang->db->custom['devopsMenu']['menu']['app'] : $lang->app->common; $html = "\n"; - echo $html; + if($printHtml) echo $html; + return true; } /**