Created
November 19, 2012 04:19
-
-
Save marinaglancy/4108926 to your computer and use it in GitHub Desktop.
Lists all icons in pix/i, pix/t and mod/*/pix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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