Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/files/lib/Search/FilesSearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
use OCP\IUser;
use OCP\Search\IProvider;
use OCP\Search\ISearchQuery;
use OCP\Search\ObjectSearchResultEntry;
use OCP\Search\SearchResult;
use OCP\Search\SearchResultEntry;

class FilesSearchProvider implements IProvider {

Expand Down Expand Up @@ -110,11 +110,13 @@ public function search(IUser $user, ISearchQuery $query): SearchResult {
? $this->urlGenerator->linkToRouteAbsolute('core.Preview.getPreviewByFileId', ['x' => 32, 'y' => 32, 'fileId' => $result->id])
: '';

return new SearchResultEntry(
return new ObjectSearchResultEntry(
$thumbnailUrl,
$result->name,
$this->formatSubline($result),
$this->urlGenerator->getAbsoluteURL($result->link),
'file',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use plurals in comments table, activity and others.
Maybe here too?

Suggested change
'file',
'files',

(string)$result->id,
$result->type === 'folder' ? 'icon-folder' : $this->mimeTypeDetector->mimeTypeIcon($result->mime_type)
);
}, $this->fileSearch->search($query->getTerm()))
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@
'OCP\\SabrePluginException' => $baseDir . '/lib/public/SabrePluginException.php',
'OCP\\Search\\IProvider' => $baseDir . '/lib/public/Search/IProvider.php',
'OCP\\Search\\ISearchQuery' => $baseDir . '/lib/public/Search/ISearchQuery.php',
'OCP\\Search\\ObjectSearchResultEntry' => $baseDir . '/lib/public/Search/ObjectSearchResultEntry.php',
'OCP\\Search\\PagedProvider' => $baseDir . '/lib/public/Search/PagedProvider.php',
'OCP\\Search\\Provider' => $baseDir . '/lib/public/Search/Provider.php',
'OCP\\Search\\Result' => $baseDir . '/lib/public/Search/Result.php',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\SabrePluginException' => __DIR__ . '/../../..' . '/lib/public/SabrePluginException.php',
'OCP\\Search\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Search/IProvider.php',
'OCP\\Search\\ISearchQuery' => __DIR__ . '/../../..' . '/lib/public/Search/ISearchQuery.php',
'OCP\\Search\\ObjectSearchResultEntry' => __DIR__ . '/../../..' . '/lib/public/Search/ObjectSearchResultEntry.php',
'OCP\\Search\\PagedProvider' => __DIR__ . '/../../..' . '/lib/public/Search/PagedProvider.php',
'OCP\\Search\\Provider' => __DIR__ . '/../../..' . '/lib/public/Search/Provider.php',
'OCP\\Search\\Result' => __DIR__ . '/../../..' . '/lib/public/Search/Result.php',
Expand Down
92 changes: 92 additions & 0 deletions lib/public/Search/ObjectSearchResultEntry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?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 OCP\Search;

use function array_merge;

/**
* @since 20.0.0
*/
class ObjectSearchResultEntry extends SearchResultEntry {

/**
* @var string
* @since 20.0.0
*/
protected $objectType;

/**
* @var string
* @since 20.0.0
*/
protected $objectId;

/**
* @param string $thumbnailUrl a relative or absolute URL to the thumbnail or icon of the entry
* @param string $title a main title of the entry
* @param string $subline the secondary line of the entry
* @param string $resourceUrl the URL where the user can find the detail, like a deep link inside the app
* @param string $icon the icon class or url to the icon
* @param boolean $rounded is the thumbnail rounded
*
* @since 20.0.0
*/
public function __construct(string $thumbnailUrl,
string $title,
string $subline,
string $resourceUrl,
string $objectType,
string $objectId,
string $icon = '',
bool $rounded = false) {
parent::__construct(
$thumbnailUrl,
$title,
$subline,
$resourceUrl,
$icon,
$rounded
);

$this->objectType = $objectType;
$this->objectId = $objectId;
}

/**
* @return mixed[]
*
* @since 20.0.0
*/
public function jsonSerialize(): array {
return array_merge(
parent::jsonSerialize(),
[
'objectType' => $this->objectType,
'objectId' => $this->objectId,
]
);
}
}
2 changes: 1 addition & 1 deletion lib/public/Search/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Result {
/**
* A unique identifier for the result, usually given as the item ID in its
* corresponding application.
* @var string
* @var string|int
* @since 7.0.0
* @deprecated 20.0.0
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/public/Search/SearchResultEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function __construct(string $thumbnailUrl,
}

/**
* @return array
* @return mixed[]
*
* @since 20.0.0
*/
Expand Down