<?php
////////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 2007 World Wide Web Consortium, 
//  (Massachusetts Institute of Technology, European Research 
//  Consortium for Informatics and Mathematics, Keio 
//  University). All Rights Reserved. 
//  Copyright © 2008 Hewlett-Packard Development Company, L.P. 
// 
//  This work is distributed under the W3CĀ Software License 
//  [1] in the hope that it will be useful, but WITHOUT ANY 
//  WARRANTY; without even the implied warranty of 
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
// 
//  [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 
//
//////////////////////////////////////////////////////////////////////////////// 

//////////////////////////////////////////////////////////////////////////////// 
//
//  results.php
//
//  Adapted from Mobile Test Harness [1]
//
//    File: results.php
//      Lines: 30-73
//
//  where herein specific contents provided by the original harness have
//  been adapted for CSS2.1 conformance testing.
//
//  Currently, this file represents a place holder for a work in progress.
//  Additional requested functionality includes the following:
//
//  1) Interface controls for generating reports based on various parameters.
//     URLs to these reports should be short and clean so they can be passed
//     around in blogs/IM/email etc.
//
//  2) Report pass/fail scores for the whole test suite with various cross
//     tabulations and consolidations.
//
//  3) Report consolidated results for various user agent strings under
//     one category name. E.g. consolidate results for all UA strings that
//     represent Opera 9.25 Beta 1 regardless of OS and localization.
//
//  4) Report consolidated pass/fail scores for individual named groups
//     of tests.
//
//  5) Prettier reports.
//
// [1] http://dev.w3.org/cvsweb/2007/mobile-test-harness/
//
//////////////////////////////////////////////////////////////////////////////// 

require_once("./lib_css2.1_harness/class.css_page.phi");
require_once("./lib_css2.1_harness/class.test_results.phi");

////////////////////////////////////////////////////////////////////////////////
//
//  class results_page
//
//  A class for generating the page for inspecting and entering data for
//  individual tests.
//
////////////////////////////////////////////////////////////////////////////////
class results_page extends css_page
{  
  ////////////////////////////////////////////////////////////////////////////
  //
  //  Instance variables.
  //
  ////////////////////////////////////////////////////////////////////////////
  var $m_results_table;

  ////////////////////////////////////////////////////////////////////////////
  //
  //  Constructor.
  //
  //  The URL accessing the page generated by an object of this class must
  //  identify a valid testsuite:
  //
  //    results.php?s=[testsuite]
  //
  //  If no test suite is identified or if the identified test suite is
  //  not valid, then an error is generated.
  //
  //  The URL accessing the page generated by an object of this class may
  //  also identify either implicitly or explicitly a particular test
  //  case or group of test cases within which to confine the generated
  //  report.
  //
  //     results.php?s=[testsuite]&c=[testcase]
  //     results.php?s=[testsuite]&g=[testgroup]
  //
  //  A modifier can be provided specifying that the order of reported 
  //  results is sorted by ascending number of responses available for
  //  listed tests. 
  //
  //     results.php?s=[testsuite]&g=[testgroup]&o=1
  //
  //  A timestamp can also be provided such that the reported results
  //  include only those responses obtained on or before the provided
  //  timestamp.
  //
  //     results.php?s=[testsuite]&g=[testgroup]&m=[timestamp]
  //
  //  If modifiers are not provided, default values are assumed. These
  //  default values can also be provided explicitly.
  //
  //  Finally, The URL accessing the page generated by an object of this 
  //  class may also identify other parameters controling report formating,
  //  data consolidation, and desired cross tabluations. These parameters
  //  are currently in development for implementing the functionalities 
  //  described above.
  //
  //  All other URL parameters are ignored.
  //
  ////////////////////////////////////////////////////////////////////////////
  function results_page() 
  {
    parent::css_page();

    $this->m_page_title = 'CSS 2.1 Conformance Testing Results';
    
    $this->m_content_title = 'Test Results for CSS 2.1 Conformance Testing';

    // $this->m_resource_id 
    //   = '$Id: results.php,v 1.4 2008-09-03 18:54:02 dberfang Exp $';    

    if(isset($_GET['s'])) {
      $suite = $_GET['s'];
    } else {
      $msg = 'No test suite identified.';
      $this->trigger_client_error($msg, E_USER_ERROR);
    }

    if( isset($_GET['c']) ) {
      $select = $_GET['c'];
      $type = 2;
    } elseif ( isset($_GET['g']) ) {
      $select = $_GET['g'];
      $type = 1;
    } else {
      $select = null;
      $type = 0;
    }

    if(isset($_GET['o'])) {
      $order = $_GET['o'];
    } else {
      $order = 0;
    }

    if(isset($_GET['m'])) {
      $modified = $_GET['m'];
    } else {
      $modified = null;
    }

    if(isset($_GET['x'])) {
      $grouping = $_GET['x'];
    } else {
      $grouping = null;
    }

    if(isset($_GET['b'])) {
      $browser = $_GET['b'];
    } else {
      $browser = null;
    }

    if(isset($_GET['v'])) {
      $version = $_GET['v'];
    } else {
      $version = null;
    }

    if(isset($_GET['p'])) {
      $platform = $_GET['p'];
    } else {
      $platform = null;
    }

    $this->m_results_table = new test_results
      ( $suite
      , $select
      , $type
      , $browser
      , $version
      , $platform
      , $grouping
      , $modified
      , $order
      );

  }
  
  ////////////////////////////////////////////////////////////////////////////
  //
  // write_body_content()
  //
  ////////////////////////////////////////////////////////////////////////////
  function write_body_content($indent = '')
  {
    $this->m_results_table->write($indent);
  }
}

$page = new results_page();
$page -> write();

?>
