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_db_multi_select()

Description

Generate an html multi-select + options block for selecting from among rows returned by a
database query in which one of the columns is the unique key (by default, the "ref" column) and one
of the others is the text to display (by default the "name" column). The value posted is an array
of the values of the column given by the $ixcol variable for the rows selected.

Defaulted to 'ref'.
user. Defaulted to 'name'.
the user. Defaulted to '' indicating that only $dispcolA is to be displayed.
Defaulted to $lang['plugin_field_fmt']. $fmt is all literal except for %A and %B which are
replaced with values. In English $fmt is '%A(%B)' which results in the i-th choice
displaying as: $choices[i][$dispcolA] . '(' . $choices[i][$dispcolB] . ')'

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
$choices array the array of db rows that make up the choices.
$ixcol string 'ref' the key in $choices (i.e., the db column) for the value of the choice
$dispcolA string 'name' the key in $choices (i.e., the db column) for the text to display to the
$dispcolB string '' the key in $choices (i.e., the db column) for secondary text to display to
$fmt string '' the formatting string for combining $dispcolA and B when both are specified.
$width integer 300 the width of the input field in pixels. Default: 300.
array string $current the current value of the config variable being set.

Location

include/plugin_functions.php lines 1296 to 1337

Definition

 
function config_db_multi_select($name$label$current$choices$ixcol 'ref'$dispcolA 'name'$dispcolB ''$fmt ''$width 300)
{
    global 
$lang;
    
?>
    <div class="Question">
        <label for=" echo escape($name); ?>" title=" echo escape(str_replace('%cvn'$name$lang['plugins-configvar'])); ?>">
             echo strip_tags_and_attributes($label, ['a'], ['href''target']); ?>
        </label>
        <fieldset
            id=" echo escape($name); ?>"
            class="MultiRTypeSelect"
            >
            <div class="MultiRtypeSelectContainer">
            
            
foreach ($choices as $item) {
                if (
$dispcolB != '') {
                    
$usertext str_replace(
                        array(
'%A''%B'),
                        array(
$item[$dispcolA], $item[$dispcolB]),
                        
$fmt == '' $lang['plugin_field_fmt'] : $fmt
                    
);
                } else {
                    
$usertext $item[$dispcolA];
                } 
?>
                <span id=" echo escape($name $item[$ixcol]); ?>">
                    <input
                        type="checkbox"
                        value=" echo escape($item[$ixcol]); ?>"
                        name=" echo escape($name); ?>[]"
                        id=" echo escape($name.$item[$ixcol]); ?>"
                         echo in_array($item[$ixcol], $current) ? ' checked="checked"' ''?>>
                         echo escape($usertext); ?>
                    </input>
                    <br />
                </span>
             ?>
            </div>
        </fieldset>
        <div class="clearerleft"></div>
    </div>
    
}

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 29th November 2024 10:35 Europe/London time.