* Remove unused code.

This commit is contained in:
sunguangming
2023-11-27 13:08:26 +08:00
parent e37899106a
commit b9b52ac28b
5 changed files with 39 additions and 428 deletions
+39 -149
View File
@@ -536,9 +536,7 @@ class commonModel extends model
*/
public static function getMainNavList(string $moduleName): array
{
global $lang;
global $app;
global $config;
global $lang, $app, $config;
$app->loadLang('my');
@@ -570,7 +568,7 @@ class commonModel extends model
if(common::hasPriv($currentModule, $currentMethod)) $display = true;
/* 2. 如果没有资产库落地页的权限,则查看是否有资产库其他方法的权限. */
if($currentModule == 'assetlib' && !$display) list($display, $currentMethod) = commonTao::setAssetLibMenu($display, $currentMethod);
if($currentModule == 'assetlib' && !$display) list($display, $currentMethod) = commonTao::setAssetLibMenu($display, $currentModule, $currentMethod);
/* 3. 可以个性化设置的导航,如果没有落地页的权限,则查看是否有其他落地页的权限。 */
$moduleLinkList = $currentModule . 'LinkList';
@@ -614,24 +612,15 @@ class commonModel extends model
}
/**
* Print the main menu.
* Get active main menu.
*
* @param bool $printHtml
* @static
* @access public
* @return string
*/
public static function printMainMenu(bool $printHtml = true): string
public static function getActiveMainMenu(): string
{
global $app, $lang, $config;
/* Set main menu by app tab and module. */
static::replaceMenuLang();
static::setMainMenu();
static::checkMenuVarsReplaced();
$activeMenu = '';
$tab = $app->tab;
global $app;
$isTutorialMode = commonModel::isTutorialMode();
$currentModule = $app->rawModule;
@@ -643,168 +632,69 @@ class commonModel extends model
/* Print all main menus. */
$menu = customModel::getMainMenu();
$menuHtml = "<ul class='nav nav-default'>\n";
$activeMenu = '';
foreach($menu as $menuItem)
{
if(isset($menuItem->hidden) and $menuItem->hidden and (!isset($menuItem->tutorial) or !$menuItem->tutorial)) continue;
if(empty($menuItem->link)) continue;
if($menuItem->divider) $menuHtml .= "<li class='divider'></li>";
/* Init the these vars. */
$alias = isset($menuItem->alias) ? $menuItem->alias : '';
$subModule = isset($menuItem->subModule) ? explode(',', $menuItem->subModule) : array();
$class = isset($menuItem->class) ? $menuItem->class : '';
$exclude = isset($menuItem->exclude) ? $menuItem->exclude : '';
$active = '';
if($menuItem->name == $currentModule and strpos(",$exclude,", ",$currentModule-$currentMethod,") === false)
{
$activeMenu = $menuItem->name;
$active = 'active';
}
if($subModule and in_array($currentModule, $subModule) and strpos(",$exclude,", ",$currentModule-$currentMethod,") === false)
{
$activeMenu = $menuItem->name;
$active = 'active';
}
if($menuItem->name == $currentModule and strpos(",$exclude,", ",$currentModule-$currentMethod,") === false) $activeMenu = $menuItem->name;
if($menuItem->link['module'] == 'execution' and $menuItem->link['method'] == 'more')
if($subModule and in_array($currentModule, $subModule) and strpos(",$exclude,", ",$currentModule-$currentMethod,") === false) $activeMenu = $menuItem->name;
if($menuItem->link)
{
$executionID = $menuItem->link['vars'];
$menuHtml .= commonModel::buildMoreButton((int)$executionID, false);
}
elseif($menuItem->link['module'] == 'app' and $menuItem->link['method'] == 'serverlink')
{
$menuHtml .= commonModel::buildAppButton(false);
}
else
{
if($menuItem->link)
$module = '';
$method = '';
if(is_array($menuItem->link))
{
$target = '';
$module = '';
$method = '';
$link = commonModel::createMenuLink($menuItem);
if(isset($menuItem->link['module'])) $module = $menuItem->link['module'];
if(isset($menuItem->link['method'])) $method = $menuItem->link['method'];
}
if($menuItem->link['module'] == 'project' and $menuItem->link['method'] == 'other') $link = 'javascript:void(0);';
if($module == $currentModule and ($method == $currentMethod or strpos(",$alias,", ",$currentMethod,") !== false) and strpos(",$exclude,", ",$currentMethod,") === false) $activeMenu = $menuItem->name;
if(is_array($menuItem->link))
/* Print drop menus. */
if(isset($menuItem->dropMenu))
{
foreach($menuItem->dropMenu as $dropMenuName => $dropMenuItem)
{
if(isset($menuItem->link['target'])) $target = $menuItem->link['target'];
if(isset($menuItem->link['module'])) $module = $menuItem->link['module'];
if(isset($menuItem->link['method'])) $method = $menuItem->link['method'];
}
if($module == $currentModule and ($method == $currentMethod or strpos(",$alias,", ",$currentMethod,") !== false) and strpos(",$exclude,", ",$currentMethod,") === false)
{
$activeMenu = $menuItem->name;
$active = 'active';
}
if(empty($dropMenuItem)) continue;
if(isset($dropMenuItem->hidden) and $dropMenuItem->hidden) continue;
$label = $menuItem->text;
$dropMenu = '';
$misc = (isset($lang->navGroup->$module) and $tab != $lang->navGroup->$module) ? "data-app='$tab'" : '';
/* Parse drop menu link. */
$dropMenuLink = zget($dropMenuItem, 'link', $dropMenuItem);
/* Print drop menus. */
if(isset($menuItem->dropMenu))
{
foreach($menuItem->dropMenu as $dropMenuName => $dropMenuItem)
list($subLabel, $subModule, $subMethod, $subParams) = explode('|', $dropMenuLink);
if(!common::hasPriv($subModule, $subMethod)) continue;
$activeMainMenu = false;
if($currentModule == strtolower($subModule) and $currentMethod == strtolower($subMethod))
{
if(empty($dropMenuItem)) continue;
if(isset($dropMenuItem->hidden) and $dropMenuItem->hidden) continue;
/* Parse drop menu link. */
$dropMenuLink = zget($dropMenuItem, 'link', $dropMenuItem);
list($subLabel, $subModule, $subMethod, $subParams) = explode('|', $dropMenuLink);
if(!common::hasPriv($subModule, $subMethod)) continue;
$subLink = helper::createLink($subModule, $subMethod, $subParams);
$subActive = '';
$activeMainMenu = false;
if($currentModule == strtolower($subModule) and $currentMethod == strtolower($subMethod))
{
$activeMainMenu = true;
}
else
{
$subModule = isset($dropMenuItem['subModule']) ? explode(',', $dropMenuItem['subModule']) : array();
$subExclude = isset($dropMenuItem['exclude']) ? $dropMenuItem['exclude'] : $exclude;
if($subModule and in_array($currentModule, $subModule) and strpos(",$subExclude,", ",$currentModule-$currentMethod,") === false) $activeMainMenu = true;
}
if($activeMainMenu)
{
$activeMenu = $dropMenuName;
$active = 'active';
$subActive = 'active';
$label = $subLabel;
}
$dropMenu .= "<li class='$subActive' data-id='$dropMenuName'>" . html::a($subLink, $subLabel, '', "data-app='$tab'") . '</li>';
$activeMainMenu = true;
}
else
{
$subModule = isset($dropMenuItem['subModule']) ? explode(',', $dropMenuItem['subModule']) : array();
$subExclude = isset($dropMenuItem['exclude']) ? $dropMenuItem['exclude'] : $exclude;
if($subModule and in_array($currentModule, $subModule) and strpos(",$subExclude,", ",$currentModule-$currentMethod,") === false) $activeMainMenu = true;
}
if(empty($dropMenu)) continue;
$label .= "<span class='caret'></span>";
$dropMenu = "<ul class='dropdown-menu'>{$dropMenu}</ul>";
$menuHtml .= "<li class='$class $active' data-id='$menuItem->name'>" . html::a($link, $label, $target, $misc) . $dropMenu . "</li>\n";
if($activeMainMenu) $activeMenu = $dropMenuName;
}
else
{
$menuHtml .= "<li class='$class $active' data-id='$menuItem->name'>" . html::a($link, $label, $target, $misc) . "</li>\n";
}
}
else
{
$menuHtml .= "<li class='$class $active' data-id='$menuItem->name'>$menuItem->text</li>\n";
}
}
}
$menuHtml .= "</ul>\n";
if($printHtml) echo $menuHtml;
return $activeMenu;
}
/**
* Print the search box.
*
* @static
* @access public
* @return void
*/
public static function printSearchBox()
{
global $lang;
global $config;
$searchObject = 'bug';
echo "<div class='input-group-btn'>";
echo html::hidden('searchType', $searchObject);
echo "<ul id='searchTypeMenu' class='dropdown-menu'>";
$searchObjects = $lang->searchObjects;
if($config->systemMode == 'light') unset($searchObjects['program']);
if(!helper::hasFeature('devops'))
{
if(isset($searchObjects['deploy'])) unset($searchObjects['deploy']);
if(isset($searchObjects['service'])) unset($searchObjects['service']);
if(isset($searchObjects['deploystep'])) unset($searchObjects['deploystep']);
}
foreach($searchObjects as $key => $value)
{
$class = $key == $searchObject ? "class='selected'" : '';
if($key == 'program') $key = 'program-product';
if($key == 'deploystep') $key = 'deploy-viewstep';
echo "<li $class><a href='javascript:$.setSearchType(\"$key\");' data-value='{$key}'>{$value}</a></li>";
}
echo '</ul></div>';
}
/**
* Print the module menu.
*
-104
View File
@@ -1,104 +0,0 @@
</div><?php /* end '.outer' in 'header.html.php'. */ ?>
<script>
$.initSidebar();
</script>
<?php if($extView = $this->getExtViewFile(__FILE__)){include $extView; return helper::cd();}?>
<iframe frameborder='0' name='hiddenwin' id='hiddenwin' scrolling='no' class='debugwin hidden'></iframe>
<?php if($onlybody != 'yes' and $app->viewType != 'xhtml'):?>
</main><?php /* end '#wrap' in 'header.html.php'. */ ?>
<div id="noticeBox"><?php if($config->vision != 'lite') echo $this->loadModel('score')->getNotice(); ?></div>
<script>
<?php $this->app->loadConfig('message');?>
<?php if($config->message->browser->turnon):?>
/* Alert got messages. */
needPing = false;
$(function()
{
var windowBlur = false;
if(window.Notification && Notification.permission == 'granted')
{
window.onblur = function(){windowBlur = true;}
window.onfocus = function(){windowBlur = false;}
}
setInterval(function()
{
$.get(createLink('message', 'ajaxGetMessage', "windowBlur=" + (windowBlur ? '1' : '0')), function(data)
{
if(!windowBlur)
{
$('#noticeBox').append(data);
adjustNoticePosition();
}
else
{
if(data)
{
if(typeof data == 'string') data = $.parseJSON(data);
if(typeof data.message == 'string') notifyMessage(data);
}
}
});
}, <?php echo $config->message->browser->pollTime * 1000;?>);
})
<?php endif;?>
<?php if(!empty($config->sso->redirect)):?>
<?php
$ranzhiAddr = $config->sso->addr;
$ranzhiURL = substr($ranzhiAddr, 0, strrpos($ranzhiAddr, '/sys/'));
?>
<?php if(!empty($ranzhiURL)):?>
$(function(){ redirect('<?php echo $ranzhiURL?>', '<?php echo $config->sso->code?>'); });
<?php endif;?>
<?php endif;?>
</script>
<?php endif;?>
<?php
if($this->loadModel('cron')->runnable()) js::execute('startCron()');
if(isset($pageJS)) js::execute($pageJS); // load the js for current page.
/* Load hook files for current page. */
$extensionRoot = $this->app->getExtensionRoot();
if($this->config->vision != 'open')
{
$extHookRule = $extensionRoot . $this->config->edition . '/common/ext/view/footer.*.hook.php';
$extHookFiles = glob($extHookRule);
if($extHookFiles) foreach($extHookFiles as $extHookFile) include $extHookFile;
}
if($this->config->vision == 'lite')
{
$extHookRule = $extensionRoot . $this->config->vision . '/common/ext/view/footer.*.hook.php';
$extHookFiles = glob($extHookRule);
if($extHookFiles) foreach($extHookFiles as $extHookFile) include $extHookFile;
}
$extHookRule = $extensionRoot . 'custom/common/ext/view/footer.*.hook.php';
$extHookFiles = glob($extHookRule);
if($extHookFiles) foreach($extHookFiles as $extHookFile) include $extHookFile;
?>
<?php if($config->debug > 2 and $config->tabSession): ?>
<div id="tid" style="position:fixed;right:0;bottom:0;z-index:10000">
<code class="bg-red">tsid=<?php if(empty($_GET['tid'])) echo session_id(); else echo md5(session_id() . $_GET['tid']);?></code>
<?php if(!empty($_GET['tid'])): ?>
<code class="bg-yellow">servertid=<?php echo $_GET['tid'];?></code>
<?php endif; ?>
<code class="bg-green">sid=<?php echo session_id();?></code>
</div>
<?php endif; ?>
<?php
/* Export page vars for zin tool */
if(isset($config->zinTool))
{
$pageVars = get_defined_vars();
$exportVars = array('lang' => $lang);
foreach($pageVars as $varName => $varValue)
{
if(is_string($varValue) || is_bool($varValue) || is_numeric($varValue)) $exportVars[$varName] = $varValue;
}
js::set('pageVars', $exportVars);
}
?>
</body>
</html>
-8
View File
@@ -1,8 +0,0 @@
<?php if($extView = $this->getExtViewFile(__FILE__)){include $extView; return helper::cd();}?>
<iframe frameborder='0' name='hiddenwin' id='hiddenwin' scrolling='no' class='debugwin hidden'></iframe>
<?php if($this->loadModel('cron')->runnable()) js::execute('startCron()');?>
<script>
<?php if(isset($pageJS)) echo $pageJS;?>
</script>
</body>
</html>
-70
View File
@@ -1,70 +0,0 @@
<?php
if($extView = $this->getExtViewFile(__FILE__)){include $extView; return helper::cd();}
include 'header.lite.html.php';
include 'chosen.html.php';
//include 'validation.html.php';
?>
<?php if(empty($_GET['onlybody']) or $_GET['onlybody'] != 'yes'):?>
<?php $this->app->loadConfig('sso');?>
<?php if(!empty($config->sso->redirect)) js::set('ssoRedirect', $config->sso->redirect);?>
<?php if($config->showMainMenu):?>
<header id='header'>
<div id='mainHeader'>
<div class='container'>
<div id='heading'>
<?php common::printHomeButton($app->tab);?>
<?php echo isset($lang->switcherMenu) ? $lang->switcherMenu : '';?>
</div>
<nav id='navbar'><?php $activeMenu = commonModel::printMainMenu();?></nav>
<div id='headerActions'><?php if(isset($lang->headerActions)) echo $lang->headerActions;?></div>
<div id='toolbar'>
<div id='userMenu'>
<ul id="userNav" class="nav nav-default">
<li class='dropdown dropdown-hover' id='globalCreate'><?php common::printCreateList();?></li>
<li class='dropdown dropdown-hover has-avatar' id='userDropDownMenu'><?php common::printUserBar();?></li>
<li class='dropdown dropdown-hover' id='visionSwitcher'><?php common::printVisionSwitcher();?></li>
</ul>
</div>
</div>
</div>
</div>
<?php if(isset($lang->{$app->tab}->menu->$activeMenu) and is_array($lang->{$app->tab}->menu->$activeMenu) and isset($lang->{$app->tab}->menu->{$activeMenu}['subMenu'])):?>
<?php $subMenuClass = $app->tab == 'admin' ? 'admin-tab-menu' : '';?>
<div id='subHeader' class="<?php echo $subMenuClass;?>">
<div class='container'>
<div id="pageNav" class='btn-toolbar'><?php if(isset($lang->modulePageNav)) echo $lang->modulePageNav;?></div>
<nav id='subNavbar'><?php common::printModuleMenu($activeMenu);?></nav>
<div id="pageActions"><div class='btn-toolbar'><?php if(isset($lang->TRActions)) echo $lang->TRActions;?></div></div>
</div>
</div>
<?php endif;?>
<?php
if(!empty($config->sso->redirect))
{
css::import($defaultTheme . 'bindranzhi.css');
js::import($jsRoot . 'bindranzhi.js');
}
?>
</header>
<?php else:?>
<header id='header'>
<div id='mainHeader' style="height: 0;"></div>
</header>
<?php endif;?>
<?php endif;?>
<script>
adjustMenuWidth();
if(window.navigator.userAgent.indexOf('xuanxuan') > 0)
{
$('li.user-tutorial').addClass('hide');
/* Fix double header covering #main. */
$('document').ready(function()
{
$('#subHeader').parent().parent().children('#main').css('top', '100px');
});
}
</script>
<main id='main' <?php if(!empty($config->sso->redirect)) echo "class='ranzhiFixedTfootAction'";?> >
<div class='container'>
-97
View File
@@ -1,97 +0,0 @@
<?php
if($extView = $this->getExtViewFile(__FILE__)){include $extView; return helper::cd();}
$clientLang = $app->getClientLang();
$webRoot = $this->app->getWebRoot();
$jsRoot = $webRoot . "js/";
$themeRoot = $webRoot . "theme/";
$defaultTheme = $webRoot . 'theme/default/';
$langTheme = $themeRoot . 'lang/' . $clientLang . '.css';
$clientTheme = $this->app->getClientTheme();
$onlybody = zget($_GET, 'onlybody', 'no');
$commonLang = array('zh-cn', 'zh-tw', 'en', 'fr', 'de');
?>
<!DOCTYPE html>
<html lang='<?php echo $clientLang;?>'>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="renderer" content="webkit">
<?php
echo html::title($title . ' - ' . $lang->zentaoPMS);
js::exportConfigVars();
if($config->debug)
{
$timestamp = time();
css::import($themeRoot . 'zui/css/min.css?t=' . $timestamp);
css::import($defaultTheme . 'style.css?t=' . $timestamp);
css::import($langTheme);
if(strpos($clientTheme, 'default') === false) css::import($clientTheme . 'style.css?t=' . $timestamp);
js::import($jsRoot . 'jquery/lib.js');
js::import($jsRoot . 'zui/min.js?t=' . $timestamp);
if(!in_array($clientLang, $commonLang)) js::import($jsRoot . 'zui/lang.' . $clientLang . '.min.js?t=' . $timestamp);
js::import($jsRoot . 'my.full.js?t=' . $timestamp);
if(isset($config->zinTool)) js::import($jsRoot . 'zui3/zintool.js');
}
else
{
$minCssFile = $defaultTheme . $this->cookie->lang . '.' . $this->cookie->theme . '.css';
if(!file_exists($this->app->getThemeRoot() . 'default/' . $this->cookie->lang . '.' . $this->cookie->theme . '.css')) $minCssFile = $defaultTheme . 'en.' . $this->cookie->theme . '.css';
css::import($minCssFile);
js::import($jsRoot . 'all.js');
if(!in_array($clientLang, $commonLang)) js::import($jsRoot . 'zui/lang.' . $clientLang . '.min.js');
}
if($this->app->getViewType() == 'xhtml') css::import($defaultTheme . 'x.style.css');
if($this->app->isServing() && commonModel::isTutorialMode())
{
$wizardModule = isset($_SESSION['wizardModule']) ? $_SESSION['wizardModule'] : $this->moduleName;
$wizardMethod = isset($_SESSION['wizardMethod']) ? $_SESSION['wizardMethod'] : $this->methodName;
$requiredFields = '';
if(isset($config->$wizardModule->$wizardMethod->requiredFields)) $requiredFields = str_replace(' ', '', $config->$wizardModule->$wizardMethod->requiredFields);
echo "<script>window.TUTORIAL = {'module': '$wizardModule', 'method': '$wizardMethod', tip: '$lang->tutorialConfirm'}; if(config) config.requiredFields = '$requiredFields'; $(function(){window.top.checkTutorialState && setTimeout(window.top.checkTutorialState, 500);});</script>";
}
if(isset($pageCSS)) css::internal($pageCSS);
echo html::favicon($webRoot . 'favicon.ico');
?>
<!--[if lt IE 10]>
<?php js::import($jsRoot . 'jquery/placeholder/min.js'); ?>
<![endif]-->
<?php
/* Load hook files for current page. */
$extensionRoot = $this->app->getExtensionRoot();
if($this->config->vision != 'open')
{
$extHookRule = $extensionRoot . $this->config->edition . '/common/ext/view/header.*.hook.php';
$extHookFiles = glob($extHookRule);
if($extHookFiles) foreach($extHookFiles as $extHookFile) include $extHookFile;
}
if($this->config->vision == 'lite')
{
$extHookRule = $extensionRoot . $this->config->vision . '/common/ext/view/header.*.hook.php';
$extHookFiles = glob($extHookRule);
if($extHookFiles) foreach($extHookFiles as $extHookFile) include $extHookFile;
}
$xuanExtFile = $extensionRoot . 'xuan/common/ext/view/header.xuanxuan.html.hook.php';
if(file_exists($xuanExtFile)) include $xuanExtFile;
?>
</head>
<?php
$bodyClass = $this->app->getViewType() == 'xhtml' ? 'allow-self-open' : '';
if(isset($pageBodyClass)) $bodyClass = $bodyClass . ' ' . $pageBodyClass;
if($this->app->moduleName == 'index' && $this->app->methodName == 'index') $bodyClass .= ' menu-' . ($this->cookie->hideMenu ? 'hide' : 'show');
if(strpos($_SERVER['HTTP_USER_AGENT'], 'xuanxuan') !== false) $bodyClass .= ' xxc-embed';
?>
<body class='<?php echo $bodyClass; ?>'>
<?php if($this->app->getViewType() == 'xhtml'):?>
<style>
.main-actions-holder {display: none !important;}
</style>
<?php endif;?>