migrate therinaldos.com data
Build & Deploy to DigitalOcean Space / build (push) Failing after 2m38s

This commit is contained in:
2024-05-05 15:50:45 -04:00
commit ef1ff240d4
23182 changed files with 3801898 additions and 0 deletions
@@ -0,0 +1,101 @@
<?php
declare(strict_types=1);
/**
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
*
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
*
* @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 InvalidArgumentException;
/**
* Filter definition
*
* Describe filter attributes
*
* @since 28.0.0
*/
class FilterDefinition {
public const TYPE_BOOL = 'bool';
public const TYPE_INT = 'int';
public const TYPE_FLOAT = 'float';
public const TYPE_STRING = 'string';
public const TYPE_STRINGS = 'strings';
public const TYPE_DATETIME = 'datetime';
public const TYPE_PERSON = 'person';
public const TYPE_NC_USER = 'nc-user';
public const TYPE_NC_GROUP = 'nc-group';
/**
* Build filter definition
*
* @param self::TYPE_* $type
* @param bool $exclusive If true, all providers not supporting this filter will be ignored when this filter is provided
* @throw InvalidArgumentException in case of invalid name. Allowed characters are -, 0-9, a-z.
* @since 28.0.0
*/
public function __construct(
private string $name,
private string $type = self::TYPE_STRING,
private bool $exclusive = true,
) {
if (!preg_match('/[-0-9a-z]+/Au', $name)) {
throw new InvalidArgumentException('Invalid filter name. Allowed characters are [-0-9a-z]');
}
}
/**
* Filter name
*
* Name is used in query string and for advanced syntax `name: <value>`
*
* @since 28.0.0
*/
public function name(): string {
return $this->name;
}
/**
* Filter type
*
* Expected type of value for the filter
*
* @return self::TYPE_*
* @since 28.0.0
*/
public function type(): string {
return $this->type;
}
/**
* Is filter exclusive?
*
* If exclusive, only provider with support for this filter will receive the query.
* Example: if an exclusive filter `mimetype` is declared, a search with this term will not
* be send to providers like `settings` that doesn't support it.
*
* @since 28.0.0
*/
public function exclusive(): bool {
return $this->exclusive;
}
}
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/**
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
*
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
*
* @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;
/**
* Interface for search filters
*
* @since 28.0.0
*/
interface IFilter {
/** @since 28.0.0 */
public const BUILTIN_TERM = 'term';
/** @since 28.0.0 */
public const BUILTIN_SINCE = 'since';
/** @since 28.0.0 */
public const BUILTIN_UNTIL = 'until';
/** @since 28.0.0 */
public const BUILTIN_PERSON = 'person';
/** @since 28.0.0 */
public const BUILTIN_TITLE_ONLY = 'title-only';
/** @since 28.0.0 */
public const BUILTIN_PLACES = 'places';
/** @since 28.0.0 */
public const BUILTIN_PROVIDER = 'provider';
/**
* Get filter value
*
* @since 28.0.0
*/
public function get(): mixed;
}
@@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
/**
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
*
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
*
* @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 IteratorAggregate;
/**
* Interface for search filters
*
* @since 28.0.0
* @extends IteratorAggregate<string, \OCP\Search\IFilter>
*/
interface IFilterCollection extends IteratorAggregate {
/**
* Check if a filter exits
*
* @since 28.0.0
*/
public function has(string $name): bool;
/**
* Get a filter by name
*
* @since 28.0.0
*/
public function get(string $name): ?IFilter;
/**
* Return Iterator of filters
*
* @since 28.0.0
*/
public function getIterator(): \Traversable;
}
@@ -0,0 +1,72 @@
<?php
declare(strict_types=1);
/**
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
*
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
*
* @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;
/**
* Interface for advanced search providers
*
* These providers will be implemented in apps, so they can participate in the
* global search results of Nextcloud. If an app provides more than one type of
* resource, e.g. contacts and address books in Nextcloud Contacts, it should
* register one provider per group.
*
* @since 28.0.0
*/
interface IFilteringProvider extends IProvider {
/**
* Return the names of filters supported by the application
*
* If a filter sent by client is not in this list,
* the current provider will be ignored.
* Example:
* array('term', 'since', 'custom-filter');
*
* @since 28.0.0
* @return string[] Name of supported filters (default or defined by application)
*/
public function getSupportedFilters(): array;
/**
* Get alternate IDs handled by this provider
*
* A search provider can complete results from other search providers.
* For example, files and full-text-search can search in files.
* If you use `in:files` in a search, provider files will be invoked,
* with all other providers declaring `files` in this method
*
* @since 28.0.0
* @return string[] IDs
*/
public function getAlternateIds(): array;
/**
* Allows application to declare custom filters
*
* @since 28.0.0
* @return list<FilterDefinition>
*/
public function getCustomFilters(): array;
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
*
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
*
* @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;
/**
* Interface for search providers supporting in-app search
*
* @since 28.0.0
*/
interface IInAppSearch extends IProvider {
}
@@ -0,0 +1,110 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @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 OCP\IUser;
/**
* Interface for search providers
*
* These providers will be implemented in apps, so they can participate in the
* global search results of Nextcloud. If an app provides more than one type of
* resource, e.g. contacts and address books in Nextcloud Contacts, it should
* register one provider per group.
*
* @since 20.0.0
*/
interface IProvider {
/**
* Get the unique ID of this search provider
*
* Ideally this should be the app name or an identifier identified with the
* app name, especially if the app registers more than one provider.
*
* Example: 'mail', 'mail_recipients', 'files_sharing'
*
* @return string
*
* @since 20.0.0
*/
public function getId(): string;
/**
* Get the translated name of this search provider
*
* Example: 'Mail', 'Contacts'...
*
* @return string
*
* @since 20.0.0
*/
public function getName(): string;
/**
* Get the search provider order
* The lower the int, the higher it will be sorted (0 will be before 10)
* If null, the search provider will be hidden in the UI and the API not called
*
* @param string $route the route the user is currently at, e.g. files.view.index
* @param array $routeParameters the parameters of the route the user is currently at, e.g. [fileId = 982, dir = "/"]
*
* @return int|null
*
* @since 20.0.0
* @since 28.0.0 Can return null
*/
public function getOrder(string $route, array $routeParameters): ?int;
/**
* Find matching search entries in an app
*
* Search results can either be a complete list of all the matches the app can
* find, or ideally a paginated result set where more data can be fetched on
* demand. To be able to tell where the next offset starts the search uses
* "cursors" which are a property of the last result entry. E.g. search results
* that show most recent entries first can look for entries older than the last
* one of the first result set. This approach was chosen over a numeric limit/
* offset approach as the offset moves as new data comes in. The cursor is
* resistant to these changes and will still show results without overlaps or
* gaps.
*
* See https://dev.to/jackmarchant/offset-and-cursor-pagination-explained-b89
* for the concept of cursors.
*
* Implementations that return result pages have to adhere to the limit
* property of a search query.
*
* @param IUser $user
* @param ISearchQuery $query
*
* @return SearchResult
*
* @since 20.0.0
*/
public function search(IUser $user, ISearchQuery $query): SearchResult;
}
@@ -0,0 +1,105 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
*
* @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;
/**
* The query objected passed into \OCP\Search\IProvider::search
*
* This mainly wraps the search term, but will ensure that Nextcloud can add new
* optional properties to a search request without having break the interface of
* \OCP\Search\IProvider::search.
*
* @see \OCP\Search\IProvider::search
*
* @since 20.0.0
*/
interface ISearchQuery {
/**
* @since 20.0.0
*/
public const SORT_DATE_DESC = 1;
/**
* Get the user-entered search term to find matches for
*
* @return string the search term
* @since 20.0.0
*/
public function getTerm(): string;
/**
* Get a single request filter
*
* @since 28.0.0
*/
public function getFilter(string $name): ?IFilter;
/**
* Get request filters
*
* @since 28.0.0
*/
public function getFilters(): IFilterCollection;
/**
* Get the sort order of results as defined as SORT_* constants on this interface
*
* @return int
* @since 20.0.0
*/
public function getSortOrder(): int;
/**
* Get the number of items to return for a paginated result
*
* @return int
* @see \OCP\Search\IProvider for details
* @since 20.0.0
*/
public function getLimit(): int;
/**
* Get the app-specific cursor of the tail of the previous result entries
*
* @return int|string|null
* @see \OCP\Search\IProvider for details
* @since 20.0.0
*/
public function getCursor();
/**
* @return string
* @since 20.0.0
*/
public function getRoute(): string;
/**
* @return array
* @since 20.0.0
*/
public function getRouteParameters(): array;
}
@@ -0,0 +1,74 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @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 OCP\Search;
/**
* Provides a template for search functionality throughout ownCloud;
* @since 8.0.0
* @deprecated 20.0.0
*/
abstract class PagedProvider extends Provider {
/**
* show all results
* @since 8.0.0
* @deprecated 20.0.0
*/
public const SIZE_ALL = 0;
/**
* Constructor
* @param array $options
* @since 8.0.0
* @deprecated 20.0.0
*/
public function __construct($options) {
parent::__construct($options);
}
/**
* Search for $query
* @param string $query
* @return array An array of OCP\Search\Result's
* @since 8.0.0
* @deprecated 20.0.0
*/
public function search($query) {
// old apps might assume they get all results, so we use SIZE_ALL
return $this->searchPaged($query, 1, self::SIZE_ALL);
}
/**
* Search for $query
* @param string $query
* @param int $page pages start at page 1
* @param int $size 0 = SIZE_ALL
* @return array An array of OCP\Search\Result's
* @since 8.0.0
* @deprecated 20.0.0
*/
abstract public function searchPaged($query, $page, $size);
}
@@ -0,0 +1,97 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Andrew Brown <andrew@casabrown.com>
* @author Bart Visscher <bartv@thisnet.nl>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Jakob Sack <mail@jakobsack.de>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Morris Jobke <hey@morrisjobke.de>
*
* @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 OCP\Search;
/**
* Provides a template for search functionality throughout Nextcloud;
* @since 7.0.0
* @deprecated 20.0.0
*/
abstract class Provider {
/**
* @since 8.0.0
* @deprecated 20.0.0
*/
public const OPTION_APPS = 'apps';
/**
* List of options
* @var array
* @since 7.0.0
* @deprecated 20.0.0
*/
protected $options;
/**
* Constructor
* @param array $options as key => value
* @since 7.0.0 - default value for $options was added in 8.0.0
* @deprecated 20.0.0
*/
public function __construct($options = []) {
$this->options = $options;
}
/**
* get a value from the options array or null
* @param string $key
* @return mixed
* @since 8.0.0
* @deprecated 20.0.0
*/
public function getOption($key) {
if (is_array($this->options) && isset($this->options[$key])) {
return $this->options[$key];
} else {
return null;
}
}
/**
* checks if the given apps and the apps this provider has results for intersect
* returns true if the given array is empty (all apps)
* or if this provider does not have a list of apps it provides results for (legacy search providers)
* or if the two above arrays have elements in common (intersect)
* @param string[] $apps
* @return bool
* @since 8.0.0
* @deprecated 20.0.0
*/
public function providesResultsFor(array $apps = []) {
$forApps = $this->getOption(self::OPTION_APPS);
return empty($apps) || empty($forApps) || array_intersect($forApps, $apps);
}
/**
* Search for $query
* @param string $query
* @return array An array of OCP\Search\Result's
* @since 7.0.0
* @deprecated 20.0.0
*/
abstract public function search($query);
}
+82
View File
@@ -0,0 +1,82 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Andrew Brown <andrew@casabrown.com>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Jakob Sack <mail@jakobsack.de>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Morris Jobke <hey@morrisjobke.de>
*
* @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 OCP\Search;
/**
* The generic result of a search
* @since 7.0.0
* @deprecated 20.0.0
*/
class Result {
/**
* A unique identifier for the result, usually given as the item ID in its
* corresponding application.
* @var string
* @since 7.0.0
* @deprecated 20.0.0
*/
public $id;
/**
* The name of the item returned; this will be displayed in the search
* results.
* @var string
* @since 7.0.0
* @deprecated 20.0.0
*/
public $name;
/**
* URL to the application item.
* @var string
* @since 7.0.0
* @deprecated 20.0.0
*/
public $link;
/**
* The type of search result returned; for consistency, name this the same
* as the class name (e.g. \OC\Search\File -> 'file') in lowercase.
* @var string
* @since 7.0.0
* @deprecated 20.0.0
*/
public $type = 'generic';
/**
* Create a new search result
* @param string $id unique identifier from application: '[app_name]/[item_identifier_in_app]'
* @param string $name displayed text of result
* @param string $link URL to the result within its app
* @since 7.0.0
* @deprecated 20.0.0
*/
public function __construct($id = null, $name = null, $link = null) {
$this->id = $id;
$this->name = $name;
$this->link = $link;
}
}
@@ -0,0 +1,113 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @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 JsonSerializable;
use function array_values;
/**
* @since 20.0.0
*/
final class SearchResult implements JsonSerializable {
/** @var string */
private $name;
/** @var bool */
private $isPaginated;
/** @var SearchResultEntry[] */
private $entries;
/** @var int|string|null */
private $cursor;
/**
* @param string $name the translated name of the result section or group, e.g. "Mail"
* @param bool $isPaginated
* @param SearchResultEntry[] $entries
* @param ?int|?string $cursor
*
* @since 20.0.0
*/
private function __construct(string $name,
bool $isPaginated,
array $entries,
$cursor = null) {
$this->name = $name;
$this->isPaginated = $isPaginated;
$this->entries = $entries;
$this->cursor = $cursor;
}
/**
* @param SearchResultEntry[] $entries
*
* @return static
*
* @since 20.0.0
*/
public static function complete(string $name, array $entries): self {
return new self(
$name,
false,
$entries
);
}
/**
* @param SearchResultEntry[] $entries
* @param int|string $cursor
*
* @return static
*
* @since 20.0.0
*/
public static function paginated(string $name,
array $entries,
$cursor): self {
return new self(
$name,
true,
$entries,
$cursor
);
}
/**
* @return array
*
* @since 20.0.0
*/
public function jsonSerialize(): array {
return [
'name' => $this->name,
'isPaginated' => $this->isPaginated,
'entries' => array_values($this->entries),
'cursor' => $this->cursor,
];
}
}
@@ -0,0 +1,143 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @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 JsonSerializable;
/**
* Represents an entry in a list of results an app returns for a unified search
* query.
*
* The app providing the results has to extend this class for customization. In
* most cases apps do not have to add any additional code.
*
* @example ``class MailResultEntry extends SearchResultEntry {}`
*
* This approach was chosen over a final class as it allows Nextcloud to later
* add new optional properties of an entry without having to break the usage of
* this class in apps.
*
* @since 20.0.0
*/
class SearchResultEntry implements JsonSerializable {
/**
* @var string
* @since 20.0.0
*/
protected $thumbnailUrl;
/**
* @var string
* @since 20.0.0
*/
protected $title;
/**
* @var string
* @since 20.0.0
*/
protected $subline;
/**
* @var string
* @since 20.0.0
*/
protected $resourceUrl;
/**
* @var string
* @since 20.0.0
*/
protected $icon;
/**
* @var boolean
* @since 20.0.0
*/
protected $rounded;
/**
* @var string[]
* @psalm-var array<string, string>
* @since 20.0.0
*/
protected $attributes = [];
/**
* @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 $icon = '',
bool $rounded = false) {
$this->thumbnailUrl = $thumbnailUrl;
$this->title = $title;
$this->subline = $subline;
$this->resourceUrl = $resourceUrl;
$this->icon = $icon;
$this->rounded = $rounded;
}
/**
* Add optional attributes to the result entry, e.g. an ID or some other
* context information that can be read by the client application
*
* @param string $key
* @param string $value
*
* @since 20.0.0
*/
public function addAttribute(string $key, string $value): void {
$this->attributes[$key] = $value;
}
/**
* @return array
*
* @since 20.0.0
*/
public function jsonSerialize(): array {
return [
'thumbnailUrl' => $this->thumbnailUrl,
'title' => $this->title,
'subline' => $this->subline,
'resourceUrl' => $this->resourceUrl,
'icon' => $this->icon,
'rounded' => $this->rounded,
'attributes' => $this->attributes,
];
}
}