-
-
Save danpoltawski/2965033 to your computer and use it in GitHub Desktop.
Script to test icons and mimetype stings in Moodle 2.3
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'); | |
require_once($CFG->libdir .'/filelib.php'); | |
$PAGE->set_context(get_system_context()); | |
$mimeicons = get_mimetypes_array(); | |
?> | |
<style> | |
table {border-collapse: collapse;} | |
.row {} | |
.icon90 {vertical-align: top;padding-top:5px;} | |
.icon24 {vertical-align: top;padding-top:25px;} | |
.extension {} | |
.mimetype {} | |
.badtype {color:#666;} | |
.goodtype {} | |
td {border-bottom: 1px solid #666; padding-left:2px;padding-right:2px;} | |
tr.last td, td.last {border-bottom: 2px solid black;} | |
</style> | |
<?php | |
echo '<table>'; | |
echo "<tr><th>big icon</th><th>small icon</th><hh>tiny icon</th><th>extension</th><th>mimetype</th><th>readable mime type</th></tr>"; | |
$mimebyicons = array(); | |
foreach ($mimeicons as $filetype => $value) { | |
$mimebyicons[$value['icon']][] = $filetype; | |
} | |
$globalcnt=0; | |
foreach ($mimebyicons as $icon => $mimes) { | |
for ($i=0;$i<count($mimes);$i++) { | |
$filetype = $mimes[$i]; | |
$value = $mimeicons[$filetype]; | |
$icon = mimeinfo('icon', '.'.$filetype); | |
$icon90 = file_extension_icon('.'.$filetype, 90); | |
$icon24 = file_extension_icon('.'.$filetype, 24); | |
$icon16 = file_extension_icon('.'.$filetype, 16); | |
$class = "row"; | |
if (!$i) {$class.=" first";} | |
if ($i==count($mimes)-1) {$class.=" last";} | |
if ((++$globalcnt)%2) {$class.=" odd";} else {$class.=" even";} | |
echo "<tr class=\"$class\">"; | |
if (!$i) { | |
echo "<td class=\"icon90 last\" rowspan=\"".count($mimes)."\">".$OUTPUT->pix_icon($icon90,'')."</td>"; | |
echo "<td class=\"icon24 last\" rowspan=\"".count($mimes)."\">".$OUTPUT->pix_icon($icon24,'')."</td>"; | |
echo "<td class=\"icon16 last\" rowspan=\"".count($mimes)."\">".$OUTPUT->pix_icon($icon16,'')."</td>"; | |
} | |
echo "<td class=\"extension\">$filetype</td><td class=\"mimetype\">{$value['type']}</td>"; | |
$type = get_mimetype_description(array('filename'=>'.'.$filetype)); | |
if ($type !== $value['type']) { | |
$class = "goodtype"; | |
} else { | |
$class = "badtype"; | |
} | |
echo "<td class=\"$class\">".$type."</td></tr>"; | |
} | |
} | |
echo '</table>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment