<?PHP
/**
 * MIP FORMS (Modul Input Forms)
 * Vorgefertigte Formulare zur Abstraktion der Eingaben
 * im Modulinput.
 *
 * Struktur:
 * fnc.mipforms.php --> Diese Datei - Hauptfunktion
 * fnc.mipforms_core.php --> Grundfunktionen
 * fnc.mipforms_extensions.php --> Erweiterungen
 * fnc.mipforms_apps.php --> Applikationen
 *
 *
 * @Author: (c) Björn Brockmann 2002 - 2003
 * @Email: bjoern@project-gooseberry.de
 * @Homepage: www.project-gooseberry.de
 * @License: GPL
 * @Version: 1.3
 */
if (!defined('IS_DEDI')) die();
//Start Fix
if (is_object($perm)){
//include mip_forms base functions
require_once $cfg_path_dedi.'inc/fnc.mipforms_core.php';

//include mip_forms applications
require_once $cfg_path_dedi.'inc/fnc.mipforms_apps.php';

//include mip_forms extensions
require_once $cfg_path_dedi.'inc/fnc.mipforms_extensions.php';
} // End Fix

/**
* HAUPTFUNKTION
* Von hier aus werden alle mip_forms erzeugt.
*
*
* @Access public
* @Args array 	in['cat'] (Ordner)
*                ['type'] ('', 'chk', 'radio', 'long', 'chk_long', 'radio_long')
*                         (Ausnahme 'hidden')
*                ['desc'] (Beschreibung Ausnahme 'hidden')
*                ['cms_var'] (MOD_VAR[x])
*                ['cms_val'] (MOD_VALUE[x])
*                ['cms_val_default'] (optionaler defaultwert, falls ['cms_val'] leer)
*					  ['tab']  (Einrückung Ausnahme 'hidden')
*
*                NUR $in['type'] = 'chk', 'chk_long'
*                 ['chk_var'] (Checkboxvariable)
*                 ['chk_val'] (Checkboxwert  "1" für angeklickt)
*                 ['chk_val_default'] (optionaler defaultwert, falls ['chk_val'] leer)
*                NUR $in['type'] = 'radio', 'radio_long'
*                 ['radio_var'] (Radiovariable)
*                 ['radio_val'] (Wert der Radiovariable)
*                 ['radio_val_default'] (optionaler defaultwert, falls ['radio_val'] leer)
*                 ['radio_user_val'] (Radiouservariable, wenn gleich ['radio_val']
*                                    ist der Radiobutton aktiviert)
*                NUR $in['type'] = 'radio', 'option'
*                 ['option_desc']['x'] (Beschreibung einer Option)
*                 ['option_val']['x'] (MOD_VALUE[x] einer Option)
*                NUR $in['type'] = 'option'
*                 ['size'] (optional default ='1') (Größe des <select>- Tags)
*                 ['flag'] (optional) (Möglicher Wert = 'multiple', wenn ['size'] > 1)
*                NUR $in['cat'] = 'chk'
*                 ['option_var'][x] (cms_var[x] einer Checkbox)
*                 ['option_val']['x'] (cms_val[x] einer Checkbox)
*                 ['option_val_select']['x']
*                NUR $in['cat'] = 'txtarea'
*                 ['rows'] (optional, default = '5')(Textareahoehe in Textzeilen)
*                NUR $in['cat'] = 'app_css'
*                 ['output_cat'] ('option' oder 'radio')
*                 ['type'] ('', 'chk', 'radio', 'long' , 'chk_long', 'radio_long')
*                 ['file'] (optional)
*                 ['flag'] (optional)
*                NUR $in['cat'] = 'app_css_db'
*                 ['output_cat'] ('option' oder 'radio')
*                 ['type'] ('', 'chk', 'radio', 'long' , 'chk_long', 'radio_long')
*                 ['file'] id der Layout-Datei
*                 ['flag'] (optional)
* @Return mip-form
*/
function mip_forms($in, $_client = '', $_lang = '')
{
    global $mip_forms_to_array;
    //check for default values
	if($in['cms_val'] == ''){
		$in['cms_val'] = $in['cms_val_default'];
	}
	if($in['radio_val'] == ''){
		$in['radio_val'] = $in['radio_val_default'];
	}


	switch($in['cat'])
	{
		case 'desc':
			$to_return = mip_forms_desc($in);
			break;
		case 'txt':
			$to_return = mip_forms_txt($in);
			break;
		case 'txtarea':
			$to_return = mip_forms_txtarea($in);
			break;
		case 'option':
			$to_return = mip_forms_option($in);
			break;
		case 'chk':
			$to_return = mip_forms_chk($in);
			break;
		case 'radio':
			$to_return = mip_forms_radio($in);
			break;
		case 'hidden':
			$to_return = mip_forms_hidden($in);
			break;
		case 'app_css':
			$to_return = mip_forms_app_css($in);
			break;
		case 'app_cat':
			$to_return = mip_forms_app_cat($in, $_client, $_lang);
			break;
		case 'app_filetype':
			$to_return = mip_forms_app_filetype($in);
			break;
		case 'app_directory':
			$to_return = mip_forms_app_directory($in);
			break;
		case 'app_group':
			$to_return = mip_forms_app_group($in);
			break;
		case 'app_file':
			$to_return = mip_forms_app_file($in);
			break;
		default:
            if ($mip_forms_to_array === true) return false;
            else echo 'mip_forms - Fehler! $in[\'cat\'] = "'. $in['cat'] . '" existiert nicht!';exit;
	}

	return $to_return;

}

function mip_formsp($in)
{
    global $mip_forms_to_array;
    if ($mip_forms_to_array === true) return mip_forms($in);
    else echo mip_forms($in);
}

function mip_formta($in)
{
    mip_forms_ob_start();
	$to_return = mip_formsp($in);
	mip_forms_ob_end();
	return $to_return;
}

function mip_forms_get_array($form_var = 'to_array', $form_key = '')
{
    if (mip_forms_check_cache($form_var, $form_key)) return mip_forms_get_cache($form_var, $form_key);
}

function mip_forms_ob_start()
{
    global $mip_forms_to_array;
    ob_start();
    $mip_forms_to_array = true;
}

function mip_forms_ob_end()
{
    global $mip_forms_to_array;
    if($mip_forms_to_array === true) {
        ob_end_clean();
        $mip_forms_to_array = false;
    }
}

function mip_forms_ob_end_clean()
{
    global $mip_forms_to_array, $mip_forms_cache_container;
    if($mip_forms_to_array === true) {
        ob_end_clean();
        $mip_forms_to_array = false;
        $mip_forms_cache_container = false;
    }
}
?>