Ejemplo n.º 1
0
/**
 * 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.
 *
 * @param $page_def mixed an array whose elements are generated by calls to config_add_xxxx functions
 *          each of which describes how one of the plugin's configuratoin variables.
 * @param $plugin_name string the name of the plugin for which the function is being invoked.
 * @param $upload_status string the status string returned by config_get_setup_post().
 * @param $plugin_page_heading string the heading to be displayed for the setup page for this plugin,
 *          typically a $lang[] variable.
 * @param $plugin_page_frontm string front matter for the setup page in html format. This material is
 *          placed after the page heading and before the form. Default: '' (i.e., no front matter).
 */
function config_gen_setup_html($page_def,$plugin_name,$upload_status,$plugin_page_heading,$plugin_page_frontm='')
    {
    global $lang,$baseurl_short;
?>
    <div class="BasicsBox">
      <h2>&nbsp;</h2>
      <h1><?php echo $plugin_page_heading ?></h1>
<?php
    if ($plugin_page_frontm!='')
        {
        echo $plugin_page_frontm;
        }
?>
      <form id="form1" name="form1" method="post" action="<?php echo $baseurl_short?>plugins/<?php echo $plugin_name?>/pages/setup.php">
<?php
    foreach ($page_def as $def)
        {
        switch ($def[0])
            {
            case 'section_header':
                 config_section_header($def[1], $def[2]);
                 break;
            case 'text_input':
                config_text_input($def[1], $def[2], $GLOBALS[$def[1]], $def[3], $def[4]);
                break;
            case 'text_list':
                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]);
                break;
            case 'multi_ftype_select':
                config_multi_ftype_select($def[1], $def[2], $GLOBALS[$def[1]], $def[3]);
                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;
            }
        }
?>
        <div class="Question">
          <label for="submit">&nbsp;</label>
          <input type="submit" name="save" id="save" value="<?php echo $lang['plugins-saveconfig']?>">
          <input type="submit" name="submit" id="submit" value="<?php echo $lang['plugins-saveandexit']?>">
        </div>
        <div class="clearerleft"></div>
      </form>
<?php
    display_rsc_upload($upload_status);
?>
    </div>
<?php
    }
/**
 * 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
 *
 * @param $page_def mixed an array whose elements are generated by calls to config_add_xxxx functions
 *          each of which describes how one of the plugin's configuratoin variables.
 * @param $plugin_name string the name of the plugin for which the function is being invoked.
 * @param $upload_status string the status string returned by config_get_setup_post().
 * @param $plugin_page_heading string the heading to be displayed for the setup page for this plugin,
 *          typically a $lang[] variable.
 * @param $plugin_page_frontm string front matter for the setup page in html format. This material is
 *          placed after the page heading and before the form. Default: '' (i.e., no front matter).
 */
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><?php 
    echo $plugin_page_heading;
    ?>
</h1>
<?php 
    if ($plugin_page_frontm != '') {
        echo $plugin_page_frontm;
    }
    ?>
      <form id="form1" name="form1" method="post" action="<?php 
    echo $baseurl_short;
    ?>
plugins/<?php 
    echo $plugin_name;
    ?>
/pages/setup.php">
<?php 
    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);
        }
        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]);
                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]);
                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;
        }
    }
    ?>
        <div class="Question">
          <label for="submit">&nbsp;</label>
          <input type="submit" name="save" id="save" value="<?php 
    echo $lang['plugins-saveconfig'];
    ?>
">
          <input type="submit" name="submit" id="submit" value="<?php 
    echo $lang['plugins-saveandexit'];
    ?>
">
        </div>
        <div class="clearerleft"></div>
      </form>
<?php 
    display_rsc_upload($upload_status);
    ?>
    </div>
<?php 
}