diff options
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/composer/composer/autoload_classmap.php | 3 | ||||
-rw-r--r-- | apps/dav/composer/composer/autoload_static.php | 3 | ||||
-rw-r--r-- | apps/dav/lib/Search/ContactsSearchProvider.php | 12 | ||||
-rw-r--r-- | apps/dav/lib/Search/ContactsSearchResultEntry.php | 30 | ||||
-rw-r--r-- | apps/dav/lib/Search/EventsSearchProvider.php | 12 | ||||
-rw-r--r-- | apps/dav/lib/Search/EventsSearchResultEntry.php | 30 | ||||
-rw-r--r-- | apps/dav/lib/Search/TasksSearchProvider.php | 12 | ||||
-rw-r--r-- | apps/dav/lib/Search/TasksSearchResultEntry.php | 30 | ||||
-rw-r--r-- | apps/dav/tests/unit/Search/ContactsSearchProviderTest.php | 10 | ||||
-rw-r--r-- | apps/dav/tests/unit/Search/EventsSearchProviderTest.php | 14 | ||||
-rw-r--r-- | apps/dav/tests/unit/Search/TasksSearchProviderTest.php | 14 |
11 files changed, 49 insertions, 121 deletions
diff --git a/apps/dav/composer/composer/autoload_classmap.php b/apps/dav/composer/composer/autoload_classmap.php index 081f334a4f9..b1b01885eef 100644 --- a/apps/dav/composer/composer/autoload_classmap.php +++ b/apps/dav/composer/composer/autoload_classmap.php @@ -212,11 +212,8 @@ return array( 'OCA\\DAV\\RootCollection' => $baseDir . '/../lib/RootCollection.php', 'OCA\\DAV\\Search\\ACalendarSearchProvider' => $baseDir . '/../lib/Search/ACalendarSearchProvider.php', 'OCA\\DAV\\Search\\ContactsSearchProvider' => $baseDir . '/../lib/Search/ContactsSearchProvider.php', - 'OCA\\DAV\\Search\\ContactsSearchResultEntry' => $baseDir . '/../lib/Search/ContactsSearchResultEntry.php', 'OCA\\DAV\\Search\\EventsSearchProvider' => $baseDir . '/../lib/Search/EventsSearchProvider.php', - 'OCA\\DAV\\Search\\EventsSearchResultEntry' => $baseDir . '/../lib/Search/EventsSearchResultEntry.php', 'OCA\\DAV\\Search\\TasksSearchProvider' => $baseDir . '/../lib/Search/TasksSearchProvider.php', - 'OCA\\DAV\\Search\\TasksSearchResultEntry' => $baseDir . '/../lib/Search/TasksSearchResultEntry.php', 'OCA\\DAV\\Server' => $baseDir . '/../lib/Server.php', 'OCA\\DAV\\Settings\\CalDAVSettings' => $baseDir . '/../lib/Settings/CalDAVSettings.php', 'OCA\\DAV\\Storage\\PublicOwnerWrapper' => $baseDir . '/../lib/Storage/PublicOwnerWrapper.php', diff --git a/apps/dav/composer/composer/autoload_static.php b/apps/dav/composer/composer/autoload_static.php index 3bfdb3b8628..ccd0d41d68b 100644 --- a/apps/dav/composer/composer/autoload_static.php +++ b/apps/dav/composer/composer/autoload_static.php @@ -227,11 +227,8 @@ class ComposerStaticInitDAV 'OCA\\DAV\\RootCollection' => __DIR__ . '/..' . '/../lib/RootCollection.php', 'OCA\\DAV\\Search\\ACalendarSearchProvider' => __DIR__ . '/..' . '/../lib/Search/ACalendarSearchProvider.php', 'OCA\\DAV\\Search\\ContactsSearchProvider' => __DIR__ . '/..' . '/../lib/Search/ContactsSearchProvider.php', - 'OCA\\DAV\\Search\\ContactsSearchResultEntry' => __DIR__ . '/..' . '/../lib/Search/ContactsSearchResultEntry.php', 'OCA\\DAV\\Search\\EventsSearchProvider' => __DIR__ . '/..' . '/../lib/Search/EventsSearchProvider.php', - 'OCA\\DAV\\Search\\EventsSearchResultEntry' => __DIR__ . '/..' . '/../lib/Search/EventsSearchResultEntry.php', 'OCA\\DAV\\Search\\TasksSearchProvider' => __DIR__ . '/..' . '/../lib/Search/TasksSearchProvider.php', - 'OCA\\DAV\\Search\\TasksSearchResultEntry' => __DIR__ . '/..' . '/../lib/Search/TasksSearchResultEntry.php', 'OCA\\DAV\\Server' => __DIR__ . '/..' . '/../lib/Server.php', 'OCA\\DAV\\Settings\\CalDAVSettings' => __DIR__ . '/..' . '/../lib/Settings/CalDAVSettings.php', 'OCA\\DAV\\Storage\\PublicOwnerWrapper' => __DIR__ . '/..' . '/../lib/Storage/PublicOwnerWrapper.php', diff --git a/apps/dav/lib/Search/ContactsSearchProvider.php b/apps/dav/lib/Search/ContactsSearchProvider.php index 656b484c2b9..d87f87d7591 100644 --- a/apps/dav/lib/Search/ContactsSearchProvider.php +++ b/apps/dav/lib/Search/ContactsSearchProvider.php @@ -32,6 +32,7 @@ use OCP\IUser; use OCP\Search\IProvider; use OCP\Search\ISearchQuery; use OCP\Search\SearchResult; +use OCP\Search\SearchResultEntry; use Sabre\VObject\Component\VCard; use Sabre\VObject\Reader; @@ -95,6 +96,13 @@ class ContactsSearchProvider implements IProvider { /** * @inheritDoc */ + public function getOrder(): int { + return 7; + } + + /** + * @inheritDoc + */ public function search(IUser $user, ISearchQuery $query): SearchResult { if (!$this->appManager->isEnabledForUser('contacts', $user)) { return SearchResult::complete($this->getName(), []); @@ -116,7 +124,7 @@ class ContactsSearchProvider implements IProvider { 'offset' => $query->getCursor(), ] ); - $formattedResults = \array_map(function (array $contactRow) use ($addressBooksById):ContactsSearchResultEntry { + $formattedResults = \array_map(function (array $contactRow) use ($addressBooksById):SearchResultEntry { $addressBook = $addressBooksById[$contactRow['addressbookid']]; /** @var VCard $vCard */ @@ -130,7 +138,7 @@ class ContactsSearchProvider implements IProvider { $subline = $this->generateSubline($vCard); $resourceUrl = $this->getDeepLinkToContactsApp($addressBook['uri'], (string) $vCard->UID); - return new ContactsSearchResultEntry($thumbnailUrl, $title, $subline, $resourceUrl, 'icon-contacts-dark', true); + return new SearchResultEntry($thumbnailUrl, $title, $subline, $resourceUrl, 'icon-contacts-dark', true); }, $searchResults); return SearchResult::paginated( diff --git a/apps/dav/lib/Search/ContactsSearchResultEntry.php b/apps/dav/lib/Search/ContactsSearchResultEntry.php deleted file mode 100644 index 698fc1b3f4a..00000000000 --- a/apps/dav/lib/Search/ContactsSearchResultEntry.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -declare(strict_types=1); - -/** - * @copyright Copyright (c) 2020, Georg Ehrke - * - * @author Georg Ehrke <oc.list@georgehrke.com> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * 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, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ -namespace OCA\DAV\Search; - -use OCP\Search\ASearchResultEntry; - -class ContactsSearchResultEntry extends ASearchResultEntry { -} diff --git a/apps/dav/lib/Search/EventsSearchProvider.php b/apps/dav/lib/Search/EventsSearchProvider.php index 43fc4f65dfc..6d264ae482e 100644 --- a/apps/dav/lib/Search/EventsSearchProvider.php +++ b/apps/dav/lib/Search/EventsSearchProvider.php @@ -28,6 +28,7 @@ use OCA\DAV\CalDAV\CalDavBackend; use OCP\IUser; use OCP\Search\ISearchQuery; use OCP\Search\SearchResult; +use OCP\Search\SearchResultEntry; use Sabre\VObject\Component; use Sabre\VObject\DateTimeParser; use Sabre\VObject\Property; @@ -81,6 +82,13 @@ class EventsSearchProvider extends ACalendarSearchProvider { /** * @inheritDoc */ + public function getOrder(): int { + return 10; + } + + /** + * @inheritDoc + */ public function search(IUser $user, ISearchQuery $query): SearchResult { if (!$this->appManager->isEnabledForUser('calendar', $user)) { @@ -102,7 +110,7 @@ class EventsSearchProvider extends ACalendarSearchProvider { 'offset' => $query->getCursor(), ] ); - $formattedResults = \array_map(function (array $eventRow) use ($calendarsById, $subscriptionsById):EventsSearchResultEntry { + $formattedResults = \array_map(function (array $eventRow) use ($calendarsById, $subscriptionsById):SearchResultEntry { $component = $this->getPrimaryComponent($eventRow['calendardata'], self::$componentType); $title = (string)($component->SUMMARY ?? $this->l10n->t('Untitled event')); $subline = $this->generateSubline($component); @@ -114,7 +122,7 @@ class EventsSearchProvider extends ACalendarSearchProvider { } $resourceUrl = $this->getDeepLinkToCalendarApp($calendar['principaluri'], $calendar['uri'], $eventRow['uri']); - return new EventsSearchResultEntry('', $title, $subline, $resourceUrl, 'icon-calendar-dark', false); + return new SearchResultEntry('', $title, $subline, $resourceUrl, 'icon-calendar-dark', false); }, $searchResults); return SearchResult::paginated( diff --git a/apps/dav/lib/Search/EventsSearchResultEntry.php b/apps/dav/lib/Search/EventsSearchResultEntry.php deleted file mode 100644 index f70f10a6e75..00000000000 --- a/apps/dav/lib/Search/EventsSearchResultEntry.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -declare(strict_types=1); - -/** - * @copyright Copyright (c) 2020, Georg Ehrke - * - * @author Georg Ehrke <oc.list@georgehrke.com> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * 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, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ -namespace OCA\DAV\Search; - -use OCP\Search\ASearchResultEntry; - -class EventsSearchResultEntry extends ASearchResultEntry { -} diff --git a/apps/dav/lib/Search/TasksSearchProvider.php b/apps/dav/lib/Search/TasksSearchProvider.php index eee4694f08f..9a0a87eb5ab 100644 --- a/apps/dav/lib/Search/TasksSearchProvider.php +++ b/apps/dav/lib/Search/TasksSearchProvider.php @@ -28,6 +28,7 @@ use OCA\DAV\CalDAV\CalDavBackend; use OCP\IUser; use OCP\Search\ISearchQuery; use OCP\Search\SearchResult; +use OCP\Search\SearchResultEntry; use Sabre\VObject\Component; /** @@ -73,6 +74,13 @@ class TasksSearchProvider extends ACalendarSearchProvider { /** * @inheritDoc */ + public function getOrder(): int { + return 10; + } + + /** + * @inheritDoc + */ public function search(IUser $user, ISearchQuery $query): SearchResult { if (!$this->appManager->isEnabledForUser('tasks', $user)) { @@ -94,7 +102,7 @@ class TasksSearchProvider extends ACalendarSearchProvider { 'offset' => $query->getCursor(), ] ); - $formattedResults = \array_map(function (array $taskRow) use ($calendarsById, $subscriptionsById):TasksSearchResultEntry { + $formattedResults = \array_map(function (array $taskRow) use ($calendarsById, $subscriptionsById):SearchResultEntry { $component = $this->getPrimaryComponent($taskRow['calendardata'], self::$componentType); $title = (string)($component->SUMMARY ?? $this->l10n->t('Untitled task')); $subline = $this->generateSubline($component); @@ -106,7 +114,7 @@ class TasksSearchProvider extends ACalendarSearchProvider { } $resourceUrl = $this->getDeepLinkToTasksApp($calendar['uri'], $taskRow['uri']); - return new TasksSearchResultEntry('', $title, $subline, $resourceUrl, 'icon-checkmark', false); + return new SearchResultEntry('', $title, $subline, $resourceUrl, 'icon-checkmark', false); }, $searchResults); return SearchResult::paginated( diff --git a/apps/dav/lib/Search/TasksSearchResultEntry.php b/apps/dav/lib/Search/TasksSearchResultEntry.php deleted file mode 100644 index ec58ba80af9..00000000000 --- a/apps/dav/lib/Search/TasksSearchResultEntry.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -declare(strict_types=1); - -/** - * @copyright Copyright (c) 2020, Georg Ehrke - * - * @author Georg Ehrke <oc.list@georgehrke.com> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * 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, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ -namespace OCA\DAV\Search; - -use OCP\Search\ASearchResultEntry; - -class TasksSearchResultEntry extends ASearchResultEntry { -} diff --git a/apps/dav/tests/unit/Search/ContactsSearchProviderTest.php b/apps/dav/tests/unit/Search/ContactsSearchProviderTest.php index e0cfe3245ba..858e79d4423 100644 --- a/apps/dav/tests/unit/Search/ContactsSearchProviderTest.php +++ b/apps/dav/tests/unit/Search/ContactsSearchProviderTest.php @@ -26,13 +26,13 @@ namespace OCA\DAV\Tests\unit; use OCA\DAV\CardDAV\CardDavBackend; use OCA\DAV\Search\ContactsSearchProvider; -use OCA\DAV\Search\ContactsSearchResultEntry; use OCP\App\IAppManager; use OCP\IL10N; use OCP\IURLGenerator; use OCP\IUser; use OCP\Search\ISearchQuery; use OCP\Search\SearchResult; +use OCP\Search\SearchResultEntry; use Sabre\VObject\Reader; use Test\TestCase; @@ -216,20 +216,20 @@ class ContactsSearchProviderTest extends TestCase { $result1 = $data['entries'][1]; $result1Data = $result1->jsonSerialize(); - $this->assertInstanceOf(ContactsSearchResultEntry::class, $result0); + $this->assertInstanceOf(SearchResultEntry::class, $result0); $this->assertEquals('', $result0Data['thumbnailUrl']); $this->assertEquals('FN of Test', $result0Data['title']); $this->assertEquals('subline', $result0Data['subline']); $this->assertEquals('deep-link-to-contacts', $result0Data['resourceUrl']); - $this->assertEquals('icon-contacts-dark', $result0Data['iconClass']); + $this->assertEquals('icon-contacts-dark', $result0Data['icon']); $this->assertTrue($result0Data['rounded']); - $this->assertInstanceOf(ContactsSearchResultEntry::class, $result1); + $this->assertInstanceOf(SearchResultEntry::class, $result1); $this->assertEquals('absolute-thumbnail-url?photo', $result1Data['thumbnailUrl']); $this->assertEquals('FN of Test2', $result1Data['title']); $this->assertEquals('subline', $result1Data['subline']); $this->assertEquals('deep-link-to-contacts', $result1Data['resourceUrl']); - $this->assertEquals('icon-contacts-dark', $result1Data['iconClass']); + $this->assertEquals('icon-contacts-dark', $result1Data['icon']); $this->assertTrue($result1Data['rounded']); } diff --git a/apps/dav/tests/unit/Search/EventsSearchProviderTest.php b/apps/dav/tests/unit/Search/EventsSearchProviderTest.php index f0d6329db5c..eedbe39f12a 100644 --- a/apps/dav/tests/unit/Search/EventsSearchProviderTest.php +++ b/apps/dav/tests/unit/Search/EventsSearchProviderTest.php @@ -26,13 +26,13 @@ namespace OCA\DAV\Tests\unit\Search; use OCA\DAV\CalDAV\CalDavBackend; use OCA\DAV\Search\EventsSearchProvider; -use OCA\DAV\Search\EventsSearchResultEntry; use OCP\App\IAppManager; use OCP\IL10N; use OCP\IURLGenerator; use OCP\IUser; use OCP\Search\ISearchQuery; use OCP\Search\SearchResult; +use OCP\Search\SearchResultEntry; use Sabre\VObject\Reader; use Test\TestCase; @@ -392,28 +392,28 @@ class EventsSearchProviderTest extends TestCase { $result2 = $data['entries'][2]; $result2Data = $result2->jsonSerialize(); - $this->assertInstanceOf(EventsSearchResultEntry::class, $result0); + $this->assertInstanceOf(SearchResultEntry::class, $result0); $this->assertEmpty($result0Data['thumbnailUrl']); $this->assertEquals('Untitled event', $result0Data['title']); $this->assertEquals('subline', $result0Data['subline']); $this->assertEquals('deep-link-to-calendar', $result0Data['resourceUrl']); - $this->assertEquals('icon-calendar-dark', $result0Data['iconClass']); + $this->assertEquals('icon-calendar-dark', $result0Data['icon']); $this->assertFalse($result0Data['rounded']); - $this->assertInstanceOf(EventsSearchResultEntry::class, $result1); + $this->assertInstanceOf(SearchResultEntry::class, $result1); $this->assertEmpty($result1Data['thumbnailUrl']); $this->assertEquals('Test Europe Berlin', $result1Data['title']); $this->assertEquals('subline', $result1Data['subline']); $this->assertEquals('deep-link-to-calendar', $result1Data['resourceUrl']); - $this->assertEquals('icon-calendar-dark', $result1Data['iconClass']); + $this->assertEquals('icon-calendar-dark', $result1Data['icon']); $this->assertFalse($result1Data['rounded']); - $this->assertInstanceOf(EventsSearchResultEntry::class, $result2); + $this->assertInstanceOf(SearchResultEntry::class, $result2); $this->assertEmpty($result2Data['thumbnailUrl']); $this->assertEquals('Test Europe Berlin', $result2Data['title']); $this->assertEquals('subline', $result2Data['subline']); $this->assertEquals('deep-link-to-calendar', $result2Data['resourceUrl']); - $this->assertEquals('icon-calendar-dark', $result2Data['iconClass']); + $this->assertEquals('icon-calendar-dark', $result2Data['icon']); $this->assertFalse($result2Data['rounded']); } diff --git a/apps/dav/tests/unit/Search/TasksSearchProviderTest.php b/apps/dav/tests/unit/Search/TasksSearchProviderTest.php index 30f57270e95..7220ff4ef48 100644 --- a/apps/dav/tests/unit/Search/TasksSearchProviderTest.php +++ b/apps/dav/tests/unit/Search/TasksSearchProviderTest.php @@ -26,13 +26,13 @@ namespace OCA\DAV\Tests\unit\Search; use OCA\DAV\CalDAV\CalDavBackend; use OCA\DAV\Search\TasksSearchProvider; -use OCA\DAV\Search\TasksSearchResultEntry; use OCP\App\IAppManager; use OCP\IL10N; use OCP\IURLGenerator; use OCP\IUser; use OCP\Search\ISearchQuery; use OCP\Search\SearchResult; +use OCP\Search\SearchResultEntry; use Sabre\VObject\Reader; use Test\TestCase; @@ -276,28 +276,28 @@ class TasksSearchProviderTest extends TestCase { $result2 = $data['entries'][2]; $result2Data = $result2->jsonSerialize(); - $this->assertInstanceOf(TasksSearchResultEntry::class, $result0); + $this->assertInstanceOf(SearchResultEntry::class, $result0); $this->assertEmpty($result0Data['thumbnailUrl']); $this->assertEquals('Untitled task', $result0Data['title']); $this->assertEquals('subline', $result0Data['subline']); $this->assertEquals('deep-link-to-tasks', $result0Data['resourceUrl']); - $this->assertEquals('icon-checkmark', $result0Data['iconClass']); + $this->assertEquals('icon-checkmark', $result0Data['icon']); $this->assertFalse($result0Data['rounded']); - $this->assertInstanceOf(TasksSearchResultEntry::class, $result1); + $this->assertInstanceOf(SearchResultEntry::class, $result1); $this->assertEmpty($result1Data['thumbnailUrl']); $this->assertEquals('Task title', $result1Data['title']); $this->assertEquals('subline', $result1Data['subline']); $this->assertEquals('deep-link-to-tasks', $result1Data['resourceUrl']); - $this->assertEquals('icon-checkmark', $result1Data['iconClass']); + $this->assertEquals('icon-checkmark', $result1Data['icon']); $this->assertFalse($result1Data['rounded']); - $this->assertInstanceOf(TasksSearchResultEntry::class, $result2); + $this->assertInstanceOf(SearchResultEntry::class, $result2); $this->assertEmpty($result2Data['thumbnailUrl']); $this->assertEquals('Task title', $result2Data['title']); $this->assertEquals('subline', $result2Data['subline']); $this->assertEquals('deep-link-to-tasks', $result2Data['resourceUrl']); - $this->assertEquals('icon-checkmark', $result2Data['iconClass']); + $this->assertEquals('icon-checkmark', $result2Data['icon']); $this->assertFalse($result2Data['rounded']); } |