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:
authorJulius Härtl <jus@bitgrid.net>2019-12-16 16:58:56 +0300
committerJulius Härtl <jus@bitgrid.net>2019-12-16 19:22:53 +0300
commitde5384466c4236181d21810142e3f2773bdeefe7 (patch)
treeb3517808930b23fe43869830663201c5bf3267b1 /lib
parent29f6f15cf3c63df07b81d7c97fe547f27a3906b3 (diff)
Return empty template for default creators
Signed-off-by: Julius Härtl <jus@bitgrid.net>
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 = [];