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

config_single_ftype_select()

Description

Generate an html single-select + options block for selecting one of the RS field types. The
selected field type is posted as the value of the "ref" column of the selected field type.

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 integer the current value of the config variable being set
$width integer 300 the width of the input field in pixels. Default: 300.
$rtype false
$ftypes array
$autosave false

Location

include/config_functions.php lines 1020 to 1073

Definition

 
function config_single_ftype_select($name$label$current$width=300$rtype=false$ftypes=array(), $autosave false)
    {
    global 
$lang;
    
$fieldtypefilter="";
    
$params = [];
    if(
count($ftypes)>0)
        {
        
$fieldtypefilter " type in ("ps_param_insert(count($ftypes)) .")";
        
$params ps_param_fill($ftypes'i');
        }
        
    if(
$rtype===false){
        
$fieldsps_query('select ' columns_in("resource_type_field") . ' from resource_type_field ' .  (($fieldtypefilter=="")?'':' where ' $fieldtypefilter) . ' order by title, name'$params"schema");
    }
    else{
        if (
$rtype === 0)
            {
            
$rtype_sql '`global` = 1';
            }
        else
            {
            
$rtype_sql 'ref IN (SELECT resource_type_field FROM resource_type_field_resource_type WHERE resource_type = ?)';
            
$params array_merge(array('i'$rtype), $params);
            }
        
$fields ps_query("select " columns_in("resource_type_field") . " from resource_type_field where $rtype_sql " .  (($fieldtypefilter == "") ? "" "and " $fieldtypefilter) . "order by title, name"$params"schema");
    }
?>
  <div class="Question">
    <label for=" echo $name?>" title=" echo str_replace('%cvn'$name$lang['plugins-configvar'])?>"> echo $label?></label>
    
     
    
if($autosave)
        {
        
?>
        <div class="AutoSaveStatus">
            <span id="AutoSaveStatus- echo $name?>" style="display:none;"></span>
        </div>
        
        
}
        
?>
    <select name=" echo $name?>" id=" echo $name?>" style="width: echo $width ?>px"
     if($autosave) { ?> onChange="AutoSaveConfigOption(' echo $name?>');" ?>>
    <option value=""  echo $current == "" ' selected' '' ?>> echo escape($lang["select"]); ?></option>

    
foreach($fields as $field)
        {
        echo 
'    <option value="'$field['ref'] . '"' . (($current==$field['ref'])?' selected':'') . '>' lang_or_i18n_get_translated($field['title'],'fieldtitle-') . '</option>';
        }
?>
    </select>
  <div class="clearerleft"></div>
  </div>

    
}

This article was last updated 19th March 2024 08:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.