JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
metaform sets main_body for site-wide template integration, and defaults to 'empty...
authorjason <jason@lappy.(none)>
Thu, 29 May 2008 03:57:25 +0000 (23:57 -0400)
committerjason <jason@lappy.(none)>
Thu, 29 May 2008 03:57:25 +0000 (23:57 -0400)
metaform.php
metaform/template.html
metaform/template.php
time.php

index c4d83a0..63c1c6e 100644 (file)
@@ -321,10 +321,8 @@ function make_php() {
        if($GLOBALS['opt_listing'] == 'Yes') {
                $tem->show('opt_listing_1');
                $tem->show('opt_listing_2');
-               $tem->show('opt_listing_3');
                $tem->show('opt_listing_4');
        } else {
-               $tem->show('opt_listing_3_else');
                $tem->show('opt_listing_4_else');
        }
        if($GLOBALS['opt_db'] == 'Yes') {
index b739c41..abd0a18 100644 (file)
@@ -32,6 +32,8 @@
 </head>
 
 <body>
+  <!--~~main_body start~~-->
+
   <!--~~message_container start~~-->
        <div style="border: 2px solid red; background: #fbb; padding: 5px; margin: 20px 0px">
        <!--~~message_box start~~-->
 <!--~opt_listing_1 start~--><!--~~listings start~~-->
   <h2>~form_name~ Listing</h2>
 
+  <!--~~populated_listing start~~-->
+  <p><a href="~form_name~.html?~form_name~_new=1">[Add a new record]</a></p>
+
   <table cellspacing="0" cellpadding="4" border="1" summary=""><!--~~listing_row start~~-->
   <tr><td class="listing"><a href="~form_name~.html?~form_name~_edit_id=~~id~~">~~~always_field~.html~~</a></td><td><a href="~form_name~.html?~form_name~_delete_id=~~id~~" onclick="return confirm('Permanently delete?')">[delete this record]</a></td></tr><!--~~end~~-->
 
   </table>
+  <!--~~end~~-->
+  <!--~~empty_listing start~~-->
+    <p>No ~~field_plural.html~~ in database.</p>
+  <!--~~end~~-->
 
   <p><a href="~form_name~.html?~form_name~_new=1">[Add a new record]</a></p>
 <!--~~end~~--><!--~end~--><!--~opt_listing_1_else start~-->
 <!--~~thankyou start~~-->
   <p>Thank you for taking the time to fill out this form.</p>
 <!--~~end~~--><!--~end~-->
+
+<!--~~end~~-->
 </body>
 </html>
index fcbbc36..e62b1d7 100644 (file)
@@ -45,7 +45,7 @@ function ~form_name~_get_fields() {<!--~formats start~-->
                $~name~ = substr(save_uploaded_image('~name~', $GLOBALS['upload_directory']), strlen($GLOBALS['upload_directory']));
        } else {
                if($_REQUEST['delete_~name~'] == 'Yes') {
-                       $name = '';
+                       $~name~ = '';
                } else {
                        $~name~ = format_filename($_REQUEST['old_~name~']);
                }
@@ -64,6 +64,8 @@ function ~form_name~_tem_sets(~php_fields~) {<!--~tem_sets start~-->
 function ~form_name~_display_listing($where = 'order by ~always_field~ limit 100') {
        $rows = db_get_rows('~form_name~', 'id,~always_field~', $where);
        if($rows == false || count($rows) == 0) {
+               tem_show('empty_listing');
+               tem_show('listings');
                return false;
        }
 
@@ -76,6 +78,7 @@ function ~form_name~_display_listing($where = 'order by ~always_field~ limit 100
                tem_set('~always_field~', $~always_field~);
                tem_show('listing_row');
        }
+       tem_show('populated_listing');
        tem_show('listings');
        return true;
 }
@@ -85,7 +88,7 @@ function ~form_name~_main() {
        if($ret) {
                return $ret;
        }
-       display_messages();
+       tem_show('main_body');
 }
 
 function _~form_name~_main() {<!--~opt_http_pass_2 start~-->
@@ -111,22 +114,15 @@ function _~form_name~_main() {<!--~opt_http_pass_2 start~-->
        unset($_REQUEST['~form_name~_delete_id']);
        if($delete_id) {
                db_delete('~form_name~', 'where id=%i', $delete_id);
-               message('Entry deleted.');<!--~opt_listing_3 start~-->
+               message('Entry deleted.');
 
-               if(~form_name~_display_listing()) {
-                       return;
-               }
-               unset($delete_id);<!--~end~--><!--~opt_listing_3_else start~-->
-
-               # FIXME: what to do after delete?
-               return;<!--~end~-->
+               return './~form_name~.html';
        }
 
        if(!$edit_id) {<!--~opt_listing_1 start~-->
                if(!isset($_REQUEST['~form_name~_new']) && !isset($_REQUEST['~always_field~'])) {
-                       if(~form_name~_display_listing()) {
-                               return;
-                       }
+                       ~form_name~_display_listing();
+                       return;
                }
                <!--~end~-->
                tem_show('new_msg');
index a3bc761..007d4b9 100644 (file)
--- a/time.php
+++ b/time.php
@@ -73,7 +73,7 @@ function clean_ymd($year, $month, $day) {
        return array($year, $month, $day);
 }
 
-# convert date string from mm/dd/yyyy to yyy-mm-dd
+# convert date string from mm/dd/yyyy to yyyy-mm-dd
 function mdy_to_ymd($date) {
        $date = ereg_replace('[^0-9/-]', '', $date);
        $date = ereg_replace('-', '/', $date);