diff --git a/CHANGELOG.md b/CHANGELOG.md
index 108c3556..7e8d4b01 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Change Log
+## 4.1.1
+## Changed
+- compatible with Nextcloud 16-17
+
## 4.1.0
## Added
- inline editor if using the same tab, opening the sidebar, sharing from the editor
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 3644de29..c455b88e 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -6,7 +6,7 @@
ONLYOFFICE connector enables you to edit Office documents within ONLYOFFICE from the familiar web interface. This will create a new Open in ONLYOFFICE action within the document library for Office documents. This allows multiple users to collaborate in real time and to save back those changes to your file storage.
agpl
Ascensio System SIA
- 4.1.0
+ 4.1.1
Onlyoffice
diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php
index 112e947d..fd562578 100644
--- a/controller/editorcontroller.php
+++ b/controller/editorcontroller.php
@@ -59,6 +59,7 @@
use OCA\Onlyoffice\DocumentService;
use OCA\Onlyoffice\FileCreator;
use OCA\Onlyoffice\FileUtility;
+use OCA\Onlyoffice\TemplateManager;
/**
* Controller with the main functions
@@ -225,7 +226,7 @@ public function create($name, $dir, $shareToken = NULL) {
return ["error" => $this->trans->t("You don't have enough permission to create")];
}
- $template = FileCreator::GetTemplate($name);
+ $template = TemplateManager::GetTemplate($name);
if (!$template) {
$this->logger->error("Template for file creation not found: $templatePath", array("app" => $this->appName));
return ["error" => $this->trans->t("Template not found")];
diff --git a/lib/filecreator.php b/lib/filecreator.php
index 788b1725..85c0a693 100644
--- a/lib/filecreator.php
+++ b/lib/filecreator.php
@@ -34,6 +34,8 @@
use OCP\IL10N;
use OCP\ILogger;
+use OCA\Onlyoffice\TemplateManager;
+
/**
* File creator
*
@@ -144,7 +146,7 @@ public function create(File $file, string $creatorId = null, string $templateId
$this->logger->debug("FileCreator: " . $file->getId() . " " . $file->getName() . " $creatorId $templateId", array("app" => $this->appName));
$fileName = $file->getName();
- $template = self::GetTemplate($fileName);
+ $template = TemplateManager::GetTemplate($fileName);
if (!$template) {
$this->logger->error("FileCreator: Template for file creation not found: $templatePath", array("app" => $this->appName));
@@ -157,38 +159,4 @@ public function create(File $file, string $creatorId = null, string $templateId
$this->logger->error("FileCreator: Can't create file: $name", array("app" => $this->appName));
}
}
-
- /**
- * Get template
- *
- * @param string $name - file name
- *
- * @return string
- */
- public static function GetTemplate(string $name) {
- $ext = strtolower("." . pathinfo($name, PATHINFO_EXTENSION));
-
- $lang = \OC::$server->getL10NFactory("")->get("")->getLanguageCode();
-
- $templatePath = self::getTemplatePath($lang, $ext);
- if (!file_exists($templatePath)) {
- $lang = "en";
- $templatePath = self::getTemplatePath($lang, $ext);
- }
-
- $template = file_get_contents($templatePath);
- return $template;
- }
-
- /**
- * Get template path
- *
- * @param string $lang - language
- * @param string $ext - file extension
- *
- * @return string
- */
- private static function GetTemplatePath(string $lang, string $ext) {
- return dirname(__DIR__) . DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . $lang . DIRECTORY_SEPARATOR . "new" . $ext;
- }
}
diff --git a/lib/templatemanager.php b/lib/templatemanager.php
new file mode 100644
index 00000000..71ad53db
--- /dev/null
+++ b/lib/templatemanager.php
@@ -0,0 +1,73 @@
+getL10NFactory("")->get("")->getLanguageCode();
+
+ $templatePath = self::getTemplatePath($lang, $ext);
+ if (!file_exists($templatePath)) {
+ $lang = "en";
+ $templatePath = self::getTemplatePath($lang, $ext);
+ }
+
+ $template = file_get_contents($templatePath);
+ return $template;
+ }
+
+ /**
+ * Get template path
+ *
+ * @param string $lang - language
+ * @param string $ext - file extension
+ *
+ * @return string
+ */
+ private static function GetTemplatePath(string $lang, string $ext) {
+ return dirname(__DIR__) . DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . $lang . DIRECTORY_SEPARATOR . "new" . $ext;
+ }
+}