Collections functions
General functions
Render functions
Theme permission functions
Resource functions

check_view_display_condition()

Parameters

ColumnTypeDefaultDescription
$fields
$n
$fields_all

Location

include/metadata_functions.php lines 290 to 328

Definition

 
function check_view_display_condition($fields,$n,$fields_all)        
    {
    
#Check if field has a display condition set
    
$displaycondition=true;
    if (
$fields[$n]["display_condition"]!="")
        {
        
$fieldstocheck=array(); #' Set up array to use in jQuery script function
        
$s=explode(";",$fields[$n]["display_condition"]);
        
$condref=0;
        foreach (
$s as $condition# Check each condition
            
{
            
$displayconditioncheck=false;
            
$s=explode("=",$condition);
            for (
$cf=0;$cf<count($fields_all);$cf++) # Check each field to see if needs to be checked
                
{
                if (
$s[0]==$fields_all[$cf]["name"]) # this field needs to be checked
                    
{                    
                    
$checkvalues $s[1];
                    
$validvalues explode("|",$checkvalues);
                    
$validvalues array_map("i18n_get_translated",$validvalues);
                    
$validvalues array_map("strtoupper",$validvalues);
                    
$v trim_array(explode(",",$fields_all[$cf]["value"] ?? ""));
                    
$v array_map("i18n_get_translated",$v);
                    
$v array_map("strtoupper",$v);
                    foreach (
$validvalues as $validvalue)
                        {
                        if (
in_array($validvalue,$v)) {$displayconditioncheck=true;} # this is  a valid value                        
                        
}
                    if (!
$displayconditioncheck) {$displaycondition=false;}                    
                    }
                    
                } 
# see if next field needs to be checked
                            
            
$condref++;
            } 
# check next condition    
        
        
}
    return 
$displaycondition;
    }

This article was last updated 30th September 2022 16:05 Europe/London time based on the source file dated 5th July 2022 12:30 Europe/London time.