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

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-12-17 12:41:48 +0300
committerGitHub <noreply@github.com>2019-12-17 12:41:48 +0300
commit76895b6945f64b25d56a55c70585c441743eb226 (patch)
treec28e7c7e0fe0b224dc3de2698736f57b7c709af6 /lib
parenta65269ffcd9094446c74145c00e21e6832264673 (diff)
parentde5384466c4236181d21810142e3f2773bdeefe7 (diff)
Merge pull request #18428 from nextcloud/bugfix/noid/empty-template
Return empty template for default creators
Diffstat (limited to 'lib')
-rw-r--r--lib/private/DirectEditing/Manager.php28
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/private/DirectEditing/Manager.php b/lib/private/DirectEditing/Manager.php
index fcaaf9e0303..a739402d629 100644
--- a/lib/private/DirectEditing/Manager.php
+++ b/lib/private/DirectEditing/Manager.php
@@ -40,7 +40,9 @@ use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\IDBConnection;
+use OCP\IL10N;
use OCP\IUserSession;
+use OCP\L10N\IFactory;
use OCP\Security\ISecureRandom;
use OCP\Share\IShare;
@@ -61,17 +63,21 @@ class Manager implements IManager {
private $random;
private $userId;
private $rootFolder;
+ /** @var IL10N */
+ private $l10n;
public function __construct(
ISecureRandom $random,
IDBConnection $connection,
IUserSession $userSession,
- IRootFolder $rootFolder
+ IRootFolder $rootFolder,
+ IFactory $l10nFactory
) {
$this->random = $random;
$this->connection = $connection;
$this->userId = $userSession->getUser() ? $userSession->getUser()->getUID() : null;
$this->rootFolder = $rootFolder;
+ $this->l10n = $l10nFactory->get('core');
}
public function registerDirectEditor(IEditor $directEditor): void {
@@ -88,8 +94,24 @@ class Manager implements IManager {
}
$templates = [];
foreach ($this->editors[$editor]->getCreators() as $creator) {
- if ($creator instanceof ACreateFromTemplate && $creator->getId() === $type) {
- $templates = $creator->getTemplates();
+ if ($creator->getId() === $type) {
+ $templates = [
+ 'empty' => [
+ 'id' => 'empty',
+ 'title' => $this->l10n->t('Empty file'),
+ 'preview' => null
+ ]
+ ];
+
+ if ($creator instanceof ACreateFromTemplate) {
+ $templates = $creator->getTemplates();
+ }
+
+ $templates = array_map(function ($template) use ($creator) {
+ $template['extension'] = $creator->getExtension();
+ $template['mimetype'] = $creator->getMimetype();
+ return $template;
+ }, $templates);
}
}
$return = [];