Skip to content

Commit

Permalink
MDL-78930 filetypes: Add MIME for PSD and JSON icon
Browse files Browse the repository at this point in the history
- The PSD icon has been there all this time, but no MIME type was using it.
A new MIME has been added (image/vnd.adobe.photoshop) for the .psd files.
The MIME type for existing PSD files will be also upgraded.

- A new JSON icon has been added. It will be used by the JSON, CSS and SCSS
MIME types.
  • Loading branch information
sarjona committed Aug 28, 2023
1 parent 9bfcd77 commit 9be5196
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion admin/tool/filetypes/tests/tool_filetypes_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ public function test_get_icons_from_path() {
*/
public function test_get_file_icons() {
$icons = utils::get_file_icons();
$this->assertCount(30, $icons);
$this->assertCount(31, $icons);
}
}
7 changes: 4 additions & 3 deletions lib/classes/filetypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected static function get_default_types() {
'cct' => array('type' => 'shockwave/director', 'icon' => 'flash'),
'cpp' => array('type' => 'text/plain', 'icon' => 'sourcecode'),
'cs' => array('type' => 'application/x-csh', 'icon' => 'sourcecode'),
'css' => array('type' => 'text/css', 'icon' => 'text', 'groups' => array('web_file')),
'css' => array('type' => 'text/css', 'icon' => 'json', 'groups' => array('web_file')),
'csv' => array('type' => 'text/csv', 'icon' => 'spreadsheet', 'groups' => array('spreadsheet')),
'dv' => array('type' => 'video/x-dv', 'icon' => 'video', 'groups' => array('video'), 'string' => 'video'),
'dmg' => array('type' => 'application/octet-stream', 'icon' => 'unknown'),
Expand Down Expand Up @@ -145,7 +145,7 @@ protected static function get_default_types() {
'string' => 'image'),
'jqz' => array('type' => 'text/xml', 'icon' => 'markup'),
'js' => array('type' => 'application/x-javascript', 'icon' => 'text', 'groups' => array('web_file')),
'json' => array('type' => 'application/json', 'icon' => 'text'),
'json' => array('type' => 'application/json', 'icon' => 'json'),
'latex' => array('type' => 'application/x-latex', 'icon' => 'text'),
'm' => array('type' => 'text/plain', 'icon' => 'sourcecode'),
'mbz' => array('type' => 'application/vnd.moodle.backup', 'icon' => 'moodle'),
Expand Down Expand Up @@ -229,6 +229,7 @@ protected static function get_default_types() {
'ppsm' => array('type' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', 'icon' => 'powerpoint',
'groups' => array('presentation')),
'ps' => array('type' => 'application/postscript', 'icon' => 'pdf'),
'psd' => array('type' => 'image/vnd.adobe.photoshop', 'icon' => 'psd'),
'pub' => array('type' => 'application/x-mspublisher', 'icon' => 'publisher', 'groups' => array('presentation')),

'qt' => array('type' => 'video/quicktime', 'icon' => 'video',
Expand All @@ -248,7 +249,7 @@ protected static function get_default_types() {
'rtx' => array('type' => 'text/richtext', 'icon' => 'text'),
'rv' => array('type' => 'audio/x-pn-realaudio-plugin', 'icon' => 'audio',
'groups' => array('video'), 'string' => 'video'),
'scss' => array('type' => 'text/x-scss', 'icon' => 'text', 'groups' => array('web_file')),
'scss' => array('type' => 'text/x-scss', 'icon' => 'json', 'groups' => array('web_file')),
'sh' => array('type' => 'application/x-sh', 'icon' => 'sourcecode'),
'sit' => array('type' => 'application/x-stuffit', 'icon' => 'archive',
'groups' => array('archive'), 'string' => 'archive'),
Expand Down
14 changes: 14 additions & 0 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3501,5 +3501,19 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2023082200.04);
}

if ($oldversion < 2023082600.01) {
// Upgrade MIME type for existing PSD files.
$DB->set_field_select(
'files',
'mimetype',
'image/vnd.adobe.photoshop',
$DB->sql_like('filename', '?', false),
['%.psd']
);

// Main savepoint reached.
upgrade_main_savepoint(true, 2023082600.01);
}

return true;
}
5 changes: 5 additions & 0 deletions pix/f/json.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

defined('MOODLE_INTERNAL') || die();

$version = 2023082600.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2023082600.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.3dev+ (Build: 20230826)'; // Human-friendly version name
Expand Down

0 comments on commit 9be5196

Please sign in to comment.