protected function output_indexes($urls, $penaltys, $path = '', $depth = 0)
{
$out = '<div class="wrapper"><table border="1" cellpadding="0" cellspacing="0">';
$out .= '<tr><td align="center">' . date("d / M / Y") . '</td>';
$out .= '<td colspan="2" align="center">' . $this->root . '</td></tr>';
$content = '';
$total = 0;
$num = 0;
foreach ($urls as $k => $_) {
$content .= '<tr>';
if (isset($_['phplinter___file'])) {
$score = SCORE_FULL + $penaltys[$_['phplinter___file']];
$total += $score;
$num++;
$class = $this->get_score_class($score);
$content .= '<td class="' . $class . '">' . sprintf('%.2f', $score) . '</td>';
$limit = $score == 10 ? 'perfect' : 'limit';
$content .= '<td class="' . $limit . '">' . sprintf('%.2f', SCORE_FULL) . '</td>';
$content .= '<td><a href="' . $_['phplinter___url'] . '">' . substr(realpath($_['phplinter___file']), strlen($this->root . $path)) . '</a></td>';
} else {
list($ototal, $onum) = $this->output_indexes($urls[$k], $penaltys, $path . $k . '/', $depth + 1);
$avarage = $ototal / $onum;
$class = $this->get_score_class($avarage);
$content .= sprintf('<td colspan="2" class="%s">Average: %.2f</td>', $class, $avarage);
$content .= '<td class="folder"><a href="' . $k . '">' . $k . '</a></td>';
$total += $ototal;
$num += $onum;
}
$content .= '</tr>';
}
$out .= '<tr>';
$avarage = $total / $num;
$class = $this->get_score_class($avarage);
$out .= sprintf('<td colspan="2" align="center" class="%s">Average: %.2f</td>', $class, $avarage);
$out .= '<td>' . $path . '</td>';
$out .= '</tr>';
$out .= $content;
$out .= '</table></div>';
$path = $path == '/' ? $this->output_dir : $path;
$dir = $path == $this->output_dir ? $path : $this->output_dir . $path;
$dir = !empty($dir) && $dir[strlen($dir) - 1] == '/' ? $dir : $dir . '/';
if (!empty($path)) {
$file = $dir . 'index.html';
Path::write_file($file, $this->html($out, $depth));
if ($this->options & OPT_VERBOSE) {
echo "Wrote to file `{$file}`\n";
}
}
$this->dirs[] = $dir;
return array($total, $num);
}