From 6b038bb1556e1b9790a49834817d0bdef530bfde Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Thu, 12 Feb 2009 22:13:20 -0500 Subject: [PATCH] metaform: default listing page now contains all non-huge failds --- metaform.php | 37 +++++++++++++++++++++++++++++++++---- metaform/template.html | 8 ++++++-- metaform/template.php | 6 +++--- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/metaform.php b/metaform.php index f89e720..06bb7dd 100644 --- a/metaform.php +++ b/metaform.php @@ -222,6 +222,7 @@ function make_html($whole_file = true) { if($input != 'hidden') { $tem->show('row'); } + if($input == 'image' && !$uploads_output_already) { $tem->show('uploads'); $tem->set('enctype_attr', '" enctype="multipart/form-data'); @@ -231,7 +232,8 @@ function make_html($whole_file = true) { $tem->set('html_field_name', $name); $tem->show('replace_textarea'); } - if($GLOBALS['opt_display']) { + + if($GLOBALS['opt_display'] == 'Yes') { switch($input) { case 'checkbox': case 'leftcheck': @@ -251,6 +253,16 @@ function make_html($whole_file = true) { } $tem->show('display_row'); } + + if($GLOBALS['opt_listing'] == 'Yes') { + if($GLOBALS['opt_display'] != 'Yes') { + $tem->show('opt_display_a_else'); + } + if(show_in_listing($type, $input, $format, $sql)) { + $tem->show('listing_head_col'); + $tem->show('listing_row_col'); + } + } } if($GLOBALS['opt_db'] == 'Yes') { @@ -261,9 +273,6 @@ function make_html($whole_file = true) { } if($GLOBALS['opt_listing'] == 'Yes') { - if($GLOBALS['opt_display'] != 'Yes') { - $tem->show('opt_display_a_else'); - } $tem->show('opt_listing_1'); } @@ -300,6 +309,19 @@ function view_html() { echo make_html(); } +function show_in_listing($type, $input, $format, $sql) { + switch($input) { + case 'submit': + case 'hidden': + case 'password': + case 'textarea': + case 'html': + return false; + default: + return true; + } +} + function make_php() { $tem = new tem(); @@ -341,6 +363,13 @@ function make_php() { } $tem->show('tem_sets'); } + + if($GLOBALS['opt_listing'] == 'Yes') { + if(show_in_listing($type, $input, $format, $sql)) { + $tem->show('listing_fields_1'); + $tem->show('listing_fields_2'); + } + } } $tem->set('always_field', $always_field); diff --git a/metaform/template.html b/metaform/template.html index de12f03..dbb1d8d 100644 --- a/metaform/template.html +++ b/metaform/template.html @@ -84,8 +84,12 @@

[Add a new ~singular~]

- - +
~~~always_field~.html~~[delete this ~singular~]
+ + + + +
~caption~
~~~name~.html~~[delete this ~singular~]
diff --git a/metaform/template.php b/metaform/template.php index be61e2f..b9c1097 100644 --- a/metaform/template.php +++ b/metaform/template.php @@ -62,7 +62,7 @@ function ~form_name~_tem_sets(~php_fields~) { # You may pass a "where clause" for the db query. function ~form_name~_display_listing($where = 'order by ~always_field~ limit 100') { - $rows = db_get_rows('~form_name~', 'id,~always_field~', $where); + $rows = db_get_rows('~form_name~', 'id,~name~', $where); if($rows == false || count($rows) == 0) { tem_show('empty_listing'); tem_show('listings'); @@ -70,12 +70,12 @@ function ~form_name~_display_listing($where = 'order by ~always_field~ limit 100 } foreach($rows as $row) { - list($id, $~always_field~) = $row; + list($id, $~name~) = $row; tem_set('id', $id); if($~always_field~ == '') { $~always_field~ = '--'; } - tem_set('~always_field~', $~always_field~); + ~form_name~_tem_sets(~php_fields~); tem_show('listing_row'); } tem_show('populated_listing'); -- 1.7.10.4