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

admin_resource_type_field_option()

Parameters

ColumnTypeDefaultDescription
$propertyname string
$propertytitle string
$helptext string
$type
$currentvalue
$fieldtype int
$system_date_field bool
$resource_type_array;
$lang
$baseurl_short
$FIXED_LIST_FIELD_TYPES
$daterange_edtf_support
$allfields
$newfield
$resource_type_array
$existingrestypes
$regexp_slash_replace

Location

include/render_functions.php lines 6455 to 6752

Definition

 
function admin_resource_type_field_option(string $propertyname,string $propertytitlestring $helptext$type,$currentvalue,int $fieldtypebool $system_date_field) : void
    
{
    
debug_function_call("admin_resource_type_field_option",func_get_args());

    global 
$ref,$lang$baseurl_short,$FIXED_LIST_FIELD_TYPES$daterange_edtf_support$allfields$newfield,
    
$resource_type_array$existingrestypes$regexp_slash_replace$resource_type_array;
    if(
$propertyname=="linked_data_field")
        {
        if(
$fieldtype==FIELD_TYPE_DATE_RANGE && $daterange_edtf_support)
            {
            
// The linked_data_field column is is only used for date range fields at present
            
$propertytitle $lang["property-field_raw_edtf"];
            }
        else
            {
            return;
            }
        }
    
$resource_types=get_resource_types("",true,false,true);
    foreach(
$resource_types as $resource_type)
        {
        
$resource_type_array[$resource_type["ref"]]=$resource_type["name"];
        }
    
    if(
$propertyname == 'regexp_filter')
        {
        
$currentvalue str_replace($regexp_slash_replace'\\', (string) $currentvalue);
        }
        
    
$alt_helptext=hook('rtfieldedithelptext''admin_resource_type_field_edit', array($propertyname));
    if(
$alt_helptext!==false){
        
$helptext=$alt_helptext;
    }
    
    
?>
    <div class="Question" >
        <label> echo ($propertytitle!="") ? escape((string) $propertytitle) : escape((string) $propertyname); ?></label>
        
        
if($propertyname=="global")
            { 
            
// Special case - new global/resource type selector
            
?>
            <table>
                <tr>
                    <td>
                        <input type="checkbox" 
                            name="global" 
                            id="globalfield" 
                            value="1"
                             if($currentvalue == 1) { ?> checked="checked" ?>s
                            onchange="showHideResTypeSelector();">
                         echo escape($lang["resourcetype-global_field"]) ?>
                    </td>
                </tr>
                
                
foreach($resource_type_array as $resource_type=>$restypename)
                    {
                    
?>
                    <tr>
                        <td>
                            <input type="checkbox"
                                name="field_restype_select_ echo escape($resource_type); ?>"
                                id="field_restype_select_ echo escape($resource_type); ?>
                                class="field_restype_select"
                                value="1"
                                 if($currentvalue == 1) { ?> disabled="true" ?>
                                 if(in_array($resource_type,$existingrestypes)) { ?> checked="checked" ?>>
                             echo escape($restypename?>
                        </td>
                    </tr>
                    
                    
}
                
?>
            </table>
            <script>
            function showHideResTypeSelector() {
                if(jQuery("#globalfield").prop("checked")){
                    jQuery(".field_restype_select").display = 'none';
                    jQuery(".field_restype_select").prop('checked',false);
                    jQuery(".field_restype_select").prop('disabled',true);
                }
                else {                    
                    jQuery(".field_restype_select").display = 'block';
                    jQuery(".field_restype_select").prop('disabled',false);
                }
            }
            </script>

            
}
        elseif(
$propertyname=="type")
            {
            global 
$field_types;

            
// Sort  so that the display order makes some sense
            //natsort($field_types);
            
?>
                <select id="field_edit_ echo escape((string) $propertyname); ?>"
                        name=" echo escape((string) $propertyname); ?>"
                        class="stdwidth"
                        onchange="
                                 if(!$newfield)
                                {
?>
                                newval=parseInt(this.value);
                                if((jQuery.inArray(newval,fixed_list_fields) > -1) && (jQuery.inArray(current_type,text_fields) > -1))
                                    {
                                    jQuery('input[name=\'keywords_index\']')[0].checked = true;

                                    if(confirm(' echo escape($lang["admin_resource_type_field_migrate_data_prompt"]) ?>'))
                                        {
                                        jQuery('#migrate_data').val('yes');
                                        }
                                    else
                                        {
                                        jQuery('#migrate_data').val('');
                                        }

                                    this.form.submit();
                                    }

                                    else if ((jQuery.inArray(newval,text_fields) > -1) && (jQuery.inArray(current_type,fixed_list_fields) > -1)) 
                                {
                                    if(confirm(' echo escape($lang["admin_resource_type_field_cannot_migrate_data_prompt"]) ?>'))
                                        {
                                            this.form.submit(); 
                                        } else {
                                            jQuery('#field_edit_type').val(current_type);
                                        }
                                }
                                else
                                    {
                                    this.form.submit();
                                    }
                                
                                
}
                            else
                                {
                                
?>
                                this.form.submit();
                                
                                
}
                                
?>
                ">
                
                
foreach($field_types as $field_type=>$field_type_description)
                    {
                    
?>
                    <option value=" echo $field_type ?>" if ($currentvalue == $field_type) { echo " selected"; } ?>> echo escape($lang[$field_type_description])  ; ?></option>
                    
                    
}
                
?>
                </select>
            
            
if (in_array($currentvalue$FIXED_LIST_FIELD_TYPES))
                {
                
?>
                <div class="clearerleft"></div>
                </div> <!-- end question -->

                <div class="Question">
                    <label>  echo escape($lang['options']) ; ?></label>
                    <span><a href=" echo $baseurl_short ?>pages/admin/admin_manage_field_options.php?field= echo $ref ?>" onClick="return CentralSpaceLoad(this,true);">  echo escape($lang['property-options_edit_link']) ; ?></a></span>
                    <div class="clearerleft"></div>

                
                
if(FIELD_TYPE_CATEGORY_TREE != $currentvalue)
                    {
                    
?>
                    </div>
                    
                    $field_index              
array_search($refarray_column($allfields'ref'));
                    
$automatic_nodes_ordering = (false !== $field_index $allfields[$field_index]['automatic_nodes_ordering'] : 0);
                    
?>
                    <div class="Question">
                        <label>  echo escape($lang['property-automatic_nodes_ordering_label']) ; ?></label>
                        <input type="checkbox" name="automatic_nodes_ordering" value="1" if(== $automatic_nodes_ordering) { ?> checked="checked" ?>>
                    
                    
// create constraints selector
                    
admin_resource_type_field_constraint($ref, (int)$currentvalue);
                    }
                }
            elseif (
in_array($currentvalue, array(FIELD_TYPE_TEXT_BOX_SINGLE_LINE)))
                { 
                
// create constraints selector
                
admin_resource_type_field_constraint($ref, (int)$currentvalue);
                }
            }
        elseif(
$propertyname=="linked_data_field")
            {
            if (
$fieldtype==FIELD_TYPE_DATE_RANGE && $daterange_edtf_support)
                {
                
// The linked_data_field column is is only used for date range fields at present            
                // Used to store the raw EDTF string submitted
                
?>
                <input id="linked_data_field" name="linked_data_field" type="text" class="stdwidth" value=" echo escape((string) $currentvalue)?>">

                
}
            }
        elseif(
$propertyname === 'tab')
            {
            
?>
            <select class="stdwidth" name=" echo escape($propertyname); ?>">
            
            
foreach(get_tab_name_options() as $tab_ref => $tab_name)
                {
                
$selected $tab_ref === (int) $currentvalue 'selected' '';
                
?>
                <option value=" echo (int) $tab_ref?> echo $selected?>> echo escape((string) $tab_name); ?></option>
                
                
}
            
?>
            </select>
            
            
}
        elseif(
$type==1)
            {
            if (
$propertyname=="advanced_search" && $system_date_field)
                {
                
?><input id="field_edit_ echo escape((string) $propertyname); ?>" name=" echo escape((string) $propertyname); ?>" type="checkbox" value="1" checked="checked" onclick="return false;">
                $helptext
=$lang["property-system_date_help_text"];
                }
            else
                {
                
?><input id="field_edit_ echo escape((string) $propertyname); ?>" name=" echo escape((string) $propertyname); ?>" type="checkbox" value="1"  if ($currentvalue==1) { ?> checked="checked" ?>>
                
}
            }
        elseif(
$type==2)
            {
            
?>
            <textarea class="stdwidth" rows="5" id="field_edit_ echo escape((string) $propertyname); ?>" name=" echo escape((string) $propertyname); ?>"> echo escape((string) $currentvalue)?></textarea>
            
            
}
        else
            {
            
?>
            <input id="field_edit_ echo escape((string) $propertyname); ?>" name=" echo escape((string) $propertyname); ?>" type="text" class="stdwidth" value=" echo escape((string) $currentvalue)?>">
            
            
}

        if(
$helptext!="")
                {
                
?>
                <div class="FormHelp" style="padding:0;clear:left;" >
                    <div class="FormHelpInner"> echo strip_tags_and_attributes(str_replace("%ref",$ref,$helptext), ["a"], ["href""target"]) ?>
                    </div>
                </div>
                
                
}

    if(
$propertyname == "name")
        {
        
?>
        <div id="shortname_err_msg" class="FormHelp DisplayNone" style="padding:0;clear:left;" >
            <div class="FormHelpInner PageInformal"> echo escape($lang["warning_duplicate_shortname_fields"]) ; ?></div>
        </div>
        <script>
        var validate_shortname_in_progress = false;
        jQuery("input[name='name']").keyup(function(event)
            {
            if(validate_shortname_in_progress)
                {
                return;
                }

            validate_shortname_in_progress = true;

            jQuery.get(
                baseurl + "/pages/admin/ajax/validate_rtf_shortname.php",
                {
                ref: " echo escape($ref); ?>",
                new_shortname: event.target.value
                },
                function (response)
                    {
                    var err_msg_el = jQuery("#shortname_err_msg");
                    if(err_msg_el.hasClass("DisplayNone") === false)
                        {
                        err_msg_el.addClass("DisplayNone");
                        }

                    if(typeof response.data !== "undefined" && !response.data.valid)
                        {
                        err_msg_el.removeClass("DisplayNone");
                        }

                    validate_shortname_in_progress = false;
                    },
                "json");

            return;
            });
        </script>
        
        
}
        
?>
        <div class="clearerleft"></div>
    </div>
    
    
}

This article was last updated 11th December 2024 20:35 Europe/London time based on the source file dated 11th December 2024 15:55 Europe/London time.