# HG changeset patch
# User Nathan Phillip Brink 
# Date 2011-02-01 20:38:50
# Node ID 91e09a37c85b10417372c0d2ad27d2dc33681865
# Parent  f046223bfea8a460cdbfbf83da53d03b87a70f7c
Fix up normaldotcom's saved_schedule box collapsing code so that the setup works with less than 4 saved schedules nicely.
diff --git a/inc/class.page.php b/inc/class.page.php
--- a/inc/class.page.php
+++ b/inc/class.page.php
@@ -276,29 +276,30 @@ class page
 
       $hidden = 'hidden';
       $numsaved = count($session['saved']);
-      $count = 0;
+      $count = $numsaved;
       $output = '';
 
-      foreach($session['saved'] as $key => $name) {
-	if($count == $numsaved - 4) {
-	  $hidden = '';
-	}
-        else {
+      foreach($session['saved'] as $key => $name)
+	{
+	  if($count <= 4)
+	    $hidden = '';
+
 	  $output =  ''  . PHP_EOL
-	           . '  #' . $key . ":" 
-	           . htmlentities($name)
-	           . ' edit'
-	           . ' delete'
-	           . ' 
' . PHP_EOL
-	           . '
' . PHP_EOL . $output;
-	  }
-          $count++;
+	    . '  #' . $key . ":" 
+	    . htmlentities($name)
+	    . ' edit'
+	    . ' delete'
+	    . ' 
' . PHP_EOL
+	    . '
' . PHP_EOL . $output;
+
+          $count --;
 	}
-	echo $output;
+      echo $output;
+      if ($numsaved > 4)
 	echo '' . PHP_EOL
-           . '' . PHP_EOL
-	   . '' . PHP_EOL;
-      }
+	  . '' . PHP_EOL;
+      echo '' . PHP_EOL;
+    }
   }
 
   /**