Fix a bug with empty actions column when browsing data
authorJehan-Guillaume (ioguix) de Rorthais <ioguix@free.fr>
Tue, 11 Sep 2012 13:23:43 +0000 (15:23 +0200)
committerJehan-Guillaume (ioguix) de Rorthais <ioguix@free.fr>
Tue, 11 Sep 2012 13:23:43 +0000 (15:23 +0200)
When no action is allowed (eg. when GuiControl removes them) on the
browsing page (display.php), the "action" header was still showed, but
not its data column, leading to a difference between the number of header
columns and data columns.

This bug was raised by Julien Rouhaud (rjuju). This patch is based on
his work (some cleanup).

display.php

index 5551500a669da374e5496f902cfa243e8fc24efa..82c95aff21c579b6bbba187c658f8f0a3299fba3 100644 (file)
                                );
                        }
 
-                       $edit_params = $actions['actionbuttons']['edit'];
-                       $delete_params = $actions['actionbuttons']['delete'];
+                       $edit_params = isset($actions['actionbuttons']['edit'])?
+                               $actions['actionbuttons']['edit']:array();
+                       $delete_params = isset($actions['actionbuttons']['delete'])?
+                               $actions['actionbuttons']['delete']:array();
 
                        // Display edit and delete actions if we have a key
                        $colspan = count($buttons);
-                       if (sizeof($key) > 0)
+                       if ($colspan > 0)
                                echo "<th colspan=\"{$colspan}\" class=\"data\">{$lang['stractions']}</th>\n";
 
                        /* we show OIDs only if we are in TABLE or SELECT type browsing */
                                $id = (($i % 2) == 0 ? '1' : '2');
                                echo "<tr class=\"data{$id}\">\n";
                                // Display edit and delete links if we have a key
-                               if (sizeof($key) > 0) {
+                               if ($colspan > 0 and count($key) > 0) {
                                        $keys_array = array();
                                        $has_nulls = false;
                                        foreach ($key as $v) {