• Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Icon: Minor Minor
    • DEV backlog
    • 2.1, 2.2
    • Files API
    • MOODLE_21_STABLE, MOODLE_22_STABLE
    • wip-MDL-32247-files23
    • Hide

      Unit test is included. For a simple custom test, open any page with WYSIWYG editor and click on 'Add image' or 'Add media', in the first case only image file should be listed in the repositories, in the second only audio and video ones.

      Show
      Unit test is included. For a simple custom test, open any page with WYSIWYG editor and click on 'Add image' or 'Add media', in the first case only image file should be listed in the repositories, in the second only audio and video ones.

      I have discovered recently that there are two separate mimetype-related features in Moodle. One is several mimetype functions that use get_mimetypes_array() as the source, another one is filetype_parser class that is using file_types.mm mindmap file as a data source.

      In my opinion, having two data sources may cause inconsistencies and dissimilarities in mime data we work with, thus I suggest to remove one of them (likely the mindmap one) and design a function for deriving the list of file extensions from existing mimetypes array (i.e. replicate filetype_parser functionality and refactor few bits where it is used).

      Andrew provided a quick proof of concept for this:

      function get_mimetype_matches($match) {
          if (!is_array($match)) {
              $match = array($match);
          }    
          $mimetypes = get_mimetypes_array();
          $results = array();
          foreach($mimetypes as $key => $data) {
              if (in_array($data['type'], $match)) {
                  $results[$key] = $data;
              }    
          }    
          return $results;
      }

      Would be good to know people's opinion about this change.

            marina Marina Glancy
            kabalin Ruslan Kabalin
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.