Browse Source
Merge pull request #14302 from nextcloud/enhancement/noid/fulltextsearch-final-class
Merge pull request #14302 from nextcloud/enhancement/noid/fulltextsearch-final-class
nc16/fulltetsearch: moving final class to private, new interface in publicpull/14451/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 1497 additions and 231 deletions
-
12lib/composer/composer/autoload_classmap.php
-
12lib/composer/composer/autoload_static.php
-
102lib/private/FullTextSearch/Model/DocumentAccess.php
-
172lib/private/FullTextSearch/Model/IndexDocument.php
-
41lib/private/FullTextSearch/Model/SearchOption.php
-
40lib/private/FullTextSearch/Model/SearchTemplate.php
-
7lib/public/Files_FullTextSearch/Model/AFilesDocument.php
-
16lib/public/FullTextSearch/IFullTextSearchPlatform.php
-
48lib/public/FullTextSearch/IFullTextSearchProvider.php
-
264lib/public/FullTextSearch/Model/IDocumentAccess.php
-
14lib/public/FullTextSearch/Model/IIndex.php
-
636lib/public/FullTextSearch/Model/IIndexDocument.php
-
171lib/public/FullTextSearch/Model/ISearchOption.php
-
14lib/public/FullTextSearch/Model/ISearchResult.php
-
179lib/public/FullTextSearch/Model/ISearchTemplate.php
@ -0,0 +1,264 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
|
|||
|
|||
/** |
|||
* FullTextSearch - Full text search framework for Nextcloud |
|||
* |
|||
* This file is licensed under the Affero General Public License version 3 or |
|||
* later. See the COPYING file. |
|||
* |
|||
* @author Maxence Lange <maxence@artificial-owl.com> |
|||
* @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 <http://www.gnu.org/licenses/>. |
|||
* |
|||
*/ |
|||
|
|||
|
|||
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 16.0.0 |
|||
* |
|||
* @package OCP\FullTextSearch\Model |
|||
*/ |
|||
interface IDocumentAccess { |
|||
|
|||
|
|||
/** |
|||
* Owner of the document can be set at the init of the object. |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* IDocumentAccess constructor. |
|||
* |
|||
* @param string $ownerId |
|||
*/ |
|||
public function __construct(string $ownerId = ''); |
|||
|
|||
|
|||
/** |
|||
* Set the Owner of the document. |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* @param string $ownerId |
|||
* |
|||
* @return IDocumentAccess |
|||
*/ |
|||
public function setOwnerId(string $ownerId): IDocumentAccess; |
|||
|
|||
/** |
|||
* Get the Owner of the document. |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* @return string |
|||
*/ |
|||
public function getOwnerId(): string; |
|||
|
|||
|
|||
/** |
|||
* Set the viewer of the document. |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* @param string $viewerId |
|||
* |
|||
* @return IDocumentAccess |
|||
*/ |
|||
public function setViewerId(string $viewerId): IDocumentAccess; |
|||
|
|||
/** |
|||
* Get the viewer of the document. |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* @return string |
|||
*/ |
|||
public function getViewerId(): string; |
|||
|
|||
|
|||
/** |
|||
* Set the list of users that have read access to the document. |
|||
* |
|||
* @since 16.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 16.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 16.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 16.0.0 |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function getUsers(): array; |
|||
|
|||
|
|||
/** |
|||
* Set the list of groups that have read access to the document. |
|||
* |
|||
* @since 16.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 16.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 16.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 16.0.0 |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function getGroups(): array; |
|||
|
|||
|
|||
/** |
|||
* Set the list of circles that have read access to the document. |
|||
* |
|||
* @since 16.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 16.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 16.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 16.0.0 |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function getCircles(): array; |
|||
|
|||
|
|||
/** |
|||
* Set the list of links that have read access to the document. |
|||
* |
|||
* @since 16.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 16.0.0 |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function getLinks(): array; |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,636 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
|
|||
|
|||
/** |
|||
* FullTextSearch - Full text search framework for Nextcloud |
|||
* |
|||
* This file is licensed under the Affero General Public License version 3 or |
|||
* later. See the COPYING file. |
|||
* |
|||
* @author Maxence Lange <maxence@artificial-owl.com> |
|||
* @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 <http://www.gnu.org/licenses/>. |
|||
* |
|||
*/ |
|||
|
|||
|
|||
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; |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,171 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
|
|||
|
|||
/** |
|||
* FullTextSearch - Full text search framework for Nextcloud |
|||
* |
|||
* This file is licensed under the Affero General Public License version 3 or |
|||
* later. See the COPYING file. |
|||
* |
|||
* @author Maxence Lange <maxence@artificial-owl.com> |
|||
* @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 <http://www.gnu.org/licenses/>. |
|||
* |
|||
*/ |
|||
|
|||
|
|||
namespace OCP\FullTextSearch\Model; |
|||
|
|||
|
|||
/** |
|||
* @since 16.0.0 |
|||
* |
|||
* Interface ISearchOption |
|||
* |
|||
* @package OCP\FullTextSearch\Model |
|||
*/ |
|||
interface ISearchOption { |
|||
|
|||
|
|||
/** |
|||
* @since 16.0.0 |
|||
*/ |
|||
const CHECKBOX = 'checkbox'; |
|||
|
|||
/** |
|||
* @since 16.0.0 |
|||
*/ |
|||
const INPUT = 'input'; |
|||
|
|||
/** |
|||
* @since 16.0.0 |
|||
*/ |
|||
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 16.0.0 |
|||
* |
|||
* @param string $name |
|||
* |
|||
* @return ISearchOption |
|||
*/ |
|||
public function setName(string $name): ISearchOption; |
|||
|
|||
/** |
|||
* Get the name/key of the option. |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* @return string |
|||
*/ |
|||
public function getName(): string; |
|||
|
|||
|
|||
/** |
|||
* Set the title/display name of the option. |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* @param string $title |
|||
* |
|||
* @return ISearchOption |
|||
*/ |
|||
public function setTitle(string $title): ISearchOption; |
|||
|
|||
/** |
|||
* Get the title of the option. |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* @return string |
|||
*/ |
|||
public function getTitle(): string; |
|||
|
|||
|
|||
/** |
|||
* Set the type of the option. |
|||
* $type can be ISearchOption::CHECKBOX or ISearchOption::INPUT |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* @param string $type |
|||
* |
|||
* @return ISearchOption |
|||
*/ |
|||
public function setType(string $type): ISearchOption; |
|||
|
|||
/** |
|||
* Get the type of the option. |
|||
* |
|||
* @since 16.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 16.0.0 |
|||
* |
|||
* @param string $size |
|||
* |
|||
* @return ISearchOption |
|||
*/ |
|||
public function setSize(string $size): ISearchOption; |
|||
|
|||
/** |
|||
* Get the size of the INPUT. |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* @return string |
|||
*/ |
|||
public function getSize(): string; |
|||
|
|||
|
|||
/** |
|||
* In case of Type is , set the placeholder to be displayed in the input |
|||
* field. |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* @param string $placeholder |
|||
* |
|||
* @return ISearchOption |
|||
*/ |
|||
public function setPlaceholder(string $placeholder): ISearchOption; |
|||
|
|||
/** |
|||
* Get the placeholder. |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* @return string |
|||
*/ |
|||
public function getPlaceholder(): string; |
|||
|
|||
} |
|||
@ -0,0 +1,179 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
|
|||
|
|||
/** |
|||
* FullTextSearch - Full text search framework for Nextcloud |
|||
* |
|||
* This file is licensed under the Affero General Public License version 3 or |
|||
* later. See the COPYING file. |
|||
* |
|||
* @author Maxence Lange <maxence@artificial-owl.com> |
|||
* @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 <http://www.gnu.org/licenses/>. |
|||
* |
|||
*/ |
|||
|
|||
|
|||
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 16.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 16.0.0 |
|||
* |
|||
* @param string $class |
|||
* |
|||
* @return ISearchTemplate |
|||
*/ |
|||
public function setIcon(string $class): ISearchTemplate; |
|||
|
|||
/** |
|||
* Get the class of the icon. |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* @return string |
|||
*/ |
|||
public function getIcon(): string; |
|||
|
|||
|
|||
/** |
|||
* Set the path of a CSS file that will be loaded when needed. |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* @param string $css |
|||
* |
|||
* @return ISearchTemplate |
|||
*/ |
|||
public function setCss(string $css): ISearchTemplate; |
|||
|
|||
/** |
|||
* Get the path of the CSS file. |
|||
* |
|||
* @since 16.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 16.0.0 |
|||
* |
|||
* @param string $template |
|||
* |
|||
* @return ISearchTemplate |
|||
*/ |
|||
public function setTemplate(string $template): ISearchTemplate; |
|||
|
|||
/** |
|||
* Get the path of the template file. |
|||
* |
|||
* @since 16.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 16.0.0 |
|||
* |
|||
* @param ISearchOption $option |
|||
* |
|||
* @return ISearchTemplate |
|||
*/ |
|||
public function addPanelOption(ISearchOption $option): ISearchTemplate; |
|||
|
|||
/** |
|||
* Get all options to be displayed in the Panel. |
|||
* |
|||
* @since 16.0.0 |
|||
* |
|||
* @return ISearchOption[] |
|||
*/ |
|||
public function getPanelOptions(): array; |
|||
|
|||
|
|||
/** |
|||
* Add an option in the left panel of the FullTextSearch navigation page. |
|||
* |
|||
* @see ISearchOption |
|||
* |
|||
* @since 16.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 16.0.0 |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function getNavigationOptions(): array; |
|||
|
|||
} |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue