From a644ad5793b75f6cb4a5ddcd6ac33619764db738 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Wed, 20 Feb 2019 09:38:19 -0100 Subject: [PATCH 1/5] moving final class to private, new interface in public Signed-off-by: Maxence Lange --- lib/composer/composer/autoload_classmap.php | 12 +- lib/composer/composer/autoload_static.php | 12 +- .../FullTextSearch/Model/DocumentAccess.php | 60 +- .../FullTextSearch/Model/IndexDocument.php | 1000 +++++++++++++++++ .../FullTextSearch/Model/SearchOption.php | 41 +- .../FullTextSearch/Model/SearchTemplate.php | 40 +- .../Model/AFilesDocument.php | 7 +- .../IFullTextSearchPlatform.php | 16 +- .../IFullTextSearchProvider.php | 48 +- .../FullTextSearch/Model/IDocumentAccess.php | 264 +++++ lib/public/FullTextSearch/Model/IIndex.php | 4 +- .../FullTextSearch/Model/IIndexDocument.php | 636 +++++++++++ .../FullTextSearch/Model/ISearchOption.php | 161 +++ .../FullTextSearch/Model/ISearchResult.php | 14 +- .../FullTextSearch/Model/ISearchTemplate.php | 179 +++ 15 files changed, 2370 insertions(+), 124 deletions(-) rename lib/{public => private}/FullTextSearch/Model/DocumentAccess.php (81%) create mode 100644 lib/private/FullTextSearch/Model/IndexDocument.php rename lib/{public => private}/FullTextSearch/Model/SearchOption.php (86%) rename lib/{public => private}/FullTextSearch/Model/SearchTemplate.php (84%) create mode 100644 lib/public/FullTextSearch/Model/IDocumentAccess.php create mode 100644 lib/public/FullTextSearch/Model/IIndexDocument.php create mode 100644 lib/public/FullTextSearch/Model/ISearchOption.php create mode 100644 lib/public/FullTextSearch/Model/ISearchTemplate.php diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 66ca39dfec04a..363dcf0d70d3f 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -253,15 +253,15 @@ 'OCP\\FullTextSearch\\IFullTextSearchManager' => $baseDir . '/lib/public/FullTextSearch/IFullTextSearchManager.php', 'OCP\\FullTextSearch\\IFullTextSearchPlatform' => $baseDir . '/lib/public/FullTextSearch/IFullTextSearchPlatform.php', 'OCP\\FullTextSearch\\IFullTextSearchProvider' => $baseDir . '/lib/public/FullTextSearch/IFullTextSearchProvider.php', - 'OCP\\FullTextSearch\\Model\\DocumentAccess' => $baseDir . '/lib/public/FullTextSearch/Model/DocumentAccess.php', + 'OCP\\FullTextSearch\\Model\\IDocumentAccess' => $baseDir . '/lib/public/FullTextSearch/Model/IDocumentAccess.php', 'OCP\\FullTextSearch\\Model\\IIndex' => $baseDir . '/lib/public/FullTextSearch/Model/IIndex.php', + 'OCP\\FullTextSearch\\Model\\IIndexDocument' => $baseDir . '/lib/public/FullTextSearch/Model/IIndexDocument.php', 'OCP\\FullTextSearch\\Model\\IIndexOptions' => $baseDir . '/lib/public/FullTextSearch/Model/IIndexOptions.php', 'OCP\\FullTextSearch\\Model\\IRunner' => $baseDir . '/lib/public/FullTextSearch/Model/IRunner.php', + 'OCP\\FullTextSearch\\Model\\ISearchOption' => $baseDir . '/lib/public/FullTextSearch/Model/ISearchOption.php', 'OCP\\FullTextSearch\\Model\\ISearchRequest' => $baseDir . '/lib/public/FullTextSearch/Model/ISearchRequest.php', 'OCP\\FullTextSearch\\Model\\ISearchResult' => $baseDir . '/lib/public/FullTextSearch/Model/ISearchResult.php', - 'OCP\\FullTextSearch\\Model\\IndexDocument' => $baseDir . '/lib/public/FullTextSearch/Model/IndexDocument.php', - 'OCP\\FullTextSearch\\Model\\SearchOption' => $baseDir . '/lib/public/FullTextSearch/Model/SearchOption.php', - 'OCP\\FullTextSearch\\Model\\SearchTemplate' => $baseDir . '/lib/public/FullTextSearch/Model/SearchTemplate.php', + 'OCP\\FullTextSearch\\Model\\ISearchTemplate' => $baseDir . '/lib/public/FullTextSearch/Model/ISearchTemplate.php', 'OCP\\FullTextSearch\\Service\\IIndexService' => $baseDir . '/lib/public/FullTextSearch/Service/IIndexService.php', 'OCP\\FullTextSearch\\Service\\IProviderService' => $baseDir . '/lib/public/FullTextSearch/Service/IProviderService.php', 'OCP\\FullTextSearch\\Service\\ISearchService' => $baseDir . '/lib/public/FullTextSearch/Service/ISearchService.php', @@ -874,6 +874,10 @@ 'OC\\Files\\View' => $baseDir . '/lib/private/Files/View.php', 'OC\\ForbiddenException' => $baseDir . '/lib/private/ForbiddenException.php', 'OC\\FullTextSearch\\FullTextSearchManager' => $baseDir . '/lib/private/FullTextSearch/FullTextSearchManager.php', + 'OC\\FullTextSearch\\Model\\DocumentAccess' => $baseDir . '/lib/private/FullTextSearch/Model/DocumentAccess.php', + 'OC\\FullTextSearch\\Model\\IndexDocument' => $baseDir . '/lib/private/FullTextSearch/Model/IndexDocument.php', + 'OC\\FullTextSearch\\Model\\SearchOption' => $baseDir . '/lib/private/FullTextSearch/Model/SearchOption.php', + 'OC\\FullTextSearch\\Model\\SearchTemplate' => $baseDir . '/lib/private/FullTextSearch/Model/SearchTemplate.php', 'OC\\GlobalScale\\Config' => $baseDir . '/lib/private/GlobalScale/Config.php', 'OC\\Group\\Backend' => $baseDir . '/lib/private/Group/Backend.php', 'OC\\Group\\Database' => $baseDir . '/lib/private/Group/Database.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index d8335e058e697..264b74065a981 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -283,15 +283,15 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\FullTextSearch\\IFullTextSearchManager' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/IFullTextSearchManager.php', 'OCP\\FullTextSearch\\IFullTextSearchPlatform' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/IFullTextSearchPlatform.php', 'OCP\\FullTextSearch\\IFullTextSearchProvider' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/IFullTextSearchProvider.php', - 'OCP\\FullTextSearch\\Model\\DocumentAccess' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/DocumentAccess.php', + 'OCP\\FullTextSearch\\Model\\IDocumentAccess' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/IDocumentAccess.php', 'OCP\\FullTextSearch\\Model\\IIndex' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/IIndex.php', + 'OCP\\FullTextSearch\\Model\\IIndexDocument' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/IIndexDocument.php', 'OCP\\FullTextSearch\\Model\\IIndexOptions' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/IIndexOptions.php', 'OCP\\FullTextSearch\\Model\\IRunner' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/IRunner.php', + 'OCP\\FullTextSearch\\Model\\ISearchOption' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/ISearchOption.php', 'OCP\\FullTextSearch\\Model\\ISearchRequest' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/ISearchRequest.php', 'OCP\\FullTextSearch\\Model\\ISearchResult' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/ISearchResult.php', - 'OCP\\FullTextSearch\\Model\\IndexDocument' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/IndexDocument.php', - 'OCP\\FullTextSearch\\Model\\SearchOption' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/SearchOption.php', - 'OCP\\FullTextSearch\\Model\\SearchTemplate' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/SearchTemplate.php', + 'OCP\\FullTextSearch\\Model\\ISearchTemplate' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/ISearchTemplate.php', 'OCP\\FullTextSearch\\Service\\IIndexService' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Service/IIndexService.php', 'OCP\\FullTextSearch\\Service\\IProviderService' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Service/IProviderService.php', 'OCP\\FullTextSearch\\Service\\ISearchService' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Service/ISearchService.php', @@ -904,6 +904,10 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Files\\View' => __DIR__ . '/../../..' . '/lib/private/Files/View.php', 'OC\\ForbiddenException' => __DIR__ . '/../../..' . '/lib/private/ForbiddenException.php', 'OC\\FullTextSearch\\FullTextSearchManager' => __DIR__ . '/../../..' . '/lib/private/FullTextSearch/FullTextSearchManager.php', + 'OC\\FullTextSearch\\Model\\DocumentAccess' => __DIR__ . '/../../..' . '/lib/private/FullTextSearch/Model/DocumentAccess.php', + 'OC\\FullTextSearch\\Model\\IndexDocument' => __DIR__ . '/../../..' . '/lib/private/FullTextSearch/Model/IndexDocument.php', + 'OC\\FullTextSearch\\Model\\SearchOption' => __DIR__ . '/../../..' . '/lib/private/FullTextSearch/Model/SearchOption.php', + 'OC\\FullTextSearch\\Model\\SearchTemplate' => __DIR__ . '/../../..' . '/lib/private/FullTextSearch/Model/SearchTemplate.php', 'OC\\GlobalScale\\Config' => __DIR__ . '/../../..' . '/lib/private/GlobalScale/Config.php', 'OC\\Group\\Backend' => __DIR__ . '/../../..' . '/lib/private/Group/Backend.php', 'OC\\Group\\Database' => __DIR__ . '/../../..' . '/lib/private/Group/Database.php', diff --git a/lib/public/FullTextSearch/Model/DocumentAccess.php b/lib/private/FullTextSearch/Model/DocumentAccess.php similarity index 81% rename from lib/public/FullTextSearch/Model/DocumentAccess.php rename to lib/private/FullTextSearch/Model/DocumentAccess.php index ef199fb7385d0..9765844d12075 100644 --- a/lib/public/FullTextSearch/Model/DocumentAccess.php +++ b/lib/private/FullTextSearch/Model/DocumentAccess.php @@ -28,14 +28,15 @@ */ -namespace OCP\FullTextSearch\Model; +namespace OC\FullTextSearch\Model; use JsonSerializable; +use OCP\FullTextSearch\Model\IDocumentAccess; /** - * Class DocumentAccess + * Class IDocumentAccess * * This object is used as a data transfer object when * @@ -48,13 +49,14 @@ * During the search, it is internally use to define to which group, circles, ... * a user that perform the search belongs to. * - * @see IndexDocument::setAccess + * @see IIndexDocument::setAccess * * @since 15.0.0 * - * @package OCP\FullTextSearch\Model + * @package OC\FullTextSearch\Model */ -final class DocumentAccess implements JsonSerializable { +final class DocumentAccess implements IDocumentAccess, JsonSerializable { + /** @var string */ private $ownerId; @@ -80,7 +82,7 @@ final class DocumentAccess implements JsonSerializable { * * @since 15.0.0 * - * DocumentAccess constructor. + * IDocumentAccess constructor. * * @param string $ownerId */ @@ -96,9 +98,9 @@ public function __construct(string $ownerId = '') { * * @param string $ownerId * - * @return DocumentAccess + * @return IDocumentAccess */ - public function setOwnerId(string $ownerId) { + public function setOwnerId(string $ownerId): IDocumentAccess { $this->ownerId = $ownerId; return $this; @@ -123,9 +125,9 @@ public function getOwnerId(): string { * * @param string $viewerId * - * @return DocumentAccess + * @return IDocumentAccess */ - public function setViewerId(string $viewerId): DocumentAccess { + public function setViewerId(string $viewerId): IDocumentAccess { $this->viewerId = $viewerId; return $this; @@ -150,9 +152,9 @@ public function getViewerId(): string { * * @param array $users * - * @return DocumentAccess + * @return IDocumentAccess */ - public function setUsers(array $users): DocumentAccess { + public function setUsers(array $users): IDocumentAccess { $this->users = $users; return $this; @@ -165,9 +167,9 @@ public function setUsers(array $users): DocumentAccess { * * @param string $user * - * @return DocumentAccess + * @return IDocumentAccess */ - public function addUser(string $user): DocumentAccess { + public function addUser(string $user): IDocumentAccess { $this->users[] = $user; return $this; @@ -181,9 +183,9 @@ public function addUser(string $user): DocumentAccess { * * @param array $users * - * @return DocumentAccess + * @return IDocumentAccess */ - public function addUsers($users): DocumentAccess { + public function addUsers($users): IDocumentAccess { $this->users = array_merge($this->users, $users); return $this; @@ -208,9 +210,9 @@ public function getUsers(): array { * * @param array $groups * - * @return DocumentAccess + * @return IDocumentAccess */ - public function setGroups(array $groups): DocumentAccess { + public function setGroups(array $groups): IDocumentAccess { $this->groups = $groups; return $this; @@ -223,9 +225,9 @@ public function setGroups(array $groups): DocumentAccess { * * @param string $group * - * @return DocumentAccess + * @return IDocumentAccess */ - public function addGroup(string $group): DocumentAccess { + public function addGroup(string $group): IDocumentAccess { $this->groups[] = $group; return $this; @@ -239,7 +241,7 @@ public function addGroup(string $group): DocumentAccess { * * @param array $groups * - * @return DocumentAccess + * @return IDocumentAccess */ public function addGroups(array $groups) { $this->groups = array_merge($this->groups, $groups); @@ -266,9 +268,9 @@ public function getGroups(): array { * * @param array $circles * - * @return DocumentAccess + * @return IDocumentAccess */ - public function setCircles(array $circles): DocumentAccess { + public function setCircles(array $circles): IDocumentAccess { $this->circles = $circles; return $this; @@ -281,9 +283,9 @@ public function setCircles(array $circles): DocumentAccess { * * @param string $circle * - * @return DocumentAccess + * @return IDocumentAccess */ - public function addCircle(string $circle): DocumentAccess { + public function addCircle(string $circle): IDocumentAccess { $this->circles[] = $circle; return $this; @@ -297,9 +299,9 @@ public function addCircle(string $circle): DocumentAccess { * * @param array $circles * - * @return DocumentAccess + * @return IDocumentAccess */ - public function addCircles(array $circles): DocumentAccess { + public function addCircles(array $circles): IDocumentAccess { $this->circles = array_merge($this->circles, $circles); return $this; @@ -324,9 +326,9 @@ public function getCircles(): array { * * @param array $links * - * @return DocumentAccess + * @return IDocumentAccess */ - public function setLinks(array $links): DocumentAccess { + public function setLinks(array $links): IDocumentAccess { $this->links = $links; return $this; diff --git a/lib/private/FullTextSearch/Model/IndexDocument.php b/lib/private/FullTextSearch/Model/IndexDocument.php new file mode 100644 index 0000000000000..fec140c81a07f --- /dev/null +++ b/lib/private/FullTextSearch/Model/IndexDocument.php @@ -0,0 +1,1000 @@ + + * @copyright 2018 + * @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 . + * + */ + + +namespace OC\FullTextSearch\Model; + + +use JsonSerializable; +use OCP\FullTextSearch\Model\IDocumentAccess; +use OCP\FullTextSearch\Model\IIndex; +use OCP\FullTextSearch\Model\IIndexDocument; + + +/** + * Class IndexDocument + * + * This is one of the main class of the FullTextSearch, used as a data transfer + * object. An IndexDocument is created to manage documents around FullTextSearch, + * during an index and during a search. + * The uniqueness of an IndexDocument is made by the Id of the Content Provider + * and the Id of the original document within the Content Provider. + * + * We will call original document the source from which the IndexDocument is + * generated. As an example, an original document can be a file, a mail, ... + * + * @since 15.0.0 + * + * @package OC\FullTextSearch\Model + */ +class IndexDocument implements IIndexDocument, JsonSerializable { + + + /** @var string */ + protected $id = ''; + + /** @var string */ + protected $providerId = ''; + + /** @var DocumentAccess */ + protected $access; + + /** @var IIndex */ + protected $index; + + /** @var int */ + protected $modifiedTime = 0; + + /** @var string */ + protected $source = ''; + + /** @var array */ + protected $tags = []; + + /** @var array */ + protected $metaTags = []; + + /** @var array */ + protected $subTags = []; + + /** @var string */ + protected $title = ''; + + /** @var string */ + protected $content = ''; + + /** @var string */ + protected $hash = ''; + + /** @var array */ + protected $parts = []; + + /** @var string */ + protected $link = ''; + + /** @var array */ + protected $more = []; + + /** @var array */ + protected $excerpts = []; + + /** @var string */ + protected $score = ''; + + /** @var array */ + protected $info = []; + + /** @var int */ + protected $contentEncoded = 0; + + + /** + * IIndexDocument constructor. + * + * On creation, we assure the uniqueness of the object using the providerId + * and the Id of the original document. + * + * @since 15.0.0 + * + * @param string $providerId + * @param string $documentId + */ + public function __construct(string $providerId, string $documentId) { + $this->providerId = $providerId; + $this->id = $documentId; + } + + + /** + * Returns the Id of the original document. + * + * @since 15.0.0 + * + * @return string + */ + final public function getId(): string { + return $this->id; + } + + + /** + * Returns the Id of the provider. + * + * @since 15.0.0 + * + * @return string + */ + final public function getProviderId(): string { + return $this->providerId; + } + + + /** + * Set the Index related to the IIndexDocument. + * + * @see IIndex + * + * @since 15.0.0 + * + * @param IIndex $index + * + * @return IIndexDocument + */ + final public function setIndex(IIndex $index): IIndexDocument { + $this->index = $index; + + return $this; + } + + /** + * Get the Index. + * + * @since 15.0.0 + * + * @return IIndex + */ + final public function getIndex(): IIndex { + return $this->index; + } + + /** + * return if Index is defined. + * + * @since 16.0.0 + * + * @return bool + */ + final public function hasIndex(): bool { + return ($this->index !== null); + } + + + /** + * Set the modified time of the original document. + * + * @since 15.0.0 + * + * @param int $modifiedTime + * + * @return IIndexDocument + */ + final public function setModifiedTime(int $modifiedTime): IIndexDocument { + $this->modifiedTime = $modifiedTime; + + return $this; + } + + /** + * Get the modified time of the original document. + * + * @since 15.0.0 + * + * @return int + */ + final public function getModifiedTime(): int { + return $this->modifiedTime; + } + + /** + * Check if the original document of the IIndexDocument is older than $time. + * + * @since 15.0.0 + * + * @param int $time + * + * @return bool + */ + final public function isOlderThan(int $time): bool { + return ($this->modifiedTime < $time); + } + + + /** + * Set the read rights of the original document using a IDocumentAccess. + * + * @see IDocumentAccess + * + * @since 15.0.0 + * + * @param IDocumentAccess $access + * + * @return $this + */ + final public function setAccess(IDocumentAccess $access): IIndexDocument { + $this->access = $access; + + return $this; + } + + /** + * Get the IDocumentAccess related to the original document. + * + * @since 15.0.0 + * + * @return IDocumentAccess + */ + final public function getAccess(): IDocumentAccess { + return $this->access; + } + + + /** + * Add a tag to the list. + * + * @since 15.0.0 + * + * @param string $tag + * + * @return IIndexDocument + */ + final public function addTag(string $tag): IIndexDocument { + $this->tags[] = $tag; + + return $this; + } + + /** + * Set the list of tags assigned to the original document. + * + * @since 15.0.0 + * + * @param array $tags + * + * @return IIndexDocument + */ + final public function setTags(array $tags): IIndexDocument { + $this->tags = $tags; + + return $this; + } + + /** + * Get the list of tags assigned to the original document. + * + * @since 15.0.0 + * + * @return array + */ + final public function getTags(): array { + return $this->tags; + } + + + /** + * Add a meta tag to the list. + * + * @since 15.0.0 + * + * @param string $tag + * + * @return IIndexDocument + */ + final public function addMetaTag(string $tag): IIndexDocument { + $this->metaTags[] = $tag; + + return $this; + } + + /** + * Set the list of meta tags assigned to the original document. + * + * @since 15.0.0 + * + * @param array $tags + * + * @return IIndexDocument + */ + final public function setMetaTags(array $tags): IIndexDocument { + $this->metaTags = $tags; + + return $this; + } + + /** + * Get the list of meta tags assigned to the original document. + * + * @since 15.0.0 + * + * @return array + */ + final public function getMetaTags(): array { + return $this->metaTags; + } + + + /** + * Add a sub tag to the list. + * + * @since 15.0.0 + * + * @param string $sub + * @param string $tag + * + * @return IIndexDocument + */ + final public function addSubTag(string $sub, string $tag): IIndexDocument { + $this->subTags[$sub] = $tag; + + return $this; + } + + /** + * Set the list of sub tags assigned to the original document. + * + * @since 15.0.0 + * + * @param array $tags + * + * @return IIndexDocument + */ + final public function setSubTags(array $tags): IIndexDocument { + $this->subTags = $tags; + + return $this; + } + + /** + * Get the list of sub tags assigned to the original document. + * If $formatted is true, the result will be formatted in a one + * dimensional array. + * + * @since 15.0.0 + * + * @param bool $formatted + * + * @return array + */ + final public function getSubTags(bool $formatted = false): array { + if ($formatted === false) { + return $this->subTags; + } + + $subTags = []; + $ak = array_keys($this->subTags); + foreach ($ak as $source) { + $tags = $this->subTags[$source]; + foreach ($tags as $tag) { + $subTags[] = $source . '_' . $tag; + } + } + + return $subTags; + } + + + /** + * Set the source of the original document. + * + * @since 15.0.0 + * + * @param string $source + * + * @return IIndexDocument + */ + final public function setSource(string $source): IIndexDocument { + $this->source = $source; + + return $this; + } + + /** + * Get the source of the original document. + * + * @since 15.0.0 + * + * @return string + */ + final public function getSource(): string { + return $this->source; + } + + + /** + * Set the title of the original document. + * + * @since 15.0.0 + * + * @param string $title + * + * @return IIndexDocument + */ + final public function setTitle(string $title): IIndexDocument { + $this->title = $title; + + return $this; + } + + /** + * Get the title of the original document. + * + * @since 15.0.0 + * + * @return string + */ + final public function getTitle(): string { + return $this->title; + } + + + /** + * Set the content of the document. + * $encoded can be NOT_ENCODED or ENCODED_BASE64 if the content is raw or + * encoded in base64. + * + * @since 15.0.0 + * + * @param string $content + * @param int $encoded + * + * @return IIndexDocument + */ + final public function setContent(string $content, int $encoded = 0): IIndexDocument { + $this->content = $content; + $this->contentEncoded = $encoded; + + return $this; + } + + /** + * Get the content of the original document. + * + * @since 15.0.0 + * + * @return string + */ + final public function getContent(): string { + return $this->content; + } + + /** + * Returns the type of the encoding on the content. + * + * @since 15.0.0 + * + * @return int + */ + final public function isContentEncoded(): int { + return $this->contentEncoded; + } + + /** + * Return the size of the content. + * + * @since 15.0.0 + * + * @return int + */ + final public function getContentSize(): int { + return strlen($this->getContent()); + } + + + /** + * Generate an hash, based on the content of the original document. + * + * @since 15.0.0 + * + * @return IIndexDocument + */ + final public function initHash(): IIndexDocument { + if ($this->getContent() === '' || is_null($this->getContent())) { + return $this; + } + + $this->hash = hash("md5", $this->getContent()); + + return $this; + } + + /** + * Set the hash of the original document. + * + * @since 15.0.0 + * + * @param string $hash + * + * @return IIndexDocument + */ + final public function setHash(string $hash): IIndexDocument { + $this->hash = $hash; + + return $this; + } + + /** + * Get the hash of the original document. + * + * @since 15.0.0 + * + * @return string + */ + final public function getHash(): string { + return $this->hash; + } + + + /** + * Add a part, identified by a string, and its content. + * + * It is strongly advised to use alphanumerical chars with no space in the + * $part string. + * + * @since 15.0.0 + * + * @param string $part + * @param string $content + * + * @return IIndexDocument + */ + final public function addPart(string $part, string $content): IIndexDocument { + $this->parts[$part] = $content; + + return $this; + } + + /** + * Set all parts and their content. + * + * @since 15.0.0 + * + * @param array $parts + * + * @return IIndexDocument + */ + final public function setParts(array $parts): IIndexDocument { + $this->parts = $parts; + + return $this; + } + + /** + * Get all parts of the IIndexDocument. + * + * @since 15.0.0 + * + * @return array + */ + final public function getParts(): array { + return $this->parts; + } + + + /** + * Add a link, usable by the frontend. + * + * @since 15.0.0 + * + * @param string $link + * + * @return IIndexDocument + */ + final public function setLink(string $link): IIndexDocument { + $this->link = $link; + + return $this; + } + + /** + * Get the link. + * + * @since 15.0.0 + * + * @return string + */ + final public function getLink(): string { + return $this->link; + } + + + /** + * Set more information that couldn't be set using other method. + * + * @since 15.0.0 + * + * @param array $more + * + * @return IIndexDocument + */ + final public function setMore(array $more): IIndexDocument { + $this->more = $more; + + return $this; + } + + /** + * Get more information. + * + * @since 15.0.0 + * + * @return array + */ + final public function getMore(): array { + return $this->more; + } + + + /** + * Add some excerpt of the content of the original document, usually based + * on the search request. + * + * @since 16.0.0 + * + * @param string $source + * @param string $excerpt + * + * @return IIndexDocument + */ + final public function addExcerpt(string $source, string $excerpt): IIndexDocument { + $excerpt = $this->cleanExcerpt($excerpt); + if (!array_key_exists($source, $this->excerpts)) { + $this->excerpts[$source] = []; + } + + $this->excerpts[$source][] = $excerpt; + + return $this; + } + + + /** + * Set all excerpts of the content of the original document. + * + * @since 16.0.0 + * + * @param array $excerpts + * + * @return IIndexDocument + */ + final public function setExcerpts(array $excerpts): IIndexDocument { + $new = []; + foreach ($excerpts as $entry) { + $newExcerpts = array_map(function (string $excerpt): string { + return $this->cleanExcerpt($excerpt); + }, $entry['excerpt']); + + $new[] = [ + 'source' => $entry['source'], + 'excerpt' => $newExcerpts + ]; + } + + $this->excerpts = $new; + + return $this; + } + + /** + * Get all excerpts of the content of the original document. + * + * @since 15.0.0 + * + * @return array + */ + final public function getExcerpts(): array { + return $this->excerpts; + } + + /** + * Clean excerpt. + * + * @since 16.0.0 + * + * @param string $excerpt + * @return string + */ + final private function cleanExcerpt(string $excerpt): string { + $excerpt = str_replace("\\n", ' ', $excerpt); + $excerpt = str_replace("\\r", ' ', $excerpt); + $excerpt = str_replace("\\t", ' ', $excerpt); + $excerpt = str_replace("\n", ' ', $excerpt); + $excerpt = str_replace("\r", ' ', $excerpt); + $excerpt = str_replace("\t", ' ', $excerpt); + + return $excerpt; + } + + + /** + * Set the score to the result assigned to this document during a search + * request. + * + * @since 15.0.0 + * + * @param string $score + * + * @return IIndexDocument + */ + final public function setScore(string $score): IIndexDocument { + $this->score = $score; + + return $this; + } + + /** + * Get the score. + * + * @since 15.0.0 + * + * @return string + */ + final public function getScore(): string { + return $this->score; + } + + + /** + * Set some information about the original document that will be available + * to the front-end when displaying search result. (as string) + * Because this information will not be indexed, this method can also be + * used to manage some data while filling the IIndexDocument before its + * indexing. + * + * @since 15.0.0 + * + * @param string $info + * @param string $value + * + * @return IIndexDocument + */ + final public function setInfo(string $info, string $value): IIndexDocument { + $this->info[$info] = $value; + + return $this; + } + + /** + * Get an information about a document. (string) + * + * @since 15.0.0 + * + * @param string $info + * @param string $default + * + * @return string + */ + final public function getInfo(string $info, string $default = ''): string { + if (!key_exists($info, $this->info)) { + return $default; + } + + return $this->info[$info]; + } + + /** + * Set some information about the original document that will be available + * to the front-end when displaying search result. (as array) + * Because this information will not be indexed, this method can also be + * used to manage some data while filling the IIndexDocument before its + * indexing. + * + * @since 15.0.0 + * + * @param string $info + * @param array $value + * + * @return IIndexDocument + */ + final public function setInfoArray(string $info, array $value): IIndexDocument { + $this->info[$info] = $value; + + return $this; + } + + /** + * Get an information about a document. (array) + * + * @since 15.0.0 + * + * @param string $info + * @param array $default + * + * @return array + */ + final public function getInfoArray(string $info, array $default = []): array { + if (!key_exists($info, $this->info)) { + return $default; + } + + return $this->info[$info]; + } + + /** + * Set some information about the original document that will be available + * to the front-end when displaying search result. (as int) + * Because this information will not be indexed, this method can also be + * used to manage some data while filling the IIndexDocument before its + * indexing. + * + * @since 15.0.0 + * + * @param string $info + * @param int $value + * + * @return IIndexDocument + */ + final public function setInfoInt(string $info, int $value): IIndexDocument { + $this->info[$info] = $value; + + return $this; + } + + /** + * Get an information about a document. (int) + * + * @since 15.0.0 + * + * @param string $info + * @param int $default + * + * @return int + */ + final public function getInfoInt(string $info, int $default = 0): int { + if (!key_exists($info, $this->info)) { + return $default; + } + + return $this->info[$info]; + } + + /** + * Set some information about the original document that will be available + * to the front-end when displaying search result. (as bool) + * Because this information will not be indexed, this method can also be + * used to manage some data while filling the IIndexDocument before its + * indexing. + * + * @since 15.0.0 + * + * @param string $info + * @param bool $value + * + * @return IIndexDocument + */ + final public function setInfoBool(string $info, bool $value): IIndexDocument { + $this->info[$info] = $value; + + return $this; + } + + /** + * Get an information about a document. (bool) + * + * @since 15.0.0 + * + * @param string $info + * @param bool $default + * + * @return bool + */ + final public function getInfoBool(string $info, bool $default = false): bool { + if (!key_exists($info, $this->info)) { + return $default; + } + + return $this->info[$info]; + } + + /** + * Get all info. + * + * @since 15.0.0 + * + * @return array + */ + final public function getInfoAll(): array { + + $info = []; + foreach ($this->info as $k => $v) { + if (substr($k, 0, 1) === '_') { + continue; + } + + $info[$k] = $v; + } + + return $info; + } + + + /** + * @since 15.0.0 + * + * On some version of PHP, it is better to force destruct the object. + * And during the index, the number of generated IIndexDocument can be + * _huge_. + */ + public function __destruct() { + unset($this->id); + unset($this->providerId); + unset($this->access); + unset($this->modifiedTime); + unset($this->title); + unset($this->content); + unset($this->hash); + unset($this->link); + unset($this->source); + unset($this->tags); + unset($this->metaTags); + unset($this->subTags); + unset($this->more); + unset($this->excerpts); + unset($this->score); + unset($this->info); + unset($this->contentEncoded); + } + + /** + * @since 15.0.0 + * + * @return array + */ + public function jsonSerialize() { + return [ + 'id' => $this->getId(), + 'providerId' => $this->getProviderId(), + 'access' => $this->access, + 'modifiedTime' => $this->getModifiedTime(), + 'title' => $this->getTitle(), + 'link' => $this->getLink(), + 'index' => $this->index, + 'source' => $this->getSource(), + 'info' => $this->getInfoAll(), + 'hash' => $this->getHash(), + 'contentSize' => $this->getContentSize(), + 'tags' => $this->getTags(), + 'metatags' => $this->getMetaTags(), + 'subtags' => $this->getSubTags(), + 'more' => $this->getMore(), + 'excerpts' => $this->getExcerpts(), + 'score' => $this->getScore() + ]; + } + +} + diff --git a/lib/public/FullTextSearch/Model/SearchOption.php b/lib/private/FullTextSearch/Model/SearchOption.php similarity index 86% rename from lib/public/FullTextSearch/Model/SearchOption.php rename to lib/private/FullTextSearch/Model/SearchOption.php index ae6ad3241b647..6a67c9fe7df4c 100644 --- a/lib/public/FullTextSearch/Model/SearchOption.php +++ b/lib/private/FullTextSearch/Model/SearchOption.php @@ -28,26 +28,21 @@ */ -namespace OCP\FullTextSearch\Model; +namespace OC\FullTextSearch\Model; use JsonSerializable; +use OCP\FullTextSearch\Model\ISearchOption; /** * @since 15.0.0 * - * Class SearchOption + * Class ISearchOption * - * @package OCP\FullTextSearch\Model + * @package OC\FullTextSearch\Model */ -final class SearchOption implements JsonSerializable { - - - const CHECKBOX = 'checkbox'; - const INPUT = 'input'; - - const INPUT_SMALL = 'small'; +final class SearchOption implements ISearchOption, JsonSerializable { /** @var string */ @@ -116,7 +111,7 @@ final class SearchOption implements JsonSerializable { */ /** - * SearchOption constructor. + * ISearchOption constructor. * * Some value can be setduring the creation of the object. * @@ -148,9 +143,9 @@ public function __construct(string $name = '', string $title = '', string $type * * @param string $name * - * @return SearchOption + * @return ISearchOption */ - public function setName(string $name): SearchOption { + public function setName(string $name): ISearchOption { $this->name = $name; return $this; @@ -175,9 +170,9 @@ public function getName(): string { * * @param string $title * - * @return SearchOption + * @return ISearchOption */ - public function setTitle(string $title): SearchOption { + public function setTitle(string $title): ISearchOption { $this->title = $title; return $this; @@ -197,15 +192,15 @@ public function getTitle(): string { /** * Set the type of the option. - * $type can be SearchOption::CHECKBOX or SearchOption::INPUT + * $type can be ISearchOption::CHECKBOX or ISearchOption::INPUT * * @since 15.0.0 * * @param string $type * - * @return SearchOption + * @return ISearchOption */ - public function setType(string $type): SearchOption { + public function setType(string $type): ISearchOption { $this->type = $type; return $this; @@ -225,15 +220,15 @@ public function getType(): string { /** * In case of Type is INPUT, set the size of the input field. - * Value can be SearchOption::INPUT_SMALL or not defined. + * Value can be ISearchOption::INPUT_SMALL or not defined. * * @since 15.0.0 * * @param string $size * - * @return SearchOption + * @return ISearchOption */ - public function setSize(string $size): SearchOption { + public function setSize(string $size): ISearchOption { $this->size = $size; return $this; @@ -259,9 +254,9 @@ public function getSize(): string { * * @param string $placeholder * - * @return SearchOption + * @return ISearchOption */ - public function setPlaceholder(string $placeholder): SearchOption { + public function setPlaceholder(string $placeholder): ISearchOption { $this->placeholder = $placeholder; return $this; diff --git a/lib/public/FullTextSearch/Model/SearchTemplate.php b/lib/private/FullTextSearch/Model/SearchTemplate.php similarity index 84% rename from lib/public/FullTextSearch/Model/SearchTemplate.php rename to lib/private/FullTextSearch/Model/SearchTemplate.php index 7d9159190eaaf..22333e712ce18 100644 --- a/lib/public/FullTextSearch/Model/SearchTemplate.php +++ b/lib/private/FullTextSearch/Model/SearchTemplate.php @@ -28,15 +28,17 @@ */ -namespace OCP\FullTextSearch\Model; +namespace OC\FullTextSearch\Model; use JsonSerializable; use OCP\FullTextSearch\IFullTextSearchProvider; +use OCP\FullTextSearch\Model\ISearchOption; +use OCP\FullTextSearch\Model\ISearchTemplate; /** - * Class SearchTemplate + * Class ISearchTemplate * * This is a data transfer object that should be created by Content Provider * when the getSearchTemplate() method is called. @@ -58,9 +60,9 @@ * * @since 15.0.0 * - * @package OCP\FullTextSearch\Model + * @package OC\FullTextSearch\Model */ -final class SearchTemplate implements JsonSerializable { +final class SearchTemplate implements ISearchTemplate, JsonSerializable { /** @var string */ @@ -80,7 +82,7 @@ final class SearchTemplate implements JsonSerializable { /** - * SearchTemplate constructor. + * ISearchTemplate constructor. * * the class of the icon and the css file to be loaded can be set during the * creation of the object. @@ -104,9 +106,9 @@ public function __construct(string $icon = '', string $css = '') { * * @param string $class * - * @return SearchTemplate + * @return ISearchTemplate */ - public function setIcon(string $class): SearchTemplate { + public function setIcon(string $class): ISearchTemplate { $this->icon = $class; return $this; @@ -131,9 +133,9 @@ public function getIcon(): string { * * @param string $css * - * @return SearchTemplate + * @return ISearchTemplate */ - public function setCss(string $css): SearchTemplate { + public function setCss(string $css): ISearchTemplate { $this->css = $css; return $this; @@ -161,9 +163,9 @@ public function getCss(): string { * * @param string $template * - * @return SearchTemplate + * @return ISearchTemplate */ - public function setTemplate(string $template): SearchTemplate { + public function setTemplate(string $template): ISearchTemplate { $this->template = $template; return $this; @@ -185,15 +187,15 @@ public function getTemplate(): string { * Add an option in the Panel that is displayed when the user start a search * within the app that generate the content. * - * @see SearchOption + * @see ISearchOption * * @since 15.0.0 * - * @param SearchOption $option + * @param ISearchOption $option * - * @return SearchTemplate + * @return ISearchTemplate */ - public function addPanelOption(SearchOption $option): SearchTemplate { + public function addPanelOption(ISearchOption $option): ISearchTemplate { $this->panelOptions[] = $option; return $this; @@ -214,15 +216,15 @@ public function getPanelOptions(): array { /** * Add an option in the left panel of the FullTextSearch navigation page. * - * @see SearchOption + * @see ISearchOption * * @since 15.0.0 * - * @param SearchOption $option + * @param ISearchOption $option * - * @return SearchTemplate + * @return ISearchTemplate */ - public function addNavigationOption(SearchOption $option): SearchTemplate { + public function addNavigationOption(ISearchOption $option): ISearchTemplate { $this->navigationOptions[] = $option; return $this; diff --git a/lib/public/Files_FullTextSearch/Model/AFilesDocument.php b/lib/public/Files_FullTextSearch/Model/AFilesDocument.php index 3eed956df84a3..143788f33ade2 100644 --- a/lib/public/Files_FullTextSearch/Model/AFilesDocument.php +++ b/lib/public/Files_FullTextSearch/Model/AFilesDocument.php @@ -31,13 +31,14 @@ namespace OCP\Files_FullTextSearch\Model; -use OCP\FullTextSearch\Model\IndexDocument; +use OC\FullTextSearch\Model\IndexDocument; +use OCP\FullTextSearch\Model\IIndexDocument; /** * Abstract Class AFilesDocument * - * This is mostly used by 3rd party apps that want to complete the IndexDocument + * This is mostly used by 3rd party apps that want to complete the IIndexDocument * with more information about a file before its index: * * \OC::$server->getEventDispatcher()->addListener( @@ -48,7 +49,6 @@ * * // @var \OCP\Files_FullTextSearch\Model\AFilesDocument $document * $document = $e->getArgument('document'); - * * } * ); * @@ -107,6 +107,5 @@ abstract public function getMimetype(): string; */ abstract public function getPath(): string; - } diff --git a/lib/public/FullTextSearch/IFullTextSearchPlatform.php b/lib/public/FullTextSearch/IFullTextSearchPlatform.php index f3f9a35bae287..01016269f6b45 100644 --- a/lib/public/FullTextSearch/IFullTextSearchPlatform.php +++ b/lib/public/FullTextSearch/IFullTextSearchPlatform.php @@ -31,9 +31,9 @@ namespace OCP\FullTextSearch; -use OCP\FullTextSearch\Model\DocumentAccess; +use OCP\FullTextSearch\Model\IDocumentAccess; use OCP\FullTextSearch\Model\IIndex; -use OCP\FullTextSearch\Model\IndexDocument; +use OCP\FullTextSearch\Model\IIndexDocument; use OCP\FullTextSearch\Model\IRunner; use OCP\FullTextSearch\Model\ISearchResult; @@ -190,11 +190,11 @@ public function deleteIndexes(array $indexes); * * @since 15.0.0 * - * @param IndexDocument $document + * @param IIndexDocument $document * * @return IIndex */ - public function indexDocument(IndexDocument $document): IIndex; + public function indexDocument(IIndexDocument $document): IIndex; /** @@ -204,9 +204,9 @@ public function indexDocument(IndexDocument $document): IIndex; * @since 15.0.0 * * @param ISearchResult $result - * @param DocumentAccess $access + * @param IDocumentAccess $access */ - public function searchRequest(ISearchResult $result, DocumentAccess $access); + public function searchRequest(ISearchResult $result, IDocumentAccess $access); /** @@ -218,9 +218,9 @@ public function searchRequest(ISearchResult $result, DocumentAccess $access); * @param string $providerId * @param string $documentId * - * @return IndexDocument + * @return IIndexDocument */ - public function getDocument(string $providerId, string $documentId): IndexDocument; + public function getDocument(string $providerId, string $documentId): IIndexDocument; } diff --git a/lib/public/FullTextSearch/IFullTextSearchProvider.php b/lib/public/FullTextSearch/IFullTextSearchProvider.php index a46ef05149141..b72c9e55435e2 100644 --- a/lib/public/FullTextSearch/IFullTextSearchProvider.php +++ b/lib/public/FullTextSearch/IFullTextSearchProvider.php @@ -33,11 +33,11 @@ use OCP\FullTextSearch\Model\IIndex; use OCP\FullTextSearch\Model\IIndexOptions; -use OCP\FullTextSearch\Model\IndexDocument; +use OCP\FullTextSearch\Model\IIndexDocument; use OCP\FullTextSearch\Model\IRunner; use OCP\FullTextSearch\Model\ISearchRequest; use OCP\FullTextSearch\Model\ISearchResult; -use OCP\FullTextSearch\Model\SearchTemplate; +use OCP\FullTextSearch\Model\ISearchTemplate; /** @@ -115,16 +115,16 @@ public function getConfiguration(): array; /** - * Must returns a SearchTemplate that contains displayable items and + * Must returns a ISearchTemplate that contains displayable items and * available options to users when searching. * - * @see SearchTemplate + * @see ISearchTemplate * * @since 15.0.0 * - * @return SearchTemplate + * @return ISearchTemplate */ - public function getSearchTemplate(): SearchTemplate; + public function getSearchTemplate(): ISearchTemplate; /** @@ -182,19 +182,19 @@ public function generateChunks(string $userId): array; /** - * Returns all indexable document for a user as an array of IndexDocument. + * Returns all indexable document for a user as an array of IIndexDocument. * - * There is no need to fill each IndexDocument with content; at this point, + * There is no need to fill each IIndexDocument with content; at this point, * only fill the object with the minimum information to not waste memory while * still being able to identify the document it is referring to. * * FullTextSearch will call 2 other methods of this interface for each - * IndexDocument of the array, prior to their indexing: + * IIndexDocument of the array, prior to their indexing: * * - first, to compare the date of the last index, - * - then, to fill each IndexDocument with complete data + * - then, to fill each IIndexDocument with complete data * - * @see IndexDocument + * @see IIndexDocument * * @since 15.0.0 * -> 16.0.0: the parameter "$chunk" was added @@ -202,7 +202,7 @@ public function generateChunks(string $userId): array; * @param string $userId * @param string $chunk * - * @return IndexDocument[] + * @return IIndexDocument[] */ public function generateIndexableDocuments(string $userId, string $chunk): array; @@ -210,40 +210,40 @@ public function generateIndexableDocuments(string $userId, string $chunk): array /** * Called to verify that the document is not already indexed and that the * old index is not up-to-date, using the IIndex from - * IndexDocument->getIndex() + * IIndexDocument->getIndex() * - * Returning true will not queue the current IndexDocument to any further + * Returning true will not queue the current IIndexDocument to any further * operation and will continue on the next element from the list returned by * generateIndexableDocuments(). * * @since 15.0.0 * - * @param IndexDocument $document + * @param IIndexDocument $document * * @return bool */ - public function isDocumentUpToDate(IndexDocument $document): bool; + public function isDocumentUpToDate(IIndexDocument $document): bool; /** - * Must fill IndexDocument with all information relative to the document, + * Must fill IIndexDocument with all information relative to the document, * before its indexing by the Search Platform. * * Method is called for each element returned previously by * generateIndexableDocuments(). * - * @see IndexDocument + * @see IIndexDocument * * @since 15.0.0 * - * @param IndexDocument $document + * @param IIndexDocument $document */ - public function fillIndexDocument(IndexDocument $document); + public function fillIndexDocument(IIndexDocument $document); /** - * The Search Provider must create and return an IndexDocument - * based on the IIndex and its status. The IndexDocument must contains all + * The Search Provider must create and return an IIndexDocument + * based on the IIndex and its status. The IIndexDocument must contains all * information as it will be send for indexing. * * Method is called during a cron or a ./occ fulltextsearch:live after a @@ -253,9 +253,9 @@ public function fillIndexDocument(IndexDocument $document); * * @param IIndex $index * - * @return IndexDocument + * @return IIndexDocument */ - public function updateDocument(IIndex $index): IndexDocument; + public function updateDocument(IIndex $index): IIndexDocument; /** diff --git a/lib/public/FullTextSearch/Model/IDocumentAccess.php b/lib/public/FullTextSearch/Model/IDocumentAccess.php new file mode 100644 index 0000000000000..66697340a8c91 --- /dev/null +++ b/lib/public/FullTextSearch/Model/IDocumentAccess.php @@ -0,0 +1,264 @@ + + * @copyright 2018 + * @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 . + * + */ + + +namespace OCP\FullTextSearch\Model; + + +/** + * Interface IDocumentAccess + * + * This object is used as a data transfer object when + * + * - indexing a document, + * - generating a search request. + * + * During the index, it is used to define which users, groups, circles, ... + * have access to the IIndexDocument + * + * During the search, it is internally use to define to which group, circles, ... + * a user that perform the search belongs to. + * + * @see IIndexDocument::setAccess + * + * @since 15.0.0 + * + * @package OCP\FullTextSearch\Model + */ +interface IDocumentAccess { + + + /** + * Owner of the document can be set at the init of the object. + * + * @since 15.0.0 + * + * IDocumentAccess constructor. + * + * @param string $ownerId + */ + public function __construct(string $ownerId = ''); + + + /** + * Set the Owner of the document. + * + * @since 15.0.0 + * + * @param string $ownerId + * + * @return IDocumentAccess + */ + public function setOwnerId(string $ownerId): IDocumentAccess; + + /** + * Get the Owner of the document. + * + * @since 15.0.0 + * + * @return string + */ + public function getOwnerId(): string; + + + /** + * Set the viewer of the document. + * + * @since 15.0.0 + * + * @param string $viewerId + * + * @return IDocumentAccess + */ + public function setViewerId(string $viewerId): IDocumentAccess; + + /** + * Get the viewer of the document. + * + * @since 15.0.0 + * + * @return string + */ + public function getViewerId(): string; + + + /** + * Set the list of users that have read access to the document. + * + * @since 15.0.0 + * + * @param array $users + * + * @return IDocumentAccess + */ + public function setUsers(array $users): IDocumentAccess; + + /** + * Add an entry to the list of users that have read access to the document. + * + * @since 15.0.0 + * + * @param string $user + * + * @return IDocumentAccess + */ + public function addUser(string $user): IDocumentAccess; + + /** + * Add multiple entries to the list of users that have read access to the + * document. + * + * @since 15.0.0 + * + * @param array $users + * + * @return IDocumentAccess + */ + public function addUsers($users): IDocumentAccess; + + /** + * Get the complete list of users that have read access to the document. + * + * @since 15.0.0 + * + * @return array + */ + public function getUsers(): array; + + + /** + * Set the list of groups that have read access to the document. + * + * @since 15.0.0 + * + * @param array $groups + * + * @return IDocumentAccess + */ + public function setGroups(array $groups): IDocumentAccess; + + /** + * Add an entry to the list of groups that have read access to the document. + * + * @since 15.0.0 + * + * @param string $group + * + * @return IDocumentAccess + */ + public function addGroup(string $group): IDocumentAccess; + + /** + * Add multiple entries to the list of groups that have read access to the + * document. + * + * @since 15.0.0 + * + * @param array $groups + * + * @return IDocumentAccess + */ + public function addGroups(array $groups); + + /** + * Get the complete list of groups that have read access to the document. + * + * @since 15.0.0 + * + * @return array + */ + public function getGroups(): array; + + + /** + * Set the list of circles that have read access to the document. + * + * @since 15.0.0 + * + * @param array $circles + * + * @return IDocumentAccess + */ + public function setCircles(array $circles): IDocumentAccess; + + /** + * Add an entry to the list of circles that have read access to the document. + * + * @since 15.0.0 + * + * @param string $circle + * + * @return IDocumentAccess + */ + public function addCircle(string $circle): IDocumentAccess; + + /** + * Add multiple entries to the list of groups that have read access to the + * document. + * + * @since 15.0.0 + * + * @param array $circles + * + * @return IDocumentAccess + */ + public function addCircles(array $circles): IDocumentAccess; + + /** + * Get the complete list of circles that have read access to the document. + * + * @since 15.0.0 + * + * @return array + */ + public function getCircles(): array; + + + /** + * Set the list of links that have read access to the document. + * + * @since 15.0.0 + * + * @param array $links + * + * @return IDocumentAccess + */ + public function setLinks(array $links): IDocumentAccess; + + /** + * Get the list of links that have read access to the document. + * + * @since 15.0.0 + * + * @return array + */ + public function getLinks(): array; + +} + diff --git a/lib/public/FullTextSearch/Model/IIndex.php b/lib/public/FullTextSearch/Model/IIndex.php index adfdf34aee67e..d8a1db1a1b7ee 100644 --- a/lib/public/FullTextSearch/Model/IIndex.php +++ b/lib/public/FullTextSearch/Model/IIndex.php @@ -38,10 +38,10 @@ * regarding the date of the last index and the date of the last modification * of the original document. * - * The uniqueness of an IndexDocument is made by the Id of the Content Provider + * The uniqueness of an IIndexDocument is made by the Id of the Content Provider * and the Id of the original document within the Content Provider. * - * We will call original document the source from which the IndexDocument is + * We will call original document the source from which the IIndexDocument is * generated. As an example, an original document can be a file, a mail, ... * * @since 15.0.0 diff --git a/lib/public/FullTextSearch/Model/IIndexDocument.php b/lib/public/FullTextSearch/Model/IIndexDocument.php new file mode 100644 index 0000000000000..d3184530a7f07 --- /dev/null +++ b/lib/public/FullTextSearch/Model/IIndexDocument.php @@ -0,0 +1,636 @@ + + * @copyright 2018 + * @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 . + * + */ + + +namespace OCP\FullTextSearch\Model; + + +/** + * Class IIndexDocument + * + * This is one of the main class of the FullTextSearch, used as a data transfer + * object. An IIndexDocument is created to manage documents around FullTextSearch, + * during an index and during a search. + * The uniqueness of an IIndexDocument is made by the Id of the Content Provider + * and the Id of the original document within the Content Provider. + * + * We will call original document the source from which the IIndexDocument is + * generated. As an example, an original document can be a file, a mail, ... + * + * @since 15.0.0 + * + * @package OC\FullTextSearch\Model + */ +interface IIndexDocument { + + + const NOT_ENCODED = 0; + const ENCODED_BASE64 = 1; + + + + /** + * Returns the Id of the original document. + * + * @since 15.0.0 + * + * @return string + */ + public function getId(): string; + + + /** + * Returns the Id of the provider. + * + * @since 15.0.0 + * + * @return string + */ + public function getProviderId(): string; + + + /** + * Set the Index related to the IIndexDocument. + * + * @see IIndex + * + * @since 15.0.0 + * + * @param IIndex $index + * + * @return IIndexDocument + */ + public function setIndex(IIndex $index): IIndexDocument; + + /** + * Get the Index. + * + * @since 15.0.0 + * + * @return IIndex + */ + public function getIndex(): IIndex; + + /** + * return if Index is defined. + * + * @since 16.0.0 + * + * @return bool + */ + public function hasIndex(): bool; + + + /** + * Set the modified time of the original document. + * + * @since 15.0.0 + * + * @param int $modifiedTime + * + * @return IIndexDocument + */ + public function setModifiedTime(int $modifiedTime): IIndexDocument; + + /** + * Get the modified time of the original document. + * + * @since 15.0.0 + * + * @return int + */ + public function getModifiedTime(): int; + + /** + * Check if the original document of the IIndexDocument is older than $time. + * + * @since 15.0.0 + * + * @param int $time + * + * @return bool + */ + public function isOlderThan(int $time): bool; + + + /** + * Set the read rights of the original document using a IDocumentAccess. + * + * @see IDocumentAccess + * + * @since 15.0.0 + * + * @param IDocumentAccess $access + * + * @return $this + */ + public function setAccess(IDocumentAccess $access): IIndexDocument; + + /** + * Get the IDocumentAccess related to the original document. + * + * @since 15.0.0 + * + * @return IDocumentAccess + */ + public function getAccess(): IDocumentAccess; + + + /** + * Add a tag to the list. + * + * @since 15.0.0 + * + * @param string $tag + * + * @return IIndexDocument + */ + public function addTag(string $tag): IIndexDocument; + + /** + * Set the list of tags assigned to the original document. + * + * @since 15.0.0 + * + * @param array $tags + * + * @return IIndexDocument + */ + public function setTags(array $tags): IIndexDocument; + + /** + * Get the list of tags assigned to the original document. + * + * @since 15.0.0 + * + * @return array + */ + public function getTags(): array; + + + /** + * Add a meta tag to the list. + * + * @since 15.0.0 + * + * @param string $tag + * + * @return IIndexDocument + */ + public function addMetaTag(string $tag): IIndexDocument; + + /** + * Set the list of meta tags assigned to the original document. + * + * @since 15.0.0 + * + * @param array $tags + * + * @return IIndexDocument + */ + public function setMetaTags(array $tags): IIndexDocument; + + /** + * Get the list of meta tags assigned to the original document. + * + * @since 15.0.0 + * + * @return array + */ + public function getMetaTags(): array; + + + /** + * Add a sub tag to the list. + * + * @since 15.0.0 + * + * @param string $sub + * @param string $tag + * + * @return IIndexDocument + */ + public function addSubTag(string $sub, string $tag): IIndexDocument; + + /** + * Set the list of sub tags assigned to the original document. + * + * @since 15.0.0 + * + * @param array $tags + * + * @return IIndexDocument + */ + public function setSubTags(array $tags): IIndexDocument; + + /** + * Get the list of sub tags assigned to the original document. + * If $formatted is true, the result will be formatted in a one + * dimensional array. + * + * @since 15.0.0 + * + * @param bool $formatted + * + * @return array + */ + public function getSubTags(bool $formatted = false): array; + + + /** + * Set the source of the original document. + * + * @since 15.0.0 + * + * @param string $source + * + * @return IIndexDocument + */ + public function setSource(string $source): IIndexDocument; + + /** + * Get the source of the original document. + * + * @since 15.0.0 + * + * @return string + */ + public function getSource(): string; + + + /** + * Set the title of the original document. + * + * @since 15.0.0 + * + * @param string $title + * + * @return IIndexDocument + */ + public function setTitle(string $title): IIndexDocument; + + /** + * Get the title of the original document. + * + * @since 15.0.0 + * + * @return string + */ + public function getTitle(): string; + + + /** + * Set the content of the document. + * $encoded can be NOT_ENCODED or ENCODED_BASE64 if the content is raw or + * encoded in base64. + * + * @since 15.0.0 + * + * @param string $content + * @param int $encoded + * + * @return IIndexDocument + */ + public function setContent(string $content, int $encoded = 0): IIndexDocument; + + /** + * Get the content of the original document. + * + * @since 15.0.0 + * + * @return string + */ + public function getContent(): string; + + /** + * Returns the type of the encoding on the content. + * + * @since 15.0.0 + * + * @return int + */ + public function isContentEncoded(): int; + + /** + * Return the size of the content. + * + * @since 15.0.0 + * + * @return int + */ + public function getContentSize(): int; + + + /** + * Generate an hash, based on the content of the original document. + * + * @since 15.0.0 + * + * @return IIndexDocument + */ + public function initHash(): IIndexDocument; + + /** + * Set the hash of the original document. + * + * @since 15.0.0 + * + * @param string $hash + * + * @return IIndexDocument + */ + public function setHash(string $hash): IIndexDocument; + + /** + * Get the hash of the original document. + * + * @since 15.0.0 + * + * @return string + */ + public function getHash(): string; + + + /** + * Add a part, identified by a string, and its content. + * + * It is strongly advised to use alphanumerical chars with no space in the + * $part string. + * + * @since 15.0.0 + * + * @param string $part + * @param string $content + * + * @return IIndexDocument + */ + public function addPart(string $part, string $content): IIndexDocument; + + /** + * Set all parts and their content. + * + * @since 15.0.0 + * + * @param array $parts + * + * @return IIndexDocument + */ + public function setParts(array $parts): IIndexDocument; + + /** + * Get all parts of the IIndexDocument. + * + * @since 15.0.0 + * + * @return array + */ + public function getParts(): array; + + + /** + * Add a link, usable by the frontend. + * + * @since 15.0.0 + * + * @param string $link + * + * @return IIndexDocument + */ + public function setLink(string $link): IIndexDocument; + + /** + * Get the link. + * + * @since 15.0.0 + * + * @return string + */ + public function getLink(): string; + + + /** + * Set more information that couldn't be set using other method. + * + * @since 15.0.0 + * + * @param array $more + * + * @return IIndexDocument + */ + public function setMore(array $more): IIndexDocument; + + /** + * Get more information. + * + * @since 15.0.0 + * + * @return array + */ + public function getMore(): array; + + + /** + * Add some excerpt of the content of the original document, usually based + * on the search request. + * + * @since 16.0.0 + * + * @param string $source + * @param string $excerpt + * + * @return IIndexDocument + */ + public function addExcerpt(string $source, string $excerpt): IIndexDocument; + + /** + * Set all excerpts of the content of the original document. + * + * @since 16.0.0 + * + * @param array $excerpts + * + * @return IIndexDocument + */ + public function setExcerpts(array $excerpts): IIndexDocument; + + /** + * Get all excerpts of the content of the original document. + * + * @since 15.0.0 + * + * @return array + */ + public function getExcerpts(): array; + + + /** + * Set the score to the result assigned to this document during a search + * request. + * + * @since 15.0.0 + * + * @param string $score + * + * @return IIndexDocument + */ + public function setScore(string $score): IIndexDocument; + + /** + * Get the score. + * + * @since 15.0.0 + * + * @return string + */ + public function getScore(): string; + + + /** + * Set some information about the original document that will be available + * to the front-end when displaying search result. (as string) + * Because this information will not be indexed, this method can also be + * used to manage some data while filling the IIndexDocument before its + * indexing. + * + * @since 15.0.0 + * + * @param string $info + * @param string $value + * + * @return IIndexDocument + */ + public function setInfo(string $info, string $value): IIndexDocument; + + /** + * Get an information about a document. (string) + * + * @since 15.0.0 + * + * @param string $info + * @param string $default + * + * @return string + */ + public function getInfo(string $info, string $default = ''): string; + + /** + * Set some information about the original document that will be available + * to the front-end when displaying search result. (as array) + * Because this information will not be indexed, this method can also be + * used to manage some data while filling the IIndexDocument before its + * indexing. + * + * @since 15.0.0 + * + * @param string $info + * @param array $value + * + * @return IIndexDocument + */ + public function setInfoArray(string $info, array $value): IIndexDocument; + + /** + * Get an information about a document. (array) + * + * @since 15.0.0 + * + * @param string $info + * @param array $default + * + * @return array + */ + public function getInfoArray(string $info, array $default = []): array; + + /** + * Set some information about the original document that will be available + * to the front-end when displaying search result. (as int) + * Because this information will not be indexed, this method can also be + * used to manage some data while filling the IIndexDocument before its + * indexing. + * + * @since 15.0.0 + * + * @param string $info + * @param int $value + * + * @return IIndexDocument + */ + public function setInfoInt(string $info, int $value): IIndexDocument; + + /** + * Get an information about a document. (int) + * + * @since 15.0.0 + * + * @param string $info + * @param int $default + * + * @return int + */ + public function getInfoInt(string $info, int $default = 0): int; + + /** + * Set some information about the original document that will be available + * to the front-end when displaying search result. (as bool) + * Because this information will not be indexed, this method can also be + * used to manage some data while filling the IIndexDocument before its + * indexing. + * + * @since 15.0.0 + * + * @param string $info + * @param bool $value + * + * @return IIndexDocument + */ + public function setInfoBool(string $info, bool $value): IIndexDocument; + + /** + * Get an information about a document. (bool) + * + * @since 15.0.0 + * + * @param string $info + * @param bool $default + * + * @return bool + */ + public function getInfoBool(string $info, bool $default = false): bool; + + /** + * Get all info. + * + * @since 15.0.0 + * + * @return array + */ + public function getInfoAll(): array; + +} + diff --git a/lib/public/FullTextSearch/Model/ISearchOption.php b/lib/public/FullTextSearch/Model/ISearchOption.php new file mode 100644 index 0000000000000..33802028547b5 --- /dev/null +++ b/lib/public/FullTextSearch/Model/ISearchOption.php @@ -0,0 +1,161 @@ + + * @copyright 2018 + * @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 . + * + */ + + +namespace OCP\FullTextSearch\Model; + + +/** + * @since 15.0.0 + * + * Interface ISearchOption + * + * @package OCP\FullTextSearch\Model + */ +interface ISearchOption { + + + const CHECKBOX = 'checkbox'; + const INPUT = 'input'; + + const INPUT_SMALL = 'small'; + + + /** + * Set the name/key of the option. + * The string should only contains alphanumerical chars and underscore. + * The key can be retrieve when using ISearchRequest::getOption + * + * @see ISearchRequest::getOption + * + * @since 15.0.0 + * + * @param string $name + * + * @return ISearchOption + */ + public function setName(string $name): ISearchOption; + + /** + * Get the name/key of the option. + * + * @since 15.0.0 + * + * @return string + */ + public function getName(): string; + + + /** + * Set the title/display name of the option. + * + * @since 15.0.0 + * + * @param string $title + * + * @return ISearchOption + */ + public function setTitle(string $title): ISearchOption; + + /** + * Get the title of the option. + * + * @since 15.0.0 + * + * @return string + */ + public function getTitle(): string; + + + /** + * Set the type of the option. + * $type can be ISearchOption::CHECKBOX or ISearchOption::INPUT + * + * @since 15.0.0 + * + * @param string $type + * + * @return ISearchOption + */ + public function setType(string $type): ISearchOption; + + /** + * Get the type of the option. + * + * @since 15.0.0 + * + * @return string + */ + public function getType(): string; + + + /** + * In case of Type is INPUT, set the size of the input field. + * Value can be ISearchOption::INPUT_SMALL or not defined. + * + * @since 15.0.0 + * + * @param string $size + * + * @return ISearchOption + */ + public function setSize(string $size): ISearchOption; + + /** + * Get the size of the INPUT. + * + * @since 15.0.0 + * + * @return string + */ + public function getSize(): string; + + + /** + * In case of Type is , set the placeholder to be displayed in the input + * field. + * + * @since 15.0.0 + * + * @param string $placeholder + * + * @return ISearchOption + */ + public function setPlaceholder(string $placeholder): ISearchOption; + + /** + * Get the placeholder. + * + * @since 15.0.0 + * + * @return string + */ + public function getPlaceholder(): string; + +} diff --git a/lib/public/FullTextSearch/Model/ISearchResult.php b/lib/public/FullTextSearch/Model/ISearchResult.php index 453ec61e7de6a..2ca61c2f37b3e 100644 --- a/lib/public/FullTextSearch/Model/ISearchResult.php +++ b/lib/public/FullTextSearch/Model/ISearchResult.php @@ -78,31 +78,31 @@ public function getProvider(): IFullTextSearchProvider; /** - * Add an IndexDocument as one of the result of the search request. + * Add an IIndexDocument as one of the result of the search request. * * @since 15.0.0 * - * @param IndexDocument $document + * @param IIndexDocument $document * * @return ISearchResult */ - public function addDocument(IndexDocument $document): ISearchResult; + public function addDocument(IIndexDocument $document): ISearchResult; /** - * Returns all result of the search request, in an array of IndexDocument. + * Returns all result of the search request, in an array of IIndexDocument. * * @since 15.0.0 * - * @return IndexDocument[] + * @return IIndexDocument[] */ public function getDocuments(): array; /** - * Set an array of IndexDocument as the result of the search request. + * Set an array of IIndexDocument as the result of the search request. * * @since 15.0.0 * - * @param IndexDocument[] $documents + * @param IIndexDocument[] $documents * * @return ISearchResult */ diff --git a/lib/public/FullTextSearch/Model/ISearchTemplate.php b/lib/public/FullTextSearch/Model/ISearchTemplate.php new file mode 100644 index 0000000000000..e0140b232522d --- /dev/null +++ b/lib/public/FullTextSearch/Model/ISearchTemplate.php @@ -0,0 +1,179 @@ + + * @copyright 2018 + * @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 . + * + */ + + +namespace OCP\FullTextSearch\Model; + + +use OCP\FullTextSearch\IFullTextSearchProvider; + + +/** + * Class ISearchTemplate + * + * This is a data transfer object that should be created by Content Provider + * when the getSearchTemplate() method is called. + * + * The object will contain templates to be displayed, and the list of the different + * options to be available to the user when he start a new search. + * + * The display of the Options is generated by the FullTextSearch app and Options + * can be displayed in 2 places: + * + * - the navigation page of the app that generate the indexed content. + * (files, bookmarks, deck, mails, ...) + * - the navigation page of the FullTextSearch app. + * + * Both pages will have different Options, and only the first one can integrate + * a specific template. + * + * @see IFullTextSearchProvider::getSearchTemplate + * + * @since 15.0.0 + * + * @package OCP\FullTextSearch\Model + */ +interface ISearchTemplate { + + + /** + * Set the class of the icon to be displayed in the left panel of the + * FullTextSearch navigation page, in front of the related Content Provider. + * + * @since 15.0.0 + * + * @param string $class + * + * @return ISearchTemplate + */ + public function setIcon(string $class): ISearchTemplate; + + /** + * Get the class of the icon. + * + * @since 15.0.0 + * + * @return string + */ + public function getIcon(): string; + + + /** + * Set the path of a CSS file that will be loaded when needed. + * + * @since 15.0.0 + * + * @param string $css + * + * @return ISearchTemplate + */ + public function setCss(string $css): ISearchTemplate; + + /** + * Get the path of the CSS file. + * + * @since 15.0.0 + * + * @return string + */ + public function getCss(): string; + + + /** + * Set the path of the file of a template that the HTML will be displayed + * below the Options. + * This should only be used if your Content Provider needs to set options in + * a way not generated by FullTextSearch + * + * @since 15.0.0 + * + * @param string $template + * + * @return ISearchTemplate + */ + public function setTemplate(string $template): ISearchTemplate; + + /** + * Get the path of the template file. + * + * @since 15.0.0 + * + * @return string + */ + public function getTemplate(): string; + + + /** + * Add an option in the Panel that is displayed when the user start a search + * within the app that generate the content. + * + * @see ISearchOption + * + * @since 15.0.0 + * + * @param ISearchOption $option + * + * @return ISearchTemplate + */ + public function addPanelOption(ISearchOption $option): ISearchTemplate; + + /** + * Get all options to be displayed in the Panel. + * + * @since 15.0.0 + * + * @return ISearchOption[] + */ + public function getPanelOptions(): array; + + + /** + * Add an option in the left panel of the FullTextSearch navigation page. + * + * @see ISearchOption + * + * @since 15.0.0 + * + * @param ISearchOption $option + * + * @return ISearchTemplate + */ + public function addNavigationOption(ISearchOption $option): ISearchTemplate; + + /** + * Get all options to be displayed in the FullTextSearch navigation page. + * + * @since 15.0.0 + * + * @return array + */ + public function getNavigationOptions(): array; + +} + From 83d70d9008b2b2ddc831d71865066ed06180cb0a Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Wed, 27 Feb 2019 11:31:48 -0100 Subject: [PATCH 2/5] cleaning Signed-off-by: Maxence Lange --- lib/public/FullTextSearch/Model/IIndex.php | 5 +- .../FullTextSearch/Model/IndexDocument.php | 985 ------------------ 2 files changed, 3 insertions(+), 987 deletions(-) delete mode 100644 lib/public/FullTextSearch/Model/IndexDocument.php diff --git a/lib/public/FullTextSearch/Model/IIndex.php b/lib/public/FullTextSearch/Model/IIndex.php index d8a1db1a1b7ee..650a0d6270784 100644 --- a/lib/public/FullTextSearch/Model/IIndex.php +++ b/lib/public/FullTextSearch/Model/IIndex.php @@ -56,8 +56,9 @@ interface IIndex { const INDEX_META = 4; const INDEX_CONTENT = 8; - const INDEX_FULL = 12; - const INDEX_REMOVE = 16; + const INDEX_PARTS = 16; + const INDEX_FULL = 28; + const INDEX_REMOVE = 32; const INDEX_DONE = 32; const INDEX_FAILED = 64; diff --git a/lib/public/FullTextSearch/Model/IndexDocument.php b/lib/public/FullTextSearch/Model/IndexDocument.php deleted file mode 100644 index d00a8461ee8b1..0000000000000 --- a/lib/public/FullTextSearch/Model/IndexDocument.php +++ /dev/null @@ -1,985 +0,0 @@ - - * @copyright 2018 - * @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 . - * - */ - - -namespace OCP\FullTextSearch\Model; - - -use JsonSerializable; - -/** - * Class IndexDocument - * - * This is one of the main class of the FullTextSearch, used as a data transfer - * object. An IndexDocument is created to manage documents around FullTextSearch, - * during an index and during a search. - * The uniqueness of an IndexDocument is made by the Id of the Content Provider - * and the Id of the original document within the Content Provider. - * - * We will call original document the source from which the IndexDocument is - * generated. As an example, an original document can be a file, a mail, ... - * - * @since 15.0.0 - * - * @package OC\FullTextSearch\Model - */ -class IndexDocument implements JsonSerializable { - - - const NOT_ENCODED = 0; - const ENCODED_BASE64 = 1; - - - /** @var string */ - protected $id = ''; - - /** @var string */ - protected $providerId = ''; - - /** @var DocumentAccess */ - protected $access; - - /** @var IIndex */ - protected $index; - - /** @var int */ - protected $modifiedTime = 0; - - /** @var string */ - protected $source = ''; - - /** @var array */ - protected $tags = []; - - /** @var array */ - protected $metaTags = []; - - /** @var array */ - protected $subTags = []; - - /** @var string */ - protected $title = ''; - - /** @var string */ - protected $content = ''; - - /** @var string */ - protected $hash = ''; - - /** @var array */ - protected $parts = []; - - /** @var string */ - protected $link = ''; - - /** @var array */ - protected $more = []; - - /** @var array */ - protected $excerpts = []; - - /** @var string */ - protected $score = ''; - - /** @var array */ - protected $info = []; - - /** @var int */ - protected $contentEncoded = 0; - - - /** - * IndexDocument constructor. - * - * On creation, we assure the uniqueness of the object using the providerId - * and the Id of the original document. - * - * @since 15.0.0 - * - * @param string $providerId - * @param string $documentId - */ - public function __construct(string $providerId, string $documentId) { - $this->providerId = $providerId; - $this->id = $documentId; - } - - - /** - * Returns the Id of the original document. - * - * @since 15.0.0 - * - * @return string - */ - final public function getId(): string { - return $this->id; - } - - - /** - * Returns the Id of the provider. - * - * @since 15.0.0 - * - * @return string - */ - final public function getProviderId(): string { - return $this->providerId; - } - - - /** - * Set the Index related to the IndexDocument. - * - * @see IIndex - * - * @since 15.0.0 - * - * @param IIndex $index - * - * @return IndexDocument - */ - final public function setIndex(IIndex $index): IndexDocument { - $this->index = $index; - - return $this; - } - - /** - * Get the Index. - * - * @since 15.0.0 - * - * @return IIndex - */ - final public function getIndex(): IIndex { - return $this->index; - } - - /** - * return if Index is defined. - * - * @since 16.0.0 - * - * @return bool - */ - final public function hasIndex(): bool { - return $this->index !== null; - } - - - /** - * Set the modified time of the original document. - * - * @since 15.0.0 - * - * @param int $modifiedTime - * - * @return IndexDocument - */ - final public function setModifiedTime(int $modifiedTime): IndexDocument { - $this->modifiedTime = $modifiedTime; - - return $this; - } - - /** - * Get the modified time of the original document. - * - * @since 15.0.0 - * - * @return int - */ - final public function getModifiedTime(): int { - return $this->modifiedTime; - } - - /** - * Check if the original document of the IndexDocument is older than $time. - * - * @since 15.0.0 - * - * @param int $time - * - * @return bool - */ - final public function isOlderThan(int $time): bool { - return ($this->modifiedTime < $time); - } - - - /** - * Set the read rights of the original document using a DocumentAccess. - * - * @see DocumentAccess - * - * @since 15.0.0 - * - * @param DocumentAccess $access - * - * @return $this - */ - final public function setAccess(DocumentAccess $access) { - $this->access = $access; - - return $this; - } - - /** - * Get the DocumentAccess related to the original document. - * - * @since 15.0.0 - * - * @return DocumentAccess - */ - final public function getAccess(): DocumentAccess { - return $this->access; - } - - - /** - * Add a tag to the list. - * - * @since 15.0.0 - * - * @param string $tag - * - * @return IndexDocument - */ - final public function addTag(string $tag): IndexDocument { - $this->tags[] = $tag; - - return $this; - } - - /** - * Set the list of tags assigned to the original document. - * - * @since 15.0.0 - * - * @param array $tags - * - * @return IndexDocument - */ - final public function setTags(array $tags): IndexDocument { - $this->tags = $tags; - - return $this; - } - - /** - * Get the list of tags assigned to the original document. - * - * @since 15.0.0 - * - * @return array - */ - final public function getTags(): array { - return $this->tags; - } - - - /** - * Add a meta tag to the list. - * - * @since 15.0.0 - * - * @param string $tag - * - * @return IndexDocument - */ - final public function addMetaTag(string $tag): IndexDocument { - $this->metaTags[] = $tag; - - return $this; - } - - /** - * Set the list of meta tags assigned to the original document. - * - * @since 15.0.0 - * - * @param array $tags - * - * @return IndexDocument - */ - final public function setMetaTags(array $tags): IndexDocument { - $this->metaTags = $tags; - - return $this; - } - - /** - * Get the list of meta tags assigned to the original document. - * - * @since 15.0.0 - * - * @return array - */ - final public function getMetaTags(): array { - return $this->metaTags; - } - - - /** - * Add a sub tag to the list. - * - * @since 15.0.0 - * - * @param string $sub - * @param string $tag - * - * @return IndexDocument - */ - final public function addSubTag(string $sub, string $tag): IndexDocument { - $this->subTags[$sub] = $tag; - - return $this; - } - - /** - * Set the list of sub tags assigned to the original document. - * - * @since 15.0.0 - * - * @param array $tags - * - * @return IndexDocument - */ - final public function setSubTags(array $tags): IndexDocument { - $this->subTags = $tags; - - return $this; - } - - /** - * Get the list of sub tags assigned to the original document. - * If $formatted is true, the result will be formatted in a one - * dimensional array. - * - * @since 15.0.0 - * - * @param bool $formatted - * - * @return array - */ - final public function getSubTags(bool $formatted = false): array { - if ($formatted === false) { - return $this->subTags; - } - - $subTags = []; - $ak = array_keys($this->subTags); - foreach ($ak as $source) { - $tags = $this->subTags[$source]; - foreach ($tags as $tag) { - $subTags[] = $source . '_' . $tag; - } - } - - return $subTags; - } - - - /** - * Set the source of the original document. - * - * @since 15.0.0 - * - * @param string $source - * - * @return IndexDocument - */ - final public function setSource(string $source): IndexDocument { - $this->source = $source; - - return $this; - } - - /** - * Get the source of the original document. - * - * @since 15.0.0 - * - * @return string - */ - final public function getSource(): string { - return $this->source; - } - - - /** - * Set the title of the original document. - * - * @since 15.0.0 - * - * @param string $title - * - * @return IndexDocument - */ - final public function setTitle(string $title): IndexDocument { - $this->title = $title; - - return $this; - } - - /** - * Get the title of the original document. - * - * @since 15.0.0 - * - * @return string - */ - final public function getTitle(): string { - return $this->title; - } - - - /** - * Set the content of the document. - * $encoded can be NOT_ENCODED or ENCODED_BASE64 if the content is raw or - * encoded in base64. - * - * @since 15.0.0 - * - * @param string $content - * @param int $encoded - * - * @return IndexDocument - */ - final public function setContent(string $content, int $encoded = 0): IndexDocument { - $this->content = $content; - $this->contentEncoded = $encoded; - - return $this; - } - - /** - * Get the content of the original document. - * - * @since 15.0.0 - * - * @return string - */ - final public function getContent(): string { - return $this->content; - } - - /** - * Returns the type of the encoding on the content. - * - * @since 15.0.0 - * - * @return int - */ - final public function isContentEncoded(): int { - return $this->contentEncoded; - } - - /** - * Return the size of the content. - * - * @since 15.0.0 - * - * @return int - */ - final public function getContentSize(): int { - return strlen($this->getContent()); - } - - - /** - * Generate an hash, based on the content of the original document. - * - * @since 15.0.0 - * - * @return IndexDocument - */ - final public function initHash(): IndexDocument { - if ($this->getContent() === '' || is_null($this->getContent())) { - return $this; - } - - $this->hash = hash("md5", $this->getContent()); - - return $this; - } - - /** - * Set the hash of the original document. - * - * @since 15.0.0 - * - * @param string $hash - * - * @return IndexDocument - */ - final public function setHash(string $hash): IndexDocument { - $this->hash = $hash; - - return $this; - } - - /** - * Get the hash of the original document. - * - * @since 15.0.0 - * - * @return string - */ - final public function getHash(): string { - return $this->hash; - } - - - /** - * Add a part, identified by a string, and its content. - * - * It is strongly advised to use alphanumerical chars with no space in the - * $part string. - * - * @since 15.0.0 - * - * @param string $part - * @param string $content - * - * @return IndexDocument - */ - final public function addPart(string $part, string $content): IndexDocument { - $this->parts[$part] = $content; - - return $this; - } - - /** - * Set all parts and their content. - * - * @since 15.0.0 - * - * @param array $parts - * - * @return IndexDocument - */ - final public function setParts(array $parts): IndexDocument { - $this->parts = $parts; - - return $this; - } - - /** - * Get all parts of the IndexDocument. - * - * @since 15.0.0 - * - * @return array - */ - final public function getParts(): array { - return $this->parts; - } - - - /** - * Add a link, usable by the frontend. - * - * @since 15.0.0 - * - * @param string $link - * - * @return IndexDocument - */ - final public function setLink(string $link): IndexDocument { - $this->link = $link; - - return $this; - } - - /** - * Get the link. - * - * @since 15.0.0 - * - * @return string - */ - final public function getLink(): string { - return $this->link; - } - - - /** - * Set more information that couldn't be set using other method. - * - * @since 15.0.0 - * - * @param array $more - * - * @return IndexDocument - */ - final public function setMore(array $more): IndexDocument { - $this->more = $more; - - return $this; - } - - /** - * Get more information. - * - * @since 15.0.0 - * - * @return array - */ - final public function getMore(): array { - return $this->more; - } - - - /** - * Add some excerpt of the content of the original document, usually based - * on the search request. - * - * @since 15.0.0 - * - * @param string $excerpt - * - * @return IndexDocument - */ - final public function addExcerpt(string $excerpt): IndexDocument { - $excerpt = $this->cleanExcerpt($excerpt); - - $this->excerpts[] = $excerpt; - - return $this; - } - - /** - * Set all excerpts of the content of the original document. - * - * @since 15.0.0 - * - * @param array $excerpts - * - * @return IndexDocument - */ - final public function setExcerpts(array $excerpts): IndexDocument { - $excerpts = array_map([$this, 'cleanExcerpt'], $excerpts); - - $this->excerpts = $excerpts; - - return $this; - } - - /** - * Get all excerpts of the content of the original document. - * - * @since 15.0.0 - * - * @return array - */ - final public function getExcerpts(): array { - return $this->excerpts; - } - - /** - * Clean excerpt. - * - * @since 15.0.0 - * - * @param string $excerpt - * - * @return string - */ - final public function cleanExcerpt(string $excerpt): string { - $excerpt = str_replace("\\n", ' ', $excerpt); - $excerpt = str_replace("\\r", ' ', $excerpt); - $excerpt = str_replace("\\t", ' ', $excerpt); - $excerpt = str_replace("\n", ' ', $excerpt); - $excerpt = str_replace("\r", ' ', $excerpt); - $excerpt = str_replace("\t", ' ', $excerpt); - - return $excerpt; - } - - /** - * Set the score to the result assigned to this document during a search - * request. - * - * @since 15.0.0 - * - * @param string $score - * - * @return IndexDocument - */ - final public function setScore(string $score): IndexDocument { - $this->score = $score; - - return $this; - } - - /** - * Get the score. - * - * @since 15.0.0 - * - * @return string - */ - final public function getScore(): string { - return $this->score; - } - - - /** - * Set some information about the original document that will be available - * to the front-end when displaying search result. (as string) - * Because this information will not be indexed, this method can also be - * used to manage some data while filling the IndexDocument before its - * indexing. - * - * @since 15.0.0 - * - * @param string $info - * @param string $value - * - * @return IndexDocument - */ - final public function setInfo(string $info, string $value): IndexDocument { - $this->info[$info] = $value; - - return $this; - } - - /** - * Get an information about a document. (string) - * - * @since 15.0.0 - * - * @param string $info - * @param string $default - * - * @return string - */ - final public function getInfo(string $info, string $default = ''): string { - if (!key_exists($info, $this->info)) { - return $default; - } - - return $this->info[$info]; - } - - /** - * Set some information about the original document that will be available - * to the front-end when displaying search result. (as array) - * Because this information will not be indexed, this method can also be - * used to manage some data while filling the IndexDocument before its - * indexing. - * - * @since 15.0.0 - * - * @param string $info - * @param array $value - * - * @return IndexDocument - */ - final public function setInfoArray(string $info, array $value): IndexDocument { - $this->info[$info] = $value; - - return $this; - } - - /** - * Get an information about a document. (array) - * - * @since 15.0.0 - * - * @param string $info - * @param array $default - * - * @return array - */ - final public function getInfoArray(string $info, array $default = []): array { - if (!key_exists($info, $this->info)) { - return $default; - } - - return $this->info[$info]; - } - - /** - * Set some information about the original document that will be available - * to the front-end when displaying search result. (as int) - * Because this information will not be indexed, this method can also be - * used to manage some data while filling the IndexDocument before its - * indexing. - * - * @since 15.0.0 - * - * @param string $info - * @param int $value - * - * @return IndexDocument - */ - final public function setInfoInt(string $info, int $value): IndexDocument { - $this->info[$info] = $value; - - return $this; - } - - /** - * Get an information about a document. (int) - * - * @since 15.0.0 - * - * @param string $info - * @param int $default - * - * @return int - */ - final public function getInfoInt(string $info, int $default = 0): int { - if (!key_exists($info, $this->info)) { - return $default; - } - - return $this->info[$info]; - } - - /** - * Set some information about the original document that will be available - * to the front-end when displaying search result. (as bool) - * Because this information will not be indexed, this method can also be - * used to manage some data while filling the IndexDocument before its - * indexing. - * - * @since 15.0.0 - * - * @param string $info - * @param bool $value - * - * @return IndexDocument - */ - final public function setInfoBool(string $info, bool $value): IndexDocument { - $this->info[$info] = $value; - - return $this; - } - - /** - * Get an information about a document. (bool) - * - * @since 15.0.0 - * - * @param string $info - * @param bool $default - * - * @return bool - */ - final public function getInfoBool(string $info, bool $default = false): bool { - if (!key_exists($info, $this->info)) { - return $default; - } - - return $this->info[$info]; - } - - /** - * Get all info. - * - * @since 15.0.0 - * - * @return array - */ - final public function getInfoAll(): array { - - $info = []; - foreach ($this->info as $k => $v) { - if (substr($k, 0, 1) === '_') { - continue; - } - - $info[$k] = $v; - } - - return $info; - } - - - /** - * @since 15.0.0 - * - * On some version of PHP, it is better to force destruct the object. - * And during the index, the number of generated IndexDocument can be - * _huge_. - */ - public function __destruct() { - unset($this->id); - unset($this->providerId); - unset($this->access); - unset($this->modifiedTime); - unset($this->title); - unset($this->content); - unset($this->hash); - unset($this->link); - unset($this->source); - unset($this->tags); - unset($this->metaTags); - unset($this->subTags); - unset($this->more); - unset($this->excerpts); - unset($this->score); - unset($this->info); - unset($this->contentEncoded); - } - - /** - * @since 15.0.0 - * - * @return array - */ - public function jsonSerialize() { - return [ - 'id' => $this->getId(), - 'providerId' => $this->getProviderId(), - 'access' => $this->access, - 'modifiedTime' => $this->getModifiedTime(), - 'title' => $this->getTitle(), - 'link' => $this->getLink(), - 'index' => $this->index, - 'source' => $this->getSource(), - 'info' => $this->getInfoAll(), - 'hash' => $this->getHash(), - 'contentSize' => $this->getContentSize(), - 'tags' => $this->getTags(), - 'metatags' => $this->getMetaTags(), - 'subtags' => $this->getSubTags(), - 'more' => $this->getMore(), - 'excerpts' => $this->getExcerpts(), - 'score' => $this->getScore() - ]; - } - -} - From 4ac0375f89cdbfc8ae7fc8d199cf0dd55079cb8a Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Fri, 1 Mar 2019 10:29:17 -0100 Subject: [PATCH 3/5] cleaning the excerpts managment Signed-off-by: Maxence Lange --- .../FullTextSearch/Model/IndexDocument.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/private/FullTextSearch/Model/IndexDocument.php b/lib/private/FullTextSearch/Model/IndexDocument.php index fec140c81a07f..55cce902a2811 100644 --- a/lib/private/FullTextSearch/Model/IndexDocument.php +++ b/lib/private/FullTextSearch/Model/IndexDocument.php @@ -671,12 +671,11 @@ final public function getMore(): array { * @return IIndexDocument */ final public function addExcerpt(string $source, string $excerpt): IIndexDocument { - $excerpt = $this->cleanExcerpt($excerpt); - if (!array_key_exists($source, $this->excerpts)) { - $this->excerpts[$source] = []; - } - - $this->excerpts[$source][] = $excerpt; + $this->excerpts[] = + [ + 'source' => $source, + 'excerpt' => $this->cleanExcerpt($excerpt) + ]; return $this; } @@ -694,13 +693,9 @@ final public function addExcerpt(string $source, string $excerpt): IIndexDocumen final public function setExcerpts(array $excerpts): IIndexDocument { $new = []; foreach ($excerpts as $entry) { - $newExcerpts = array_map(function (string $excerpt): string { - return $this->cleanExcerpt($excerpt); - }, $entry['excerpt']); - $new[] = [ 'source' => $entry['source'], - 'excerpt' => $newExcerpts + 'excerpt' => $this->cleanExcerpt($entry['excerpt']) ]; } From 3bdc78e981576b4c965cd9f6965d26f9b3b68292 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Fri, 1 Mar 2019 10:29:31 -0100 Subject: [PATCH 4/5] fixing INDEX_DONE Signed-off-by: Maxence Lange --- lib/public/FullTextSearch/Model/IIndex.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/public/FullTextSearch/Model/IIndex.php b/lib/public/FullTextSearch/Model/IIndex.php index 650a0d6270784..c1c83db2d4b58 100644 --- a/lib/public/FullTextSearch/Model/IIndex.php +++ b/lib/public/FullTextSearch/Model/IIndex.php @@ -59,9 +59,8 @@ interface IIndex { const INDEX_PARTS = 16; const INDEX_FULL = 28; const INDEX_REMOVE = 32; - - const INDEX_DONE = 32; - const INDEX_FAILED = 64; + const INDEX_DONE = 64; + const INDEX_FAILED = 128; const ERROR_FAILED = 1; const ERROR_FAILED2 = 2; From adfadf821b88d1a704a05a9eeded7f4e9b81066a Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Mon, 4 Mar 2019 09:49:29 -0100 Subject: [PATCH 5/5] fixing phpdoc Signed-off-by: Maxence Lange --- .../FullTextSearch/Model/DocumentAccess.php | 42 +++++++++---------- .../FullTextSearch/Model/IDocumentAccess.php | 40 +++++++++--------- .../FullTextSearch/Model/ISearchOption.php | 32 +++++++++----- .../FullTextSearch/Model/ISearchTemplate.php | 22 +++++----- 4 files changed, 73 insertions(+), 63 deletions(-) diff --git a/lib/private/FullTextSearch/Model/DocumentAccess.php b/lib/private/FullTextSearch/Model/DocumentAccess.php index 9765844d12075..088bf075ae681 100644 --- a/lib/private/FullTextSearch/Model/DocumentAccess.php +++ b/lib/private/FullTextSearch/Model/DocumentAccess.php @@ -51,7 +51,7 @@ * * @see IIndexDocument::setAccess * - * @since 15.0.0 + * @since 16.0.0 * * @package OC\FullTextSearch\Model */ @@ -80,7 +80,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { /** * Owner of the document can be set at the init of the object. * - * @since 15.0.0 + * @since 16.0.0 * * IDocumentAccess constructor. * @@ -94,7 +94,7 @@ public function __construct(string $ownerId = '') { /** * Set the Owner of the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $ownerId * @@ -109,7 +109,7 @@ public function setOwnerId(string $ownerId): IDocumentAccess { /** * Get the Owner of the document. * - * @since 15.0.0 + * @since 16.0.0 * * @return string */ @@ -121,7 +121,7 @@ public function getOwnerId(): string { /** * Set the viewer of the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $viewerId * @@ -136,7 +136,7 @@ public function setViewerId(string $viewerId): IDocumentAccess { /** * Get the viewer of the document. * - * @since 15.0.0 + * @since 16.0.0 * * @return string */ @@ -148,7 +148,7 @@ public function getViewerId(): string { /** * Set the list of users that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param array $users * @@ -163,7 +163,7 @@ public function setUsers(array $users): IDocumentAccess { /** * Add an entry to the list of users that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $user * @@ -179,7 +179,7 @@ public function addUser(string $user): IDocumentAccess { * Add multiple entries to the list of users that have read access to the * document. * - * @since 15.0.0 + * @since 16.0.0 * * @param array $users * @@ -194,7 +194,7 @@ public function addUsers($users): IDocumentAccess { /** * Get the complete list of users that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @return array */ @@ -206,7 +206,7 @@ public function getUsers(): array { /** * Set the list of groups that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param array $groups * @@ -221,7 +221,7 @@ public function setGroups(array $groups): IDocumentAccess { /** * Add an entry to the list of groups that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $group * @@ -237,7 +237,7 @@ public function addGroup(string $group): IDocumentAccess { * Add multiple entries to the list of groups that have read access to the * document. * - * @since 15.0.0 + * @since 16.0.0 * * @param array $groups * @@ -252,7 +252,7 @@ public function addGroups(array $groups) { /** * Get the complete list of groups that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @return array */ @@ -264,7 +264,7 @@ public function getGroups(): array { /** * Set the list of circles that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param array $circles * @@ -279,7 +279,7 @@ public function setCircles(array $circles): IDocumentAccess { /** * Add an entry to the list of circles that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $circle * @@ -295,7 +295,7 @@ public function addCircle(string $circle): IDocumentAccess { * Add multiple entries to the list of groups that have read access to the * document. * - * @since 15.0.0 + * @since 16.0.0 * * @param array $circles * @@ -310,7 +310,7 @@ public function addCircles(array $circles): IDocumentAccess { /** * Get the complete list of circles that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @return array */ @@ -322,7 +322,7 @@ public function getCircles(): array { /** * Set the list of links that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param array $links * @@ -337,7 +337,7 @@ public function setLinks(array $links): IDocumentAccess { /** * Get the list of links that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @return array */ @@ -347,7 +347,7 @@ public function getLinks(): array { /** - * @since 15.0.0 + * @since 16.0.0 * * @return array */ diff --git a/lib/public/FullTextSearch/Model/IDocumentAccess.php b/lib/public/FullTextSearch/Model/IDocumentAccess.php index 66697340a8c91..848e2200f607b 100644 --- a/lib/public/FullTextSearch/Model/IDocumentAccess.php +++ b/lib/public/FullTextSearch/Model/IDocumentAccess.php @@ -47,7 +47,7 @@ * * @see IIndexDocument::setAccess * - * @since 15.0.0 + * @since 16.0.0 * * @package OCP\FullTextSearch\Model */ @@ -57,7 +57,7 @@ interface IDocumentAccess { /** * Owner of the document can be set at the init of the object. * - * @since 15.0.0 + * @since 16.0.0 * * IDocumentAccess constructor. * @@ -69,7 +69,7 @@ public function __construct(string $ownerId = ''); /** * Set the Owner of the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $ownerId * @@ -80,7 +80,7 @@ public function setOwnerId(string $ownerId): IDocumentAccess; /** * Get the Owner of the document. * - * @since 15.0.0 + * @since 16.0.0 * * @return string */ @@ -90,7 +90,7 @@ public function getOwnerId(): string; /** * Set the viewer of the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $viewerId * @@ -101,7 +101,7 @@ public function setViewerId(string $viewerId): IDocumentAccess; /** * Get the viewer of the document. * - * @since 15.0.0 + * @since 16.0.0 * * @return string */ @@ -111,7 +111,7 @@ public function getViewerId(): string; /** * Set the list of users that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param array $users * @@ -122,7 +122,7 @@ public function setUsers(array $users): IDocumentAccess; /** * Add an entry to the list of users that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $user * @@ -134,7 +134,7 @@ public function addUser(string $user): IDocumentAccess; * Add multiple entries to the list of users that have read access to the * document. * - * @since 15.0.0 + * @since 16.0.0 * * @param array $users * @@ -145,7 +145,7 @@ public function addUsers($users): IDocumentAccess; /** * Get the complete list of users that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @return array */ @@ -155,7 +155,7 @@ public function getUsers(): array; /** * Set the list of groups that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param array $groups * @@ -166,7 +166,7 @@ public function setGroups(array $groups): IDocumentAccess; /** * Add an entry to the list of groups that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $group * @@ -178,7 +178,7 @@ public function addGroup(string $group): IDocumentAccess; * Add multiple entries to the list of groups that have read access to the * document. * - * @since 15.0.0 + * @since 16.0.0 * * @param array $groups * @@ -189,7 +189,7 @@ public function addGroups(array $groups); /** * Get the complete list of groups that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @return array */ @@ -199,7 +199,7 @@ public function getGroups(): array; /** * Set the list of circles that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param array $circles * @@ -210,7 +210,7 @@ public function setCircles(array $circles): IDocumentAccess; /** * Add an entry to the list of circles that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $circle * @@ -222,7 +222,7 @@ public function addCircle(string $circle): IDocumentAccess; * Add multiple entries to the list of groups that have read access to the * document. * - * @since 15.0.0 + * @since 16.0.0 * * @param array $circles * @@ -233,7 +233,7 @@ public function addCircles(array $circles): IDocumentAccess; /** * Get the complete list of circles that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @return array */ @@ -243,7 +243,7 @@ public function getCircles(): array; /** * Set the list of links that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @param array $links * @@ -254,7 +254,7 @@ public function setLinks(array $links): IDocumentAccess; /** * Get the list of links that have read access to the document. * - * @since 15.0.0 + * @since 16.0.0 * * @return array */ diff --git a/lib/public/FullTextSearch/Model/ISearchOption.php b/lib/public/FullTextSearch/Model/ISearchOption.php index 33802028547b5..4ac995ad75f3a 100644 --- a/lib/public/FullTextSearch/Model/ISearchOption.php +++ b/lib/public/FullTextSearch/Model/ISearchOption.php @@ -32,7 +32,7 @@ /** - * @since 15.0.0 + * @since 16.0.0 * * Interface ISearchOption * @@ -41,9 +41,19 @@ interface ISearchOption { + /** + * @since 16.0.0 + */ const CHECKBOX = 'checkbox'; + + /** + * @since 16.0.0 + */ const INPUT = 'input'; + /** + * @since 16.0.0 + */ const INPUT_SMALL = 'small'; @@ -54,7 +64,7 @@ interface ISearchOption { * * @see ISearchRequest::getOption * - * @since 15.0.0 + * @since 16.0.0 * * @param string $name * @@ -65,7 +75,7 @@ public function setName(string $name): ISearchOption; /** * Get the name/key of the option. * - * @since 15.0.0 + * @since 16.0.0 * * @return string */ @@ -75,7 +85,7 @@ public function getName(): string; /** * Set the title/display name of the option. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $title * @@ -86,7 +96,7 @@ public function setTitle(string $title): ISearchOption; /** * Get the title of the option. * - * @since 15.0.0 + * @since 16.0.0 * * @return string */ @@ -97,7 +107,7 @@ public function getTitle(): string; * Set the type of the option. * $type can be ISearchOption::CHECKBOX or ISearchOption::INPUT * - * @since 15.0.0 + * @since 16.0.0 * * @param string $type * @@ -108,7 +118,7 @@ public function setType(string $type): ISearchOption; /** * Get the type of the option. * - * @since 15.0.0 + * @since 16.0.0 * * @return string */ @@ -119,7 +129,7 @@ public function getType(): string; * In case of Type is INPUT, set the size of the input field. * Value can be ISearchOption::INPUT_SMALL or not defined. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $size * @@ -130,7 +140,7 @@ public function setSize(string $size): ISearchOption; /** * Get the size of the INPUT. * - * @since 15.0.0 + * @since 16.0.0 * * @return string */ @@ -141,7 +151,7 @@ public function getSize(): string; * In case of Type is , set the placeholder to be displayed in the input * field. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $placeholder * @@ -152,7 +162,7 @@ public function setPlaceholder(string $placeholder): ISearchOption; /** * Get the placeholder. * - * @since 15.0.0 + * @since 16.0.0 * * @return string */ diff --git a/lib/public/FullTextSearch/Model/ISearchTemplate.php b/lib/public/FullTextSearch/Model/ISearchTemplate.php index e0140b232522d..9cd6753f2a78e 100644 --- a/lib/public/FullTextSearch/Model/ISearchTemplate.php +++ b/lib/public/FullTextSearch/Model/ISearchTemplate.php @@ -55,7 +55,7 @@ * * @see IFullTextSearchProvider::getSearchTemplate * - * @since 15.0.0 + * @since 16.0.0 * * @package OCP\FullTextSearch\Model */ @@ -66,7 +66,7 @@ interface ISearchTemplate { * Set the class of the icon to be displayed in the left panel of the * FullTextSearch navigation page, in front of the related Content Provider. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $class * @@ -77,7 +77,7 @@ public function setIcon(string $class): ISearchTemplate; /** * Get the class of the icon. * - * @since 15.0.0 + * @since 16.0.0 * * @return string */ @@ -87,7 +87,7 @@ public function getIcon(): string; /** * Set the path of a CSS file that will be loaded when needed. * - * @since 15.0.0 + * @since 16.0.0 * * @param string $css * @@ -98,7 +98,7 @@ public function setCss(string $css): ISearchTemplate; /** * Get the path of the CSS file. * - * @since 15.0.0 + * @since 16.0.0 * * @return string */ @@ -111,7 +111,7 @@ public function getCss(): string; * This should only be used if your Content Provider needs to set options in * a way not generated by FullTextSearch * - * @since 15.0.0 + * @since 16.0.0 * * @param string $template * @@ -122,7 +122,7 @@ public function setTemplate(string $template): ISearchTemplate; /** * Get the path of the template file. * - * @since 15.0.0 + * @since 16.0.0 * * @return string */ @@ -135,7 +135,7 @@ public function getTemplate(): string; * * @see ISearchOption * - * @since 15.0.0 + * @since 16.0.0 * * @param ISearchOption $option * @@ -146,7 +146,7 @@ public function addPanelOption(ISearchOption $option): ISearchTemplate; /** * Get all options to be displayed in the Panel. * - * @since 15.0.0 + * @since 16.0.0 * * @return ISearchOption[] */ @@ -158,7 +158,7 @@ public function getPanelOptions(): array; * * @see ISearchOption * - * @since 15.0.0 + * @since 16.0.0 * * @param ISearchOption $option * @@ -169,7 +169,7 @@ public function addNavigationOption(ISearchOption $option): ISearchTemplate; /** * Get all options to be displayed in the FullTextSearch navigation page. * - * @since 15.0.0 + * @since 16.0.0 * * @return array */