Web: Online demo report use now a table for the results

This commit is contained in:
Tim Gerundt 2012-06-02 15:38:33 +02:00
parent ca9acc7ede
commit a2b0f77310
2 changed files with 38 additions and 9 deletions

View File

@ -69,10 +69,11 @@
$parsed = array();
$xml = simplexml_load_string($output);
foreach ($xml->errors->error as $error) { //for all errors...
$severity = (string)$error->attributes()->severity;
$msg = (string)$error->attributes()->msg;
$line = (string)$error->location->attributes()->line;
if (!empty($msg) && !empty($line)) { //if complete error...
$parsed[$line][] = $msg;
if (!empty($severity) && !empty($msg) && !empty($line)) { //if complete error...
$parsed[] = array('severity' => $severity, 'msg' => $msg, 'line' => $line);
}
}
return $parsed;
@ -106,16 +107,23 @@
echo "<h3>Output</h3>\n";
$output = get_democlient_output($code);
$report = parse_democlient_output($output);
$results = parse_democlient_output($output);
echo "<dl>\n";
foreach ($report as $lineNumber => $results) { //for each line results...
echo " <dt>Line $lineNumber:</dt>\n";
foreach ($results as $result) { //for each results...
echo " <dd>" . htmlspecialchars($result) . "</dd>\n";
if (!empty($results)) {
echo "<table class=\"results\">\n";
echo "<thead>\n";
echo " <tr><th class=\"center\">Line</th><th class=\"center\">Severity</th><th>Message</th></tr>\n";
echo "</thead>\n";
echo "<tbody>\n";
foreach ($results as $result) { //for each result...
echo " <tr><td class=\"center\">" . htmlspecialchars($result['line']) . "</td><td class=\"center\">" . htmlspecialchars($result['severity']) . "</td><td>" . htmlspecialchars($result['msg']) . "</td></tr>\n";
}
echo "</tbody>\n";
echo "</table>\n";
}
else {
echo "<p>No errors found.</p>\n";
}
echo "</dl>\n";
}
else {
echo "<p>Use the <a href=\"/demo/\">online demo</a> page to create the report.</p>\n";

View File

@ -136,8 +136,29 @@ pre.code em {
border: 1px solid #e2e2e2;
}
/* Results table */
table.results {
border-collapse: collapse;
}
table.results th {
padding: .25em;
text-align: left;
background: #e2e2e2;
border: 1px solid #e2e2e2;
}
table.results td {
padding: .25em;
background: #f7f7f7;
border: 1px solid #e2e2e2;
}
table.results .center {
text-align: center;
}
/* Printing */
@media print {
#header { color: black; border-bottom: 1px solid black; }
#tabs { display: none; }
table.results th { background: white; border: 1px solid black; }
table.results td { background: white; border: 1px solid black; }
}