X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl.git;a=blobdiff_plain;f=metaform.php;h=f8112aacb0679f8a3c824b153170c9a0c87bb39f;hp=9f67385271ff1a58651842353220cc146a42ff1f;hb=062d46e16429f2e55573567518cb01c83b319ac4;hpb=fe9a487e1b5ed0700481aee4609055dc6c47505d diff --git a/metaform.php b/metaform.php index 9f67385..f8112aa 100644 --- a/metaform.php +++ b/metaform.php @@ -175,13 +175,24 @@ function get_fields() { $fields_str = rtrim($fields_str); $fields = split("\n", $fields_str); foreach($fields as $field) { + $first_char = substr($field, 0, 1); $field = trim($field); + if ($first_char === ' ' || $first_char === "\t") { + $i = count($GLOBALS['gotten_fields']); + if($i > 0) { + $i -= 1; + if (!$GLOBALS['gotten_fields'][$i]['options']) { + $GLOBALS['gotten_fields'][$i]['options'] = array(); + } + $GLOBALS['gotten_fields'][$i]['options'][] = $field; + continue; + } + } if(substr($field, -1) == '{') { $caption = trim(substr($field, 0, -1)); $name = format_varname($caption); $type = '{'; $options = null; - # FIXME restore parsing of option lists for pulldowns } else { $options = null; $type = null; @@ -240,7 +251,7 @@ function get_fields() { # this one, that you're using to create forms function set_form_action() { - $action = ereg_replace('.*/', '', $_SERVER['REQUEST_URI']); + $action = preg_replace('|.*/|', '', $_SERVER['REQUEST_URI']); if($action == '') $action = './'; tem_set('form_action', $action); } @@ -317,6 +328,20 @@ function make_html($whole_file = true) { 'caption' => $field['caption'] ) ); + if($field['type'] == 'radio') { + $i = 0; + $opts = array(); + foreach ($field['options'] as $row) { + if (is_array($row)) { + $cap = $row[1]; + } else { + $cap = $row; + } + $opts[] = array('i' => $i, 'option_caption' => $cap); + $i += 1; + } + $visible_fields[count($visible_fields) - 1]['options'] = $opts; + } } if($field['input'] == 'image' || $field['input'] == 'file') { @@ -527,10 +552,9 @@ function make_php() { # make a URL for the edit page with all the fields filled in function edit_url() { $url = this_url(); - $url = ereg_replace('view_php=[^&]*', 'edit=yes', $url); - $url = ereg_replace('download_tar=[^&]*', 'edit=yes', $url); - $url = ereg_replace('/[a-z0-9_.]*\?', '/?', $url); - $url = str_replace('jasonwoof.l', 'jasonwoof.com', $url); # so that code generated on Jason's home computer will display a publically accessible link. + $url = preg_replace('|view_php=[^&]*|', 'edit=yes', $url); + $url = preg_replace('|download_tar=[^&]*|', 'edit=yes', $url); + $url = preg_replace('|/[a-z0-9_.]*\?|', '/?', $url); return $url; } @@ -587,7 +611,7 @@ function preview() { } $preview = $preview_tem->run(); unset($preview_tem); - $preview = ereg_replace('type="submit"', 'type="submit" disabled="disabled"', $preview); + $preview = preg_replace('|type="submit"|', 'type="submit" disabled="disabled"', $preview); tem_set('preview', $preview); tem_show('hiddens'); set_form_action(); @@ -598,9 +622,10 @@ function download_tar() { $admin_name = $GLOBALS['file_name']; $nice_name = $GLOBALS['public_file_name']; $files = array( - "INSTALL" => read_whole_file(__DIR__.'/'.'metaform/INSTALL'), + "README" => "These files are meant to work with wfpl.\n\nSee: http://sametwice.com/wfpl\n", ".htaccess" => make_htaccess(), - "config.php" => " " read_whole_file(__DIR__.'/'.'metaform/wfpl_main.php'), "styl.styl" => read_whole_file(__DIR__.'/'.'metaform/styl.styl'), "template.html" => read_whole_file(__DIR__.'/'.'metaform/site-template.html'), "$admin_name.html" => make_html(),