Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ONLYOFFICE/onlyoffice-nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Linnik <sergey.linnik@onlyoffice.com>2020-01-16 17:55:50 +0300
committerGitHub <noreply@github.com>2020-01-16 17:55:50 +0300
commitc8fc3c84a77202568fa9c7b09f44950a24b00703 (patch)
treef0bcd476971df2c6ec387d8b4793873b57639c4d /lib/filecreator.php
parentc05cbbf9a226810fa24b8e02371c7f9aee504072 (diff)
parent068d8a610494a2ddeae702735432db234ff357f8 (diff)
Merge pull request #211 from ONLYOFFICE/developv4.1.1
Release/4.1.1
Diffstat (limited to 'lib/filecreator.php')
-rw-r--r--lib/filecreator.php38
1 files changed, 3 insertions, 35 deletions
diff --git a/lib/filecreator.php b/lib/filecreator.php
index 788b172..85c0a69 100644
--- a/lib/filecreator.php
+++ b/lib/filecreator.php
@@ -34,6 +34,8 @@ use OCP\Files\File;
use OCP\IL10N;
use OCP\ILogger;
+use OCA\Onlyoffice\TemplateManager;
+
/**
* File creator
*
@@ -144,7 +146,7 @@ class FileCreator extends ACreateEmpty {
$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 @@ class FileCreator extends ACreateEmpty {
$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;
- }
}