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

Description

Generate the second half of the "guts" of a plugin setup page from a page definition array. The
page definition array is typically constructed by a series of calls to config_add_xxxx functions
(see below). See the setup page for the sample plugin for information on how to use this and the
associated functions.

If wishing to ouput array of values for one config option, in your setup page have something like the
following which adds a single definition for each key of your config option:
foreach($usergroups as $k => $group)
{
global $usergroupemails;
if(!isset($usergroupemails[$group["ref"]])){$usergroupemails[$group["ref"]]=array();} // Define any missing keys
$page_def[] = config_add_text_list_input("usergroupemails[".$group["ref"]."]",$group["name"]); //need to pass a string that looks like: "$configoption["key"]"
}
The key can consist of numbers, letters or an underscore contained within "" or ''. If using numbers you don't need the quote marks

each of which describes how one of the plugin's configuratoin variables.
typically a $lang[] variable.
placed after the page heading and before the form. Default: '' (i.e., no front matter).

Parameters

ColumnTypeDefaultDescription
$page_def
$plugin_name
$upload_status
$plugin_page_heading
$plugin_page_frontm ''
mixed $page_def an array whose elements are generated by calls to config_add_xxxx functions
string $plugin_page_frontm front matter for the setup page in html format. This material is

Location

include/plugin_functions.php lines 512 to 642

Definition

 
function config_gen_setup_html($page_def,$plugin_name,$upload_status,$plugin_page_heading,$plugin_page_frontm='')
    {
    global 
$lang,$baseurl_short;
?>
    <div class="BasicsBox">
    <h1> echo strip_tags_and_attributes($plugin_page_heading, ['a'], ['href''target']); ?></h1>

    $links_trail 
= array(
        array(
            
'title' => $lang["systemsetup"],
            
'href'  => $baseurl_short "pages/admin/admin_home.php",
            
'menu' =>  true
        
),
        array(
            
'title' => $lang["pluginmanager"],
            
'href'  => $baseurl_short "pages/team/team_plugins.php"
        
),
        array(
            
'title' => $plugin_page_heading
        
)
    );
    
renderBreadcrumbs($links_trail);

    if (
$plugin_page_frontm!='')
        {
        echo 
$plugin_page_frontm;
        }
?>
        <form id="form1" name="form1" method="post" action=" echo escape($_SERVER["PHP_SELF"]); ?>">
    
    generateFormToken
("form1");

    foreach (
$page_def as $def)
        {
        
$array_offset="";
        if(
preg_match("/\[[\"|']?\w+[\"|']?\]/",$def[1],$array_offset))
            {
            
$array=preg_replace("/\[[\"|']?\w+[\"|']?\]/","",$def[1]);
            
preg_match("/[\"|']?\w+[\"|']?/",$array_offset[0],$array_offset);
            }

        
hook ("custom_config_def"'', array($def)); //this comes first so overriding the below is possible

        
switch ($def[0])
            {
            case 
'section_header':
                 
config_section_header($def[1], $def[2]);
                 break;
            case 
'html':
                 
config_html($def[1]);
                 break;
            case 
'text_input':
                
config_text_input($def[1], $def[2], $GLOBALS[$def[1]], $def[3], $def[4], $def[5], $def[6], $def[7], $def[8]);
                break;
            case 
'text_hidden_input':
                
$value = (trim($def[2]) !== '' $def[2] : $GLOBALS[$def[1]]);
                
render_hidden_input($def[1], $value);
                break;
            case 
'text_list':
            if (!empty(
$array_offset))
                {
                
config_text_input($def[1], $def[2], implode(','$GLOBALS[$array][$array_offset[0]]), $def[3], $def[4]);
                }
            else
                {
                
config_text_input($def[1], $def[2], implode(','$GLOBALS[$def[1]]), $def[3], $def[4]);
                }

                break;
            case 
'boolean_select':
                
config_boolean_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3], $def[4]);
                break;
            case 
'single_select':
                
config_single_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3], $def[4], $def[5]);
                break;
            case 
'multi_select':
                
config_multi_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3], $def[4], $def[5]);
                break;
            case 
'single_user_select':
                
config_single_user_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3]);
                break;
            case 
'multi_user_select':
                
config_multi_user_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3]);
                break;
            case 
'single_ftype_select':
                
config_single_ftype_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3], $def[4], $def[5],$def[6]);
                break;
            case 
'multi_ftype_select':
                
config_multi_ftype_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3],$def[4], $def[5]);
                break;
            case 
'single_rtype_select':
                
config_single_rtype_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3]);
                break;
            case 
'multi_rtype_select':
                
config_multi_rtype_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3]);
                break;
            case 
'db_single_select':
                
config_db_single_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3], $def[4], $def[5], $def[6], $def[7], $def[8]);
                break;
            case 
'db_multi_select':
                
config_db_multi_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3], $def[4], $def[5], $def[6], $def[7], $def[8]);
                break;
            case 
'single_group_select':
                
config_single_group_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3]);
                break;
            case 
'multi_group_select':
                
config_multi_group_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3]);
                break;
            case 
'checkbox_select':
                
config_checkbox_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3], $def[4], $def[5], $def[6], $def[7], $def[8], $def[9]);
                break;
            case 
'multi_archive_select':
                
config_multi_archive_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3]);
                break;
            case 
'fixed_input':
                
render_fixed_text_question($def[1], $def[2], $def[3]);
                break;
            default:
                break;
            }
        }
        
?>
        <div class="Question">
          <input type="submit" name="save" id="save" value=" echo escape($lang['plugins-saveconfig']); ?>">
          <input type="submit" name="submit" id="submit" value=" echo escape($lang['plugins-saveandexit']); ?>">
          <div class="clearerleft"></div>
        </div>
      </form>
    </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.