";
// now get all terms found in all PHP files of Chamilo (this takes some
// time and memory)
$usedTerms = array();
$l = strlen(api_get_path(SYS_PATH));
$files = get_all_php_files(api_get_path(SYS_PATH));
// Browse files
foreach ($files as $file) {
//echo 'Analyzing '.$file."
";
$shortFile = substr($file, $l);
//echo 'Analyzing '.$shortFile."
";
$lines = file($file);
// Browse lines inside file $file
foreach ($lines as $line) {
$myTerms = array();
$res = preg_match_all('/get_lang\(\'(\\w*)\'\)/', $line, $myTerms);
if ($res > 0) {
foreach ($myTerms[1] as $term) {
if (substr($term, 0, 4)=='lang') {
$term = substr($term, 4);
}
$usedTerms[$term] = $shortFile;
}
} else {
$res = 0;
$res = preg_match_all('/\{[\'"](\\w*)[\'"]\|get_lang\}/', $line, $myTerms);
if ($res > 0) {
foreach ($myTerms[1] as $term) {
if (substr($term, 0, 4)=='lang') {
$term = substr($term, 4);
}
$usedTerms[$term] = $shortFile;
}
}
}
}
flush();
}
// Compare defined terms VS used terms. Used terms should be smaller than
// defined terms, and this should prove the concept that there are much
// more variables than what we really use
if (count($usedTerms)<1) {
die("No used terms
\n");
} else {
echo "The following terms were defined but never used:
\n
$i | $term |