From d966b2e214ee2aab4579082aaff7868c48f32ee7 Mon Sep 17 00:00:00 2001 From: zhujinyong Date: Wed, 31 Mar 2021 16:07:11 +0800 Subject: [PATCH] * Ajdust openApp logic. --- framework/base/control.class.php | 7 +++++++ framework/base/router.class.php | 12 ++++++++++-- framework/control.class.php | 2 ++ module/common/lang/menu.php | 2 ++ module/common/model.php | 27 +++++++-------------------- module/index/js/index.js | 4 ++-- module/project/control.php | 3 ++- module/repo/control.php | 2 +- 8 files changed, 33 insertions(+), 26 deletions(-) diff --git a/framework/base/control.class.php b/framework/base/control.class.php index 1778c5c804..6c174342a7 100644 --- a/framework/base/control.class.php +++ b/framework/base/control.class.php @@ -961,6 +961,13 @@ class baseControl */ public function locate($url) { + /* If openApp is set, use it next visit. */ + $module = $this->app->rawModule; + if(isset($this->lang->navGroup->$module) and $this->lang->navGroup->$module != $this->app->openApp) + { + setCookie('openApp', $this->app->openApp); + } + header("location: $url"); exit; } diff --git a/framework/base/router.class.php b/framework/base/router.class.php index 43a0bc0428..5e8583aa49 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -376,7 +376,6 @@ class baseRouter $this->loadClass('dao', $static = true); $this->loadClass('mobile', $static = true); - $this->setOpenApp(); $this->setSuperVars(); $this->setDebug(); $this->setErrorHandler(); @@ -862,7 +861,16 @@ class baseRouter */ public function setOpenApp() { - if(isset($_COOKIE['openApp'])) $this->openApp = $_COOKIE['openApp']; + if(isset($_COOKIE['openApp']) and $_COOKIE['openApp']) + { + $this->openApp = $_COOKIE['openApp']; + setCookie('openApp', ''); + } + else + { + $module = $this->rawModule; + $this->openApp = $this->lang->navGroup->$module; + } } /** diff --git a/framework/control.class.php b/framework/control.class.php index c3521f7c82..a7f8a16d69 100644 --- a/framework/control.class.php +++ b/framework/control.class.php @@ -33,6 +33,8 @@ class control extends baseControl { parent::__construct($moduleName, $methodName, $appName); + $this->app->setOpenApp(); + if(defined('IN_USE') or (defined('RUN_MODE') and RUN_MODE == 'api')) $this->setPreference(); if(!isset($this->config->bizVersion)) return false; diff --git a/module/common/lang/menu.php b/module/common/lang/menu.php index d77f96e89f..7a2c9ee2c5 100644 --- a/module/common/lang/menu.php +++ b/module/common/lang/menu.php @@ -539,3 +539,5 @@ $lang->navGroup->dev = 'admin'; $lang->navGroup->entry = 'admin'; $lang->navGroup->extension = 'admin'; $lang->navGroup->action = 'admin'; + +$lang->navGroup->tree = 'tree'; diff --git a/module/common/model.php b/module/common/model.php index 69b99e5b76..c7af0d1ff3 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -33,7 +33,6 @@ class commonModel extends model $this->loadCustomFromDB(); if(!$this->checkIP()) die($this->lang->ipLimited); $this->app->loadLang('company'); - $this->setOpenApp(); } } @@ -116,21 +115,6 @@ class commonModel extends model } } - /** - * Set openApp. - * - * @access public - * @return void - */ - public function setOpenApp() - { - $openApp = $this->app->openApp; - if(isset($this->lang->navGroup->$openApp)) - { - $this->app->openApp = $this->lang->navGroup->$openApp; - } - } - /** * Load configs from database and save it to config->system and config->personal. * @@ -829,7 +813,7 @@ class commonModel extends model } if($module == $currentModule and ($method == $currentMethod or strpos(",$alias,", ",$currentMethod,") !== false)) $active = 'active'; - $label = $menuItem->text; + $label = $menuItem->text; $dropMenu = ''; /* Print sub menus. */ if(isset($menuItem->dropMenu)) @@ -851,7 +835,8 @@ class commonModel extends model if($currentModule == strtolower($subModule) && $currentMethod == strtolower($subMethod)) $subActive = 'active'; - $dropMenu .= "
  • " . html::a($subLink, $subLabel) . '
  • '; + $misc = (isset($lang->navGroup->$subModule) and $openApp != $lang->navGroup->$subModule) ? "data-app='$openApp'" : ''; + $dropMenu .= "
  • " . html::a($subLink, $subLabel, '', $misc) . '
  • '; } if(empty($dropMenu)) continue; @@ -860,8 +845,10 @@ class commonModel extends model $dropMenu = ""; } - $menuItemHtml = "
  • " . html::a($link, $label, $target) . $dropMenu . "
  • \n"; - if($isMobile) $menuItemHtml = html::a($link, $menuItem->text, $target, "class='$class $active'") . "\n"; + $misc = (isset($lang->navGroup->$module) and $openApp != $lang->navGroup->$module) ? "data-app='$openApp'" : ''; + $menuItemHtml = "
  • " . html::a($link, $label, $target, $misc) . $dropMenu . "
  • \n"; + + if($isMobile) $menuItemHtml = html::a($link, $menuItem->text, $target, $misc . " class='$class $active'") . "\n"; echo $menuItemHtml; } else diff --git a/module/index/js/index.js b/module/index/js/index.js index b7c7ebca46..0e709fd59e 100644 --- a/module/index/js/index.js +++ b/module/index/js/index.js @@ -548,8 +548,8 @@ { defaultOpenUrl = decodeURIComponent(location.hash.substr(5)); } - if(defaultOpenUrl) openApp(defaultOpenUrl); - else openApp(defaultApp); + + openApp(defaultOpenUrl ? defaultOpenUrl : defaultApp); /* Refresh more menu on window resize */ $(window).on('resize', refreshMoreMenu); diff --git a/module/project/control.php b/module/project/control.php index 5a868b00ce..69892e43e0 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -655,7 +655,8 @@ class project extends control { $uri = $this->app->getURI(true); $this->app->session->set('executionList', $uri, 'project'); - $this->locate($this->createLink('execution', 'all', "status=all&projectID=$projectID", '', false)); + + echo $this->fetch('execution', 'all', "status=all&projectID=$projectID"); } /** diff --git a/module/repo/control.php b/module/repo/control.php index a1fba1ef04..b718fd3e7e 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -61,7 +61,7 @@ class repo extends control $this->repo->setMenu($this->repos, $repoID); } - if(empty($this->repos) and $this->methodName != 'create') die(js::locate($this->repo->createLink('create', "objectID=$objectID"))); + if(empty($this->repos) and $this->methodName != 'create') die($this->locate($this->repo->createLink('create', "objectID=$objectID"))); } /**