Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

config_multi_ftype_select()

Description

Generate an html multi-select + options block for selecting multiple RS field types. The
selected field type is posted as an array of the values of the "ref" column of the selected
field types.

Parameters

ColumnTypeDefaultDescription
$name string the name of the select block. Usually the name of the config variable being set.
$label string the user text displayed to label the select block. Usually a $lang string.
$current array Array holding the current field IDs of the config variable being set
$width integer 300 the width of the input field in pixels. Default: 300.
$size integer 7 - Number of visible options. Default 7
$rtype integer false - Limit to fields associated with a specific resource type

Location

include/plugin_functions.php lines 927 to 967

Definition

 
function config_multi_ftype_select($name$label$current$width=300,$size=7,$rtype=false
    {
    global 
$lang;
    if(
$rtype===false){
        
$fields get_resource_type_fields("","order_by");
    }
    else{
        
$fields get_resource_type_fields($rtype,"order_by");
    }
    
$all_resource_types get_resource_types();
    
$resource_types array_column($all_resource_types,"name","ref");
    
?>
    <div class="Question">
    <label for=" echo $name?>" title=" echo escape(str_replace('%cvn'$name$lang['plugins-configvar'])); ?>"> echo escape($label); ?></label>
    <select name=" echo $name?>[]" id=" echo $name?>" class="MultiSelect" multiple="multiple" size=" echo $size?>" style="width: echo $width ?>px">
    
    
foreach($fields as $field)
        {
        
$str_restypes "";
        
$fieldrestypes explode(",",(string)$field["resource_types"]);
        
$fieldrestypenames = [];
        if(
$field["global"] != 1)
            {
            foreach(
$fieldrestypes as $fieldrestype)
                {
                
$fieldrestypenames[] =i18n_get_translated($resource_types[$fieldrestype]);
                }
            if(
count($fieldrestypes) < count($all_resource_types)-2)
                {
                
// Don't show this if they are linked to all but one resource types
                
$str_restypes " (" .  implode(",",$fieldrestypenames) . ")";
                }
            }
        echo 
'<option value="'$field['ref'] . '"' . (in_array($field['ref'],$current) ? ' selected':'') . '>' escape(lang_or_i18n_get_translated($field['title'],'fieldtitle-') .  $str_restypes) .  '</option>';
        }
?>
    </select>
    <div class="clearerleft"></div>
  </div>

    
}

This article was last updated 22nd July 2024 21:35 Europe/London time based on the source file dated 12th July 2024 13:45 Europe/London time.