Issue Details (XML | Word | Printable)

Key: MDL-19707
Type: Sub-task Sub-task
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Sam Hemelryk
Reporter: Tim Hunt
Votes: 0
Watchers: 2
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle
MDL-19077

Need a better way to print the appropriate icon for files

Created: 03/Jul/09 02:56 PM   Updated: 07/Jul/09 04:05 PM
Return to search
Component/s: Lib
Affects Version/s: 2.0
Fix Version/s: 2.0

Participants: Sam Hemelryk and Tim Hunt
Security Level: None
Resolved date: 07/Jul/09
Affected Branches: MOODLE_20_STABLE
Fixed Branches: MOODLE_20_STABLE


 Description  « Hide
In the change to $CFG->pixpath to $OUTPUT->old_icon_url I had to do a nasty hack for file icons.

There is now a couple of dozen instances of code like

str_replace(array('.gif', '.png'), '', mimeinfo_from_type('icon', $mimetype));


I think what we need is:

1. a new method $OUTPUT->file_icon_url($mimetype); the does the same as $OUTPUT->old_icon_url(... above search and replace ...);

2. a new method $OUTPUT->link_to_file($file); that does the half-a-dozen lines of code we have duplicated around the place that is a link to a file, with the appropriate icon next to it. (For example, look at where it outputs forum attachements, or uploaded files in assignment.)

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Sam Hemelryk committed 1 file to 'Moodle CVS' - 07/Jul/09 11:56 AM
lib-filelib MDL-19707 Added file_extension_icon() and file_mimetype_icon()
After talking with Tim we decided that this would be a better solution than adding more methods to $OUTPUT
MODIFY lib/filelib.php   Rev. 1.153    (+75 -0 lines)
Sam Hemelryk committed 1 file to 'Moodle CVS' - 07/Jul/09 12:03 PM
lib-filelib MDL-19707 Modified file_extension_icon() to accept full filename
MODIFY lib/filelib.php   Rev. 1.154    (+8 -11 lines)
Sam Hemelryk committed 23 files to 'Moodle CVS' - 07/Jul/09 02:16 PM
filelib MDL-19707 Converted existing ...str_replace('png','gif')... to use file_extension_icon and file_mimetype_icon
MODIFY repository/filesystem/repository.class.php   Rev. 1.14    (+2 -2 lines)
MODIFY repository/wikimedia/repository.class.php   Rev. 1.6    (+1 -1 lines)
MODIFY course/lib.php   Rev. 1.668    (+3 -3 lines)
MODIFY mod/assignment/type/upload/assignment.class.php   Rev. 1.70    (+4 -7 lines)
MODIFY mod/assignment/type/uploadsingle/assignment.class.php   Rev. 1.46    (+2 -3 lines)
MODIFY blog/lib.php   Rev. 1.112    (+2 -3 lines)
MODIFY repository/boxnet/repository.class.php   Rev. 1.71    (+2 -2 lines)
MODIFY mod/assignment/lib.php   Rev. 1.394    (+1 -2 lines)
MODIFY question/contextmove_form.php   Rev. 1.5    (+3 -4 lines)
MODIFY repository/url/repository.class.php   Rev. 1.9    (+2 -2 lines)
MODIFY mod/forum/lib.php   Rev. 1.803    (+1 -2 lines)
MODIFY repository/lib.php   Rev. 1.190    (+2 -2 lines)
MODIFY files/index.php   Rev. 1.143    (+1 -2 lines)
MODIFY repository/s3/repository.class.php   Rev. 1.11    (+2 -2 lines)
MODIFY mod/resource/type/directory/Attic/resource.class.php   Rev. 1.47    (+3 -3 lines)
MODIFY repository/mahara/repository.class.php   Rev. 1.11    (+1 -1 lines)
MODIFY question/contextmoveq_form.php   Rev. 1.5    (+2 -3 lines)
MODIFY files/draftfiles.php   Rev. 1.11    (+1 -2 lines)
MODIFY repository/alfresco/repository.class.php   Rev. 1.20    (+2 -2 lines)
MODIFY mod/data/field/file/field.class.php   Rev. 1.34    (+3 -5 lines)
MODIFY mod/wiki/ewiki/plugins/moodle/downloads.php   Rev. 1.21    (+2 -3 lines)
MODIFY repository/webdav/repository.class.php   Rev. 1.12    (+2 -2 lines)
MODIFY mod/glossary/lib.php   Rev. 1.257    (+1 -2 lines)
Sam Hemelryk committed 2 files to 'Moodle CVS' - 08/Jul/09 09:52 AM
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
MODIFY course/lib.php   Rev. 1.669    (+3 -3 lines)
MODIFY lib/filelib.php   Rev. 1.155    (+5 -20 lines)