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