Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

get_simple_search_fields()

Description

Retrieves a list of fields suitable for the simple search box.

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.

properties, filtered by permissions and search capabilities.

Parameters

This function accepts no parameters.

Return

array An array of fields suitable for simple search, including their titles and other

Location

include/search_functions.php lines 2881 to 2909

Definition

 
function get_simple_search_fields()
    {
    global 
$FIXED_LIST_FIELD_TYPES$country_search;

    
# First get all the fields
    
$allfields=get_resource_type_fields("","global,order_by");

    
# Applies field permissions and translates field titles in the newly created array.
    
$return = array();
    for (
$n 0;$n<count($allfields);$n++)
        {
        if (
            
# Check if for simple_search
            # Also include the country field even if not selected
            # This is to provide compatibility for older systems on which the simple search box was not configurable
            # and had a simpler 'country search' option.
            
($allfields[$n]["simple_search"] == || (isset($country_search) && $country_search && $allfields[$n]["ref"] == 3))
        &&
            
# Must be either indexed or a fixed list type
            
($allfields[$n]["keywords_index"] == || in_array($allfields[$n]["type"],$FIXED_LIST_FIELD_TYPES))
        &&
            
metadata_field_view_access($allfields[$n]["ref"]))
            {
            
$allfields[$n]["title"] = lang_or_i18n_get_translated($allfields[$n]["title"], "fieldtitle-");
            
$return[] = $allfields[$n];
            }
        }
    return 
$return;
    }

This article was last updated 4th December 2024 09:05 Europe/London time based on the source file dated 27th November 2024 09:40 Europe/London time.