#!/usr/bin/php
<?
function rec_glob($pattern){
	$ret=array();
	foreach(glob($pattern) as $r) 
		if(is_dir($r)) $ret=array_merge($ret,rec_glob("$r/*")); else $ret[]=$r;
	return $ret;
}
foreach(file('MIMviewer.properties') as $l) {
	list($a,$b)=explode('#',$l,2);
	if(strlen($a)<=1) continue;
	list($k,$v)=explode('=',trim($l),2);
	if(strlen($k)<1) continue;
	$klist[$k]=0;
	$comments[$k]=0;
	$textlist[$k]=$v;
}
foreach(array_merge(rec_glob('../../src/com/mimvista/viewer/*'), rec_glob('../../src/com/mimvista/capture/*')) as $filen){
	print "Reading $filen... "; $tf=0; $tc=0;
	foreach(file($filen) as $l){
		foreach($klist as $k=>$v) {
#			$q="getProperty(\"$k\"";
			$q="\"$k\"";
			$f=substr_count($l,$q); $tf+=$f;
			$klist[$k]+=$f;
			$commented=explode('//',$l,2);
			$c=substr_count($commented[1],$q); $tc+=$c;
			$comments[$k]+=$c;
		}
	}
	$c=$tc>0?", $tc commented out":'';
	print "$tf items found $c\n";
}
foreach($klist as $k=>$v){
	$c=$comments[$k]>0?"{$comments[$k]} times in comments":'';
	print "$k used $v times $c\n";
}
print "----------\n";
foreach($klist as $k=>$v){
	if($v-$comments[$k]>0) continue;
	$c=$comments[$k]>0?"{$comments[$k]} times in comments":'';
	print "$k used $v times $c\n";
	
}
?>
