JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
metaform: default listing page now contains all non-huge failds
authorJason Woofenden <jason283@herkamire.com>
Fri, 13 Feb 2009 03:13:20 +0000 (22:13 -0500)
committerJason Woofenden <jason283@herkamire.com>
Fri, 13 Feb 2009 03:13:20 +0000 (22:13 -0500)
metaform.php
metaform/template.html
metaform/template.php

index f89e720..06bb7dd 100644 (file)
@@ -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);
index de12f03..dbb1d8d 100644 (file)
   <!--~~populated_listing start~~-->
   <p><a href="~form_name~?~form_name~_new=1">[Add a new ~singular~]</a></p>
 
-  <table cellspacing="0" cellpadding="4" border="1" summary=""><!--~~listing_row start~~-->
-  <tr><td class="listing"><a href="~form_name~?~form_name~_<!--~opt_display_a_else start~-->edit_<!--~end~-->id=~~id~~">~~~always_field~.html~~</a></td><td><a href="~form_name~?~form_name~_delete_id=~~id~~" onclick="return confirm('Permanently delete?')">[delete this ~singular~]</a></td></tr><!--~~end~~-->
+  <table cellspacing="0" cellpadding="4" border="1" summary="">
+    <!--~listing_head_col start~--><th>~caption~</th><!--~end~--><th></th><!--~~listing_row start~~-->
+    <tr><!--~listing_row_col start~-->
+      <td class="listing"><a href="~form_name~?~form_name~_<!--~opt_display_a_else start~-->edit_<!--~end~-->id=~~id~~">~~~name~.html~~</a></td><!--~end~-->
+      <td><a href="~form_name~?~form_name~_delete_id=~~id~~" onclick="return confirm('Permanently delete?')">[delete this ~singular~]</a></td>
+    </tr><!--~~end~~-->
 
   </table>
   <!--~~end~~-->
index be61e2f..b9c1097 100644 (file)
@@ -62,7 +62,7 @@ function ~form_name~_tem_sets(~php_fields~) {<!--~tem_sets start~-->
 <!--~opt_listing_2 start~-->
 # 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<!--~listing_fields_1 start~-->,~name~<!--~end~-->', $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<!--~listing_fields_2 start~-->, $~name~<!--~end~-->) = $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');