[COMPONENT][Search][Attachment][DOC] Add doocumentation to search related functions

This commit is contained in:
Hugo Sales 2021-12-16 10:52:06 +00:00
parent 24291a268a
commit 1b45fb251a
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 12 additions and 0 deletions

View File

@ -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;

View File

@ -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;