From 39b77f36b6b2dadf5987e23c00e014d597ba3b14 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 10 May 2022 13:24:06 +0800 Subject: [PATCH] * Add codes for saas extension. --- framework/base/control.class.php | 8 +++++++- framework/base/model.class.php | 1 + framework/base/router.class.php | 26 ++++++++++++++++++++++++-- framework/control.class.php | 16 +++++++++++----- framework/router.class.php | 1 + 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/framework/base/control.class.php b/framework/base/control.class.php index c4d051fadb..1576843b29 100644 --- a/framework/base/control.class.php +++ b/framework/base/control.class.php @@ -416,7 +416,7 @@ class baseControl $moduleName = basename(dirname(dirname(realpath($viewFile)))); $extPath = $this->app->getModuleExtPath('', $moduleName, 'view'); - $checkedOrder = array('site', 'custom', 'vision', 'xuan', 'common'); + $checkedOrder = array('site', 'saas', 'custom', 'vision', 'xuan', 'common'); $fileName = basename($viewFile); foreach($checkedOrder as $checkedType) { @@ -805,6 +805,12 @@ class baseControl $commonActionExtFile = $actionExtPath['custom'] . strtolower($methodName) . '.php'; if(file_exists($commonActionExtFile)) $file2Included = $commonActionExtFile; + if(!empty($actionExtPath['saas'])) + { + $commonActionExtFile = $actionExtPath['saas'] . strtolower($methodName) . '.php'; + if(file_exists($commonActionExtFile)) $file2Included = $commonActionExtFile; + } + if(!empty($actionExtPath['site'])) { /** diff --git a/framework/base/model.class.php b/framework/base/model.class.php index 0dbb3372be..519def4741 100644 --- a/framework/base/model.class.php +++ b/framework/base/model.class.php @@ -260,6 +260,7 @@ class baseModel $moduleExtPath = $this->app->getModuleExtPath($this->appName, $moduleName, 'model'); if(!empty($moduleExtPath['site'])) $extensionFile = $moduleExtPath['site'] . 'class/' . $extensionName . '.class.php'; if(!isset($extensionFile) or !file_exists($extensionFile)) $extensionFile = $moduleExtPath['custom'] . 'class/' . $extensionName . '.class.php'; + if(!isset($extensionFile) or !file_exists($extensionFile)) $extensionFile = $moduleExtPath['saas'] . 'class/' . $extensionName . '.class.php'; if(!isset($extensionFile) or !file_exists($extensionFile)) $extensionFile = $moduleExtPath['vision'] . 'class/' . $extensionName . '.class.php'; if(!isset($extensionFile) or !file_exists($extensionFile)) $extensionFile = $moduleExtPath['xuan'] . 'class/' . $extensionName . '.class.php'; if(!isset($extensionFile) or !file_exists($extensionFile)) $extensionFile = $moduleExtPath['common'] . 'class/' . $extensionName . '.class.php'; diff --git a/framework/base/router.class.php b/framework/base/router.class.php index 1216e2f4a6..1a44b0585d 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -1390,6 +1390,9 @@ class baseRouter if($this->checkModuleName($moduleName)) { + $modulePath = $this->getExtensionRoot() . 'saas' . DS . $moduleName . DS; + if(is_dir($modulePath) and (file_exists($modulePath . 'control.php') or file_exists($modulePath . 'model.php'))) return $modulePath; + /* 1. 最后尝试在定制开发中寻找。 Finally, try to find the module in the custom dir. */ $modulePath = $this->getExtensionRoot() . 'custom' . DS . $moduleName . DS; if(is_dir($modulePath) and (file_exists($modulePath . 'control.php') or file_exists($modulePath . 'model.php'))) return $modulePath; @@ -1432,8 +1435,10 @@ class baseRouter */ public function getModuleExtPath($appName, $moduleName, $ext) { + $saasExtPath = $this->getExtensionRoot() . 'saas' . DS . $moduleName . DS . 'ext' . DS . $ext . DS; + /* 检查失败或者extensionLevel为0,直接返回空。If check failed or extensionLevel == 0, return empty array. */ - if(!$this->checkModuleName($moduleName) or $this->config->framework->extensionLevel == 0) return array(); + if(!$this->checkModuleName($moduleName) or $this->config->framework->extensionLevel == 0) return array('saas' => $saasExtPath); $paths = array(); @@ -1442,10 +1447,16 @@ class baseRouter $paths['xuan'] = $this->getExtensionRoot() . 'xuan' . DS . $moduleName . DS . 'ext' . DS . $ext . DS; $paths['vision'] = $this->config->vision == 'rnd' ? '' : $this->basePath . 'extension' . DS . $this->config->vision . DS . $moduleName . DS . 'ext' . DS . $ext . DS; $paths['custom'] = $this->getExtensionRoot() . 'custom' . DS . $moduleName . DS . 'ext' . DS . $ext . DS; - if($this->config->framework->extensionLevel == 1) return $paths; + if($this->config->framework->extensionLevel == 1) + { + $paths['saas'] = $saasExtPath; + return $paths; + } /* When extensionLevel == 2. */ $paths['site'] = empty($this->siteCode) ? '' : $this->getExtensionRoot() . $this->config->edition . DS . $moduleName . DS . 'ext' . DS . '_' . $this->siteCode . DS . $ext . DS; + $paths['saas'] = $saasExtPath; + return $paths; } @@ -1494,6 +1505,12 @@ class baseRouter /* 如果扩展目录为空,不包含任何扩展文件。If there's no ext paths return false.*/ if(empty($moduleExtPaths)) return false; + if(!empty( $moduleExtPaths['saas'])) + { + $this->extActionFile = $moduleExtPaths['saas'] . $this->methodName . '.php'; + if(file_exists($this->extActionFile)) return true; + } + /* 1. 如果extensionLevel == 2,且扩展文件存在,返回该站点扩展文件。 If extensionLevel == 2 and site extensionFile exists, return it. */ if($this->config->framework->extensionLevel == 2 and !empty( $moduleExtPaths['site'])) { @@ -2322,6 +2339,7 @@ class baseRouter if(!empty($extConfigPath['common'])) $commonExtConfigFiles = helper::ls($extConfigPath['common'], '.php'); if(!empty($extConfigPath['xuan'])) $commonExtConfigFiles = array_merge($commonExtConfigFiles, helper::ls($extConfigPath['xuan'], '.php')); if(!empty($extConfigPath['vision'])) $commonExtConfigFiles = array_merge($commonExtConfigFiles, helper::ls($extConfigPath['vision'], '.php')); + if(!empty($extConfigPath['saas'])) $commonExtConfigFiles = array_merge($commonExtConfigFiles, helper::ls($extConfigPath['saas'], '.php')); if(!empty($extConfigPath['custom'])) $commonExtConfigFiles = array_merge($commonExtConfigFiles, helper::ls($extConfigPath['custom'], '.php')); } if($config->framework->extensionLevel == 2 and !empty($extConfigPath['site'])) $siteExtConfigFiles = helper::ls($extConfigPath['site'], '.php'); @@ -2427,6 +2445,9 @@ class baseRouter { $path = $moduleName . DS . 'lang' . DS . $this->clientLang . '.php'; + $modulePath = $this->getExtensionRoot() . 'saas' . DS; + if(file_exists($modulePath . $path)) return $modulePath . $path; + /* 1. 如果通用版本里有此模块,优先使用。 If module is in the open edition, use it. */ $modulePath = $this->getModuleRoot($appName); if(file_exists($modulePath . $path)) return $modulePath . $path; @@ -2489,6 +2510,7 @@ class baseRouter if(!empty($extLangPath['xuan'])) $commonExtLangFiles = array_merge($commonExtLangFiles, helper::ls($extLangPath['xuan'] . $this->clientLang, '.php')); if(!empty($extLangPath['vision'])) $commonExtLangFiles = array_merge($commonExtLangFiles, helper::ls($extLangPath['vision'] . $this->clientLang, '.php')); if(!empty($extLangPath['custom'])) $commonExtLangFiles = array_merge($commonExtLangFiles, helper::ls($extLangPath['custom'] . $this->clientLang, '.php')); + if(!empty($extLangPath['saas'])) $commonExtLangFiles = array_merge($commonExtLangFiles, helper::ls($extLangPath['saas'] . $this->clientLang, '.php')); } if($this->config->framework->extensionLevel == 2 and !empty($extLangPath['site'])) $siteExtLangFiles = helper::ls($extLangPath['site'] . $this->clientLang, '.php'); $extLangFiles = array_merge($commonExtLangFiles, $siteExtLangFiles); diff --git a/framework/control.class.php b/framework/control.class.php index c7666ca0db..f10b4fe31d 100644 --- a/framework/control.class.php +++ b/framework/control.class.php @@ -86,7 +86,7 @@ class control extends baseControl /** * Det default priv by workflow. - * + * * @access public * @return bool */ @@ -197,6 +197,7 @@ class control extends baseControl $commonExtViewFile = $viewExtPath['common'] . $this->devicePrefix . $methodName . ".{$viewType}.php"; $xuanExtViewFile = $viewExtPath['xuan'] . $this->devicePrefix . $methodName . ".{$viewType}.php"; $visionExtViewFile = $viewExtPath['vision'] . $this->devicePrefix . $methodName . ".{$viewType}.php"; + $saasExtViewFile = $viewExtPath['saas'] . $this->devicePrefix . $methodName . ".{$viewType}.php"; $customExtViewFile = $viewExtPath['custom'] . $this->devicePrefix . $methodName . ".{$viewType}.php"; $siteExtViewFile = empty($viewExtPath['site']) ? '' : $viewExtPath['site'] . $this->devicePrefix . $methodName . ".{$viewType}.php"; @@ -217,6 +218,10 @@ class control extends baseControl { $viewFile = $xuanExtViewFile; } + else if(file_exists($saasExtViewFile)) + { + $viewFile = $saasExtViewFile; + } else if(file_exists($commonExtViewFile)) { $viewFile = $commonExtViewFile; @@ -235,10 +240,11 @@ class control extends baseControl $commonExtHookFiles = glob($viewExtPath['vision'] . $this->devicePrefix . $methodName . ".*.{$viewType}.hook.php"); } $xuanExtHookFiles = glob($viewExtPath['xuan'] . $this->devicePrefix . $methodName . ".*.{$viewType}.hook.php"); + $saasExtHookFiles = glob($viewExtPath['saas'] . $this->devicePrefix . $methodName . ".*.{$viewType}.hook.php"); $customExtHookFiles = glob($viewExtPath['custom'] . $this->devicePrefix . $methodName . ".*.{$viewType}.hook.php"); $siteExtHookFiles = empty($viewExtPath['site']) ? '' : glob($viewExtPath['site'] . $this->devicePrefix . $methodName . ".*.{$viewType}.hook.php"); - $extHookFiles = array_merge((array)$commonExtHookFiles, (array)$xuanExtHookFiles, (array)$customExtHookFiles, (array)$siteExtHookFiles); + $extHookFiles = array_merge((array)$commonExtHookFiles, (array)$xuanExtHookFiles, (array)$saasExtHookFiles, (array)$customExtHookFiles, (array)$siteExtHookFiles); } if(!empty($extHookFiles)) return array('viewFile' => $viewFile, 'hookFiles' => $extHookFiles); @@ -342,9 +348,9 @@ class control extends baseControl } /** - * Set workflow export fields - * - * @param array $fields + * Set workflow export fields + * + * @param array $fields * @access public * @return array */ diff --git a/framework/router.class.php b/framework/router.class.php index 500761517b..3fb5136cfa 100755 --- a/framework/router.class.php +++ b/framework/router.class.php @@ -327,6 +327,7 @@ class router extends baseRouter if(!empty($extConfigPath['common'])) $commonExtConfigFiles = helper::ls($extConfigPath['common'], '.php'); if(!empty($extConfigPath['xuan'])) $commonExtConfigFiles = array_merge($commonExtConfigFiles, helper::ls($extConfigPath['xuan'], '.php')); if(!empty($extConfigPath['vision'])) $commonExtConfigFiles = array_merge($commonExtConfigFiles, helper::ls($extConfigPath['vision'], '.php')); + if(!empty($extConfigPath['saas'])) $commonExtConfigFiles = array_merge($commonExtConfigFiles, helper::ls($extConfigPath['saas'], '.php')); if(!empty($extConfigPath['custom'])) $commonExtConfigFiles = array_merge($commonExtConfigFiles, helper::ls($extConfigPath['custom'], '.php')); } if($config->framework->extensionLevel == 2 and !empty($extConfigPath['site'])) $siteExtConfigFiles = helper::ls($extConfigPath['site'], '.php');