<?php 
    # $Id: benchmarkInstance_SHOW.php,v 1.10 2007/01/14 15:09:31 jarda Exp $

    /* Page that shows contents of a benchmark instance
    */

    require_once('structuredPage.inc.php');

    class PageClass extends ViewStructuredPage {

        function checkEnvironment()
        {
            if (!$_GET['id'])
                return False;

            return True;
        }


        function handleInvalidEnvironment()
        {
            header("Location: index.php"); /* Redirect browser */
        }


        function getTitle()
        {
            return 'Benchmark instance information';
        }


        function printContents() {
            echo "<strong>Basic instance information:</strong><p>\n";
            
            $db = connect();

            $query = "SELECT benchmark.name AS name, benchmarkInstance.description AS instancedescription, " .
                "benchmark.description AS benchmarkdescription, format.name AS formatName, " .
                "benchmarkSet.name AS benchmarksetname, benchmarkSet.id AS benchmarksetid " .
                "FROM benchmarkInstance, benchmark, benchmarkSet, format " .
                "WHERE benchmarkInstance.id=$_GET[id] AND " .
                "benchmark.id = benchmarkInstance.benchmarkId AND " .
                "benchmarkSet.id = benchmarkInstance.benchmarkSetId AND " .
                "format.id = benchmarkInstance.formatId";
                
            $result = $db->Execute($query);
            
            $row = $result->FetchRow();
            
            echo("<table border=\"1\">\n");
            echo("    <tr><td>Benchmark name:</td><td>$row[name]</td></tr>\n");
            echo("    <tr><td>Format:</td><td>$row[formatname]</td></tr>\n");
            echo("    <tr><td>General description:</td><td>$row[benchmarkdescription]</td></tr>\n");
            echo("    <tr><td>Instance description:</td><td>$row[instancedescription]</td></tr>\n");
            echo("    <tr><td>Benchmark set:</td><td><a href=\"benchmarkSet_SHOW.php?id=$row[benchmarksetid]\">$row[benchmarksetname]</a></td></tr>\n");
            echo("</table>\n");
            echo("<p>\n");
            echo("<strong>Attributes:</strong>\n");
            echo("<p>\n");
            echo("<table border=\"1\">\n");
            
            $query = "SELECT attribute.name AS name, benchmarkInstanceAttribute.value AS value ".
                "FROM attribute, benchmarkInstanceAttribute ".
                "WHERE benchmarkInstanceAttribute.benchmarkInstanceId =$_GET[id] AND ".
                "benchmarkInstanceAttribute.attributeId = attribute.id";

            $result = $db->Execute($query);

            while ($row = $result->FetchRow()) {
                echo "<tr><td>$row[name]</td><td>$row[value]</td></tr>\n";
            }

            echo("</table>\n");
        }

    }

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