Moodle

Need a better way to print the appropriate icon for files

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: Libraries
  • Labels:
    None
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

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.)

Activity

Hide
Sam Hemelryk added a comment -

Am resolving this issue.
After talking with Tim I think it is better to hold off on implementing a link_to_file method until such time the $OUTPUT->link has been implemented.

Show
Sam Hemelryk added a comment - Am resolving this issue. After talking with Tim I think it is better to hold off on implementing a link_to_file method until such time the $OUTPUT->link has been implemented.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: