+function metaform() {
+ if(isset($_REQUEST['singular'])) {
+ $GLOBALS['file_name'] = format_varname($_REQUEST['file_name']);
+ $GLOBALS['table_name'] = format_varname($_REQUEST['table_name']);
+ $GLOBALS['plural'] = format_oneline($_REQUEST['plural']);
+ # backwards compatibility:
+ if(isset($_REQUEST['form_name'])) {
+ $GLOBALS['file_name'] = $GLOBALS['table_name'] = $GLOBALS['plural'] = format_varname($_REQUEST['form_name']);
+ }
+
+ $GLOBALS['singular'] = format_oneline($_REQUEST['singular']);
+ $GLOBALS['opt_email'] = format_bool($_REQUEST['opt_email']);
+ $GLOBALS['opt_db'] = format_bool($_REQUEST['opt_db']);
+ $GLOBALS['opt_listing'] = format_bool($_REQUEST['opt_listing']);
+ $GLOBALS['opt_display'] = format_bool($_REQUEST['opt_display']);
+ $GLOBALS['opt_pass'] = format_bool($_REQUEST['opt_pass']);
+ $GLOBALS['opt_public_form'] = format_bool($_REQUEST['opt_public_form']);
+ $GLOBALS['opt_public_display'] = format_bool($_REQUEST['opt_public_display']);
+
+ tem_init();
+ tem_set_globals($GLOBALS['wfpl_template']);
+ }
+
+ if(isset($_REQUEST['fields'])) {
+ if(isset($_REQUEST['view_sql'])) {
+ view_sql();
+ exit();
+ } elseif(isset($_REQUEST['view_php'])) {
+ view_php();
+ exit();
+ } elseif(isset($_REQUEST['view_html'])) {
+ view_html();
+ exit();
+ } elseif(isset($_REQUEST['view_email'])) {
+ view_email();
+ exit();
+ } elseif(isset($_REQUEST['download_tar'])) {
+ download_tar();
+ exit();
+ } elseif(isset($_REQUEST['preview'])) {
+ preview();
+ exit();
+ } elseif(isset($_REQUEST['edit'])) {
+ tem_set('fields', $_REQUEST['fields']);
+ # fall through
+ } else {
+ die("Sorry... couldn't tell which button you pressed");
+ }
+ }
+
+
+ set_form_action();
+ tem_load('code/wfpl/metaform/main.html');
+ list_available_types();
+ tem_output();
+}