summaryrefslogtreecommitdiffstats
path: root/lib/private/Collaboration
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2022-09-01 20:09:33 +0200
committerJulius Härtl <jus@bitgrid.net>2023-03-02 21:01:44 +0100
commit6130f1a78ea4f7fba3e3690528f2b53a0d9f5b82 (patch)
tree404bcf6ad7790b7ecda2eed0efb3a9d4618fddbb /lib/private/Collaboration
parentb6d8fc97afe28bc1b017026447264ba37ed37caa (diff)
downloadnextcloud-server-6130f1a78ea4f7fba3e3690528f2b53a0d9f5b82.tar.gz
nextcloud-server-6130f1a78ea4f7fba3e3690528f2b53a0d9f5b82.zip
Implement file reference wiget
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/private/Collaboration')
-rw-r--r--lib/private/Collaboration/Reference/File/FileReferenceProvider.php42
1 files changed, 33 insertions, 9 deletions
diff --git a/lib/private/Collaboration/Reference/File/FileReferenceProvider.php b/lib/private/Collaboration/Reference/File/FileReferenceProvider.php
index 95e49cdf860..d423a830495 100644
--- a/lib/private/Collaboration/Reference/File/FileReferenceProvider.php
+++ b/lib/private/Collaboration/Reference/File/FileReferenceProvider.php
@@ -25,8 +25,8 @@ declare(strict_types=1);
namespace OC\Collaboration\Reference\File;
use OC\User\NoUserException;
+use OCP\Collaboration\Reference\ADiscoverableReferenceProvider;
use OCP\Collaboration\Reference\IReference;
-use OCP\Collaboration\Reference\IReferenceProvider;
use OCP\Collaboration\Reference\Reference;
use OCP\Files\IMimeTypeDetector;
use OCP\Files\InvalidPathException;
@@ -34,27 +34,34 @@ use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
+use OCP\IL10N;
use OCP\IPreview;
use OCP\IURLGenerator;
use OCP\IUserSession;
+use OCP\L10N\IFactory;
-class FileReferenceProvider implements IReferenceProvider {
+class FileReferenceProvider extends ADiscoverableReferenceProvider {
private IURLGenerator $urlGenerator;
private IRootFolder $rootFolder;
private ?string $userId;
private IPreview $previewManager;
private IMimeTypeDetector $mimeTypeDetector;
-
- public function __construct(IURLGenerator $urlGenerator,
- IRootFolder $rootFolder,
- IUserSession $userSession,
- IMimeTypeDetector $mimeTypeDetector,
- IPreview $previewManager) {
+ private IL10N $l10n;
+
+ public function __construct(
+ IURLGenerator $urlGenerator,
+ IRootFolder $rootFolder,
+ IUserSession $userSession,
+ IMimeTypeDetector $mimeTypeDetector,
+ IPreview $previewManager,
+ IFactory $l10n
+ ) {
$this->urlGenerator = $urlGenerator;
$this->rootFolder = $rootFolder;
$this->userId = $userSession->getUser() ? $userSession->getUser()->getUID() : null;
$this->previewManager = $previewManager;
$this->mimeTypeDetector = $mimeTypeDetector;
+ $this->l10n = $l10n->get('files');
}
public function matchReference(string $referenceText): bool {
@@ -145,9 +152,10 @@ class FileReferenceProvider implements IReferenceProvider {
'id' => $file->getId(),
'name' => $file->getName(),
'size' => $file->getSize(),
- 'path' => $file->getPath(),
+ 'path' => $userFolder->getRelativePath($file->getPath()),
'link' => $reference->getUrl(),
'mimetype' => $file->getMimetype(),
+ 'mtime' => $file->getMTime(),
'preview-available' => $this->previewManager->isAvailable($file)
]);
} catch (InvalidPathException|NotFoundException|NotPermittedException|NoUserException $e) {
@@ -162,4 +170,20 @@ class FileReferenceProvider implements IReferenceProvider {
public function getCacheKey(string $referenceId): ?string {
return $this->userId ?? '';
}
+
+ public function getId(): string {
+ return 'files';
+ }
+
+ public function getTitle(): string {
+ return $this->l10n->t('Files');
+ }
+
+ public function getOrder(): int {
+ return 0;
+ }
+
+ public function getIconUrl(): string {
+ return $this->urlGenerator->imagePath('files', 'folder.svg');
+ }
}