Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

get_resource_type_fields()

Description

Gets all metadata fields, optionally for a specified array of resource types

Parameters

ColumnTypeDefaultDescription
$restypes array "" Optional array of resource types to check
$field_order_by string "ref" Order by column
$field_sort string "asc" Sort order
$find string "" Parameter value to search for
$fieldtypes array array List of field types to include
$include_inactive boolean false Should inactive resources be checked, default is false

Return

array

Location

include/resource_functions.php lines 7248 to 7344

Definition

 
function get_resource_type_fields($restypes=""$field_order_by="ref"$field_sort="asc"$find=""$fieldtypes = array(), $include_inactive=false)
    {
    
$conditionsql="";
    if(
is_array($restypes))
        {
        
$conditionsql " WHERE resource_type IN (" implode(",",$restypes) . ")";
        }
    if (
$include_inactive==false)
        {
        if(
$conditionsql != "")
            {
            
$conditionsql .= " AND active=1 ";
            }
        else
            {
            
$conditionsql .= " WHERE active=1 ";
            }
        }
    if(
$find!="")
        {
        
$find=escape_check($find);
        if(
$conditionsql != "")
            {
            
$conditionsql .= " AND ( ";
            }
        else
            {
            
$conditionsql .= " WHERE ( ";
            }
        
$conditionsql.=" name LIKE '%" $find "%' OR title LIKE '%" $find "%' OR tab_name LIKE '%" $find "%' OR exiftool_field LIKE '%" $find "%' OR help_text LIKE '%" $find "%' OR ref LIKE '%" $find "%' OR tooltip_text LIKE '%" $find "%' OR display_template LIKE '%" $find "%')";
        }
    
    
$newfieldtypes array_filter($fieldtypes,function($v){return (string)(int)$v == $v;}); 
    
    if(
count($newfieldtypes) > 0)
        {
        if(
$conditionsql != "")
            {
            
$conditionsql .= " AND ( ";
            }
        else
            {
            
$conditionsql .= " WHERE ( ";
            }
        
$conditionsql .= " type IN ('" implode("','",$newfieldtypes) . "'))";
        }
    
// Allow for sorting, enabled for use by System Setup pages
    //if(!in_array($field_order_by,array("ref","name","tab_name","type","order_by","keywords_index","resource_type","display_field","required"))){$field_order_by="ref";}       
        
    
$allfields 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,
               display_as_dropdown,
               external_user_access,
               autocomplete_macro,
               hide_when_uploading,
               hide_when_restricted,
               value_filter,
               exiftool_filter,
               omit_when_copying,
               tooltip_text,
               regexp_filter,
               sync_field,
               display_condition,
               onchange_macro,
               field_constraint,
               linked_data_field,
               automatic_nodes_ordering,
               fits_field,
               personal_data,
               include_in_csv_export,
               browse_bar,
               active,
               read_only,
               full_width
          FROM resource_type_field" 
$conditionsql " ORDER BY active desc," escape_check($field_order_by) . " " escape_check($field_sort), "schema");

    return 
$allfields;
    }

This article was last updated 10th July 2020 00:05 Europe/London time based on the source file dated 8th July 2020 11:40 Europe/London time.