JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
delete string_array.php (buggy, stupid)
[wfpl.git] / metaform.php
index ad980a6..a0dce78 100644 (file)
@@ -23,7 +23,7 @@ require_once(__DIR__.'/'.'http.php');
 require_once(__DIR__.'/'.'tar.php');
 require_once(__DIR__.'/'.'format.php');
 
-# see code/wfpl/metaform/template.html for the html templates for these elements
+# see wfpl/metaform/template.html for the html templates for these elements
 $GLOBALS['types'] = array(
 #    type                  input          format        sql     
        'varname' =>    array('textbox',     'varname',    'varchar(50) binary'),
@@ -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;
@@ -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') {
@@ -530,7 +555,6 @@ function edit_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.
        return $url;
 }
 
@@ -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" => "<?php\n\nrequire_once(__DIR__.'/'.'inc/wfpl/main.php');\nmetaform_main();\n",
+               "config.php" => "<?php\n\n# put your site-wide configuration here\n",
+               "wfpl_main.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(),