0) {
foreach ($myterms as $mytermsentry) {
if (count($mytermsentry)==0) { continue; }
foreach ($mytermsentry as $term) {
if (!isset($found_img[$term])) {
$unexisting_img[$term] = $shortfile;
} else {
$used_icons[$term][] = $shortfile;
}
}
}
}
}
flush();
$counter++;
}
echo '
';
/*if (count($unexisting_img)<1) { die("No missing image
\n"); } else { echo "The following images were nowhere to be found:
\n"; }
foreach ($unexisting_img as $term => $file) {
echo "$term | in $file |
\n";
}*/
echo 'Existing images('.count($found_img).'), used('.count($used_icons).') and unused |
'."\n";
echo 'Image file | Img path | Used in... |
'."\n";
$r = ksort($found_img);
foreach ($found_img as $term => $path) {
if (isset($used_icons[$term])) {
echo '';
echo ''.$term.' | ';
echo ''.($path=='/'?'/':$path.'/').$term.' | ';
$st = '';
foreach ($used_icons[$term] as $entry) {
$st .= $entry."\n";
}
echo ''.$st.' | ';
echo '
'."\n";
} else {
echo '';
echo ''.$term.' | ';
echo ''.($path=='/'?'/':$path.'/').$term.' | ';
echo '- | ';
echo '
'."\n";
}
}
echo "
\n";
echo "Analysed files:
\n";
print_r($files);
function get_all_php_files($base_path) {
$list = scandir($base_path);
$files = array();
foreach ($list as $item) {
if (substr($item,0,1)=='.') {continue;}
$special_dirs = array(api_get_path(SYS_TEST_PATH),api_get_path(SYS_COURSE_PATH),api_get_path(SYS_LANG_PATH),api_get_path(SYS_ARCHIVE_PATH));
if (in_array($base_path.$item.'/',$special_dirs)) {continue;}
if (is_dir($base_path.$item)) {
$files = array_merge($files,get_all_php_files($base_path.$item.'/'));
} else {
//only analyse php files
$ext = substr($item,-4);
if (in_array($ext,array('.php','html','.htm','.css'))) {
$files[] = $base_path.$item;
}
}
}
$list = null;
return $files;
}
function get_img_files($path) {
$files = array();
//We know there are max 3 levels
$list = scandir($path);
foreach ($list as $entry) {
if (substr($entry,0,1)=='.') { continue; }
if (is_dir($path.$entry)) {
$sublist = scandir($path.$entry);
foreach ($sublist as $subentry) {
if (substr($subentry,0,1)=='.') { continue; }
if (is_dir($path.$entry.'/'.$subentry)) {
$subsublist = scandir($path.$entry.'/'.$subentry);
foreach ($subsublist as $subsubentry) {
if (substr($subsubentry,0,1)=='.') { continue; }
if (is_file($path.$entry.'/'.$subentry.'/'.$subsubentry)) {
$files[$subsubentry] = '/'.$entry.'/'.$subentry;
}
}
} elseif (is_file($path.$entry.'/'.$subentry)) {
$files[$subentry] = '/'.$entry;
}
}
} elseif (is_file($path.$entry)) {
$files[$entry] = '/';
}
}
return $files;
}