diff options
Diffstat (limited to 'lib/public/Files/Search')
-rw-r--r-- | lib/public/Files/Search/ISearchBinaryOperator.php | 47 | ||||
-rw-r--r-- | lib/public/Files/Search/ISearchComparison.php | 99 | ||||
-rw-r--r-- | lib/public/Files/Search/ISearchOperator.php | 31 | ||||
-rw-r--r-- | lib/public/Files/Search/ISearchOrder.php | 58 | ||||
-rw-r--r-- | lib/public/Files/Search/ISearchQuery.php | 60 |
5 files changed, 295 insertions, 0 deletions
diff --git a/lib/public/Files/Search/ISearchBinaryOperator.php b/lib/public/Files/Search/ISearchBinaryOperator.php new file mode 100644 index 00000000000..fa7ef4d1bb3 --- /dev/null +++ b/lib/public/Files/Search/ISearchBinaryOperator.php @@ -0,0 +1,47 @@ +<?php + +/** + * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Files\Search; + +/** + * @since 12.0.0 + */ +interface ISearchBinaryOperator extends ISearchOperator { + /** + * @since 12.0.0 + */ + public const OPERATOR_AND = 'and'; + + /** + * @since 12.0.0 + */ + public const OPERATOR_OR = 'or'; + + /** + * @since 12.0.0 + */ + public const OPERATOR_NOT = 'not'; + + /** + * The type of binary operator + * + * One of the ISearchBinaryOperator::OPERATOR_* constants + * + * @return string + * @since 12.0.0 + */ + public function getType(); + + /** + * The arguments for the binary operator + * + * One argument for the 'not' operator and two for 'and' and 'or' + * + * @return ISearchOperator[] + * @since 12.0.0 + */ + public function getArguments(); +} diff --git a/lib/public/Files/Search/ISearchComparison.php b/lib/public/Files/Search/ISearchComparison.php new file mode 100644 index 00000000000..ab298fa0a57 --- /dev/null +++ b/lib/public/Files/Search/ISearchComparison.php @@ -0,0 +1,99 @@ +<?php + +/** + * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Files\Search; + +/** + * @since 12.0.0 + * + * @psalm-type ParamSingleValue = \DateTime|int|string|bool + * @psalm-type ParamValue = ParamSingleValue|list<ParamSingleValue> + */ +interface ISearchComparison extends ISearchOperator { + /** + * @since 12.0.0 + */ + public const COMPARE_EQUAL = 'eq'; + + /** + * @since 12.0.0 + */ + public const COMPARE_GREATER_THAN = 'gt'; + + /** + * @since 12.0.0 + */ + public const COMPARE_GREATER_THAN_EQUAL = 'gte'; + + /** + * @since 12.0.0 + */ + public const COMPARE_LESS_THAN = 'lt'; + + /** + * @since 12.0.0 + */ + public const COMPARE_LESS_THAN_EQUAL = 'lte'; + + /** + * @since 12.0.0 + */ + public const COMPARE_LIKE = 'like'; + + /** + * @since 23.0.0 + */ + public const COMPARE_LIKE_CASE_SENSITIVE = 'clike'; + + /** + * @since 28.0.0 + */ + public const COMPARE_DEFINED = 'is-defined'; + + /** + * @since 29.0.0 + */ + public const COMPARE_IN = 'in'; + + /** + * @since 23.0.0 + */ + public const HINT_PATH_EQ_HASH = 'path_eq_hash'; // transform `path = "$path"` into `path_hash = md5("$path")`, on by default + + /** + * Get the type of comparison, one of the ISearchComparison::COMPARE_* constants + * + * @return string + * @since 12.0.0 + */ + public function getType(): string; + + /** + * Get the name of the field to compare with + * + * i.e. 'size', 'name' or 'mimetype' + * + * @return string + * @since 12.0.0 + */ + public function getField(): string; + + /** + * extra means data are not related to the main files table + * + * @return string + * @since 28.0.0 + */ + public function getExtra(): string; + + /** + * Get the value to compare the field with + * + * @return ParamValue + * @since 12.0.0 + */ + public function getValue(): string|int|bool|\DateTime|array; +} diff --git a/lib/public/Files/Search/ISearchOperator.php b/lib/public/Files/Search/ISearchOperator.php new file mode 100644 index 00000000000..f6ae8edcbb1 --- /dev/null +++ b/lib/public/Files/Search/ISearchOperator.php @@ -0,0 +1,31 @@ +<?php + +/** + * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Files\Search; + +/** + * @since 12.0.0 + */ +interface ISearchOperator { + /** + * Get a query builder hint by name + * + * @param string $name + * @param $default + * @return mixed + * @since 23.0.0 + */ + public function getQueryHint(string $name, $default); + + /** + * Get a query builder hint + * + * @param string $name + * @param $value + * @since 23.0.0 + */ + public function setQueryHint(string $name, $value): void; +} diff --git a/lib/public/Files/Search/ISearchOrder.php b/lib/public/Files/Search/ISearchOrder.php new file mode 100644 index 00000000000..e6e68849443 --- /dev/null +++ b/lib/public/Files/Search/ISearchOrder.php @@ -0,0 +1,58 @@ +<?php + +/** + * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Files\Search; + +use OCP\Files\FileInfo; + +/** + * @since 12.0.0 + */ +interface ISearchOrder { + /** + * @since 12.0.0 + */ + public const DIRECTION_ASCENDING = 'asc'; + + /** + * @since 12.0.0 + */ + public const DIRECTION_DESCENDING = 'desc'; + + /** + * The direction to sort in, either ISearchOrder::DIRECTION_ASCENDING or ISearchOrder::DIRECTION_DESCENDING + * + * @return string + * @since 12.0.0 + */ + public function getDirection(): string; + + /** + * The field to sort on + * + * @return string + * @since 12.0.0 + */ + public function getField(): string; + + /** + * extra means data are not related to the main files table + * + * @return string + * @since 28.0.0 + */ + public function getExtra(): string; + + /** + * Apply the sorting on 2 FileInfo objects + * + * @param FileInfo $a + * @param FileInfo $b + * @return int -1 if $a < $b, 0 if $a = $b, 1 if $a > $b (for ascending, reverse for descending) + * @since 22.0.0 + */ + public function sortFileInfo(FileInfo $a, FileInfo $b): int; +} diff --git a/lib/public/Files/Search/ISearchQuery.php b/lib/public/Files/Search/ISearchQuery.php new file mode 100644 index 00000000000..1b400c56e5b --- /dev/null +++ b/lib/public/Files/Search/ISearchQuery.php @@ -0,0 +1,60 @@ +<?php + +/** + * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Files\Search; + +use OCP\IUser; + +/** + * @since 12.0.0 + */ +interface ISearchQuery { + /** + * @return ISearchOperator + * @since 12.0.0 + */ + public function getSearchOperation(); + + /** + * Get the maximum number of results to return + * + * @return integer + * @since 12.0.0 + */ + public function getLimit(); + + /** + * Get the offset for returned results + * + * @return integer + * @since 12.0.0 + */ + public function getOffset(); + + /** + * The fields and directions to order by + * + * @return ISearchOrder[] + * @since 12.0.0 + */ + public function getOrder(); + + /** + * The user that issued the search + * + * @return ?IUser + * @since 12.0.0 + */ + public function getUser(); + + /** + * Whether or not the search should be limited to the users home storage + * + * @return bool + * @since 18.0.0 + */ + public function limitToHome(): bool; +} |