From 1b45fb251a4550e4ec4d842ab1d94ead12a6a7e3 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Thu, 16 Dec 2021 10:52:06 +0000 Subject: [PATCH] [COMPONENT][Search][Attachment][DOC] Add doocumentation to search related functions --- components/Attachment/Attachment.php | 3 +++ components/Search/Search.php | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/components/Attachment/Attachment.php b/components/Attachment/Attachment.php index 2f5f26f2e3..e8a7982090 100644 --- a/components/Attachment/Attachment.php +++ b/components/Attachment/Attachment.php @@ -71,6 +71,9 @@ class Attachment extends Component return Event::next; } + /** + * Populate $note_expr with the criteria for looking for notes with attachments + */ public function onSearchCreateExpression(ExpressionBuilder $eb, string $term, ?string $language, &$note_expr, &$actor_expr): bool { $include_term = str_contains($term, ':') ? explode(':', $term)[1] : $term; diff --git a/components/Search/Search.php b/components/Search/Search.php index 0804ab6aec..9dded07dbb 100644 --- a/components/Search/Search.php +++ b/components/Search/Search.php @@ -45,6 +45,11 @@ class Search extends Component $r->connect('search', '/search', Controller\Search::class); } + /** + * Helper function for generating and processing the search form, so it can be embedded in + * multiple places. Can be provided with a $query, which will prefill the query field. If + * $add_subscribe, allow the user to add the current query to their left panel + */ public static function searchForm(Request $request, ?string $query = null, bool $add_subscribe = false): FormView { $actor = Common::actor(); @@ -136,6 +141,10 @@ class Search extends Component return Event::next; } + /** + * Convert $term to $note_expr and $actor_expr, search criteria. Handles searching for text + * notes, for different types of actors and for the content of text notes + */ public function onSearchCreateExpression(ExpressionBuilder $eb, string $term, ?string $language, &$note_expr, &$actor_expr): bool { $include_term = str_contains($term, ':') ? explode(':', $term)[1] : $term;