JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
db_printf()'s %s, dwt_append(), states pulldown, tem_top_subs()
[wfpl.git] / metaform.php
index 8263797..f5c71f2 100644 (file)
@@ -22,6 +22,7 @@
 # This file writes the code for you (sql, php, html, email) to handle a form.
 
 require_once('code/wfpl/template.php');
+require_once('code/wfpl/http.php');
 require_once('code/wfpl/tar.php');
 
 # see code/wfpl/metaform/template.html for the html templates for these elements
@@ -29,9 +30,11 @@ $GLOBALS['types'] = array(
 #    type                  input          format        sql     
        'name' =>       array('textbox',     'oneline',    'varchar(200)'),
        'textbox' =>    array('textbox',     'oneline',    'varchar(200)'),
-       'int' =>        array('textbox',     'int',        'varchar(100)'),
+       'int' =>        array('textbox',     'int',        'int'),
+       'bigint' =>     array('textbox',     'int',        'varchar(100)'), # up to 100 digits, stored as a string
        'email' =>      array('textbox',     'email',      'varchar(100)'),
        'phone' =>      array('textbox',     'phone',      'varchar(32)'),
+       'state' =>      array('states',      'oneline',    'varchar(2)'),
        'money' =>      array('textbox',     'money',      'varchar(32)'),
        'dollars' =>    array('textbox',     'dollars',    'varchar(32)'),
        'url' =>        array('textbox',     'url',        'varchar(200)'),
@@ -231,9 +234,19 @@ function make_php() {
        $tem->set('always_field', $always_field);
        $tem->set('db_fields', $db_fields);
        $tem->set('php_fields', $php_fields);
+       $tem->set('metaform_url', edit_url());
        return $tem->run();
 }
 
+# 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);
+       return $url;
+}
+
 function view_php() {
        view_headers();
        echo make_php();
@@ -249,7 +262,11 @@ function make_email() {
                list($name, $type, $input, $format, $sql) = $field;
                $tem->set('name', $name);
                $tem->set('caption', $name); # fixme
-               $tem->sub('fields');
+               if($type == 'textarea') {
+                       $tem->sub('multi_line');
+               } else {
+                       $tem->sub('fields');
+               }
        }
        return $tem->run();
 }