Skip to content

Rename all known .gif icon names in c_tool to .png #2107

Closed
@ywarnier

Description

@ywarnier

Current behavior

The c_tool records created by Chamilo all use .gif icon references (except for plugins). In the "big-activity" view, the course homepage view transforms these .gif in .png, but this is an added process (see https://github.com/chamilo/chamilo-lms/blob/1.11.x/main/inc/lib/course_home.lib.php#L1037).

Expected behavior

We started to remove all .gif images, so it would make sense to move all these references to .png.

In a sense, and considering we are often still cutting the image names to add the "_na" suffix for gray icons, it would make sense to only keep the name of the icon without any extension, but that would make other things (like the return_icon function) more complicated and it is likely it would not result in a performance gain overall.

How to proceed

This change involves an upgrade procedure. As such, it should be included in the upgrade process to get to the next major version (2.0).
Also, it should not affect c_tool records that are not part of the default Chamilo. As such, we should provide a whiltelist of the only icons which need modifications and do something like this:

$list = [
    'info.gif' => 'info.png',
    'agenda.gif' => 'agenda.png',
    'folder_document.gif' => 'folder_document.png',
    'scorms.gif' => 'scorms.png',
    'links.gif' => 'links.png',
    'quiz.gif' => 'quiz.png',
    'valves.gif' => 'valves.png',
    'forum.gif' => 'forum.png',
    'dropbox.gif' => 'dropbox.png',
    'members.gif' => 'members.png',
    'group.gif' => 'group.png',
    'chat.gif' => 'chat.png',
    'works.gif' => 'works.png',
    'survey.gif' => 'survey.png',
    'wiki.gif' => 'wiki.png',
    'gradebook.gif' => 'gradebook.png',
    'glossary.gif' => 'glossary.png',
    'notebook.gif' => 'notebook.png',
    'attendance.gif' => 'attendance.png',
    'course_progress.gif' => 'course_progress.png',
    'blog_admin.gif' => 'blog_admin.png',
    'statistics.gif' => 'statistics.png',
    'reference.gif' => 'reference.png',
    'backup.gif' => 'backup.png',
    'blog.gif' => 'blog.png',
];
foreach ($list as $original => $new) {
    $query = $db->query("UPDATE c_tool SET image = '$new' WHERE image = '$original'");
    $query->exec();
}

After that, the main/course_home/ scripts would probably need to be updated to reflect the change to PNG, which implies adding the size of the icon as well (which is currently not part of the image path, as there is only one version of the gifs). And of course updating the course_home.lib.php reference above to remove the str_replace() in getToolIcon()

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions