The buttonbar at the top of each page is now a fixed 'div' element
[gnucomo.git] / src / web / parameter_compare.php
index 9cc64bd..0755d80 100644 (file)
@@ -9,7 +9,7 @@
 ***********************
 **      FILE NAME      : parameter_compare.php
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.4 $
+**      VERSION NUMBER : $Revision: 1.7 $
 **
 **  DESCRIPTION      : 
 **
 ********************************
 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
 **      CREATION DATE   : Dec 04, 2002
-**      LAST UPDATE     : Feb 03, 2003
+**      LAST UPDATE     : Dec 03, 2003
 **      MODIFICATIONS   : 
 **************************************************************************/
 
 /*****************************
    $Log: parameter_compare.php,v $
-   Revision 1.4  2003-07-15 11:06:45  arjen
+   Revision 1.7  2007-11-21 14:38:06  arjen
+   The buttonbar at the top of each page is now a fixed 'div' element
+   instead of a framed page.
+   Contributed by Edwin Nadorp.
+
+   Revision 1.6  2003/12/03 08:03:28  arjen
+   Optionally show or hide removed parameters from the parameter
+   comparison page.
+
+   Revision 1.5  2003/08/14 10:31:57  arjen
+   BUGFIX: Removed parameters were somtimes shown on the wrong side
+   of the parameter difference page.
+
+   Revision 1.4  2003/07/15 11:06:45  arjen
    Removed parameters are displayed in a shaded style.
 
    Revision 1.3  2003/02/13 09:01:29  arjen
@@ -38,7 +51,7 @@
 
 ******************************/
 
-// RCSID = "$Id: parameter_compare.php,v 1.4 2003-07-15 11:06:45 arjen Exp $";
+// RCSID = "$Id: parameter_compare.php,v 1.7 2007-11-21 14:38:06 arjen Exp $";
 
 ini_set('include_path', '.:./classes:../phpclasses');
 
@@ -129,10 +142,12 @@ class param_diff extends page
    {
    if (!empty($_POST['oid']))
    {
-      $res = pg_exec($this->database, "SELECT objectid, objectname FROM object WHERE objectid=" . $_POST['oid']);
+      $res = pg_exec($this->database, "SELECT objectid, objectname FROM object
+                                       WHERE objectid=" . $_POST['oid']);
       $obj = pg_fetch_object($res, 0);
       echo "<h1>" . $_POST['class'] . " parameters for " . $obj->objectname;
-      $res = pg_exec($this->database, "SELECT objectid, objectname FROM object WHERE objectid=" . $_POST['compare_to']);
+      $res = pg_exec($this->database, "SELECT objectid, objectname FROM object
+                                       WHERE objectid=" . $_POST['compare_to']);
       $cmp_obj = pg_fetch_object($res, 0);
       echo " compared to " . $cmp_obj->objectname . "</h1><hr>";
 
@@ -144,14 +159,35 @@ class param_diff extends page
       echo "<tr><th colspan='2'>" . $obj->objectname . "</th>";
       echo "<th colspan='2'>" . $cmp_obj->objectname . "</th></tr>\n";
       echo "<tr><th>Name</th><th>Properties</th><th>Name</th><th>Propterties</th></tr>\n";
+
+      $hide_removed = true;
+      $hide_removed = empty($_POST['show_removed']) || $_POST['show_removed'] != 'on';
+
       $row = 0;
       while ($row < pg_numrows($res))
       {
-         $par = pg_fetch_object($res, $row);
-         $nextpar = 'false';
-         if ($row + 1 < pg_numrows($res))
+         //   Find the next two parameters, optionally skipping removed parameters.
+
+         $par = false;
+         while (!$par && $row < pg_numrows($res))
          {
-            $nextpar = pg_fetch_object($res, $row + 1);
+            $par = pg_fetch_object($res, $row);
+            if ($hide_removed && $this->is_removed($par->paramid))
+            {
+               $par = false;
+               $row++;
+            }
+         }
+         $nextpar = false;
+         $nextrow = $row + 1;
+         while (!$nextpar && $nextrow < pg_numrows($res))
+         {
+            $nextpar = pg_fetch_object($res, $nextrow);
+            if ($hide_removed && $this->is_removed($nextpar->paramid))
+            {
+               $nextpar = false;
+               $nextrow++;
+            }
          }
          echo "<tr>";
 
@@ -164,24 +200,24 @@ class param_diff extends page
             $prnext = param_properties($this->database, $nextpar->paramid);
             if (property_compare($pr, $prnext))
             {
-               display_parameter($par->name, $pr, "", $this->is_removed($par->paramid));
-               display_parameter($nextpar->name, $prnext, "", $this->is_removed($nextpar->paramid));
+               $Style = "";
+            }
+            else
+            {
+               $Style = "both";
+            }
+            // We want the parameters of $obj on the left, so we need
+            // to swap the left and right sides if appropriate.
+
+            if ($par->objectid == $obj->objectid)
+            {
+               display_parameter($par->name, $pr, $Style, $this->is_removed($par->paramid));
+               display_parameter($nextpar->name, $prnext, $Style, $this->is_removed($nextpar->paramid));
             }
             else
             {
-               // We want the parameters of $obj on the left, so we need
-               // to swap the left and right sides if appropriate.
-
-               if ($par->objectid == $obj->objectid)
-               {
-                  display_parameter($par->name, $pr, "both", $this->is_removed($par->paramid));
-                  display_parameter($nextpar->name, $prnext, "both", $this->is_removed($nextpar->paramid));
-               }
-               else
-               {
-                  display_parameter($nextpar->name, $prnext, "both", $this->is_removed($nextpar->paramid));
-                  display_parameter($par->name, $pr, "both", $this->is_removed($par->paramid));
-               }
+               display_parameter($nextpar->name, $prnext, $Style, $this->is_removed($nextpar->paramid));
+               display_parameter($par->name, $pr, $Style, $this->is_removed($par->paramid));
             }
          }
          else