diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-08-04 10:00:27 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-08-04 21:36:22 +0200 |
commit | 71b62c4203a25beefeab73f73668919c813e3a50 (patch) | |
tree | e75b6b0338ed800ddf88bfe27ce6703045c18e48 /apps/files | |
parent | 6eced42b7a40f5b0ea0489244583219d0ee2e7af (diff) | |
download | nextcloud-server-71b62c4203a25beefeab73f73668919c813e3a50.tar.gz nextcloud-server-71b62c4203a25beefeab73f73668919c813e3a50.zip |
Show mime icon, bump bundles, make the SearchResultEntry class non-abstract, Fix header search icon, various fixes
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | apps/files/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | apps/files/lib/Search/FilesSearchProvider.php | 35 | ||||
-rw-r--r-- | apps/files/lib/Search/FilesSearchResultEntry.php | 38 |
4 files changed, 29 insertions, 46 deletions
diff --git a/apps/files/composer/composer/autoload_classmap.php b/apps/files/composer/composer/autoload_classmap.php index 04c24ee52d9..ecb91fee9c9 100644 --- a/apps/files/composer/composer/autoload_classmap.php +++ b/apps/files/composer/composer/autoload_classmap.php @@ -48,7 +48,6 @@ return array( 'OCA\\Files\\Migration\\Version11301Date20191205150729' => $baseDir . '/../lib/Migration/Version11301Date20191205150729.php', 'OCA\\Files\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php', 'OCA\\Files\\Search\\FilesSearchProvider' => $baseDir . '/../lib/Search/FilesSearchProvider.php', - 'OCA\\Files\\Search\\FilesSearchResultEntry' => $baseDir . '/../lib/Search/FilesSearchResultEntry.php', 'OCA\\Files\\Service\\DirectEditingService' => $baseDir . '/../lib/Service/DirectEditingService.php', 'OCA\\Files\\Service\\OwnershipTransferService' => $baseDir . '/../lib/Service/OwnershipTransferService.php', 'OCA\\Files\\Service\\TagService' => $baseDir . '/../lib/Service/TagService.php', diff --git a/apps/files/composer/composer/autoload_static.php b/apps/files/composer/composer/autoload_static.php index f9050eca862..a8c80a4201a 100644 --- a/apps/files/composer/composer/autoload_static.php +++ b/apps/files/composer/composer/autoload_static.php @@ -63,7 +63,6 @@ class ComposerStaticInitFiles 'OCA\\Files\\Migration\\Version11301Date20191205150729' => __DIR__ . '/..' . '/../lib/Migration/Version11301Date20191205150729.php', 'OCA\\Files\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php', 'OCA\\Files\\Search\\FilesSearchProvider' => __DIR__ . '/..' . '/../lib/Search/FilesSearchProvider.php', - 'OCA\\Files\\Search\\FilesSearchResultEntry' => __DIR__ . '/..' . '/../lib/Search/FilesSearchResultEntry.php', 'OCA\\Files\\Service\\DirectEditingService' => __DIR__ . '/..' . '/../lib/Service/DirectEditingService.php', 'OCA\\Files\\Service\\OwnershipTransferService' => __DIR__ . '/..' . '/../lib/Service/OwnershipTransferService.php', 'OCA\\Files\\Service\\TagService' => __DIR__ . '/..' . '/../lib/Service/TagService.php', diff --git a/apps/files/lib/Search/FilesSearchProvider.php b/apps/files/lib/Search/FilesSearchProvider.php index 077335e220a..d0a4bf56624 100644 --- a/apps/files/lib/Search/FilesSearchProvider.php +++ b/apps/files/lib/Search/FilesSearchProvider.php @@ -27,12 +27,14 @@ namespace OCA\Files\Search; use OC\Search\Provider\File; use OC\Search\Result\File as FileResult; +use OCP\Files\IMimeTypeDetector; use OCP\IL10N; use OCP\IURLGenerator; use OCP\IUser; use OCP\Search\IProvider; use OCP\Search\ISearchQuery; use OCP\Search\SearchResult; +use OCP\Search\SearchResultEntry; class FilesSearchProvider implements IProvider { @@ -45,37 +47,58 @@ class FilesSearchProvider implements IProvider { /** @var IURLGenerator */ private $urlGenerator; + /** @var IMimeTypeDetector */ + private $mimeTypeDetector; + public function __construct(File $fileSearch, IL10N $l10n, - IURLGenerator $urlGenerator) { + IURLGenerator $urlGenerator, + IMimeTypeDetector $mimeTypeDetector) { $this->l10n = $l10n; $this->fileSearch = $fileSearch; $this->urlGenerator = $urlGenerator; + $this->mimeTypeDetector = $mimeTypeDetector; } + /** + * @inheritDoc + */ public function getId(): string { return 'files'; } + /** + * @inheritDoc + */ public function getName(): string { return $this->l10n->t('Files'); } + /** + * @inheritDoc + */ + public function getOrder(): int { + return 5; + } + + /** + * @inheritDoc + */ public function search(IUser $user, ISearchQuery $query): SearchResult { return SearchResult::complete( $this->l10n->t('Files'), array_map(function (FileResult $result) { // Generate thumbnail url - $thumbnailUrl = $result->type === 'folder' - ? '' - : $this->urlGenerator->linkToRoute('core.Preview.getPreviewByFileId', ['x' => 32, 'y' => 32, 'fileId' => $result->id]); + $thumbnailUrl = $result->has_preview + ? $this->urlGenerator->linkToRoute('core.Preview.getPreviewByFileId', ['x' => 32, 'y' => 32, 'fileId' => $result->id]) + : ''; - return new FilesSearchResultEntry( + return new SearchResultEntry( $thumbnailUrl, $result->name, $this->formatSubline($result), $result->link, - $result->type === 'folder' ? 'icon-folder' : 'icon-filetype-file' + $result->type === 'folder' ? 'icon-folder' : $this->mimeTypeDetector->mimeTypeIcon($result->mime_type) ); }, $this->fileSearch->search($query->getTerm())) ); diff --git a/apps/files/lib/Search/FilesSearchResultEntry.php b/apps/files/lib/Search/FilesSearchResultEntry.php deleted file mode 100644 index 53346154be1..00000000000 --- a/apps/files/lib/Search/FilesSearchResultEntry.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -declare(strict_types=1); - -/** - * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -namespace OCA\Files\Search; - -use OCP\Search\ASearchResultEntry; - -class FilesSearchResultEntry extends ASearchResultEntry { - public function __construct(string $thumbnailUrl, - string $filename, - string $path, - string $url, - string $icon) { - parent::__construct($thumbnailUrl, $filename, $path, $url, $icon, false); - } -} |