From e7fc9bb8c295455dfa8d2c8aac02be8ee360efd0 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 8 Feb 2023 10:22:54 +0300 Subject: [PATCH] php: ConfigManager class added, config.json for ConfigManager added (instead of $GLOBALS array in future) --- web/documentserver-example/php/config.json | 85 +++++++++++++++++++ .../php/helpers/ConfigManager.php | 46 ++++++++++ 2 files changed, 131 insertions(+) create mode 100644 web/documentserver-example/php/config.json create mode 100644 web/documentserver-example/php/helpers/ConfigManager.php diff --git a/web/documentserver-example/php/config.json b/web/documentserver-example/php/config.json new file mode 100644 index 00000000..5a58ea20 --- /dev/null +++ b/web/documentserver-example/php/config.json @@ -0,0 +1,85 @@ +{ + "version": "1.5.0", + + "fileSizeMax": 5242880, + "storagePath": "", + "alone": false, + + "docServFillforms": [".oform", ".docx"], + "docServViewd": [".pdf", ".djvu", ".xps", ".oxps"], + "docServEdited": [".docx", ".xlsx", ".csv", ".pptx", ".txt", ".docxf"], + "docServConvert": [".docm", ".doc", ".dotx", ".dotm", ".dot", + ".odt", ".fodt", ".ott", ".xlsm", ".xlsb", ".xls", ".xltx", ".xltm", + ".xlt", ".ods", ".fods", ".ots", ".pptm", ".ppt", ".ppsx", ".ppsm", ".pps", + ".potx", ".potm", ".pot", ".odp", ".fodp", ".otp", ".rtf", ".mht", ".html", ".htm", ".xml", ".epub", ".fb2"], + + "docServTimeout": "120000", + "docServSiteUrl": "http://127.0.0.1/", + + "docServConverterUrl": "ConvertService.ashx", + "docServApiUrl": "web-apps/apps/api/documents/api.js", + "docServPreloaderUrl": "web-apps/apps/api/documents/cache-scripts.html", + "docServCommandUrl": "coauthoring/CommandService.ashx", + + "docServJwtSecret": "9GKkwG4oUrswxS0sp1RJ", + "docServJwtHeader": "Authorization", + "docServJwtUseForRequest": true, + + "docServVerifyPeerOff": true, + + "exampleUrl": "", + "mobileRegex": "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino", + "extsSpreadsheet": [".xls", ".xlsx", ".xlsm", ".xlsb", + ".xlt", ".xltx", ".xltm", + ".ods", ".fods", ".ots", ".csv"], + "extsPresentation": [".pps", ".ppsx", ".ppsm", + ".ppt", ".pptx", ".pptm", + ".pot", ".potx", ".potm", + ".odp", ".fodp", ".otp"], + "extsDocument": [".doc", ".docx", ".docm", + ".dot", ".dotx", ".dotm", + ".odt", ".fodt", ".ott", ".rtf", ".txt", + ".html", ".htm", ".mht", ".xml", + ".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps", ".oform"], + "languages": { + "en": "English", + "hy": "Armenian", + "az": "Azerbaijani", + "eu": "Basque", + "be": "Belarusian", + "bg": "Bulgarian", + "ca": "Catalan", + "zh" : "Chinese (People's Republic of China)", + "zh-TW" : "Chinese (Traditional, Taiwan)", + "cs": "Czech", + "da": "Danish", + "nl": "Dutch", + "fi": "Finnish", + "fr": "French", + "gl": "Galego", + "de": "German", + "el": "Greek", + "hu": "Hungarian", + "id": "Indonesian", + "it": "Italian", + "ja": "Japanese", + "ko": "Korean", + "lv": "Latvian", + "lo": "Lao", + "ms": "Malay (Malaysia)", + "nb": "Norwegian", + "pl": "Polish", + "pt" : "Portuguese (Brazil)", + "pt-PT" : "Portuguese (Portugal)", + "ro": "Romanian", + "ru": "Russian", + "sk": "Slovak", + "sl": "Slovenian", + "es": "Spanish", + "sv": "Swedish", + "tr": "Turkish", + "uk": "Ukrainian", + "vi": "Vietnamese", + "aa-AA": "Test Language" + } +} diff --git a/web/documentserver-example/php/helpers/ConfigManager.php b/web/documentserver-example/php/helpers/ConfigManager.php new file mode 100644 index 00000000..af898522 --- /dev/null +++ b/web/documentserver-example/php/helpers/ConfigManager.php @@ -0,0 +1,46 @@ +config = json_decode($this->getConfigurationJson()); + } + + private function getConfigurationJson(): bool|string + { + return file_exists("./config.json") ? file_get_contents("./config.json") : false; + } + + /** + * @param string|null $configName + * @return mixed + */ + public function getConfig(string $configName = null): mixed + { + if ($configName) { + return $this->config->$configName ?? ""; + } + return $this->config; + } +}