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

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 989 to 1045

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 escape($name); ?>" title=" echo escape(str_replace('%cvn'$name$lang['plugins-configvar'])); ?>">
             echo escape($label); ?>
        </label>
        <fieldset
            name=" echo escape($name); ?>[]"
            id=" echo escape($name); ?>"
            class="MultiRTypeSelect"
            style="width: echo (int) $width?>px;">
            <div style="height: echo (int) $size 21;?>px;overflow:auto">
            
            
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) . ")";
                    }
                } 
?>
                <span id="ftype echo (int) $field['ref'];?>">
                    <input
                        type="checkbox"
                        value=" echo (int) $field['ref']; ?>"
                        name=" echo escape($name); ?>[]"
                        id=" echo escape($name.$field['ref']); ?>"
                         echo in_array($field['ref'], $current) ? ' checked="checked"':''?>>
                         echo escape(lang_or_i18n_get_translated($field['title'], 'fieldtitle-') .  $str_restypes); ?>
                    </input>
                    <br />
                </span>
             ?>
            </div>
        </fieldset>
        <div class="clearerleft"></div>
    </div>
    
}

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 8th November 2024 11:50 Europe/London time.