search_functions.php
Table of Contents
Functions
- resolve_soundex() : string|false
- Resolves the most commonly used keyword that sounds like the given keyword.
- suggest_refinement() : array<string|int, mixed>
- Suggests search refinements based on common keywords from a set of resource references.
- get_advanced_search_fields() : array<string|int, mixed>
- Retrieves a list of fields suitable for advanced searching.
- get_advanced_search_collection_fields() : array<string|int, mixed>
- Retrieves a list of fields suitable for advanced searching within collections.
- search_form_to_search_query() : string
- Constructs a search query string from the posted search form data.
- refine_searchstring() : string
- Refines the search string to eliminate duplicates and ensure proper formatting.
- compile_search_actions() : array<string|int, mixed>
- Compiles a list of actions based on the provided top actions and search parameters.
- search_filter() : PreparedStatementQuery
- Constructs a SQL filter based on the provided search parameters.
- search_special() : mixed
- Processes special searches and constructs a corresponding SQL query.
- resolve_nodes_from_string() : array<string|int, mixed>
- Function used to create a list of nodes found in a search string
- rebuild_specific_field_search_from_node() : string
- Utility function which helps rebuilding a specific field search string from a node element
- search_get_previews() : mixed
- get_upload_here_selected_nodes() : mixed
- get_default_search_states() : array<string|int, mixed>
- get the default archive states to search
- get_filter_sql() : PreparedStatementQuery
- Get the required search filter sql for the given filter for use in do_search()
- split_keywords() : mixed
- cleanse_string() : string
- Removes characters from a string, for example full stops, prior to keyword splitting - {@see split_keywords()}.
- resolve_keyword() : int|bool
- Resolve keyword
- add_partial_index() : array<string|int, mixed>
- Generates a list of keywords for indexing, including all possible infixes for each keyword in the provided list.
- get_suggested_keywords() : array<string|int, mixed>
- Suggests complete existing keywords based on a partial search term.
- get_related_keywords() : array<string|int, mixed>
- Retrieves keywords related to a given keyword reference.
- get_grouped_related_keywords() : array<string|int, mixed>
- Retrieves keywords and their related keywords, optionally filtered by specific keywords.
- save_related_keywords() : bool
- Saves the related keywords for a specified keyword.
- get_simple_search_fields() : array<string|int, mixed>
- Retrieves a list of fields suitable for the simple search box.
- get_fields_for_search_display() : array<string|int, mixed>
- Retrieves a list of fields/properties suitable for search display based on the provided field references.
- get_filters() : array<string|int, mixed>
- Get all defined filters (currently only used for search)
- get_filter() : array<string|int, mixed>
- Get filter summary details
- get_filter_rules() : array<string|int, mixed>
- Get filter rules for use in search
- get_filter_rule() : array<string|int, mixed>
- Get filter rule
- save_filter() : bool|int
- Save filter, will return existing filter ID if text matches already migrated
- save_filter_rule() : bool|int
- Save filter rule, will return existing rule ID if text matches already migrated
- delete_filter() : bool|array<string|int, mixed>
- Delete specified filter
- delete_filter_rule() : bool|int
- Delete specified filter_rule
- copy_filter() : bool|int
- Copy specified filter_rule
- update_search_from_request() : string
- Add POST/GET parameters into search string. Moved from pages/search.php
- get_search_default_restypes() : array<string|int, mixed>
- Retrieves the default resource types for search functionality.
- get_selectedtypes() : array<string|int, mixed>
- Retrieves the selected resource types for the search functionality.
- render_advanced_search_buttons() : void
- Renders the buttons for the advanced search form.
- check_order_by_in_table_joins() : string
- If a "fieldX" order_by is used, check it's a valid value.
- get_collections_resource_count() : array<string|int, mixed>
- Get collection total resource count for a list of collections
- get_search_params() : mixed
- Get all search request parameters. Note that this does not escape the parameters which must be sanitised using e.g. htmlspecialchars() or urlencode() before rendering on page
- is_not_wildcard_only() : bool
- Helper function to check a string is not just the asterisk.
- search_title_node_processing() : string
- Convert node searches into a friendly syntax. Used by search_title_processing.php
- setup_search_chunks() : void
- Allow $fetchrows as supplied to do_search() to support an integer or array. If integer then search will recieve the number of rows with no offset.
- log_keyword_usage() : mixed
- Log which keywords are used in a search
- set_search_order_by() : string
- Validate and set the order_by for the current search from the requested values passed to do_search()
- prepare_regex_search_string() : string
- Escape and process a string from ResourceSpace search syntax to regex syntax Wildcards are replaced with '.*?' - any character 0 or more times Multiple keyword matches are split into an OR group Word boundaries are added to avoid unintended wildcards.
- convert_search_form_date_to_search_query() : string
- Utility converter between sumitted date input and ResourceSpace search query
Functions
resolve_soundex()
Resolves the most commonly used keyword that sounds like the given keyword.
resolve_soundex(string $keyword) : string|false
This function attempts to find a keyword that phonetically matches the provided keyword using the Soundex algorithm. If no Soundex match is found, it will suggest the most commonly used keyword that starts with the same first few letters.
Parameters
- $keyword : string
-
The keyword to resolve.
Return values
string|false —Returns the matched keyword if found, or false if no match is found.
suggest_refinement()
Suggests search refinements based on common keywords from a set of resource references.
suggest_refinement(array<string|int, mixed> $refs, string $search) : array<string|int, mixed>
This function analyzes the provided array of resource references and the original search query. It identifies common keywords associated with the specified resources and suggests new search queries by appending these keywords to the original search query, provided they are not already included in it.
Parameters
- $refs : array<string|int, mixed>
-
An array of resource references to analyze.
- $search : string
-
The original search query.
Return values
array<string|int, mixed> —An array of suggested search refinements. Returns an empty array if no refinements can be suggested.
get_advanced_search_fields()
Retrieves a list of fields suitable for advanced searching.
get_advanced_search_fields([bool $archive = false ][, string $hiddenfields = "" ]) : array<string|int, mixed>
This function queries the database for resource type fields that are marked for advanced searching. It checks for visibility based on user permissions and whether the fields are hidden from the search. If a designated date field is specified and not already included in the results, it will be added to the beginning of the list if it matches the resource types of the other fields.
Parameters
- $archive : bool = false
-
Whether to include fields related to archived resources. Defaults to false.
- $hiddenfields : string = ""
-
A comma-separated string of field references that should be hidden from the search.
Return values
array<string|int, mixed> —An array of searchable fields that can be used in an advanced search form.
get_advanced_search_collection_fields()
Retrieves a list of fields suitable for advanced searching within collections.
get_advanced_search_collection_fields([bool $archive = false ][, string $hiddenfields = "" ]) : array<string|int, mixed>
This function constructs an array of fields specifically related to collections, including collection title, keywords, and owner. It checks against a list of hidden fields to determine which fields should be included in the return array for advanced searching.
Parameters
- $archive : bool = false
-
Whether to include fields related to archived collections. Defaults to false.
- $hiddenfields : string = ""
-
A comma-separated string of field references that should be hidden from the search.
Return values
array<string|int, mixed> —An array of fields suitable for advanced searching in the context of collections.
search_form_to_search_query()
Constructs a search query string from the posted search form data.
search_form_to_search_query(array<string|int, mixed> $fields[, bool $fromsearchbar = false ]) : string
This function takes the advanced search form fields and assembles them into a search query string that can be used for a standard search. It processes various input fields, including dates, keywords, and resource IDs, while respecting user permissions and field visibility settings.
Parameters
- $fields : array<string|int, mixed>
-
An array of fields used in the search form.
- $fromsearchbar : bool = false
-
Indicates if the search is initiated from a search bar.
Return values
string —The constructed search query string based on the input data.
refine_searchstring()
Refines the search string to eliminate duplicates and ensure proper formatting.
refine_searchstring(string $search) : string
This function addresses several issues related to searching, including:
- Eliminating duplicate terms from the search query.
- Preserving string search functionality when quotes are used.
- Formatting date-related keywords correctly.
- Adjusting keywords for advanced search fields and ensuring they carry over properly.
- Fixing bugs related to search separators and ensuring valid search syntax.
Parameters
- $search : string
-
The original search string to be refined.
Return values
string —The refined search string, with duplicates removed and properly formatted.
compile_search_actions()
Compiles a list of actions based on the provided top actions and search parameters.
compile_search_actions(bool $top_actions) : array<string|int, mixed>
This function generates an array of options for various actions that can be performed on search results, such as saving searches to collections, saving to dashboards, exporting results, editing resources, and running reports. The available actions depend on user permissions and specific conditions.
Parameters
- $top_actions : bool
-
Indicates whether to include top actions in the options.
Return values
array<string|int, mixed> —An array of action options, each containing value, label, data attributes, category, and order for sorting.
search_filter()
Constructs a SQL filter based on the provided search parameters.
search_filter(string $search, mixed $archive, string $restypes, int $recent_search_daylimit, mixed $access_override, bool $return_disk_usage[, bool $editable_only = false ][, int|null $access = null ][, bool $smartsearch = false ]) : PreparedStatementQuery
This function generates a prepared statement query that can be used to filter search results based on various criteria, including archive status, resource types, user permissions, and more. The function also takes into account user-specific access rights and other configurations to ensure that the returned resources meet the necessary visibility and editability criteria.
Parameters
- $search : string
-
The search query string.
- $archive : mixed
-
Archive states to filter by (can be a comma-separated string).
- $restypes : string
-
Resource types to include in the search.
- $recent_search_daylimit : int
-
Limit for filtering recent searches by creation date.
- $access_override : mixed
-
If set, overrides access restrictions.
- $return_disk_usage : bool
-
Indicates whether to include disk usage information.
- $editable_only : bool = false
-
If true, only returns resources that are editable by the user.
- $access : int|null = null
-
The specific access level to filter by (if applicable).
- $smartsearch : bool = false
-
If true, enables smart search features.
Tags
Return values
PreparedStatementQuery —A prepared statement object containing the SQL query and parameters.
search_special()
Processes special searches and constructs a corresponding SQL query.
search_special(string $search, PreparedStatementQuery $sql_join, int $fetchrows, string $sql_prefix, string $sql_suffix, string $order_by, string $orig_order, PreparedStatementQuery $select, PreparedStatementQuery $sql_filter, mixed $archive, bool $return_disk_usage[, bool $return_refs_only = false ][, bool $returnsql = false ]) : mixed
This function handles various special search commands (like viewing the last resources, resources with no downloads, duplicates, collections, etc.) and creates a prepared statement for the query that retrieves the desired resources based on the search parameters. It also incorporates user permissions and other configurations into the search logic.
Parameters
- $search : string
-
The search string indicating the type of special search.
- $sql_join : PreparedStatementQuery
-
The SQL JOIN query to be applied.
- $fetchrows : int
-
The number of rows to fetch.
- $sql_prefix : string
-
The prefix for the SQL query.
- $sql_suffix : string
-
The suffix for the SQL query.
- $order_by : string
-
The order by clause for sorting the results.
- $orig_order : string
-
The original order specified by the user.
- $select : PreparedStatementQuery
-
The fields to select in the query.
- $sql_filter : PreparedStatementQuery
-
The SQL WHERE filter to apply.
- $archive : mixed
-
Archive states to filter by.
- $return_disk_usage : bool
-
Indicates whether to return disk usage information.
- $return_refs_only : bool = false
-
If true, returns only resource references.
- $returnsql : bool = false
-
If true, returns the constructed SQL query instead of executing it.
Tags
Return values
mixed —The results of the special search or false if no special search was matched.
resolve_nodes_from_string()
Function used to create a list of nodes found in a search string
resolve_nodes_from_string(string $string) : array<string|int, mixed>
IMPORTANT: use resolve_given_nodes() if you need to detect nodes based on search string format (ie. @@253@@255 and/ or @@!260)
Parameters
- $string : string
Return values
array<string|int, mixed>rebuild_specific_field_search_from_node()
Utility function which helps rebuilding a specific field search string from a node element
rebuild_specific_field_search_from_node(array<string|int, mixed> $node) : string
Parameters
- $node : array<string|int, mixed>
-
A node element as returned by get_node() or get_nodes()
Return values
stringsearch_get_previews()
search_get_previews(mixed $search[, mixed $restypes = "" ][, mixed $order_by = "relevance" ][, mixed $archive = 0 ][, mixed $fetchrows = -1 ][, mixed $sort = "DESC" ][, mixed $access_override = false ][, mixed $ignore_filters = false ][, mixed $return_disk_usage = false ][, mixed $recent_search_daylimit = "" ][, mixed $go = false ][, mixed $stats_logging = true ][, mixed $return_refs_only = false ][, mixed $editable_only = false ][, mixed $returnsql = false ][, mixed $getsizes = array() ][, mixed $previewextension = "jpg" ]) : mixed
Parameters
- $search : mixed
- $restypes : mixed = ""
- $order_by : mixed = "relevance"
- $archive : mixed = 0
- $fetchrows : mixed = -1
- $sort : mixed = "DESC"
- $access_override : mixed = false
- $ignore_filters : mixed = false
- $return_disk_usage : mixed = false
- $recent_search_daylimit : mixed = ""
- $go : mixed = false
- $stats_logging : mixed = true
- $return_refs_only : mixed = false
- $editable_only : mixed = false
- $returnsql : mixed = false
- $getsizes : mixed = array()
- $previewextension : mixed = "jpg"
get_upload_here_selected_nodes()
get_upload_here_selected_nodes(mixed $search, array<string|int, mixed> $nodes) : mixed
Parameters
- $search : mixed
- $nodes : array<string|int, mixed>
get_default_search_states()
get the default archive states to search
get_default_search_states() : array<string|int, mixed>
Return values
array<string|int, mixed>get_filter_sql()
Get the required search filter sql for the given filter for use in do_search()
get_filter_sql(mixed $filterid) : PreparedStatementQuery
Parameters
- $filterid : mixed
Return values
PreparedStatementQuerysplit_keywords()
split_keywords(mixed $search[, mixed $index = false ][, mixed $partial_index = false ][, mixed $is_date = false ][, mixed $is_html = false ][, mixed $keepquotes = false ][, bool $preserve_separators = false ]) : mixed
Parameters
- $search : mixed
- $index : mixed = false
- $partial_index : mixed = false
- $is_date : mixed = false
- $is_html : mixed = false
- $keepquotes : mixed = false
- $preserve_separators : bool = false
Tags
cleanse_string()
Removes characters from a string, for example full stops, prior to keyword splitting - {@see split_keywords()}.
cleanse_string(string $string, bool $preserve_separators[, bool $for_search = false ]) : string
Also makes the string lower case ready for indexing.
Parameters
- $string : string
-
Text value which needs to be pre-processed
- $preserve_separators : bool
-
Set to false to separate keywords when specifying multiple field/keyword pairs (comma and colon)
- $for_search : bool = false
-
Set to true if you need certain characters to be preserved during a search (e.g. the wildcard or minus for NOT searches).
Return values
stringresolve_keyword()
Resolve keyword
resolve_keyword(string $keyword[, bool $create = false ][, bool $normalize = true ][, bool $stem = true ]) : int|bool
Parameters
- $keyword : string
-
The keyword to resolve
- $create : bool = false
-
If keyword not found, should we create it instead?
- $normalize : bool = true
-
Should we normalize the keyword before resolving?
- $stem : bool = true
-
Should we use the keywords' stem when resolving?
Return values
int|bool —Returns the keyword reference for $keyword, or false if no such keyword exists.
add_partial_index()
Generates a list of keywords for indexing, including all possible infixes for each keyword in the provided list.
add_partial_index(array<string|int, mixed> $keywords) : array<string|int, mixed>
This function processes each keyword and, for those without spaces, adds all possible infixes of a specified minimum length to the return array. The resulting array is suitable for indexing in fields that have partial indexing enabled.
Parameters
- $keywords : array<string|int, mixed>
-
An array of keywords to process for partial indexing.
Return values
array<string|int, mixed> —An array of keywords, each with its associated position in the original list.
get_suggested_keywords()
Suggests complete existing keywords based on a partial search term.
get_suggested_keywords(string $search[, string $ref = "" ]) : array<string|int, mixed>
This function fetches keywords that match the given partial word, returning suggestions from the keyword database. It also considers user permissions by excluding indexed fields that are hidden from the user. Additionally, it can restrict results to a specific resource type field.
Parameters
- $search : string
-
The partial keyword to search for.
- $ref : string = ""
-
(optional) The resource type field to restrict suggestions to.
Return values
array<string|int, mixed> —An array of suggested keywords matching the search criteria.
get_related_keywords()
Retrieves keywords related to a given keyword reference.
get_related_keywords(int $keyref) : array<string|int, mixed>
This function checks a cache for related keywords associated with the provided keyword reference. If not found in the cache, it queries the database for related keywords. The relationship can be one-way or bidirectional based on the configuration. It returns an array of related keyword references.
Parameters
- $keyref : int
-
The reference ID of the keyword for which to find related keywords.
Return values
array<string|int, mixed> —An array of related keyword references.
get_grouped_related_keywords()
Retrieves keywords and their related keywords, optionally filtered by specific keywords.
get_grouped_related_keywords([string $find = "" ][, string $specific = "" ]) : array<string|int, mixed>
This function returns a list of keywords along with their related keywords grouped together. It can filter the results based on the provided keyword or specific keyword string. The related keywords are returned as a comma-separated string.
Parameters
- $find : string = ""
-
An optional keyword to find related keywords for. If specified, it filters the results to include only the related keywords for this keyword.
- $specific : string = ""
-
An optional specific keyword to find. If specified, it filters the results to include only the related keywords for this specific keyword.
Return values
array<string|int, mixed> —An array of keywords and their related keywords grouped together.
save_related_keywords()
Saves the related keywords for a specified keyword.
save_related_keywords(string $keyword, string $related) : bool
This function first resolves the keyword reference for the provided keyword. It then deletes any existing relationships for that keyword and inserts the new related keywords into the database.
Parameters
- $keyword : string
-
The keyword for which related keywords are being saved.
- $related : string
-
A comma-separated string of related keywords to associate with the specified keyword.
Return values
bool —Returns true on success, or false on failure.
get_simple_search_fields()
Retrieves a list of fields suitable for the simple search box.
get_simple_search_fields() : array<string|int, mixed>
This function gathers all resource type fields that are marked for simple search usage. It includes standard fields and custom fields that have their titles translated. It ensures that only fields with appropriate permissions and those that are either indexed or of a fixed list type are included in the returned array.
Return values
array<string|int, mixed> —An array of fields suitable for simple search, including their titles and other properties, filtered by permissions and search capabilities.
get_fields_for_search_display()
Retrieves a list of fields/properties suitable for search display based on the provided field references.
get_fields_for_search_display(array<string|int, mixed> $field_refs) : array<string|int, mixed>
Parameters
- $field_refs : array<string|int, mixed>
-
An array of field references to filter the search display fields.
Tags
Return values
array<string|int, mixed> —An array of fields with their properties, including translated titles, that are visible to the user based on permission checks.
get_filters()
Get all defined filters (currently only used for search)
get_filters([string $order = "ref" ][, string $sort = "ASC" ][, string $find = "" ]) : array<string|int, mixed>
Parameters
- $order : string = "ref"
-
column to order by
- $sort : string = "ASC"
-
sort order ("ASC" or "DESC")
- $find : string = ""
-
text to search for in filter
Return values
array<string|int, mixed>get_filter()
Get filter summary details
get_filter(int $filterid) : array<string|int, mixed>
Parameters
- $filterid : int
-
ID of filter (from usergroup search_filter_id or user search_filter_oid)
Return values
array<string|int, mixed>get_filter_rules()
Get filter rules for use in search
get_filter_rules(int $filterid) : array<string|int, mixed>
Parameters
- $filterid : int
-
ID of filter (from usergroup search_filter_id or user search_filter_oid)
Return values
array<string|int, mixed>get_filter_rule()
Get filter rule
get_filter_rule(int $ruleid) : array<string|int, mixed>
Parameters
- $ruleid : int
-
- ID of filter rule
Return values
array<string|int, mixed>save_filter()
Save filter, will return existing filter ID if text matches already migrated
save_filter(int $filter, int $filter_name, int $filter_condition) : bool|int
Parameters
- $filter : int
-
- ID of filter. Set to 0 for new filter
- $filter_name : int
-
- Name of filter
- $filter_condition : int
-
- One of RS_FILTER_ALL,RS_FILTER_NONE,RS_FILTER_ANY
Return values
bool|int —- false, or ID of filter
save_filter_rule()
Save filter rule, will return existing rule ID if text matches already migrated
save_filter_rule(int $filter_rule, int $filterid, mixed $rule_data) : bool|int
Parameters
- $filter_rule : int
-
- ID of filter_rule
- $filterid : int
-
- ID of associated filter
- $rule_data : mixed
Return values
bool|int —- false, or ID of filter_rule
delete_filter()
Delete specified filter
delete_filter(int $filter) : bool|array<string|int, mixed>
Parameters
- $filter : int
-
- ID of filter
Return values
bool|array<string|int, mixed> —of users/groups using filter
delete_filter_rule()
Delete specified filter_rule
delete_filter_rule(mixed $filter_rule) : bool|int
Parameters
- $filter_rule : mixed
Return values
bool|int —- false, or ID of filter_rule
copy_filter()
Copy specified filter_rule
copy_filter(int $filter) : bool|int
Parameters
- $filter : int
-
- ID of filter_rule to copy
Return values
bool|int —- false, or ID of new filter
update_search_from_request()
Add POST/GET parameters into search string. Moved from pages/search.php
update_search_from_request(string $search) : string
Parameters
- $search : string
-
Existing search string without params added
Return values
string —Updated string with params added
get_search_default_restypes()
Retrieves the default resource types for search functionality.
get_search_default_restypes() : array<string|int, mixed>
This function determines which resource types to include in the search based on the global settings for resource and theme inclusion. If resources are to be included, it checks the default resource types and returns them as an array. If no specific default resource types are defined, it defaults to including "Global." If resources are not to be included, it defaults to "Collections," and if themes are included, "FeaturedCollections" is also added.
Return values
array<string|int, mixed> —An array of default resource types to be used in the search.
get_selectedtypes()
Retrieves the selected resource types for the search functionality.
get_selectedtypes() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of selected resource types for the search.
render_advanced_search_buttons()
Renders the buttons for the advanced search form.
render_advanced_search_buttons() : void
This function generates HTML for two buttons: one to reset the search form and clear the submitted search criteria, and another to execute the search.
Return values
void —This function outputs HTML directly and does not return a value.
check_order_by_in_table_joins()
If a "fieldX" order_by is used, check it's a valid value.
check_order_by_in_table_joins(mixed $order_by) : string
Where the value is invalid, the default 'resourceid' will be used instead.
Parameters
- $order_by : mixed
Return values
string —Order by string if valid else default 'resourceid'
get_collections_resource_count()
Get collection total resource count for a list of collections
get_collections_resource_count(array<string|int, mixed> $refs) : array<string|int, mixed>
Parameters
- $refs : array<string|int, mixed>
-
List of collection IDs
Return values
array<string|int, mixed> —Returns table of collections and their total resource count (taking into account access controls). Please note that the returned array might NOT contain keys for all the input IDs (e.g validation failed).
get_search_params()
Get all search request parameters. Note that this does not escape the parameters which must be sanitised using e.g. htmlspecialchars() or urlencode() before rendering on page
get_search_params() : mixed
Tags
is_not_wildcard_only()
Helper function to check a string is not just the asterisk.
is_not_wildcard_only(string $str) : bool
Parameters
- $str : string
-
The string to be checked.
Return values
boolsearch_title_node_processing()
Convert node searches into a friendly syntax. Used by search_title_processing.php
search_title_node_processing(string $string) : string
Parameters
- $string : string
-
Search string
Return values
stringsetup_search_chunks()
Allow $fetchrows as supplied to do_search() to support an integer or array. If integer then search will recieve the number of rows with no offset.
setup_search_chunks(int|array<string|int, mixed> $fetchrows, int &$chunk_offset, int &$search_chunk_size) : void
If array then search will receive the number of rows to return and an offset allowing for chunking of results. $chunk_offset[0] is the offset of the first row to return. $chunk_offset[1] is the number of rows to return in the batch. $chunk_offset[0] will normally be 0 in the first search, increasing by $chunk_offset[1] for each search, generated by an external looping structure. This allows for batches of $chunk_offset[1] search results up to the total size of the search. For an example pages/csv_export_results_metadata.php. This approach can be used to avoid particularly large searches exceeding the PHP memory_limit when processing the data in ps_query().
Parameters
- $fetchrows : int|array<string|int, mixed>
-
$fetchrows value passed from do_search() / search_special(). See details above.
- $chunk_offset : int
-
Starting position for offset. Default is 0 if none supplied i.e. $fetchrows is int.
- $search_chunk_size : int
-
Number of rows to return.
log_keyword_usage()
Log which keywords are used in a search
log_keyword_usage(array<string|int, mixed> $keywords, mixed $search_result) : mixed
Parameters
- $keywords : array<string|int, mixed>
-
refs of keywords used in a search
- $search_result : mixed
set_search_order_by()
Validate and set the order_by for the current search from the requested values passed to do_search()
set_search_order_by(string $search, string $order_by, string $sort) : string
Parameters
- $search : string
- $order_by : string
- $sort : string
Return values
stringprepare_regex_search_string()
Escape and process a string from ResourceSpace search syntax to regex syntax Wildcards are replaced with '.*?' - any character 0 or more times Multiple keyword matches are split into an OR group Word boundaries are added to avoid unintended wildcards.
prepare_regex_search_string(string $keyword) : string
Parameters
- $keyword : string
-
Keyword string without any field names or special search strings
Return values
string —Processed string ready for RLIKE searches
convert_search_form_date_to_search_query()
Utility converter between sumitted date input and ResourceSpace search query
convert_search_form_date_to_search_query(array{ref: int, name: string, type: int} $field[, array{html_field_name?: string} $ctx = [] ]) : string
Parameters
- $field : array{ref: int, name: string, type: int}
-
Field information relevant for the submitted data
- $ctx : array{html_field_name?: string} = []
Return values
string —The constructed search query string (based on the input/submitted data).