Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

get_advanced_search_fields()

Parameters

ColumnTypeDefaultDescription
$archive false
$hiddenfields ""

Location

include/search_functions.php lines 40 to 97

Definition

 
function get_advanced_search_fields($archive=false$hiddenfields="")
    {
    global 
$FIXED_LIST_FIELD_TYPES$date_field$daterange_search;
    
# Returns a list of fields suitable for advanced searching. 
    
$return=array();

    
$date_field_already_present=false# Date field not present in searchable fields array
    
$date_field_data=null# If set then this is the date field to be added to searchable fields array

    
$hiddenfields=explode(",",$hiddenfields);

    
$fields=sql_query("SELECT *, ref, name, title, type ,order_by, keywords_index, partial_index, resource_type, resource_column, display_field, use_for_similar, iptc_equiv, display_template, tab_name, required, smart_theme_name, exiftool_field, advanced_search, simple_search, help_text, tooltip_text, display_as_dropdown, display_condition, field_constraint, active FROM resource_type_field WHERE advanced_search=1 AND active=1 AND ((keywords_index=1 AND length(name)>0) OR type IN (" implode(",",$FIXED_LIST_FIELD_TYPES) . ")) " . (($archive)?"":"and resource_type<>999") . " ORDER BY resource_type,order_by""schema");
    
# Apply field permissions and check for fields hidden in advanced search
    
for ($n=0;$n<count($fields);$n++)
        {
        if (
metadata_field_view_access($fields[$n]["ref"]) && !checkperm("T" $fields[$n]["resource_type"]) && !in_array($fields[$n]["ref"], $hiddenfields))
            {
            
$return[]=$fields[$n];
            if(
$fields[$n]["ref"]==$date_field)
                {
                
$date_field_already_present=true;
                }
            }
        }

    
# If not already in the list of advanced search metadata fields, insert the field which is the designated searchable date ($date_field)
    
if(!$date_field_already_present 
        
&& $daterange_search 
        
&& metadata_field_view_access($date_field
        && !
in_array($date_field$hiddenfields))
        {
        
$date_field_data get_resource_type_field($date_field);
        
# Insert searchable date field so that it appears as the first array entry for a given resource type
        
$return1=array();
        for (
$n=0;$n<count($return);$n++)
            {
            if (isset(
$date_field_data))
                {
                if (
$return[$n]["resource_type"] == $date_field_data['resource_type']) 
                    {
                    
$return1[]=$date_field_data;
                    
$date_field_data=null# Only insert it once
                    
}
                }
            
$return1[]=$return[$n];
            }
        
# If not yet added because it's resource type differs from everything in the list then add it to the end of the list
        
if (isset($date_field_data))
            {
            
$return1[]=$date_field_data;
            
$date_field_data=null# Keep things tidy
        
}
        return 
$return1;
        }
 
    
# Designated searchable date_field is already present in the lost of advanced search metadata fields        }
    
return $return;
    }

This article was last updated 23rd November 2020 18:35 Europe/London time based on the source file dated 19th November 2020 14:20 Europe/London time.