client manager change

This commit is contained in:
yuri
2018-12-25 17:54:55 +02:00
parent ad8b954401
commit aaeb905dcf
9 changed files with 78 additions and 175 deletions
+6 -3
View File
@@ -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;
}
}
+62 -14
View File
@@ -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 .= ' ' .
'<script type="text/javascript" src="'.$src.'" data-base-path="'.$this->basePath.'"></script>' . "\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;
+1 -2
View File
@@ -1,2 +1 @@
<p class="credit small">&copy; 2018 <a href="http://www.espocrm.com">EspoCRM</a></p>
<p class="credit small">&copy; 2018 <a href="https://www.espocrm.com">EspoCRM</a></p>
+1 -1
View File
@@ -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 () {
+1 -1
View File
@@ -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 () {
-56
View File
@@ -1,56 +0,0 @@
<!doctype html>
<html>
<head>
<title>{{applicationName}}</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="description" content="EspoCRM is Open Source CRM application. Increase profitability through customer loyalty!">
<script type="text/javascript" src="{{basePath}}client/lib/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/underscore-min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/es6-promise.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/backbone-min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/handlebars.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/base64.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/jquery-ui.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/moment.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/moment-timezone-with-data.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/jquery.timepicker.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/jquery.autocomplete.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/bootstrap.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/bull.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/marked.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/src/loader.js" data-base-path="{{basePath}}"></script>
<script type="text/javascript" src="{{basePath}}client/src/utils.js"></script>
<script type="text/javascript" src="{{basePath}}client/src/exceptions.js"></script>
<link href="{{basePath}}{{stylesheet}}?r={{cacheTimestamp}}" rel="stylesheet" id='main-stylesheet'>
<link rel="icon" href="{{basePath}}client/img/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="{{basePath}}client/img/favicon.ico" type="image/x-icon">
<script type="text/javascript">
$(function () {
Espo.require('app', function (App) {
var app = new App({
useCache: {{useCacheInDeveloperMode}},
cacheTimestamp: {{cacheTimestamp}},
url: 'api/v1',
basePath: '{{basePath}}'
}, function (app) {
{{runScript}}
});
});
});
</script>
</head>
<body>
<div class="container content"></div>
<footer>
<p class="credit small">&copy; 2018 <a href="http://www.espocrm.com" title="Powered by EspoCRM" alt="Visit official EspoCRM website">EspoCRM</a></p>
</footer>
</body>
</html>
-57
View File
@@ -1,57 +0,0 @@
<!doctype html>
<html>
<head>
<title>{{applicationName}}</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="description" content="EspoCRM is Open Source CRM application. Increase profitability through customer loyalty!">
<script type="text/javascript" src="{{basePath}}client/lib/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/underscore-min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/es6-promise.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/backbone-min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/handlebars.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/base64.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/jquery-ui.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/moment.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/moment-timezone-with-data.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/jquery.timepicker.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/jquery.autocomplete.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/bootstrap.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/bull.js"></script>
<script type="text/javascript" src="{{basePath}}client/lib/marked.min.js"></script>
<script type="text/javascript" src="{{basePath}}client/src/loader.js" data-base-path="{{basePath}}"></script>
<script type="text/javascript" src="{{basePath}}client/src/utils.js"></script>
<script type="text/javascript" src="{{basePath}}client/src/exceptions.js"></script>
<link href="{{basePath}}{{stylesheet}}?r={{cacheTimestamp}}" rel="stylesheet" id='main-stylesheet'>
<link rel="icon" href="{{basePath}}client/img/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="{{basePath}}client/img/favicon.ico" type="image/x-icon">
<script type="text/javascript">
$(function () {
Espo.require('app-portal', function (App) {
var app = new App({
id: '{{portalId}}',
useCache: {{useCacheInDeveloperMode}},
cacheTimestamp: {{cacheTimestamp}},
url: 'api/v1/portal-access/{{portalId}}',
basePath: '{{basePath}}'
}, function (app) {
{{runScript}}
});
});
});
</script>
</head>
<body>
<div class="container content"></div>
<footer>
<p class="credit small">&copy; 2018 <a href="http://www.espocrm.com" title="Powered by EspoCRM" alt="Visit official EspoCRM website">EspoCRM</a></p>
</footer>
</body>
</html>
+7 -5
View File
@@ -2,7 +2,7 @@
<html>
<head>
<title>{{applicationName}}</title>
<script type="text/javascript" src="{{basePath}}client/espo.min.js?r={{cacheTimestamp}}" data-base-path="{{basePath}}"></script>
{{scriptsHtml}}
<link href="{{basePath}}{{stylesheet}}?r={{cacheTimestamp}}" rel="stylesheet" id='main-stylesheet'>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
@@ -15,12 +15,14 @@
<link rel="shortcut icon" href="{{basePath}}client/img/favicon.ico" type="image/x-icon">
<script type="text/javascript">
$(function () {
Espo.loader.cacheTimestamp = {{cacheTimestamp}};
Espo.require('app', function (App) {
Espo.loader.cacheTimestamp = {{loaderCacheTimestamp}};
Espo.require('{{appClientClassName}}', function (App) {
var app = new App({
id: '{{applicationId}}',
useCache: {{useCache}},
cacheTimestamp: {{cacheTimestamp}},
basePath: '{{basePath}}'
basePath: '{{basePath}}',
url: '{{apiUrl}}'
}, function (app) {
{{runScript}}
});
@@ -31,7 +33,7 @@
<body>
<div class="container content"></div>
<footer>
<p class="credit small">&copy; 2018 <a href="http://www.espocrm.com" title="Powered by EspoCRM" alt="Visit official EspoCRM website">EspoCRM</a></p>
<p class="credit small">&copy; 2018 <a href="https://www.espocrm.com" title="Powered by EspoCRM" alt="Visit official EspoCRM website">EspoCRM</a></p>
</footer>
</body>
</html>
-36
View File
@@ -1,36 +0,0 @@
<!doctype html>
<html>
<head>
<title>{{applicationName}}</title>
<script type="text/javascript" src="{{basePath}}client/espo.min.js?r={{cacheTimestamp}}" data-base-path="{{basePath}}"></script>
<link href="{{basePath}}{{stylesheet}}?r={{cacheTimestamp}}" rel="stylesheet" id='main-stylesheet'>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="description" content="EspoCRM is Open Source CRM application. Increase profitability through customer loyalty!">
<link rel="icon" href="{{basePath}}client/img/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="{{basePath}}client/img/favicon.ico" type="image/x-icon">
<script type="text/javascript">
$(function () {
Espo.loader.cacheTimestamp = {{cacheTimestamp}};
Espo.require('app-portal', function (App) {
var app = new App({
id: '{{portalId}}',
useCache: {{useCache}},
cacheTimestamp: {{cacheTimestamp}},
url: 'api/v1/portal-access/{{portalId}}',
basePath: '{{basePath}}'
}, function (app) {
{{runScript}}
});
});
});
</script>
</head>
<body>
<div class="container content"></div>
<footer>
<p class="credit small">&copy; 2018 <a href="http://www.espocrm.com" title="Powered by EspoCRM" alt="Visit official EspoCRM website">EspoCRM</a></p>
</footer>
</body>
</html>