Changeset 124
- Timestamp:
- 09/03/2006 04:20:00 AM (7 years ago)
- Location:
- trunk/coverager
- Files:
-
- 3 added
- 4 modified
-
common-en.lang.php (added)
-
common-zh-simplified-utf-8.lang.php (added)
-
common.php (added)
-
config.php.example (modified) (2 diffs)
-
coverager.css (modified) (3 diffs)
-
coverager.php (modified) (5 diffs)
-
coverager.tpl.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/coverager/config.php.example
r33 r124 1 1 <?php 2 2 3 // should be named as config.php 3 // this is an example only 4 // write your own config and name it as config.php 5 6 // detected by browser 7 // $lang = 'en-us'; 4 8 5 9 $charset = "UTF-8"; 10 11 // developers only 12 $show_todo_strings = false; 13 6 14 // $include_paths = array("/www/my-php-project/"); 7 15 // $exclude_paths = array("/www/my-php-project/tmp/"); … … 13 21 function ob_filter_path_nicer($o) 14 22 { 23 $o = str_replace($_SERVER['DOCUMENT_ROOT'], "{DOCROOT}/", $o); 24 $xcachedir = realpath(dirname(__FILE__) . "/../"); 25 $o = str_replace($xcachedir . "/", "{XCache}/", $o); 15 26 $o = str_replace("/home/", "{H}/", $o); 16 27 return $o; 17 28 } 18 29 30 // implement your auth here if needed 31 // {{{ home made login example 32 // this is an example only, it's won't work for you without your implemention. 33 function check_admin_auth() 34 { 35 require("/path/to/user-login-and-permission-lib.php"); 36 session_start(); 37 38 if (!user_logined()) { 39 if (!ask_the_user_to_login()) { 40 exit; 41 } 42 } 43 44 user_load_permissions(); 45 if (!user_is_admin()) { 46 die("Permission denied"); 47 } 48 49 return true; 50 } 51 52 // uncomment: 53 // check_admin_auth() 54 // }}} 55 19 56 ?> -
trunk/coverager/coverager.css
r33 r124 1 h1 { text-align: center; } 1 2 input, table { font-family: monospace; font-size: 11px; } 2 3 table.cycles { border: 1px solid black; background: white; margin-top: 5px; margin-bottom: 5px; } 3 4 table.cycles .col1 { background-color: #f5f5f5; } 4 5 table.cycles .col2 { background-color: #e0e0e0; } 5 table.cycles th { background-color: #707090; color: white; font-weight: bold; height: 20px; line-height: 1 6px; font-family: serif; }6 table.cycles th { background-color: #707090; color: white; font-weight: bold; height: 20px; line-height: 18px; font-family: serif; } 6 7 th a { color: white; font-weight: bold; display: block; width: 100%; height: 100%; } 7 8 … … 34 35 width: 100%; 35 36 } 36 .coverBarHi, .coverBarMed, .coverBarLo { left: 1px; top: 1px; }37 .coverBarHi, .coverBarMed, .coverBarLo { left: 1px; top: 1px; height: 14px; } 37 38 .coverBarHi { background-color: #A7FC9D; } 38 39 .coverBarMed { background-color: #FFEA20; } … … 56 57 border: 1px solid gray; 57 58 } 59 60 .footnote { text-align: right; font-size: 12px; } -
trunk/coverager/coverager.php
r33 r124 1 1 <?php 2 2 3 error_reporting(E_ALL); 4 define('REQUEST_TIME', time()); 3 include("./common.php"); 5 4 6 5 class Cycle … … 41 40 var $exclude_paths = array(); 42 41 var $charset = 'UTF-8'; 42 var $lang = 'en-us'; 43 var $datadir = null; 44 var $datadir_len = null; 45 var $path = null; 46 var $outpath = null; 43 47 44 48 function XcacheCoverageViewer() … … 47 51 48 52 // copy config 49 foreach (array('charset', 'include_paths', 'exclude_paths', 'syntaxhiglight', 'usecache', 'datadir' ) as $k) {50 if (isset($GLOBALS[ 'usecache'])) {51 $this->{$k} = $GLOBALS[ 'usecache'];53 foreach (array('charset', 'include_paths', 'exclude_paths', 'syntaxhiglight', 'usecache', 'datadir', 'lang') as $k) { 54 if (isset($GLOBALS[$k])) { 55 $this->{$k} = $GLOBALS[$k]; 52 56 } 53 57 } 54 58 55 59 $this->datadir = preg_replace('!/$!', '', $this->datadir); 56 $this->datadir_len = strlen($this->datadir);60 $this->datadir_len = strlen($this->datadir); 57 61 58 62 $this->path = isset($_GET['path']) ? $_GET['path'] : ''; … … 125 129 } 126 130 131 $xcache_version = XCACHE_VERSION; 127 132 include("coverager.tpl.php"); 128 133 } … … 304 309 } 305 310 306 if (file_exists("config.php")) {307 include("config.php");308 }309 310 311 $app = new XcacheCoverageViewer(); 311 312 $app->main(); -
trunk/coverager/coverager.tpl.php
r33 r124 6 6 echo <<<HEAD 7 7 <meta http-equiv="Content-Type" content="text/html; charset=$this->charset" /> 8 <meta http-equiv="Content-Language" content="{$this->lang}" /> 8 9 <script type="text/javascript" src="tablesort.js" charset="$this->charset"></script> 9 10 HEAD; … … 11 12 12 13 <link rel="stylesheet" type="text/css" href="coverager.css" /> 13 <title> XCache Coverage Viewer</title>14 <title><?php echo _T("XCache PHP Code Coverage Viewer"); ?></title> 14 15 </head> 15 16 <body> 17 <h1><?php echo _T("XCache PHP Code Coverage Viewer"); ?></h1> 16 18 17 19 <?php … … 49 51 global $cycle; 50 52 $cycle = new Cycle('class="col1"', 'class="col2"'); 53 $l_dir = _T("Directory"); 54 $l_per = _T("Percent"); 55 $l_hit = _T("Hits"); 56 $l_lns = _T("Lines"); 57 $l_tds = _T("TODO"); 51 58 return <<<EOS 52 59 <table align="center" cellpadding="2" cellspacing="1" border="0" class="cycles"> 53 60 <tr> 54 <th> Directory</th><th>Percent</th><th>Hits</th><th>Lines</th><th>TODO</th>61 <th>{$l_dir}</th><th>{$l_per}</th><th>{$l_hit}</th><th>{$l_lns}</th><th>{$l_tds}</th> 55 62 </tr> 56 63 EOS; … … 105 112 global $cycle; 106 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"); 107 118 return <<<EOS 108 119 <br> 109 120 <table align="center" cellpadding="2" cellspacing="1" border="0" class="cycles"> 110 121 <tr> 111 <th> File</th><th>Percent</th><th>Hits</th><th>Lines</th>122 <th>{$l_fil}</th><th>{$l_per}</th><th>{$l_hit}</th><th>{$l_lns}</th> 112 123 </tr> 113 124 EOS; … … 154 165 } 155 166 167 $l_root = _T("root"); 156 168 if ($action == 'dir') { 169 if (function_exists('ob_filter_path_nicer')) { 170 ob_start('ob_filter_path_nicer'); 171 } 157 172 $path_html = htmlspecialchars($path); 158 173 echo <<<EOS 159 <a href="?"> root</a> $path<br />174 <a href="?">$l_root</a> $path<br /> 160 175 EOS; 161 176 echo dir_head($dirinfo); … … 178 193 } 179 194 else if ($action == 'file') { 195 if (function_exists('ob_filter_path_nicer')) { 196 ob_start('ob_filter_path_nicer'); 197 } 180 198 $dir_url = urlencode($dir); 181 199 $dir_html = htmlspecialchars($dir); 182 200 echo <<<EOS 183 <a href="?"> root</a> <a href="?path={$dir_url}">{$dir_html}</a>/<b>{$filename}</b><br />201 <a href="?">$l_root</a> <a href="?path={$dir_url}">{$dir_html}</a>/<b>{$filename}</b><br /> 184 202 EOS; 185 203 … … 194 212 EOS; 195 213 } 214 if (function_exists('ob_filter_path_nicer')) { 215 ob_end_flush(); 216 } 196 217 echo <<<EOS 197 218 <pre class="code"><ol>{$filecov}</ol></pre> … … 209 230 ?> 210 231 232 <div class="footnote"> 233 Powered By: XCache <?php echo $xcache_version; ?> coverager <?php echo _T("module"); ?> 234 </div> 235 211 236 </body> 212 237 </html>

