FMCorz
11/19/2012 - 4:20 AM

Lists all icons in pix/i, pix/t and mod/*/pix

Lists all icons in pix/i, pix/t and mod/*/pix

<?php

require_once('config.php');

echo '<table border=1>';
iconslist('/pix/i/');
iconslist('/pix/t/');
$modlist = get_plugin_list('mod');
foreach ($modlist as $modname => $path) {
    iconslist('/mod/'.$modname.'/pix/');
}
echo '</table>';

function iconslist($path) {
    global $CFG;
    $extensions = array('svg', 'png', 'gif');
    echo '<tr><td colspan="4"><h1>'.$path.'</h1></td></tr>';
    $images = array();
    if ($handle = opendir($CFG->dirroot.$path)) {
        while (false !== ($entry = readdir($handle))) {
            $extension = strtolower(pathinfo($entry, PATHINFO_EXTENSION));
            if (in_array($extension, array('gif', 'svg', 'png'))) {
                $filename = pathinfo($entry, PATHINFO_FILENAME);
                $images[$filename][$extension] = $entry;
            }
        }
        closedir($handle);
    }
    ksort($images);
    echo '<tr><th></th>';
    foreach ($extensions as $extension) {
        echo '<th>'.$extension.'</th>';
    }
    echo '</tr>';
    foreach ($images as $filename => $image) {
        echo '<tr><th align="left">'.$filename.'</th>';
        foreach ($extensions as $extension) {
            echo '<td>';
            if (isset($image[$extension])) {
                echo '<img src="'.$CFG->wwwroot.$path.$image[$extension].'">';
            }
            echo '</td>';
        }
        echo '</tr>';
    }
}