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
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/appconfig.php72
-rw-r--r--lib/directeditor.php4
-rw-r--r--lib/documentservice.php2
-rw-r--r--lib/hooks.php2
-rw-r--r--lib/notifier.php152
-rw-r--r--lib/preview.php14
-rw-r--r--lib/templatemanager.php60
-rw-r--r--lib/templateprovider.php91
8 files changed, 337 insertions, 60 deletions
diff --git a/lib/appconfig.php b/lib/appconfig.php
index 3d0d6f3..87865dc 100644
--- a/lib/appconfig.php
+++ b/lib/appconfig.php
@@ -271,6 +271,13 @@ class AppConfig {
public $_customization_autosave = "customization_autosave";
/**
+ * The config key for the goback
+ *
+ * @var string
+ */
+ public $_customization_goback = "customization_goback";
+
+ /**
* @param string $AppName - application name
*/
public function __construct($AppName) {
@@ -623,7 +630,7 @@ class AppConfig {
* @return bool
*/
public function GetSameTab() {
- return $this->config->getAppValue($this->appName, $this->_sameTab, "false") === "true";
+ return $this->config->getAppValue($this->appName, $this->_sameTab, "true") === "true";
}
/**
@@ -960,6 +967,7 @@ class AppConfig {
$group = \OC::$server->getGroupManager()->get($groupName);
if ($group === null) {
\OC::$server->getLogger()->error("Group is unknown $groupName", ["app" => $this->appName]);
+ $this->SetLimitGroups(array_diff($groups, [$groupName]));
} else {
if ($group->inGroup($user)) {
return true;
@@ -1080,39 +1088,39 @@ class AppConfig {
* @var array
*/
private $formats = [
- "csv" => [ "mime" => "text/csv", "type" => "spreadsheet", "edit" => true, "editable" => true ],
- "doc" => [ "mime" => "application/msword", "type" => "text", "conv" => true ],
- "docm" => [ "mime" => "application/vnd.ms-word.document.macroEnabled.12", "type" => "text", "conv" => true ],
- "docx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "type" => "text", "edit" => true, "def" => true ],
- "dot" => [ "type" => "text", "conv" => true ],
- "dotx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "type" => "text", "conv" => true ],
- "epub" => [ "mime" => "application/epub+zip", "type" => "text", "conv" => true ],
+ "csv" => [ "mime" => "text/csv", "type" => "spreadsheet", "edit" => true, "editable" => true, "saveas" => ["ods", "pdf", "xlsx"] ],
+ "doc" => [ "mime" => "application/msword", "type" => "text", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
+ "docm" => [ "mime" => "application/vnd.ms-word.document.macroEnabled.12", "type" => "text", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
+ "docx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "type" => "text", "edit" => true, "def" => true, "saveas" => ["odt", "pdf", "rtf", "txt"] ],
+ "dot" => [ "type" => "text", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
+ "dotx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "type" => "text", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
+ "epub" => [ "mime" => "application/epub+zip", "type" => "text", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
"htm" => [ "type" => "text", "conv" => true ],
- "html" => [ "mime" => "text/html", "type" => "text", "conv" => true ],
- "odp" => [ "mime" => "application/vnd.oasis.opendocument.presentation", "type" => "presentation", "conv" => true, "editable" => true ],
- "ods" => [ "mime" => "application/vnd.oasis.opendocument.spreadsheet", "type" => "spreadsheet", "conv" => true, "editable" => true ],
- "odt" => [ "mime" => "application/vnd.oasis.opendocument.text", "type" => "text", "conv" => true, "editable" => true ],
- "otp" => [ "mime" => "application/vnd.oasis.opendocument.presentation-template", "type" => "presentation", "conv" => true ],
- "ots" => [ "mime" => "application/vnd.oasis.opendocument.spreadsheet-template", "type" => "spreadsheet", "conv" => true ],
- "ott" => [ "mime" => "application/vnd.oasis.opendocument.text-template", "type" => "text", "conv" => true ],
+ "html" => [ "mime" => "text/html", "type" => "text", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
+ "odp" => [ "mime" => "application/vnd.oasis.opendocument.presentation", "type" => "presentation", "conv" => true, "editable" => true, "saveas" => ["pdf", "pptx"] ],
+ "ods" => [ "mime" => "application/vnd.oasis.opendocument.spreadsheet", "type" => "spreadsheet", "conv" => true, "editable" => true, "saveas" => ["csv", "pdf", "xlsx"] ],
+ "odt" => [ "mime" => "application/vnd.oasis.opendocument.text", "type" => "text", "conv" => true, "editable" => true, "saveas" => ["docx", "pdf", "rtf", "txt"] ],
+ "otp" => [ "mime" => "application/vnd.oasis.opendocument.presentation-template", "type" => "presentation", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
+ "ots" => [ "mime" => "application/vnd.oasis.opendocument.spreadsheet-template", "type" => "spreadsheet", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ],
+ "ott" => [ "mime" => "application/vnd.oasis.opendocument.text-template", "type" => "text", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
"pdf" => [ "mime" => "application/pdf", "type" => "text" ],
- "pot" => [ "type" => "presentation", "conv" => true ],
- "potm" => [ "mime" => "application/vnd.ms-powerpoint.template.macroEnabled.12", "type" => "presentation", "conv" => true ],
- "potx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.template", "type" => "presentation", "conv" => true ],
- "pps" => [ "type" => "presentation", "conv" => true ],
- "ppsm" => [ "mime" => "application/vnd.ms-powerpoint.slideshow.macroEnabled.12", "type" => "presentation", "conv" => true ],
- "ppsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "type" => "presentation", "conv" => true ],
- "ppt" => [ "mime" => "application/vnd.ms-powerpoint", "type" => "presentation", "conv" => true ],
- "pptm" => [ "mime" => "application/vnd.ms-powerpoint.presentation.macroEnabled.12", "type" => "presentation", "conv" => true ],
- "pptx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", "type" => "presentation", "edit" => true, "def" => true ],
- "rtf" => [ "mime" => "text/rtf", "type" => "text", "conv" => true, "editable" => true ],
- "txt" => [ "mime" => "text/plain", "type" => "text", "edit" => true, "editable" => true ],
- "xls" => [ "mime" => "application/vnd.ms-excel", "type" => "spreadsheet", "conv" => true ],
- "xlsm" => [ "mime" => "application/vnd.ms-excel.sheet.macroEnabled.12", "type" => "spreadsheet", "conv" => true ],
- "xlsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "type" => "spreadsheet", "edit" => true, "def" => true ],
- "xlt" => [ "type" => "spreadsheet", "conv" => true ],
- "xltm" => [ "mime" => "application/vnd.ms-excel.template.macroEnabled.12", "type" => "spreadsheet", "conv" => true ],
- "xltx" => [ "mime" => "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "type" => "spreadsheet", "conv" => true ]
+ "pot" => [ "type" => "presentation", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
+ "potm" => [ "mime" => "application/vnd.ms-powerpoint.template.macroEnabled.12", "type" => "presentation", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
+ "potx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.template", "type" => "presentation", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
+ "pps" => [ "type" => "presentation", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
+ "ppsm" => [ "mime" => "application/vnd.ms-powerpoint.slideshow.macroEnabled.12", "type" => "presentation", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
+ "ppsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "type" => "presentation", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
+ "ppt" => [ "mime" => "application/vnd.ms-powerpoint", "type" => "presentation", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
+ "pptm" => [ "mime" => "application/vnd.ms-powerpoint.presentation.macroEnabled.12", "type" => "presentation", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
+ "pptx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", "type" => "presentation", "edit" => true, "def" => true, "saveas" => ["pdf", "odp"] ],
+ "rtf" => [ "mime" => "text/rtf", "type" => "text", "conv" => true, "editable" => true, "saveas" => ["docx", "odt", "pdf", "txt"] ],
+ "txt" => [ "mime" => "text/plain", "type" => "text", "edit" => true, "editable" => true, "saveas" => ["docx", "odt", "pdf", "rtf"] ],
+ "xls" => [ "mime" => "application/vnd.ms-excel", "type" => "spreadsheet", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ],
+ "xlsm" => [ "mime" => "application/vnd.ms-excel.sheet.macroEnabled.12", "type" => "spreadsheet", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ],
+ "xlsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "type" => "spreadsheet", "edit" => true, "def" => true, "saveas" => ["csv", "ods", "pdf"] ],
+ "xlt" => [ "type" => "spreadsheet", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ],
+ "xltm" => [ "mime" => "application/vnd.ms-excel.template.macroEnabled.12", "type" => "spreadsheet", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ],
+ "xltx" => [ "mime" => "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "type" => "spreadsheet", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ]
];
/**
diff --git a/lib/directeditor.php b/lib/directeditor.php
index 87a7857..f7f694c 100644
--- a/lib/directeditor.php
+++ b/lib/directeditor.php
@@ -235,7 +235,9 @@ class DirectEditor implements IEditor {
"shareToken" => null,
"directToken" => $directToken,
"version" => 0,
- "inframe" => false
+ "isTemplate" => false,
+ "inframe" => false,
+ "anchor" => null
];
$response = new TemplateResponse($this->appName, "editor", $params, "base");
diff --git a/lib/documentservice.php b/lib/documentservice.php
index 308d1d6..5069506 100644
--- a/lib/documentservice.php
+++ b/lib/documentservice.php
@@ -383,7 +383,7 @@ class DocumentService {
if (preg_match("/^https:\/\//i", $urlGenerator->getAbsoluteURL("/"))
&& preg_match("/^http:\/\//i", $this->config->GetDocumentServerUrl())) {
- throw new \Exception($this->trans->t("Mixed Active Content is not allowed. HTTPS address for Document Server is required."));
+ throw new \Exception($this->trans->t("Mixed Active Content is not allowed. HTTPS address for ONLYOFFICE Docs is required."));
}
} catch (\Exception $e) {
diff --git a/lib/hooks.php b/lib/hooks.php
index b338c6d..d5ca173 100644
--- a/lib/hooks.php
+++ b/lib/hooks.php
@@ -187,6 +187,8 @@ class Hooks {
$fileId = $fileInfo->getId();
+ KeyManager::delete($fileId);
+
FileVersions::deleteVersion($ownerId, $fileId, $versionId);
} catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, ["message" => "Hook: fileVersionRestore " . json_encode($params), "app" => self::$appName]);
diff --git a/lib/notifier.php b/lib/notifier.php
new file mode 100644
index 0000000..1b52fe3
--- /dev/null
+++ b/lib/notifier.php
@@ -0,0 +1,152 @@
+<?php
+/**
+ *
+ * (c) Copyright Ascensio System SIA 2021
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace OCA\Onlyoffice;
+
+use OCP\IURLGenerator;
+use OCP\ILogger;
+use OCP\IUserManager;
+use OCP\L10N\IFactory;
+use OCP\Notification\INotification;
+use OCP\Notification\INotifier;
+
+class Notifier implements INotifier {
+
+ /**
+ * Application name
+ *
+ * @var string
+ */
+ private $appName;
+
+ /**
+ * IFactory
+ *
+ * @var IFactory
+ */
+ private $l10nFactory;
+
+ /**
+ * Url generator service
+ *
+ * @var IURLGenerator
+ */
+ private $urlGenerator;
+
+ /**
+ * Logger
+ *
+ * @var ILogger
+ */
+ private $logger;
+
+ /**
+ * User manager
+ *
+ * @var IUserManager
+ */
+ private $userManager;
+
+ /**
+ * @param string $AppName - application name
+ * @param IFactory $l10NFactory - l10n
+ * @param IURLGenerator $urlGenerator - url generator service
+ * @param ILogger $logger - logger
+ * @param IUserManager $userManager - user manager
+ */
+ public function __construct(string $appName,
+ IFactory $l10nFactory,
+ IURLGenerator $urlGenerator,
+ ILogger $logger,
+ IUserManager $userManager
+ ) {
+ $this->appName = $appName;
+ $this->l10nFactory = $l10nFactory;
+ $this->urlGenerator = $urlGenerator;
+ $this->logger = $logger;
+ $this->userManager = $userManager;
+ }
+
+ /**
+ * Identifier of the notifier, only use [a-z0-9_]
+ *
+ * @return string
+ */
+ public function getID(): string {
+ return $this->appName;
+ }
+
+ /**
+ * Human readable name describing the notifier
+ *
+ * @return string
+ */
+ public function getName(): string {
+ return $this->appName;
+ }
+
+ /**
+ * @param INotification $notification - notification object
+ * @param string $languageCode - the code of the language that should be used to prepare the notification
+ *
+ * @return INotification
+ */
+ public function prepare(INotification $notification, string $languageCode): INotification {
+ if ($notification->getApp() !== $this->appName) {
+ throw new \InvalidArgumentException("Notification not from " . $this->appName);
+ }
+
+ $parameters = $notification->getSubjectParameters();
+
+ $notifierId = $parameters["notifierId"];
+ $fileId = $parameters["fileId"];
+ $fileName = $parameters["fileName"];
+ $anchor = $parameters["anchor"];
+
+ $this->logger->info("Notify prepare: from $notifierId about $fileId ", ["app" => $this->appName]);
+
+ $notifier = $this->userManager->get($notifierId);
+ $notifierName = $notifier->getDisplayName();
+ $trans = $this->l10nFactory->get($this->appName, $languageCode);
+
+ $notification->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath($this->appName, "app-dark.svg")))
+ ->setParsedSubject($trans->t("%1\$s mentioned in the %2\$s: \"%3\$s\".", [$notifierName, $fileName, $notification->getObjectId()]))
+ ->setRichSubject($trans->t("{notifier} mentioned in the {file}: \"%1\$s\".", [$notification->getObjectId()]), [
+ "notifier" => [
+ "type" => "user",
+ "id" => $notifierId,
+ "name" => $notifierName
+ ],
+ "file" => [
+ "type" => "highlight",
+ "id" => $fileId,
+ "name" => $fileName
+ ]
+ ]);
+
+ $editorLink = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".editor.index", [
+ "fileId" => $fileId,
+ "anchor" => $anchor
+ ]);
+
+ $notification->setLink($editorLink);
+
+ return $notification;
+ }
+} \ No newline at end of file
diff --git a/lib/preview.php b/lib/preview.php
index 2627712..42c50e6 100644
--- a/lib/preview.php
+++ b/lib/preview.php
@@ -40,6 +40,7 @@ use OCA\Onlyoffice\Crypt;
use OCA\Onlyoffice\DocumentService;
use OCA\Onlyoffice\FileUtility;
use OCA\Onlyoffice\FileVersions;
+use OCA\Onlyoffice\TemplateManager;
/**
* Preview provider
@@ -293,10 +294,11 @@ class Preview extends Provider {
* @param File $file - file
* @param IUser $user - user with access
* @param int $version - file version
+ * @param bool $template - file is template
*
* @return string
*/
- private function getUrl($file, $user = null, $version = 0) {
+ private function getUrl($file, $user = null, $version = 0, $template = false) {
$data = [
"action" => "download",
@@ -311,6 +313,9 @@ class Preview extends Provider {
if ($version > 0) {
$data["version"] = $version;
}
+ if ($template) {
+ $data["template"] = true;
+ }
$hashUrl = $this->crypt->GetHash($data);
@@ -342,6 +347,7 @@ class Preview extends Provider {
$key = null;
$versionNum = 0;
+ $template = false;
if (FileVersions::splitPathVersion($path) !== false) {
if ($this->versionManager === null || $owner === null) {
return [null, null, null];
@@ -375,7 +381,11 @@ class Preview extends Provider {
$key = DocumentService::GenerateRevisionId($key);
}
- $fileUrl = $this->getUrl($fileInfo, $owner, $versionNum);
+ if (TemplateManager::IsTemplate($fileInfo->getId())) {
+ $template = true;
+ }
+
+ $fileUrl = $this->getUrl($fileInfo, $owner, $versionNum, $template);
$fileExtension = $fileInfo->getExtension();
diff --git a/lib/templatemanager.php b/lib/templatemanager.php
index 0dd1b3d..dcadfb0 100644
--- a/lib/templatemanager.php
+++ b/lib/templatemanager.php
@@ -19,6 +19,7 @@
namespace OCA\Onlyoffice;
+use OCP\Files\File;
/**
* Template manager
@@ -60,60 +61,51 @@ class TemplateManager {
/**
* Get global templates
*
- * @param string $type - template format type
+ * @param string $mimetype - mimetype of the template
*
* @return array
*/
- public static function GetGlobalTemplates($type = null) {
- $templates = [];
+ public static function GetGlobalTemplates($mimetype = null) {
$templateDir = self::GetGlobalTemplateDir();
- if (!empty($type)) {
- $mime = self::GetMimeTemplate($type);
- $templatesList = $templateDir->searchByMime($mime);
+ if (!empty($mimetype)) {
+ $templatesList = $templateDir->searchByMime($mimetype);
} else {
$templatesList = $templateDir->getDirectoryListing();
}
- foreach ($templatesList as $templatesItem) {
- $template = [
- "id" => $templatesItem->getId(),
- "name" => $templatesItem->getName(),
- "type" => TemplateManager::GetTypeTemplate($templatesItem->getMimeType())
- ];
- array_push($templates, $template);
- }
-
- return $templates;
+ return $templatesList;
}
/**
- * Get template content
+ * Get template file
*
- * @param string $templateId - identifier file template
+ * @param string $templateId - identifier of the template
*
- * @return string
+ * @return File
*/
public static function GetTemplate($templateId) {
$logger = \OC::$server->getLogger();
+ if (empty($templateId)) {
+ $logger->info("templateId is empty", ["app" => self::$appName]);
+ return null;
+ }
+
$templateDir = self::GetGlobalTemplateDir();
try {
$templates = $templateDir->getById($templateId);
- } catch(\Exception $e) {
+ } catch (\Exception $e) {
$logger->logException($e, ["message" => "GetTemplate: $templateId", "app" => self::$appName]);
return null;
}
if (empty($templates)) {
- $logger->info("Template not found: $templateId", ["app" => self::$appName]);
return null;
}
- $content = $templates[0]->getContent();
-
- return $content;
+ return $templates[0];
}
/**
@@ -176,6 +168,23 @@ class TemplateManager {
}
/**
+ * Check file if it's template
+ *
+ * @param int $fileId - identifier file
+ *
+ * @return bool
+ */
+ public static function IsTemplate($fileId) {
+ $template = self::GetTemplate($fileId);
+
+ if (empty($template)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
* Get template
*
* @param string $name - file name
@@ -188,6 +197,9 @@ class TemplateManager {
$lang = \OC::$server->getL10NFactory("")->get("")->getLanguageCode();
$templatePath = self::GetEmptyTemplatePath($lang, $ext);
+ if (!file_exists($templatePath)) {
+ return false;
+ }
$template = file_get_contents($templatePath);
return $template;
diff --git a/lib/templateprovider.php b/lib/templateprovider.php
new file mode 100644
index 0000000..1cc918a
--- /dev/null
+++ b/lib/templateprovider.php
@@ -0,0 +1,91 @@
+<?php
+/**
+ *
+ * (c) Copyright Ascensio System SIA 2020
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace OCA\Onlyoffice;
+
+use OCP\Files\File;
+use OCP\Files\Template\ICustomTemplateProvider;
+use OCP\Files\Template\Template;
+use OCP\IURLGenerator;
+
+use OCA\Onlyoffice\TemplateManager;
+
+class TemplateProvider implements ICustomTemplateProvider {
+
+ /**
+ * Application name
+ *
+ * @var string
+ */
+ private $appName;
+
+ /**
+ * Url generator service
+ *
+ * @var IURLGenerator
+ */
+ private $urlGenerator;
+
+ /**
+ * @param string $AppName - application name
+ * @param IURLGenerator $urlGenerator - url generator service
+ */
+ public function __construct($AppName, IURLGenerator $urlGenerator) {
+ $this->appName = $AppName;
+ $this->urlGenerator = $urlGenerator;
+ }
+
+ /**
+ * Return a list of additional templates that the template provider is offering
+ *
+ * @param string $template - mimetype of the template
+ *
+ * @return array
+ */
+ public function getCustomTemplates($mimetype) : array {
+ $templates = [];
+
+ $templateFiles = TemplateManager::GetGlobalTemplates($mimetype);
+
+ foreach ($templateFiles as $templateFile) {
+ $template = new Template(
+ TemplateProvider::class,
+ $templateFile->getId(),
+ $templateFile
+ );
+
+ $template->setCustomPreviewUrl($this->urlGenerator->linkToRouteAbsolute($this->appName . ".template.preview", ["fileId" => $templateFile->getId()]));
+
+ array_push($templates, $template);
+ }
+
+ return $templates;
+ }
+
+ /**
+ * Return the file for a given template id
+ *
+ * @param string $templateId - identifier of the template
+ *
+ * @return File
+ */
+ public function getCustomTemplate($templateId) : File {
+ return TemplateManager::GetTemplate($templateId);
+ }
+} \ No newline at end of file