mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
filelib MDL-19707 Modified file_extension_icon to use extisting function mimeinfo and reverted
two uses of file_extension_icon in course-lib that were incorrect
This commit is contained in:
parent
8abf70817a
commit
405efa5f95
@ -1333,9 +1333,9 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
||||
if (!empty($customicon)) {
|
||||
if (substr($customicon, 0, 4) === 'mod/') {
|
||||
list($modname, $iconname) = explode('/', substr($customicon, 4), 2);
|
||||
$icon = $OUTPUT->mod_icon_url(file_extension_icon($iconname), $modname);
|
||||
$icon = $OUTPUT->mod_icon_url(str_replace(array('.gif', '.png'), '', $customicon), $modname);
|
||||
} else {
|
||||
$icon = $OUTPUT->old_icon_url(file_extension_icon($customicon));
|
||||
$icon = $OUTPUT->old_icon_url(str_replace(array('.gif', '.png'), '', $customicon));
|
||||
}
|
||||
} else {
|
||||
$icon = "" . $OUTPUT->mod_icon_url('icon', $mod->modname) . "";
|
||||
|
@ -1175,30 +1175,15 @@ function file_mimetype_icon($mimetype, $size=null) {
|
||||
* @todo Implement $size
|
||||
*
|
||||
* @param string filename The filename to get the icon for
|
||||
* @param int $size The size of the icon. Not yet implemented
|
||||
* @param int $size The size of the icon. Defaults to null can also be 32
|
||||
* @return string
|
||||
*/
|
||||
function file_extension_icon($filename, $size=null) {
|
||||
// Get the extension
|
||||
$extension = substr($filename, strrpos($filename, '.'));
|
||||
$mimeinfo = get_mimetypes_array();
|
||||
foreach ($mimeinfo as $ext=>$mime) {
|
||||
// Check each till we find an exact match for extension
|
||||
if ($ext === $extension) {
|
||||
$icon = $mime['icon'];
|
||||
$icon = substr($icon, 0, strrpos($icon, '.'));
|
||||
if ($size!=null && is_int($size)) {
|
||||
$icon .= '-'.$size;
|
||||
}
|
||||
return 'f/'.$icon;
|
||||
}
|
||||
}
|
||||
// Didn't find a match return the default
|
||||
$icon = $mimeinfo['xxx']['icon'];
|
||||
$icon = substr($icon, 0, strrpos($icon, '.'));
|
||||
if ($size!=null && is_int($size)) {
|
||||
$icon .= '-'.$size;
|
||||
$element = 'icon';
|
||||
if ($size!==null) {
|
||||
$element .= (string)$size;
|
||||
}
|
||||
$icon = mimeinfo($element, $filename);
|
||||
return 'f/'.$icon;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user