Skip to content

Instantly share code, notes, and snippets.

@FMCorz
Forked from marinaglancy/iconslist.php
Created November 19, 2012 04:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FMCorz/4108929 to your computer and use it in GitHub Desktop.
Save FMCorz/4108929 to your computer and use it in GitHub Desktop.
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>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment