diff --git a/application/Espo/Core/Loaders/EntityManagerUtil.php b/application/Espo/Core/Loaders/EntityManagerUtil.php index 04a26148b2..ef8a6ef1ec 100644 --- a/application/Espo/Core/Loaders/EntityManagerUtil.php +++ b/application/Espo/Core/Loaders/EntityManagerUtil.php @@ -37,6 +37,7 @@ class EntityManagerUtil extends Base $this->getContainer()->get('metadata'), $this->getContainer()->get('language'), $this->getContainer()->get('fileManager'), + $this->getContainer()->get('config'), $this->getContainer() ); diff --git a/application/Espo/Core/Templates/Metadata/Event/clientDefs.json b/application/Espo/Core/Templates/Metadata/Event/clientDefs.json index 31713ec365..9404869fe2 100644 --- a/application/Espo/Core/Templates/Metadata/Event/clientDefs.json +++ b/application/Espo/Core/Templates/Metadata/Event/clientDefs.json @@ -4,5 +4,17 @@ "activityDefs": { "activitiesCreate": true, "historyCreate": true - } + }, + "filterList": [ + { + "name":"planned" + }, + { + "name":"held", + "style": "success" + }, + { + "name":"todays" + } + ] } diff --git a/application/Espo/Core/Templates/SelectManagers/Event.php b/application/Espo/Core/Templates/SelectManagers/Event.php new file mode 100644 index 0000000000..c702ba9f42 --- /dev/null +++ b/application/Espo/Core/Templates/SelectManagers/Event.php @@ -0,0 +1,57 @@ + 'Planned' + ); + } + + protected function filterHeld(&$result) + { + $result['whereClause'][] = array( + 'status' => 'Held' + ); + } + + protected function filterTodays(&$result) + { + $result['whereClause'][] = $this->convertDateTimeWhere(array( + 'type' => 'today', + 'attribute' => 'dateStart', + 'timeZone' => $this->getUserTimeZone() + )); + } +} + diff --git a/application/Espo/Core/Templates/i18n/en_US/Base.json b/application/Espo/Core/Templates/i18n/en_US/Base.json new file mode 100644 index 0000000000..2597fd689e --- /dev/null +++ b/application/Espo/Core/Templates/i18n/en_US/Base.json @@ -0,0 +1,9 @@ +{ + "fields": { + }, + "links": { + }, + "labels": { + "Create {entityType}": "Create {entityTypeTranslated}" + } +} diff --git a/application/Espo/Core/Templates/i18n/en_US/BasePlus.json b/application/Espo/Core/Templates/i18n/en_US/BasePlus.json new file mode 100644 index 0000000000..e925510d72 --- /dev/null +++ b/application/Espo/Core/Templates/i18n/en_US/BasePlus.json @@ -0,0 +1,12 @@ +{ + "fields": { + }, + "links": { + "meetings": "Meetings", + "calls": "Calls", + "tasks": "Tasks" + }, + "labels": { + "Create {entityType}": "Create {entityTypeTranslated}" + } +} diff --git a/application/Espo/Core/Templates/i18n/en_US/Company.json b/application/Espo/Core/Templates/i18n/en_US/Company.json new file mode 100644 index 0000000000..341895d86c --- /dev/null +++ b/application/Espo/Core/Templates/i18n/en_US/Company.json @@ -0,0 +1,15 @@ +{ + "fields": { + "billingAddress": "Billing Address", + "shippingAddress": "Shipping Address", + "website": "Website" + }, + "links": { + "meetings": "Meetings", + "calls": "Calls", + "tasks": "Tasks" + }, + "labels": { + "Create {entityType}": "Create {entityTypeTranslated}" + } +} diff --git a/application/Espo/Core/Templates/i18n/en_US/Event.json b/application/Espo/Core/Templates/i18n/en_US/Event.json new file mode 100644 index 0000000000..ac53c1d9cf --- /dev/null +++ b/application/Espo/Core/Templates/i18n/en_US/Event.json @@ -0,0 +1,35 @@ +{ + "fields": { + "parent": "Parent", + "dateStart": "Date Start", + "dateEnd": "Date End", + "duration": "Duration", + "status": "Status" + }, + "links": { + "parent": "Parent" + }, + "options": { + "status": { + "Planned": "Planned", + "Held": "Held", + "Not Held": "Not Held" + } + }, + "labels": { + "Create {entityType}": "Create {entityTypeTranslated}", + "Schedule {entityType}": "Schedule {entityTypeTranslated}", + "Log {entityType}": "Log {entityTypeTranslated}", + "Set Held": "Set Held", + "Set Not Held": "Set Not Held" + }, + "massActions": { + "setHeld": "Set Held", + "setNotHeld": "Set Not Held" + }, + "presetFilters": { + "planned": "Planned", + "held": "Held", + "todays": "Today's" + } +} diff --git a/application/Espo/Core/Templates/i18n/en_US/Person.json b/application/Espo/Core/Templates/i18n/en_US/Person.json new file mode 100644 index 0000000000..7793632bb6 --- /dev/null +++ b/application/Espo/Core/Templates/i18n/en_US/Person.json @@ -0,0 +1,13 @@ +{ + "fields": { + "address": "Address" + }, + "links": { + "meetings": "Meetings", + "calls": "Calls", + "tasks": "Tasks" + }, + "labels": { + "Create {entityType}": "Create {entityTypeTranslated}" + } +} diff --git a/application/Espo/Core/Utils/EntityManager.php b/application/Espo/Core/Utils/EntityManager.php index 544204bb8c..ebf3b2381f 100644 --- a/application/Espo/Core/Utils/EntityManager.php +++ b/application/Espo/Core/Utils/EntityManager.php @@ -43,15 +43,18 @@ class EntityManager private $fileManager; + private $config; + private $metadataHelper; private $container; - public function __construct(Metadata $metadata, Language $language, File\Manager $fileManager, Container $container = null) + public function __construct(Metadata $metadata, Language $language, File\Manager $fileManager, Config $config, Container $container = null) { $this->metadata = $metadata; $this->language = $language; $this->fileManager = $fileManager; + $this->config = $config; $this->metadataHelper = new \Espo\Core\Utils\Metadata\Helper($this->metadata); @@ -73,6 +76,11 @@ class EntityManager return $this->fileManager; } + protected function getConfig() + { + return $this->config; + } + protected function getMetadataHelper() { return $this->metadataHelper; @@ -126,6 +134,17 @@ class EntityManager $filePath = "custom/Espo/Custom/Repositories/{$normalizedName}.php"; $this->getFileManager()->putContents($filePath, $contents); + if (file_exists('application/Espo/Core/Templates/SelectManagers/' . $type . '.php')) { + $contents = "<" . "?" . "php\n\n". + "namespace Espo\Custom\SelectManagers;\n\n". + "class {$normalizedName} extends \Espo\Core\Templates\SelectManagers\\{$type}\n". + "{\n". + "}\n"; + + $filePath = "custom/Espo/Custom/SelectManagers/{$normalizedName}.php"; + $this->getFileManager()->putContents($filePath, $contents); + } + $stream = false; if (!empty($params['stream'])) { $stream = $params['stream']; @@ -142,14 +161,17 @@ class EntityManager if (!empty($params['labelPlural'])) { $labelPlural = $params['labelPlural']; } - $labelCreate = $this->getLanguage()->translate('Create') . ' ' . $labelSingular; - if ($type == 'Event') { - $labelSchedule = $this->getLanguage()->translate('Schedule', 'labels', 'EntityManager') . ' ' . $labelSingular; - $this->getLanguage()->set($name, 'labels', 'Schedule ' . $name, $labelSchedule); + $languageList = $this->getConfig()->get('languageList', []); + foreach ($languageList as $language) { + $filePath = 'application/Espo/Core/Templates/i18n/' . $language . '/' . $type . '.json'; + if (!file_exists($filePath)) continue; + $languageContents = $this->getFileManager()->getContents($filePath); + $languageContents = str_replace('{entityType}', $name, $languageContents); + $languageContents = str_replace('{entityTypeTranslated}', $labelSingular, $languageContents); - $labelLog = $this->getLanguage()->translate('Log', 'labels', 'EntityManager') . ' ' . $labelSingular; - $this->getLanguage()->set($name, 'labels', 'Log ' . $name, $labelLog); + $destinationFilePath = 'custom/Espo/Custom/Resources/i18n/' . $language . '/' . $name . '.json'; + $this->getFileManager()->putContents($destinationFilePath, $languageContents); } $filePath = "application/Espo/Core/Templates/Metadata/{$type}/scopes.json"; @@ -180,7 +202,6 @@ class EntityManager $this->getLanguage()->set('Global', 'scopeNames', $name, $labelSingular); $this->getLanguage()->set('Global', 'scopeNamesPlural', $name, $labelPlural); - $this->getLanguage()->set($name, 'labels', 'Create ' . $name, $labelCreate); $this->getMetadata()->save(); $this->getLanguage()->save(); @@ -277,9 +298,20 @@ class EntityManager $this->getFileManager()->removeFile("custom/Espo/Custom/Controllers/{$normalizedName}.php"); $this->getFileManager()->removeFile("custom/Espo/Custom/Repositories/{$normalizedName}.php"); + if (file_exists("custom/Espo/Custom/SelectManagers/{$normalizedName}.php")) { + $this->getFileManager()->removeFile("custom/Espo/Custom/SelectManagers/{$normalizedName}.php"); + } + $this->getFileManager()->removeInDir("custom/Espo/Custom/Resources/layouts/{$normalizedName}"); $this->getFileManager()->removeDir("custom/Espo/Custom/Resources/layouts/{$normalizedName}"); + $languageList = $this->getConfig()->get('languageList', []); + foreach ($languageList as $language) { + $filePath = 'custom/Espo/Custom/Resources/i18n/' . $language . '/' . $normalizedName . '.json' ; + if (!file_exists($filePath)) continue; + $this->getFileManager()->removeFile($filePath); + } + try { $this->getLanguage()->delete('Global', 'scopeNames', $name); $this->getLanguage()->delete('Global', 'scopeNamesPlural', $name); diff --git a/lang.js b/lang.js index 72c9877c4d..5f45003157 100644 --- a/lang.js +++ b/lang.js @@ -92,6 +92,11 @@ function Lang (poPath, espoPath) { dirs.push(installDir); dirNames[installDir] = 'install/core/i18n/' + resLang + '/'; + + var templatesDir = this.espoPath + 'application/Espo/Core/Templates/i18n/' + this.baseLanguage + '/'; + dirs.push(templatesDir); + dirNames[templatesDir] = 'application/Espo/Core/Templates/i18n/' + resLang + '/'; + this.dirs = dirs; }; diff --git a/po.js b/po.js index 67e3120707..4e07a12078 100644 --- a/po.js +++ b/po.js @@ -53,7 +53,8 @@ function PO (espoPath, language) { var dirs = [ this.path + 'application/Espo/Resources/i18n/', - this.path + 'install/core/i18n/' + this.path + 'install/core/i18n/', + this.path + 'application/Espo/Core/Templates/i18n/' ]; this.moduleList.forEach(function (moduleName) { dirs.push(this.path + 'application/Espo/Modules/' + moduleName + '/Resources/i18n/');