<?php
    # $Id: benchmarkSets_LISTING.php,v 1.11 2007/01/08 14:49:30 jarda Exp $

    /* Page that displays list of existing benchmark sets
    */

    require_once('structuredPage.inc.php');

    class PageClass extends ViewStructuredPage 
    {
        function getTitle()
        {
            return 'Benchmark sets listing';
        }

        
        function printContents() {
            $db = connect();

            $query = 'SELECT * FROM benchmarkSet ORDER BY name';
            $result = $db->Execute($query);

            print '<table border="1">';

            while ($row = $result->FetchRow()) {
                $this->addTableRow($row);
            }
            echo '</table><br />';

            if ($this->userCanEditDB()) {
                echo "<form action=\"benchmarkSet_NEW.php\" method=\"post\">\n";    
                echo "<input type=\"submit\" value=\"New set\" name=\"new\">";
                echo "</form>\n";
            }
        }

        
        /* Adds one row to the table of benchmark sets
        */
        function addTableRow($row)
        {
            echo "<tr><td><a href=\"benchmarkSet_SHOW.php?id=$row[id]\">$row[name]</a></td>";

            if ($this->userCanEditDB()) {
                echo "<td><a href=\"benchmarkSet_EDIT.php?id=$row[id]\">Edit</a></td>";
            }

            echo "<td><a href=\"benchmarkInstances_SEARCH.php?benchmarkSetId=$row[id]&search=OK\">Search instances</a></td>";
            echo "</tr>\n";
        }

    }
    
    launchPage();
    
    # vim:enc=iso8859-2:fenc=iso8859-2:
?>
