Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Class with static back-end methods used by the file type tool.

Copyright: 2014 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 122 lines (4 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

utils:: (4 methods):
  is_extension_invalid()
  is_defaulticon_allowed()
  get_icons_from_path()
  get_file_icons()


Class: utils  - X-Ref

Class with static back-end methods used by the file type tool.

is_extension_invalid($extension, $oldextension = '')   X-Ref
Checks if the given file type extension is invalid.
The added file type extension must be unique and must not begin with a dot.

param: string $extension Extension of the file type to add
param: string $oldextension Extension prior to update (empty string if adding new type)
return: bool True if it the file type trying to add already exists

is_defaulticon_allowed($mimetype, $oldextension = '')   X-Ref
Checks if we are allowed to turn on the 'default icon' option. You can
only have one of these for a given MIME type.

param: string $mimetype MIME type
param: string $oldextension File extension name (before any change)

get_icons_from_path($path)   X-Ref
Gets all unique file type icons from a specific path, not including
sub-directories.

Icon files such as pdf.png, pdf-24.png and pdf-36.png etc. are counted as
the same icon type.

The resultant array has both key and value set to the icon name prefix,
such as 'pdf' => 'pdf'.

param: string $path The path of the icon path
return: array An array of unique file icons within the given path

get_file_icons()   X-Ref
Gets unique file type icons from pix/f folder.

return: array An array of unique file type icons e.g. 'pdf' => 'pdf'