2008-02-15 19:05:09 +00:00
|
|
|
<?php
|
|
|
|
class HTMLOutput extends OutputModule {
|
|
|
|
function write( $filename ) {
|
|
|
|
global $faults, $files;
|
|
|
|
$output = fopen( $filename, 'w' );
|
|
|
|
if( $output === false ) {
|
|
|
|
err( "Cannot write to $filename\n" );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
fwrite( $output,
|
|
|
|
'<html>
|
|
|
|
<head>
|
|
|
|
<title>Code Scanner Output</title>
|
|
|
|
<style type="text/css">
|
|
|
|
.fault {
|
|
|
|
padding: 5px;
|
|
|
|
margin-bottom: 5px;
|
|
|
|
border-style: solid;
|
|
|
|
border-width: 1px;
|
|
|
|
}
|
|
|
|
.fault.level_0 {
|
|
|
|
color: #3f1c00;
|
|
|
|
background-color: #cf5c00;
|
|
|
|
border-color: #8f4000;
|
|
|
|
}
|
|
|
|
.fault.level_1 {
|
|
|
|
color: #3f0000;
|
|
|
|
background-color: #cf0000;
|
|
|
|
border-color: #8f0000;
|
|
|
|
}
|
|
|
|
.fault.level_2 {
|
|
|
|
color: #eee;
|
|
|
|
background-color: #333;
|
|
|
|
border-color: #999;
|
|
|
|
}
|
|
|
|
.fault dt {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
.fault code {
|
|
|
|
color: #000;
|
|
|
|
display: block;
|
|
|
|
margin-left: 10px;
|
|
|
|
border: 1px dashed #999;
|
|
|
|
background-color: #eee;
|
|
|
|
padding: 5px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<script type="text/javascript">
|
|
|
|
function toggleDisplay( id ) {
|
|
|
|
var e = document.getElementById( "info_" + id );
|
|
|
|
if( e.style.display == "none" ) {
|
|
|
|
e.style.display = "block";
|
|
|
|
} else {
|
|
|
|
e.style.display = "none";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>Code Scanner Output</h1>
|
|
|
|
<h2>Summary</h2>
|
|
|
|
<p>Found ' . count( $faults ) . ' faults in ' . count( $files ) . ' files</p>
|
|
|
|
<h2>Faults by file</h2>
|
|
|
|
<dl>'
|
|
|
|
);
|
|
|
|
$current_file = '';
|
|
|
|
foreach( $faults as $id => $fault ) {
|
|
|
|
if( $current_file != $fault['object']['file'] ) {
|
|
|
|
if( $current_file != '' ) {
|
|
|
|
fwrite( $output, '</ul></dd>' );
|
|
|
|
}
|
|
|
|
$current_file = $fault['object']['file'];
|
|
|
|
fwrite( $output, "<dt>$current_file</dt><dd><ul>" );
|
|
|
|
}
|
|
|
|
fprintf( $output,
|
|
|
|
'<li>
|
|
|
|
<dl class="fault level_%s">
|
|
|
|
<dt onclick="toggleDisplay( ' . $id . ')"><strong>%s:</strong> <span class="reason">%s</span></dt>
|
|
|
|
<dd id="info_' . $id . '" style="display: none;">
|
|
|
|
<strong>Line:</strong> <span class="line">%d</span><br />
|
|
|
|
<strong>Author:</strong> <span class="author">%s</span><br />
|
|
|
|
<strong>Revision:</strong> <span class="revision">%s</span><br />
|
|
|
|
<strong>Code:</strong>
|
|
|
|
<code>%s</code>
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
</li>',
|
|
|
|
|
|
|
|
$fault['level'],
|
|
|
|
$fault['module'],
|
|
|
|
$fault['reason'],
|
|
|
|
$fault['object']['line'],
|
2008-02-28 17:06:07 +00:00
|
|
|
!empty( $fault['author'] ) ? $fault['author'] : 'Unknown',
|
|
|
|
!empty( $fault['revision'] ) ? $fault['revision'] : 'Unknown',
|
2008-02-15 19:05:09 +00:00
|
|
|
$fault['object']['context']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
fwrite( $output,
|
|
|
|
' </dl>
|
|
|
|
</body>
|
|
|
|
</html>' . "\n"
|
|
|
|
);
|
|
|
|
fclose( $output );
|
2008-02-28 16:39:33 +00:00
|
|
|
return true;
|
2008-02-15 19:05:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
addModule( new HTMLOutput() );
|
|
|
|
?>
|