| 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 | <?php |
|---|
| 5 | echo <<<HEAD |
|---|
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=$this->charset" /> |
|---|
| 7 | <meta http-equiv="Content-Language" content="{$this->lang}" /> |
|---|
| 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><?php echo _T("XCache PHP Code Coverage Viewer"); ?></title> |
|---|
| 14 | </head> |
|---|
| 15 | <body> |
|---|
| 16 | <h1><?php echo _T("XCache PHP Code Coverage Viewer"); ?></h1> |
|---|
| 17 | |
|---|
| 18 | <?php |
|---|
| 19 | function calc_percent($info, &$percent, &$class) |
|---|
| 20 | { |
|---|
| 21 | if (!$info['total']) { |
|---|
| 22 | $percent = 0; |
|---|
| 23 | } |
|---|
| 24 | else { |
|---|
| 25 | $percent = (int) ($info['hits'] / $info['total'] * 100); |
|---|
| 26 | } |
|---|
| 27 | if ($percent < 15) { |
|---|
| 28 | $class = "Lo"; |
|---|
| 29 | } |
|---|
| 30 | else if ($percent < 50) { |
|---|
| 31 | $class = "Med"; |
|---|
| 32 | } |
|---|
| 33 | else { |
|---|
| 34 | $class = "Hi"; |
|---|
| 35 | } |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | function bar($percent, $class) |
|---|
| 39 | { |
|---|
| 40 | return <<<EOS |
|---|
| 41 | <div class="coverBarOutline"> |
|---|
| 42 | <div class="coverBar{$class}" style="width:{$percent}%"></div> |
|---|
| 43 | <div class="coverPer{$class}">{$percent}</div> |
|---|
| 44 | </div> |
|---|
| 45 | EOS; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | function dir_head() |
|---|
| 49 | { |
|---|
| 50 | global $cycle; |
|---|
| 51 | $cycle = new Cycle('class="col1"', 'class="col2"'); |
|---|
| 52 | $l_dir = _T("Directory"); |
|---|
| 53 | $l_per = _T("Percent"); |
|---|
| 54 | $l_hit = _T("Hits"); |
|---|
| 55 | $l_lns = _T("Lines"); |
|---|
| 56 | $l_tds = _T("TODO"); |
|---|
| 57 | return <<<EOS |
|---|
| 58 | <table align="center" cellpadding="2" cellspacing="0" border="0" class="cycles"> |
|---|
| 59 | <tr> |
|---|
| 60 | <th>{$l_dir}</th><th>{$l_per}</th><th>{$l_hit}</th><th>{$l_lns}</th><th>{$l_tds}</th> |
|---|
| 61 | </tr> |
|---|
| 62 | EOS; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | function dir_row($info, $srcdir) |
|---|
| 66 | { |
|---|
| 67 | global $cycle; |
|---|
| 68 | if ($info['files'] || $info['todos']) { |
|---|
| 69 | $srcdir .= DIRECTORY_SEPARATOR; |
|---|
| 70 | $c = $cycle->next(); |
|---|
| 71 | $srcdir_html = htmlspecialchars($srcdir); |
|---|
| 72 | $todos = number_format($info['todos']); |
|---|
| 73 | if ($info['total']) { |
|---|
| 74 | $srcdir_url = urlencode($srcdir); |
|---|
| 75 | $hits = number_format($info['hits']); |
|---|
| 76 | $total = number_format($info['total']); |
|---|
| 77 | calc_percent($info, $percent, $class); |
|---|
| 78 | $bar = bar($percent, $class); |
|---|
| 79 | return <<<EOS |
|---|
| 80 | <tr $c> |
|---|
| 81 | <td class="coverFile"><a href="?path={$srcdir_url}">{$srcdir_html}</a></td> |
|---|
| 82 | <td class="coverBar">$bar</td> |
|---|
| 83 | <td class="coverNum{$class}">{$hits}</td> |
|---|
| 84 | <td class="coverNum{$class}">{$total}</td> |
|---|
| 85 | <td class="coverNum{$class}">{$todos}</td> |
|---|
| 86 | </tr> |
|---|
| 87 | EOS; |
|---|
| 88 | } |
|---|
| 89 | else { |
|---|
| 90 | return <<<EOS |
|---|
| 91 | <tr $c> |
|---|
| 92 | <td class="coverFile">{$srcdir_html}</td> |
|---|
| 93 | <td class="coverBar"></td> |
|---|
| 94 | <td class="coverNumLo"></td> |
|---|
| 95 | <td class="coverNumLo"></td> |
|---|
| 96 | <td class="coverNumLo">{$todos}</td> |
|---|
| 97 | </tr> |
|---|
| 98 | EOS; |
|---|
| 99 | } |
|---|
| 100 | } |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | function dir_foot() |
|---|
| 104 | { |
|---|
| 105 | return <<<EOS |
|---|
| 106 | </table> |
|---|
| 107 | EOS; |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | function file_head() |
|---|
| 111 | { |
|---|
| 112 | global $cycle; |
|---|
| 113 | $cycle = new Cycle('class="col1"', 'class="col2"'); |
|---|
| 114 | $l_fil = _T("File"); |
|---|
| 115 | $l_per = _T("Percent"); |
|---|
| 116 | $l_hit = _T("Hits"); |
|---|
| 117 | $l_lns = _T("Lines"); |
|---|
| 118 | return <<<EOS |
|---|
| 119 | <br> |
|---|
| 120 | <table align="center" cellpadding="2" cellspacing="0" border="0" class="cycles"> |
|---|
| 121 | <tr> |
|---|
| 122 | <th>{$l_fil}</th><th>{$l_per}</th><th>{$l_hit}</th><th>{$l_lns}</th> |
|---|
| 123 | </tr> |
|---|
| 124 | EOS; |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | function file_row($info, $srcfile) |
|---|
| 128 | { |
|---|
| 129 | global $cycle; |
|---|
| 130 | |
|---|
| 131 | $c = $cycle->next(); |
|---|
| 132 | $srcfile_html = htmlspecialchars($srcfile); |
|---|
| 133 | $total = number_format($info['total']); |
|---|
| 134 | if ($info['total']) { |
|---|
| 135 | $hits = number_format($info['hits']); |
|---|
| 136 | $srcfile_url = urlencode($srcfile); |
|---|
| 137 | calc_percent($info, $percent, $class); |
|---|
| 138 | $bar = bar($percent, $class); |
|---|
| 139 | return <<<EOS |
|---|
| 140 | <tr $c> |
|---|
| 141 | <td class="coverFile"><a href="?path={$srcfile_url}">{$srcfile_html}</a></td> |
|---|
| 142 | <td class="coverBar">$bar</td> |
|---|
| 143 | <td class="coverNum{$class}">{$hits}</td> |
|---|
| 144 | <td class="coverNum{$class}">{$total}</td> |
|---|
| 145 | </tr> |
|---|
| 146 | EOS; |
|---|
| 147 | } |
|---|
| 148 | else { |
|---|
| 149 | return <<<EOS |
|---|
| 150 | <tr $c> |
|---|
| 151 | <td class="coverFile">{$srcfile_html}</a></td> |
|---|
| 152 | <td class="coverBar"></td> |
|---|
| 153 | <td class="coverNumLo"></td> |
|---|
| 154 | <td class="coverNumLo">{$total}</td> |
|---|
| 155 | </tr> |
|---|
| 156 | EOS; |
|---|
| 157 | } |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | function file_foot() |
|---|
| 161 | { |
|---|
| 162 | return <<<EOS |
|---|
| 163 | </table> |
|---|
| 164 | EOS; |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | $l_root = _T("root"); |
|---|
| 168 | if ($action == 'dir') { |
|---|
| 169 | if (function_exists('ob_filter_path_nicer')) { |
|---|
| 170 | ob_start('ob_filter_path_nicer'); |
|---|
| 171 | } |
|---|
| 172 | $path_html = htmlspecialchars($path); |
|---|
| 173 | echo <<<EOS |
|---|
| 174 | <a href="?">$l_root</a> $path<br /> |
|---|
| 175 | EOS; |
|---|
| 176 | echo dir_head($dirinfo); |
|---|
| 177 | echo dir_row($dirinfo, $path); |
|---|
| 178 | echo dir_foot($dirinfo); |
|---|
| 179 | if ($dirinfo['subdirs']) { |
|---|
| 180 | echo dir_head(); |
|---|
| 181 | foreach ($dirinfo['subdirs'] as $srcdir => $info) { |
|---|
| 182 | echo dir_row($info, $srcdir); |
|---|
| 183 | } |
|---|
| 184 | echo dir_foot(); |
|---|
| 185 | } |
|---|
| 186 | if ($dirinfo['files']) { |
|---|
| 187 | echo file_head(); |
|---|
| 188 | foreach ($dirinfo['files'] as $srcfile => $info) { |
|---|
| 189 | echo file_row($info, $srcfile); |
|---|
| 190 | } |
|---|
| 191 | echo file_foot(); |
|---|
| 192 | } |
|---|
| 193 | } |
|---|
| 194 | else if ($action == 'file') { |
|---|
| 195 | if (function_exists('ob_filter_path_nicer')) { |
|---|
| 196 | ob_start('ob_filter_path_nicer'); |
|---|
| 197 | } |
|---|
| 198 | $dir_url = urlencode($dir); |
|---|
| 199 | $dir_html = htmlspecialchars($dir); |
|---|
| 200 | echo <<<EOS |
|---|
| 201 | <a href="?">$l_root</a> <a href="?path={$dir_url}">{$dir_html}</a>/<b>{$filename}</b><br /> |
|---|
| 202 | EOS; |
|---|
| 203 | |
|---|
| 204 | echo file_head(); |
|---|
| 205 | echo file_row($fileinfo, $path); |
|---|
| 206 | echo file_foot(); |
|---|
| 207 | |
|---|
| 208 | if ($tplfile) { |
|---|
| 209 | $tplfile_html = htmlspecialchars($tplfile); |
|---|
| 210 | echo <<<EOS |
|---|
| 211 | <a href="#tpl">{$tplfile_html}</a><br /> |
|---|
| 212 | EOS; |
|---|
| 213 | } |
|---|
| 214 | if (function_exists('ob_filter_path_nicer')) { |
|---|
| 215 | ob_end_flush(); |
|---|
| 216 | } |
|---|
| 217 | echo <<<EOS |
|---|
| 218 | <pre class="code"><ol>{$filecov}</ol></pre> |
|---|
| 219 | EOS; |
|---|
| 220 | if ($tplfile) { |
|---|
| 221 | echo <<<EOS |
|---|
| 222 | <a name="tpl">{$tplfile}</a> |
|---|
| 223 | <pre class="code"><ol>{$tplcov}</ol></pre> |
|---|
| 224 | EOS; |
|---|
| 225 | } |
|---|
| 226 | } |
|---|
| 227 | else { |
|---|
| 228 | echo htmlspecialchars($action); |
|---|
| 229 | } |
|---|
| 230 | ?> |
|---|
| 231 | |
|---|
| 232 | <div class="footnote"> |
|---|
| 233 | Powered By: XCache <?php echo $xcache_version; ?> coverager <?php echo _T("module"); ?> |
|---|
| 234 | </div> |
|---|
| 235 | |
|---|
| 236 | </body> |
|---|
| 237 | </html> |
|---|