Module: appdb Branch: master Commit: 5c6b3bb45ede3a31b0c388dd5decb3bb2b1ebb66 URL: http://source.winehq.org/git/appdb.git/?a=commit;h=5c6b3bb45ede3a31b0c388dd5...
Author: Alexander Nicolaysen Sørnes alex@thehandofagony.com Date: Sun Nov 4 23:09:12 2007 +0100
version: Properly handle missing test results
---
application.css | 6 ++++++ include/html.php | 14 ++++++++++++++ include/version.php | 45 ++++++++++++++++++++++++++++++++++----------- 3 files changed, 54 insertions(+), 11 deletions(-)
diff --git a/application.css b/application.css index 15b99dc..0746379 100644 --- a/application.css +++ b/application.css @@ -63,6 +63,12 @@ div.info_contents { padding:10px; background-color: #eee; } div.title_class { font-weight: bold; border-bottom: 1px solid; padding: 4px; font-size: 140%; background-color: #ddd; }
+/* Classes for a note box */ +div.note_container { margin:6px; border: 1px solid; } +div.note_body { padding: 10px; background-color: #ffe732; } +div.note_title { font-weight: bold; border-bottom: 1px solid; padding: 4px; + font-size: 140%; background-color: #ffc004; } + /* classes for the main page */ div.rating_header { padding: 8px; } div.rating_title { padding-bottom: 4px; font-weight: bold; font-size: 160%; } diff --git a/include/html.php b/include/html.php index e8cdfdb..b0aa6c8 100644 --- a/include/html.php +++ b/include/html.php @@ -286,4 +286,18 @@ function make_inx_option_list($varname, $inx = null)
}
+/* Displays a note box */ +function html_note($shTitle, $shBody) +{ + $shRet = '<div class="note_container">'; + $shRet .= '<div class="note_title">'; + $shRet .= $shTitle; + $shRet .= '</div>'; + $shRet .= '<div class="note_body">'; + $shRet .= $shBody; + $shRet .= '</div></div>'; + + return $shRet; +} + ?> diff --git a/include/version.php b/include/version.php index 3b9bd2f..ea8c121 100644 --- a/include/version.php +++ b/include/version.php @@ -987,11 +987,7 @@ class version {
////////////////////// // Show test data - echo "<div class='info_container'>\n";
- echo "\t<div class='title_class'>\n"; - echo "\t\tSelected test results <small><small>(selected in 'Test Results' table below)</small></small>\n"; - echo "\t</div>\n";
/* Set if the use chose to display a particular test report */ if($iTestingId) @@ -999,18 +995,45 @@ class version { else if($this->iVersionId) /* Let's query for the latest rest report */ { $iTestingId = testData::getNewestTestIdFromVersionId($this->iVersionId); - $oTest = new testData($iTestingId); + + if($iTestingId) /* We want all entries to have test data, but old versions might lack + it, or data may have been deleted */ + $oTest = new testData($iTestingId); } else /* Perhaps we have a cached entry? There should be */ { $aTests = $this->getTestResults(); - $oTest = $aTests[0]; + + if(sizeof($aTests)) /* ... but we cannot be certain */ + $oTest = $aTests[0]; }
- echo "<div class='info_contents'>\n"; - $oTest->ShowTestResult(); - echo "</div>\n"; + if($oTest) + { + echo "<div class='info_container'>\n";
- echo "</div>\n"; // end the 'info_container' div + echo "\t<div class='title_class'>\n"; + echo "\t\tSelected test results <small><small>(selected in 'Test Results' table below)</small></small>\n"; + echo "\t</div>\n"; + + echo "<div class='info_contents'>\n"; + + $oTest->ShowTestResult(); + + echo "</div>\n"; + + echo "</div>\n"; + } else /* Show a note saying that no test results are present, + and encourage the user to take action */ + { + echo html_note('No Test Results', + 'This version has no test results, please consider submitting some.<br />'. + 'They may be part of the '. + 'version or application description. If they are, please '. + 'consider becoming a maintainer and remove them, submitting '. + 'a proper test report instead.'); + } + + // end the 'info_container' div // end show test data /////////////////////
@@ -1020,7 +1043,7 @@ class version { if($oTest->iTestingId) { $oTest->ShowVersionsTestingTable($this->objectMakeUrl()."&iTestingId=", 5); - } else /* We are previewing the version */ + } else if($oTest) /* We are previewing the version */ { $oTable = $oTest->CreateTestTable(); $oTable->AddRow($oTest->CreateTestTableRow(0, ""));