bugfix: the slice page was broken when nobody is in slice
[plewww.git] / plekit / php / table.php
index 0a21c40..2257d88 100644 (file)
@@ -280,15 +280,27 @@ EOF;
   // (*) hfill
   // (*) align
   public function cell ($text,$options=NULL) { print $this->cell_html ($text,$options); }
-  public function cell_html ($text,$options=NULL) {
+  public function cell_html ($text, $options=NULL) {
     if (isset ($options['only-if']) && ! $options['only-if'] )
-      $text="n/a";
-    $html="";
+      $text = "n/a";
+    $html = "";
     $html .= "<td";
-    $option=$options['class']; if ($option) $html .= " class='$option'";
-    $option=$options['columns'];if ($option) $html .= " colspan='$option'";
-    $option=$options['hfill']; if ($option) $html .= " colspan='" . $this->columns() . "'";
-    $option=$options['align']; if ($option) $html .= " style='text-align:$option'";
+    // xxx this should not happen, but we see it sometimes - ignoring for now
+    if ($options && ! is_array($options)) {
+      //print_r("<br>options=");
+      //var_dump($options);
+    }
+  if ($options && is_array($options)) {
+      $option = get_array($options, 'class');
+      if ($option)
+        $html .= " class='$option'";
+      $option = get_array($options, 'columns');
+        if ($option) $html .= " colspan='$option'";
+      $option = get_array($options, 'hfill');
+        if ($option) $html .= " colspan='" . $this->columns() . "'";
+      $option = get_array($options, 'align');
+        if ($option) $html .= " style='text-align:$option'";
+    }
     $html .= ">$text</td>";
     return $html;
   }