diff --git a/api/v1/portal/index.php b/api/v1/portal/index.php index 6ab5c3479f..58e67273a2 100644 --- a/api/v1/portal/index.php +++ b/api/v1/portal/index.php @@ -31,5 +31,5 @@ require_once('../../../bootstrap.php'); $portalId = explode('/', $_SERVER['REQUEST_URI'])[count(explode('/', $_SERVER['SCRIPT_NAME'])) - 1]; -$app = new \Espo\Core\ApplicationPortal($portalId); +$app = new \Espo\Core\Portal\Application($portalId); $app->run(); diff --git a/application/Espo/Controllers/I18n.php b/application/Espo/Controllers/I18n.php index 68fc2dfec0..43f50c1de2 100644 --- a/application/Espo/Controllers/I18n.php +++ b/application/Espo/Controllers/I18n.php @@ -31,7 +31,6 @@ namespace Espo\Controllers; class I18n extends \Espo\Core\Controllers\Base { - public function actionRead($params, $data) { return $this->getContainer()->get('language')->getAll(); diff --git a/application/Espo/Controllers/Settings.php b/application/Espo/Controllers/Settings.php index 6216134e4a..c4df08da7c 100644 --- a/application/Espo/Controllers/Settings.php +++ b/application/Espo/Controllers/Settings.php @@ -50,6 +50,12 @@ class Settings extends \Espo\Core\Controllers\Base foreach ($this->getContainer()->get('portal')->getSettingsAttributeList() as $attribute) { $data[$attribute] = $this->getContainer()->get('portal')->get($attribute); } + if (empty($data['language'])) { + $data['language'] = $this->getConfig()->get('language'); + } + if (empty($data['theme'])) { + $data['theme'] = $this->getConfig()->get('theme'); + } } return $data; } diff --git a/application/Espo/Core/AclPortal.php b/application/Espo/Core/Portal/Acl.php similarity index 97% rename from application/Espo/Core/AclPortal.php rename to application/Espo/Core/Portal/Acl.php index 05ba2cdc2e..c9a8bf4d0b 100644 --- a/application/Espo/Core/AclPortal.php +++ b/application/Espo/Core/Portal/Acl.php @@ -27,12 +27,12 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -namespace Espo\Core; +namespace Espo\Core\Portal; use \Espo\ORM\Entity; use \Espo\Entities\User; -class AclPortal extends Acl +class Acl extends \Espo\Core\Acl { public function checkReadOnlyAccount($scope) { diff --git a/application/Espo/Core/AclPortalManager.php b/application/Espo/Core/Portal/AclManager.php similarity index 98% rename from application/Espo/Core/AclPortalManager.php rename to application/Espo/Core/Portal/AclManager.php index e6e94745ca..1430a10923 100644 --- a/application/Espo/Core/AclPortalManager.php +++ b/application/Espo/Core/Portal/AclManager.php @@ -27,13 +27,13 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -namespace Espo\Core; +namespace Espo\Core\Portal; use \Espo\ORM\Entity; use \Espo\Entities\User; use \Espo\Core\Utils\Util; -class AclPortalManager extends AclManager +class AclManager extends \Espo\Core\AclManager { protected $tableClassName = '\\Espo\\Core\\AclPortal\\Table'; diff --git a/application/Espo/Core/ApplicationPortal.php b/application/Espo/Core/Portal/Application.php similarity index 93% rename from application/Espo/Core/ApplicationPortal.php rename to application/Espo/Core/Portal/Application.php index 53a37f0f54..2c7f5f4857 100644 --- a/application/Espo/Core/ApplicationPortal.php +++ b/application/Espo/Core/Portal/Application.php @@ -27,11 +27,13 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -namespace Espo\Core; +namespace Espo\Core\Portal; use \Espo\Core\Exceptions\Error; +use \Espo\Core\Exceptions\NotFound; +use \Espo\Core\Exceptions\Forbidden; -class ApplicationPortal extends Application +class Application extends \Espo\Core\Application { public function __construct($portalId) { @@ -56,7 +58,6 @@ class ApplicationPortal extends Application $this->getContainer()->setPortal($portal); - $GLOBALS['log'] = $this->getContainer()->get('log'); $this->initAutoloads(); @@ -69,7 +70,7 @@ class ApplicationPortal extends Application protected function initContainer() { - $this->container = new ContainerPortal(); + $this->container = new Container(); } protected function getRouteList() diff --git a/application/Espo/Core/ContainerPortal.php b/application/Espo/Core/Portal/Container.php similarity index 80% rename from application/Espo/Core/ContainerPortal.php rename to application/Espo/Core/Portal/Container.php index f81102aaee..665c567476 100644 --- a/application/Espo/Core/ContainerPortal.php +++ b/application/Espo/Core/Portal/Container.php @@ -27,9 +27,9 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -namespace Espo\Core; +namespace Espo\Core\Portal; -class ContainerPortal extends Container +class Container extends \Espo\Core\Container { protected function getServiceClassName($name, $default) { @@ -40,7 +40,7 @@ class ContainerPortal extends Container protected function loadAclManager() { - $className = $this->getServiceClassName('aclManager', '\\Espo\\Core\\AclPortalManager'); + $className = $this->getServiceClassName('aclManager', '\\Espo\\Core\\Portal\\AclManager'); return new $className( $this->get('container') ); @@ -48,7 +48,7 @@ class ContainerPortal extends Container protected function loadAcl() { - $className = $this->getServiceClassName('acl', '\\Espo\\Core\\AclPortal'); + $className = $this->getServiceClassName('acl', '\\Espo\\Core\\Portal\\Acl'); return new $className( $this->get('aclManager'), $this->get('user') @@ -57,7 +57,7 @@ class ContainerPortal extends Container protected function loadThemeManager() { - return new \Espo\Core\Utils\ThemePortalManager( + return new \Espo\Core\Portal\Utils\ThemeManager( $this->get('config'), $this->get('metadata'), $this->get('portal') @@ -66,13 +66,25 @@ class ContainerPortal extends Container protected function loadLayout() { - return new \Espo\Core\Utils\LayoutPortal( + return new \Espo\Core\Portal\Utils\Layout( $this->get('fileManager'), $this->get('metadata'), $this->get('user') ); } + protected function loadLanguage() + { + $language = new \Espo\Core\Portal\Utils\Language( + $this->get('fileManager'), + $this->get('config'), + $this->get('metadata'), + $this->get('preferences') + ); + $language->setPortal($this->get('portal')); + return $language; + } + public function setPortal(\Espo\Entities\Portal $portal) { $this->set('portal', $portal); diff --git a/application/Espo/Core/Portal/Utils/Language.php b/application/Espo/Core/Portal/Utils/Language.php new file mode 100644 index 0000000000..2ccff0711f --- /dev/null +++ b/application/Espo/Core/Portal/Utils/Language.php @@ -0,0 +1,46 @@ +get('language') !== '' && $portal->get('language')) { + if (!$this->getPreferences()->get('language')) { + $this->setLanguage($portal->get('language')); + } + } + } + +} diff --git a/application/Espo/Core/Utils/LayoutPortal.php b/application/Espo/Core/Portal/Utils/Layout.php similarity index 97% rename from application/Espo/Core/Utils/LayoutPortal.php rename to application/Espo/Core/Portal/Utils/Layout.php index 73d22e9fe0..f65f21efd6 100644 --- a/application/Espo/Core/Utils/LayoutPortal.php +++ b/application/Espo/Core/Portal/Utils/Layout.php @@ -27,11 +27,13 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -namespace Espo\Core\Utils; +namespace Espo\Core\Portal\Utils; -class LayoutPortal extends Layout +use \Espo\Core\Utils\Util; +use \Espo\Core\Utils\Json; + +class Layout extends \Espo\Core\Utils\Layout { - public function get($scope, $name) { $scope = $this->sanitizeInput($scope); diff --git a/application/Espo/Core/Utils/ThemePortalManager.php b/application/Espo/Core/Portal/Utils/ThemeManager.php similarity index 83% rename from application/Espo/Core/Utils/ThemePortalManager.php rename to application/Espo/Core/Portal/Utils/ThemeManager.php index f01f220652..501e7edc69 100644 --- a/application/Espo/Core/Utils/ThemePortalManager.php +++ b/application/Espo/Core/Portal/Utils/ThemeManager.php @@ -27,22 +27,15 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -namespace Espo\Core\Utils; +namespace Espo\Core\Portal\Utils; use \Espo\Entities\Portal; -class ThemePortalManager +use \Espo\Core\Utils\Config; +use \Espo\Core\Utils\Metadata; + +class ThemeManager extends \Espo\Core\Utils\ThemeManager { - protected $config; - - protected $metadata; - - protected $portal; - - private $defaultName = 'Espo'; - - private $defaultStylesheet = 'Espo'; - public function __construct(Config $config, Metadata $metadata, Portal $portal) { $this->config = $config; @@ -58,11 +51,6 @@ class ThemePortalManager } return $theme; } - - public function getStylesheet() - { - return $this->metadata->get('themes.' . $this->getName() . '.stylesheet', 'client/css/espo.css'); - } } diff --git a/application/Espo/Core/Utils/Language.php b/application/Espo/Core/Utils/Language.php index 4a84e7dc67..40d4d51e47 100644 --- a/application/Espo/Core/Utils/Language.php +++ b/application/Espo/Core/Utils/Language.php @@ -35,9 +35,13 @@ use \Espo\Core\Utils\Util, class Language { private $fileManager; + private $config; + private $metadata; + private $preferences; + private $unifier; /** diff --git a/application/Espo/Entities/Portal.php b/application/Espo/Entities/Portal.php index cf73f4453a..e27a799be6 100644 --- a/application/Espo/Entities/Portal.php +++ b/application/Espo/Entities/Portal.php @@ -32,7 +32,7 @@ namespace Espo\Entities; class Portal extends \Espo\Core\ORM\Entity { - protected $settingsAttributeList = ['companyLogoId', 'tabList', 'quickCreateList', 'theme']; + protected $settingsAttributeList = ['companyLogoId', 'tabList', 'quickCreateList', 'theme', 'language']; public function getSettingsAttributeList() { diff --git a/application/Espo/EntryPoints/Portal.php b/application/Espo/EntryPoints/Portal.php index 2b72b92d47..d70e0a2cf1 100644 --- a/application/Espo/EntryPoints/Portal.php +++ b/application/Espo/EntryPoints/Portal.php @@ -48,7 +48,7 @@ class Portal extends \Espo\Core\EntryPoints\Base } } - $application = new \Espo\Core\ApplicationPortal($id); + $application = new \Espo\Core\Portal\Application($id); $application->runClient(); } } diff --git a/application/Espo/Repositories/Preferences.php b/application/Espo/Repositories/Preferences.php index a098f168fb..99b719957d 100644 --- a/application/Espo/Repositories/Preferences.php +++ b/application/Espo/Repositories/Preferences.php @@ -49,7 +49,6 @@ class Preferences extends \Espo\Core\ORM\Repository 'thousandSeparator', 'weekStart', 'timeZone', - 'language', 'exportDelimiter' ); diff --git a/application/Espo/Resources/i18n/en_US/Portal.json b/application/Espo/Resources/i18n/en_US/Portal.json index f9b5c7618a..89e3cee03b 100644 --- a/application/Espo/Resources/i18n/en_US/Portal.json +++ b/application/Espo/Resources/i18n/en_US/Portal.json @@ -9,7 +9,8 @@ "tabList": "Tab List", "quickCreateList": "Quick Create List", "companyLogo": "Logo", - "theme": "Theme" + "theme": "Theme", + "language": "Language" }, "links": { "users": "Users", diff --git a/application/Espo/Resources/layouts/Portal/detail.json b/application/Espo/Resources/layouts/Portal/detail.json index 563f31afdf..6c1b99012a 100644 --- a/application/Espo/Resources/layouts/Portal/detail.json +++ b/application/Espo/Resources/layouts/Portal/detail.json @@ -4,7 +4,7 @@ "rows": [ [{"name": "name"}, {"name": "isActive"}], [{"name": "url"}, {"name": "isDefault"}], - [{"name": "portalRoles"}, false] + [{"name": "portalRoles"}, {"name": "language"}] ] }, { diff --git a/application/Espo/Resources/layouts/Portal/detailSmall.json b/application/Espo/Resources/layouts/Portal/detailSmall.json new file mode 100644 index 0000000000..2189e741f4 --- /dev/null +++ b/application/Espo/Resources/layouts/Portal/detailSmall.json @@ -0,0 +1,19 @@ +[ + { + "label": "General", + "rows": [ + [{"name": "name", "fullWidth": true}], + [{"name": "url", "fullWidth": true}], + [{"name": "isDefault"}, {"name": "isActive"}], + [{"name": "portalRoles", "fullWidth": true}], + [{"name": "language"}, false] + ] + }, + { + "label": "User Interface", + "rows": [ + [{"name": "companyLogo"}, {"name": "theme"}], + [{"name": "tabList"}, {"name": "quickCreateList"}] + ] + } +] \ No newline at end of file diff --git a/application/Espo/Resources/metadata/entityDefs/Portal.json b/application/Espo/Resources/metadata/entityDefs/Portal.json index 678a5ff597..131c6a66b1 100644 --- a/application/Espo/Resources/metadata/entityDefs/Portal.json +++ b/application/Espo/Resources/metadata/entityDefs/Portal.json @@ -40,9 +40,14 @@ }, "theme": { "type": "enum", - "view": "views/settings/fields/theme", + "view": "views/preferences/fields/theme", "translation": "Global.themes", - "default": "Espo" + "default": "" + }, + "language": { + "type": "enum", + "view": "views/portal/fields/language", + "default": "" }, "modifiedAt": { "type": "datetime", diff --git a/application/Espo/Resources/metadata/entityDefs/Preferences.json b/application/Espo/Resources/metadata/entityDefs/Preferences.json index 3144e2d1cd..567c05d3d4 100644 --- a/application/Espo/Resources/metadata/entityDefs/Preferences.json +++ b/application/Espo/Resources/metadata/entityDefs/Preferences.json @@ -76,7 +76,8 @@ }, "language": { "type": "enum", - "default": "en_US" + "default": "", + "view": "views/preferences/fields/language" }, "exportDelimiter": { "type": "varchar", diff --git a/frontend/client/modules/crm/src/views/knowledge-base-article/fields/language.js b/frontend/client/modules/crm/src/views/knowledge-base-article/fields/language.js index b532158871..c3a4cdc330 100644 --- a/frontend/client/modules/crm/src/views/knowledge-base-article/fields/language.js +++ b/frontend/client/modules/crm/src/views/knowledge-base-article/fields/language.js @@ -33,7 +33,7 @@ Espo.define('crm:views/knowledge-base-article/fields/language', 'views/fields/en setupOptions: function () { this.params.options = Espo.Utils.clone(this.getConfig().get('languageList') || []); this.params.options.unshift(''); - this.translatedOptions = this.getLanguage().translate('language', 'options') || {}; + this.translatedOptions = Espo.Utils.clone(this.getLanguage().translate('language', 'options') || {}); this.translatedOptions[''] = this.translate('Any', 'labels', 'KnowledgeBaseArticle') } diff --git a/frontend/client/res/templates/modals/detail.tpl b/frontend/client/res/templates/modals/detail.tpl index c5c847ef73..325e04fc63 100644 --- a/frontend/client/res/templates/modals/detail.tpl +++ b/frontend/client/res/templates/modals/detail.tpl @@ -1 +1 @@ -