JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
silenced warning when evenodd called with no data
[wfpl.git] / template.php
index 4480391..44db726 100644 (file)
@@ -279,7 +279,7 @@ function merge_templates($main, $tem) {
 #      <!--~rows {~-->
 #              <!--~row {~-->
 #                      row content...
-#                      <!--~separator sep {~--><hr><!--~}"-->
+#                      <!--~separator sep {~--><hr><!--~}~-->
 #              <!--~}~-->
 #      <!--~}~-->
 #
@@ -290,7 +290,7 @@ function tem_auto_sep(&$value, $key, $context) {
 }
 
 # 'show' sections will be shown unless the corresponding data value
-# is false.  We check only for false; 0 or '' will not work.
+# is false (only false, not 0 or '' or array()).
 
 function tem_auto_show(&$value) {
        if($value !== false) $value = array(array());
@@ -301,8 +301,8 @@ function tem_auto_show(&$value) {
 # alternates between 'even' and 'odd'.
 
 function tem_auto_evenodd(&$values) {
-       $even = false;
-       foreach($values as &$value) {
+       $even = true;
+       if($values) foreach($values as &$value) {
                $value['evenodd'] = $even ? 'even' : 'odd';
                $even = !$even;
        }
@@ -349,6 +349,7 @@ function &tem_is_old_sub($name, &$template) {
                        if($tem) return $tem;
                }
        }
+       return false;
 }
 
 class tem {
@@ -382,7 +383,9 @@ class tem {
 
        function show($name) {
                $tem = tem_is_old_sub($name, $this->template);
-               $this->data[$name] .= fill_template($tem, $this->data);
+               if($tem) {
+                       $this->data[$name] .= fill_template($tem, $this->data);
+               }
        }
 
        function show_separated($name) {