Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
tool_filetypes\utils Class Reference

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

Static Public Member Functions

static get_file_icons ()
 Gets unique file type icons from pix/f folder.
 
static get_icons_from_path ($path)
 Gets all unique file type icons from a specific path, not including sub-directories.
 
static is_defaulticon_allowed ($mimetype, $oldextension='')
 Checks if we are allowed to turn on the 'default icon' option.
 
static is_extension_invalid ($extension, $oldextension='')
 Checks if the given file type extension is invalid.
 

Detailed Description

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

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ get_file_icons()

static tool_filetypes\utils::get_file_icons ( )
static

Gets unique file type icons from pix/f folder.

Return values
arrayAn array of unique file type icons e.g. 'pdf' => 'pdf'

◆ get_icons_from_path()

static tool_filetypes\utils::get_icons_from_path ( $path)
static

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

Parameters
string$pathThe path of the icon path
Return values
arrayAn array of unique file icons within the given path

◆ is_defaulticon_allowed()

static tool_filetypes\utils::is_defaulticon_allowed ( $mimetype,
$oldextension = '' )
static

Checks if we are allowed to turn on the 'default icon' option.

You can only have one of these for a given MIME type.

Parameters
string$mimetypeMIME type
string$oldextensionFile extension name (before any change)

◆ is_extension_invalid()

static tool_filetypes\utils::is_extension_invalid ( $extension,
$oldextension = '' )
static

Checks if the given file type extension is invalid.

The added file type extension must be unique and must not begin with a dot.

Parameters
string$extensionExtension of the file type to add
string$oldextensionExtension prior to update (empty string if adding new type)
Return values
boolTrue if it the file type trying to add already exists

The documentation for this class was generated from the following file: