| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|---|
| 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|---|
| 3 | <head> |
|---|
| 4 | <meta http-equiv="Content-Language" content="en-us" /> |
|---|
| 5 | <?php |
|---|
| 6 | echo <<<HEAD |
|---|
| 7 | <meta http-equiv="Content-Type" content="text/html; charset=$this->charset" /> |
|---|
| 8 | <script type="text/javascript" src="tablesort.js" charset="$this->charset"></script> |
|---|
| 9 | HEAD; |
|---|
| 10 | ?> |
|---|
| 11 | |
|---|
| 12 | <link rel="stylesheet" type="text/css" href="coverager.css" /> |
|---|
| 13 | <title>XCache Coverage Viewer</title> |
|---|
| 14 | </head> |
|---|
| 15 | <body> |
|---|
| 16 | |
|---|
| 17 | <?php |
|---|
| 18 | function calc_percent($info, &$percent, &$class) |
|---|
| 19 | { |
|---|
| 20 | if (!$info['total']) { |
|---|
| 21 | $percent = 0; |
|---|
| 22 | } |
|---|
| 23 | else { |
|---|
| 24 | $percent = (int) ($info['hits'] / $info['total'] * 100); |
|---|
| 25 | } |
|---|
| 26 | if ($percent < 15) { |
|---|
| 27 | $class = "Lo"; |
|---|
| 28 | } |
|---|
| 29 | else if ($percent < 50) { |
|---|
| 30 | $class = "Med"; |
|---|
| 31 | } |
|---|
| 32 | else { |
|---|
| 33 | $class = "Hi"; |
|---|
| 34 | } |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | function bar($percent, $class) |
|---|
| 38 | { |
|---|
| 39 | return <<<EOS |
|---|
| 40 | <div class="coverBarOutline"> |
|---|
| 41 | <div class="coverBar{$class}" style="width:{$percent}%"></div> |
|---|
| 42 | <div class="coverPer{$class}">{$percent}</div> |
|---|
| 43 | </div> |
|---|
| 44 | EOS; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | function dir_head() |
|---|
| 48 | { |
|---|
| 49 | global $cycle; |
|---|
| 50 | $cycle = new Cycle('class="col1"', 'class="col2"'); |
|---|
| 51 | return <<<EOS |
|---|
| 52 | <table align="center" cellpadding="2" cellspacing="1" border="0" class="cycles"> |
|---|
| 53 | <tr> |
|---|
| 54 | <th>Directory</th><th>Percent</th><th>Hits</th><th>Lines</th><th>TODO</th> |
|---|
| 55 | </tr> |
|---|
| 56 | EOS; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | function dir_row($info, $srcdir) |
|---|
| 60 | { |
|---|
| 61 | global $cycle; |
|---|
| 62 | if ($info['files'] || $info['todos']) { |
|---|
| 63 | $c = $cycle->next(); |
|---|
| 64 | $srcdir_html = htmlspecialchars($srcdir); |
|---|
| 65 | $todos = number_format($info['todos']); |
|---|
| 66 | if ($info['total']) { |
|---|
| 67 | $srcdir_url = urlencode($srcdir); |
|---|
| 68 | $hits = number_format($info['hits']); |
|---|
| 69 | $total = number_format($info['total']); |
|---|
| 70 | calc_percent($info, $percent, $class); |
|---|
| 71 | $bar = bar($percent, $class); |
|---|
| 72 | return <<<EOS |
|---|
| 73 | <tr $c> |
|---|
| 74 | <td class="coverFile"><a href="?path={$srcdir_url}">{$srcdir_html}</a></td> |
|---|
| 75 | <td class="coverBar">$bar</td> |
|---|
| 76 | <td class="coverNum{$class}">{$hits}</td> |
|---|
| 77 | <td class="coverNum{$class}">{$total}</td> |
|---|
| 78 | <td class="coverNum{$class}">{$todos}</td> |
|---|
| 79 | </tr> |
|---|
| 80 | EOS; |
|---|
| 81 | } |
|---|
| 82 | else { |
|---|
| 83 | return <<<EOS |
|---|
| 84 | <tr $c> |
|---|
| 85 | <td class="coverFile">{$srcdir_html}</td> |
|---|
| 86 | <td class="coverBar"></td> |
|---|
| 87 | <td class="coverNumLo"></td> |
|---|
| 88 | <td class="coverNumLo"></td> |
|---|
| 89 | <td class="coverNumLo">{$todos}</td> |
|---|
| 90 | </tr> |
|---|
| 91 | EOS; |
|---|
| 92 | } |
|---|
| 93 | } |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | function dir_foot() |
|---|
| 97 | { |
|---|
| 98 | return <<<EOS |
|---|
| 99 | </table> |
|---|
| 100 | EOS; |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | function file_head() |
|---|
| 104 | { |
|---|
| 105 | global $cycle; |
|---|
| 106 | $cycle = new Cycle('class="col1"', 'class="col2"'); |
|---|
| 107 | return <<<EOS |
|---|
| 108 | <br> |
|---|
| 109 | <table align="center" cellpadding="2" cellspacing="1" border="0" class="cycles"> |
|---|
| 110 | <tr> |
|---|
| 111 | <th>File</th><th>Percent</th><th>Hits</th><th>Lines</th> |
|---|
| 112 | </tr> |
|---|
| 113 | EOS; |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | function file_row($info, $srcfile) |
|---|
| 117 | { |
|---|
| 118 | global $cycle; |
|---|
| 119 | |
|---|
| 120 | $c = $cycle->next(); |
|---|
| 121 | $srcfile_html = htmlspecialchars($srcfile); |
|---|
| 122 | $total = number_format($info['total']); |
|---|
| 123 | if ($info['total']) { |
|---|
| 124 | $hits = number_format($info['hits']); |
|---|
| 125 | $srcfile_url = urlencode($srcfile); |
|---|
| 126 | calc_percent($info, $percent, $class); |
|---|
| 127 | $bar = bar($percent, $class); |
|---|
| 128 | return <<<EOS |
|---|
| 129 | <tr $c> |
|---|
| 130 | <td class="coverFile"><a href="?path={$srcfile_url}">{$srcfile_html}</a></td> |
|---|
| 131 | <td class="coverBar">$bar</td> |
|---|
| 132 | <td class="coverNum{$class}">{$hits}</td> |
|---|
| 133 | <td class="coverNum{$class}">{$total}</td> |
|---|
| 134 | </tr> |
|---|
| 135 | EOS; |
|---|
| 136 | } |
|---|
| 137 | else { |
|---|
| 138 | return <<<EOS |
|---|
| 139 | <tr $c> |
|---|
| 140 | <td class="coverFile">{$srcfile_html}</a></td> |
|---|
| 141 | <td class="coverBar"></td> |
|---|
| 142 | <td class="coverNumLo"></td> |
|---|
| 143 | <td class="coverNumLo">{$total}</td> |
|---|
| 144 | </tr> |
|---|
| 145 | EOS; |
|---|
| 146 | } |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | function file_foot() |
|---|
| 150 | { |
|---|
| 151 | return <<<EOS |
|---|
| 152 | </table> |
|---|
| 153 | EOS; |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | if ($action == 'dir') { |
|---|
| 157 | $path_html = htmlspecialchars($path); |
|---|
| 158 | echo <<<EOS |
|---|
| 159 | <a href="?">root</a> $path<br /> |
|---|
| 160 | EOS; |
|---|
| 161 | echo dir_head($dirinfo); |
|---|
| 162 | echo dir_row($dirinfo, $path); |
|---|
| 163 | echo dir_foot($dirinfo); |
|---|
| 164 | if ($dirinfo['subdirs']) { |
|---|
| 165 | echo dir_head(); |
|---|
| 166 | foreach ($dirinfo['subdirs'] as $srcdir => $info) { |
|---|
| 167 | echo dir_row($info, $srcdir); |
|---|
| 168 | } |
|---|
| 169 | echo dir_foot(); |
|---|
| 170 | } |
|---|
| 171 | if ($dirinfo['files']) { |
|---|
| 172 | echo file_head(); |
|---|
| 173 | foreach ($dirinfo['files'] as $srcfile => $info) { |
|---|
| 174 | echo file_row($info, $srcfile); |
|---|
| 175 | } |
|---|
| 176 | echo file_foot(); |
|---|
| 177 | } |
|---|
| 178 | } |
|---|
| 179 | else if ($action == 'file') { |
|---|
| 180 | $dir_url = urlencode($dir); |
|---|
| 181 | $dir_html = htmlspecialchars($dir); |
|---|
| 182 | echo <<<EOS |
|---|
| 183 | <a href="?">root</a> <a href="?path={$dir_url}">{$dir_html}</a>/<b>{$filename}</b><br /> |
|---|
| 184 | EOS; |
|---|
| 185 | |
|---|
| 186 | echo file_head(); |
|---|
| 187 | echo file_row($fileinfo, $path); |
|---|
| 188 | echo file_foot(); |
|---|
| 189 | |
|---|
| 190 | if ($tplfile) { |
|---|
| 191 | $tplfile_html = htmlspecialchars($tplfile); |
|---|
| 192 | echo <<<EOS |
|---|
| 193 | <a href="#tpl">{$tplfile_html}</a><br /> |
|---|
| 194 | EOS; |
|---|
| 195 | } |
|---|
| 196 | echo <<<EOS |
|---|
| 197 | <pre class="code"><ol>{$filecov}</ol></pre> |
|---|
| 198 | EOS; |
|---|
| 199 | if ($tplfile) { |
|---|
| 200 | echo <<<EOS |
|---|
| 201 | <a name="tpl">{$tplfile}</a> |
|---|
| 202 | <pre class="code"><ol>{$tplcov}</ol></pre> |
|---|
| 203 | EOS; |
|---|
| 204 | } |
|---|
| 205 | } |
|---|
| 206 | else { |
|---|
| 207 | echo htmlspecialchars($action); |
|---|
| 208 | } |
|---|
| 209 | ?> |
|---|
| 210 | |
|---|
| 211 | </body> |
|---|
| 212 | </html> |
|---|