diff --git a/application/Espo/Core/Portal/Application.php b/application/Espo/Core/Portal/Application.php index 08ee8e83be..d577223fc1 100644 --- a/application/Espo/Core/Portal/Application.php +++ b/application/Espo/Core/Portal/Application.php @@ -96,9 +96,12 @@ class Application extends \Espo\Core\Application public function runClient() { - $this->getContainer()->get('clientManager')->display(null, 'html/portal.html', array( - 'portalId' => $this->getPortal()->id - )); + $this->getContainer()->get('clientManager')->display(null, null, [ + 'portalId' => $this->getPortal()->id, + 'applicationId' => $this->getPortal()->id, + 'apiUrl' => 'api/v1/portal-access/' . $this->getPortal()->id, + 'appClientClassName' => 'app-portal' + ]); exit; } } diff --git a/application/Espo/Core/Utils/ClientManager.php b/application/Espo/Core/Utils/ClientManager.php index 38b6092866..08833aeaee 100644 --- a/application/Espo/Core/Utils/ClientManager.php +++ b/application/Espo/Core/Utils/ClientManager.php @@ -37,12 +37,36 @@ class ClientManager protected $mainHtmlFilePath = 'html/main.html'; - protected $htmlFilePathForDeveloperMode = 'frontend/html/main.html'; - protected $runScript = "app.start();"; protected $basePath = ''; + protected $jsFileList = [ + 'client/espo.min.js' + ]; + + protected $developerModeJsFileList = [ + 'client/lib/jquery-2.1.4.min.js', + 'client/lib/underscore-min.js', + 'client/lib/es6-promise.min.js', + 'client/lib/backbone-min.js', + 'client/lib/handlebars.js', + 'client/lib/base64.js', + 'client/lib/jquery-ui.min.js', + 'client/lib/jquery.ui.touch-punch.min.js', + 'client/lib/moment.min.js', + 'client/lib/moment-timezone-with-data.min.js', + 'client/lib/jquery.timepicker.min.js', + 'client/lib/jquery.autocomplete.js', + 'client/lib/bootstrap.min.js', + 'client/lib/bootstrap-datepicker.js', + 'client/lib/bull.js', + 'client/lib/marked.min.js', + 'client/src/loader.js', + 'client/src/utils.js', + 'client/src/exceptions.js', + ]; + public function __construct(Config $config, ThemeManager $themeManager) { $this->config = $config; @@ -77,7 +101,7 @@ class ClientManager return $this->getConfig()->get('cacheTimestamp', 0); } - public function display($runScript = null, $htmlFilePath = null, $vars = array()) + public function display($runScript = null, $htmlFilePath = null, $vars = []) { if (is_null($runScript)) { $runScript = $this->runScript; @@ -88,24 +112,48 @@ class ClientManager $isDeveloperMode = $this->getConfig()->get('isDeveloperMode'); + $cacheTimestamp = $this->getCacheTimestamp(); + if ($isDeveloperMode) { - if (file_exists('frontend/' . $htmlFilePath)) { - $htmlFilePath = 'frontend/' . $htmlFilePath; - } + $useCache = $this->getConfig()->get('useCacheInDeveloperMode'); + $jsFileList = $this->developerModeJsFileList; + $loaderCacheTimestamp = 'null'; + } else { + $useCache = $this->getConfig()->get('useCache'); + $jsFileList = $this->jsFileList; + $loaderCacheTimestamp = $cacheTimestamp; } + $scriptsHtml = ''; + foreach ($jsFileList as $jsFile) { + $src = $this->basePath . $jsFile . '?r=' . $cacheTimestamp; + $scriptsHtml .= ' ' . + '' . "\n"; + } + + $data = [ + 'applicationId' => 'espocrm-application-id', + 'apiUrl' => 'api/v1', + 'applicationName' => $this->getConfig()->get('applicationName', 'EspoCRM'), + 'cacheTimestamp' => $cacheTimestamp, + 'loaderCacheTimestamp' => $loaderCacheTimestamp, + 'stylesheet' => $this->getThemeManager()->getStylesheet(), + 'runScript' => $runScript, + 'basePath' => $this->basePath, + 'useCache' => $useCache ? 'true' : 'false', + 'appClientClassName' => 'app', + 'scriptsHtml' => $scriptsHtml + ]; + $html = file_get_contents($htmlFilePath); + foreach ($vars as $key => $value) { $html = str_replace('{{'.$key.'}}', $value, $html); } - $html = str_replace('{{applicationName}}', $this->getConfig()->get('applicationName', 'EspoCRM'), $html); - $html = str_replace('{{cacheTimestamp}}', $this->getCacheTimestamp(), $html); - $html = str_replace('{{useCache}}', $this->getConfig()->get('useCache') ? 'true' : 'false', $html); - $html = str_replace('{{stylesheet}}', $this->getThemeManager()->getStylesheet(), $html); - $html = str_replace('{{runScript}}', $runScript , $html); - $html = str_replace('{{basePath}}', $this->basePath , $html); - if ($isDeveloperMode) { - $html = str_replace('{{useCacheInDeveloperMode}}', $this->getConfig()->get('useCacheInDeveloperMode') ? 'true' : 'false', $html); + + foreach ($data as $key => $value) { + if (array_key_exists($key, $vars)) continue; + $html = str_replace('{{'.$key.'}}', $value, $html); } echo $html; diff --git a/client/res/templates/site/footer.tpl b/client/res/templates/site/footer.tpl index 82476aa644..e7dc3773d8 100644 --- a/client/res/templates/site/footer.tpl +++ b/client/res/templates/site/footer.tpl @@ -1,2 +1 @@ -

© 2018 EspoCRM

- +

© 2018 EspoCRM

diff --git a/client/src/views/login.js b/client/src/views/login.js index 2a6cbdb9a4..53ea99de6c 100644 --- a/client/src/views/login.js +++ b/client/src/views/login.js @@ -60,7 +60,7 @@ Espo.define('views/login', 'view', function (Dep) { if (!companyLogoId) { return this.getBasePath() + ('client/img/logo.png'); } - return this.getBasePath() + '?entryPoint=LogoImage&id='+companyLogoId+'&t=' + companyLogoId; + return this.getBasePath() + '?entryPoint=LogoImage&id='+companyLogoId; }, login: function () { diff --git a/client/src/views/site/navbar.js b/client/src/views/site/navbar.js index 9155fb51bc..414d091498 100644 --- a/client/src/views/site/navbar.js +++ b/client/src/views/site/navbar.js @@ -149,7 +149,7 @@ Espo.define('views/site/navbar', 'view', function (Dep) { if (!companyLogoId) { return this.getBasePath() + (this.getThemeManager().getParam('logo') || 'client/img/logo.png'); } - return this.getBasePath() + '?entryPoint=LogoImage&t=' + companyLogoId; + return this.getBasePath() + '?entryPoint=LogoImage&id='+companyLogoId; }, getTabList: function () { diff --git a/frontend/html/main.html b/frontend/html/main.html deleted file mode 100644 index c522ba1e99..0000000000 --- a/frontend/html/main.html +++ /dev/null @@ -1,56 +0,0 @@ - - - - {{applicationName}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - diff --git a/frontend/html/portal.html b/frontend/html/portal.html deleted file mode 100644 index a9c3bd832d..0000000000 --- a/frontend/html/portal.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - {{applicationName}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - diff --git a/html/main.html b/html/main.html index c56894a970..a7648a678b 100644 --- a/html/main.html +++ b/html/main.html @@ -2,7 +2,7 @@ {{applicationName}} - +{{scriptsHtml}} @@ -15,12 +15,14 @@ - - - - - - - - - - -
- - -