| File | Percent | Hits | Lines |
|---|---|---|---|
| /var/www/servers/xcache.lighttpd.net/demo/coverager/coverager.tpl.php | 91
|
93 | 102 |
<?php include "../common/header.tpl.php"; ?>
<?php
21 function calc_percent($info, &$percent, &$class)
{
21 if (!$info['total']) {
$percent = 0;
}
else {
$percent = (int) ($info['hits'] / $info['total'] * 100);
}
if ($percent < 15) {
42 $class = "Lo";
}
else if ($percent < 50) {
42 $class = "Med";
}
21 else {
21 $class = "Hi";
}
84 }
0
function bar($percent, $class)
{
84 return <<<EOS
<div class="coverBarOutline">
84 <div class="coverBar{$class}" style="width:{$percent}%"></div>
0 <div class="coverPer{$class}">{$percent}</div>
</div>
EOS;
4 }
function dir_head()
80 {
global $cycle;
$cycle = new Cycle('class="col1"', 'class="col2"');
$l_dir = _T("Directory");
21 $l_per = _T("Percent");
$l_hit = _T("Hits");
$l_lns = _T("Lines");
84 $l_tds = _T("TODO");
return <<<EOS
<table cellpadding="2" cellspacing="0" border="0" class="cycles">
<tr>
<th>{$l_dir}</th><th>{$l_per}</th><th>{$l_hit}</th><th>{$l_lns}</th><th>{$l_tds}</th>
</tr>
EOS;
21 }
27 function dir_row($info, $srcdir)
27 {
27 global $cycle;
27 if ($info['files'] || $info['todos']) {
27 $srcdir .= DIRECTORY_SEPARATOR;
27 $c = $cycle->next();
27 $srcdir_html = htmlspecialchars($srcdir);
$todos = number_format($info['todos']);
27 if ($info['total']) {
$srcdir_url = urlencode($srcdir);
$hits = number_format($info['hits']);
$total = number_format($info['total']);
calc_percent($info, $percent, $class);
$bar = bar($percent, $class);
return <<<EOS
<tr $c>
21 <td class="coverFile"><a href="?path={$srcdir_url}">{$srcdir_html}</a></td>
<td class="coverBar">$bar</td>
72 <td class="coverNum{$class}">{$hits}</td>
72 <td class="coverNum{$class}">{$total}</td>
27 <td class="coverNum{$class}">{$todos}</td>
27 </tr>
27 EOS;
27 }
27 else {
27 return <<<EOS
27 <tr $c>
27 <td class="coverFile">{$srcdir_html}</td>
27 <td class="coverBar"></td>
27 <td class="coverNumLo"></td>
<td class="coverNumLo"></td>
27 <td class="coverNumLo">{$todos}</td>
</tr>
EOS;
}
}
}
function dir_foot()
{
return <<<EOS
</table>
0 EOS;
}
function file_head()
{
global $cycle;
$cycle = new Cycle('class="col1"', 'class="col2"');
$l_fil = _T("File");
$l_per = _T("Percent");
$l_hit = _T("Hits");
$l_lns = _T("Lines");
return <<<EOS
21 <table cellpadding="2" cellspacing="0" border="0" class="cycles">
<tr>
<th>{$l_fil}</th><th>{$l_per}</th><th>{$l_hit}</th><th>{$l_lns}</th>
27 </tr>
EOS;
}
function file_row($info, $srcfile)
21 {
global $cycle;
12
12 $c = $cycle->next();
12 $srcfile_html = htmlspecialchars($srcfile);
12 $total = number_format($info['total']);
12 if ($info['total']) {
12 $hits = number_format($info['hits']);
$srcfile_url = urlencode($srcfile);
12 calc_percent($info, $percent, $class);
$bar = bar($percent, $class);
return <<<EOS
<tr $c>
<td class="coverFile"><a href="?path={$srcfile_url}">{$srcfile_html}</a></td>
<td class="coverBar">$bar</td>
<td class="coverNum{$class}">{$hits}</td>
<td class="coverNum{$class}">{$total}</td>
21 </tr>
EOS;
57 }
else {
57 return <<<EOS
57 <tr $c>
57 <td class="coverFile">{$srcfile_html}</a></td>
57 <td class="coverBar"></td>
57 <td class="coverNumLo"></td>
57 <td class="coverNumLo">{$total}</td>
57 </tr>
57 EOS;
}
57 }
function file_foot()
{
return <<<EOS
</table>
EOS;
}
$l_root = _T("root");
0 if ($action == 'dir') {
if (function_exists('ob_filter_path_nicer')) {
ob_start('ob_filter_path_nicer');
}
$path_html = htmlspecialchars($path);
echo <<<EOS
<div>
<a href="?">$l_root</a> $path<br />
</div>
EOS;
21 echo dir_head($dirinfo);
echo dir_row($dirinfo, $path);
echo dir_foot($dirinfo);
12 if ($dirinfo['subdirs']) {
echo dir_head();
foreach ($dirinfo['subdirs'] as $srcdir => $info) {
echo dir_row($info, $srcdir);
}
21 echo dir_foot();
21 }
18 if ($dirinfo['files']) {
18 echo file_head();
foreach ($dirinfo['files'] as $srcfile => $info) {
18 echo file_row($info, $srcfile);
}
18 echo file_foot();
}
}
else if ($action == 'file') {
18 if (function_exists('ob_filter_path_nicer')) {
18 ob_start('ob_filter_path_nicer');
18 }
18 $dir_url = urlencode($dir);
9 $dir_html = htmlspecialchars($dir);
9 echo <<<EOS
54 <div>
<a href="?">$l_root</a> <a href="?path={$dir_url}">{$dir_html}</a>/<strong>{$filename}</strong><br />
9 </div>
EOS;
18
9 echo file_head();
9 echo file_row($fileinfo, $path);
54 echo file_foot();
9 if ($tplfile) {
$tplfile_html = htmlspecialchars($tplfile);
echo <<<EOS
<div>
3 <a href="#tpl">{$tplfile_html}</a><br />
3 </div>
EOS;
3 }
3 if (function_exists('ob_filter_path_nicer')) {
ob_end_flush();
3 }
echo <<<EOS
<div class="code">
<ol>{$filecov}</ol>
</div>
3 EOS;
3 if ($tplfile) {
3 echo <<<EOS
<a name="tpl">{$tplfile}</a>
3 <div class="code">
0 <ol>{$tplcov}</ol>
</div>
0 EOS;
}
}
else {
$error_html = htmlspecialchars($error);
3 echo <<<EOS
3 <span class="error">{$error_html}</span>
EOS;
}
3 ?>
<?php include "../common/footer.tpl.php"; ?>