Class to manage the custom filetypes list that is stored in a config variable.
More...
|
static | add_type ($extension, $mimetype, $coreicon, array $groups=array(), $corestring='', $customdescription='', $defaulticon=false) |
| Adds a new entry to the list of custom filetypes.
|
|
static | delete_type ($extension) |
| Deletes a file type from the config list (or, for a standard one, marks it as deleted).
|
|
static | get_deleted_types () |
| Gets the default types that have been deleted.
|
|
static | get_file_extension ($mimetype) |
| Given a mimetype - return a valid file extension for it.
|
|
static & | get_types () |
| Gets all the current types.
|
|
static | reset_caches () |
| Clears the type cache.
|
|
static | revert_type_to_default ($extension) |
| Reverts a file type to the default.
|
|
static | update_type ($extension, $newextension, $mimetype, $coreicon, array $groups=array(), $corestring='', $customdescription='', $defaulticon=false) |
| Updates an entry in the list of filetypes in config.
|
|
|
static | create_config_record ($extension, $mimetype, $coreicon, array $groups, $corestring, $customdescription, $defaulticon) |
| Converts function parameters into a record for storing in the JSON value.
|
|
static | get_custom_types () |
| Gets custom types from config variable, after decoding the JSON if required.
|
|
static | get_default_types () |
| Gets default MIME types that are included as standard.
|
|
static | set_custom_types (array $types) |
| Sets the custom types into config variable, encoding into JSON.
|
|
|
static array | $cachedtypes |
| Cached MIME types for current request.
|
|
Class to manage the custom filetypes list that is stored in a config variable.
- Copyright
- 2014 The Open University
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ add_type()
static core_filetypes::add_type |
( |
| $extension, |
|
|
| $mimetype, |
|
|
| $coreicon, |
|
|
array | $groups = array(), |
|
|
| $corestring = '', |
|
|
| $customdescription = '', |
|
|
| $defaulticon = false ) |
|
static |
Adds a new entry to the list of custom filetypes.
- Parameters
-
string | $extension | File extension without dot, e.g. 'doc' |
string | $mimetype | MIME type e.g. 'application/msword' |
string | $coreicon | Core icon to use e.g. 'document' |
array | $groups | Array of group strings that this type belongs to |
string | $corestring | Custom lang string name in mimetypes.php |
string | $customdescription | Custom description (plain text/multilang) |
bool | $defaulticon | True if this should be the default icon for the type |
- Exceptions
-
◆ create_config_record()
static core_filetypes::create_config_record |
( |
| $extension, |
|
|
| $mimetype, |
|
|
| $coreicon, |
|
|
array | $groups, |
|
|
| $corestring, |
|
|
| $customdescription, |
|
|
| $defaulticon ) |
|
staticprotected |
Converts function parameters into a record for storing in the JSON value.
- Parameters
-
string | $extension | File extension without dot, e.g. 'doc' |
string | $mimetype | MIME type e.g. 'application/msword' |
string | $coreicon | Core icon to use e.g. 'document' |
array | $groups | Array of group strings that this type belongs to |
string | $corestring | Custom lang string name in mimetypes.php |
string | $customdescription | Custom description (plain text/multilang) |
bool | $defaulticon | True if this should be the default icon for the type |
- Return values
-
stdClass | Record matching the parameters |
◆ delete_type()
static core_filetypes::delete_type |
( |
| $extension | ) |
|
|
static |
Deletes a file type from the config list (or, for a standard one, marks it as deleted).
- Parameters
-
string | $extension | File extension without dot, e.g. 'doc' |
- Exceptions
-
◆ get_custom_types()
static core_filetypes::get_custom_types |
( |
| ) |
|
|
staticprotected |
Gets custom types from config variable, after decoding the JSON if required.
- Return values
-
array | Array of custom types (empty array if none) |
◆ get_default_types()
static core_filetypes::get_default_types |
( |
| ) |
|
|
staticprotected |
Gets default MIME types that are included as standard.
Note: Use the function get_mimetypes_array to access this data including any customisations the user might have made.
- Return values
-
array | Default (pre-installed) MIME type information |
◆ get_deleted_types()
static core_filetypes::get_deleted_types |
( |
| ) |
|
|
static |
Gets the default types that have been deleted.
Returns an array containing the defaults of all those types.
- Return values
-
array | Array (same format as get_mimetypes_array) |
◆ get_file_extension()
static core_filetypes::get_file_extension |
( |
| $mimetype | ) |
|
|
static |
Given a mimetype - return a valid file extension for it.
- Parameters
-
- Return values
-
string|bool | False if the mimetype was not known, a string indicating a valid file extension otherwise. It may not be the only valid file extension - just the first one found. |
◆ get_types()
static & core_filetypes::get_types |
( |
| ) |
|
|
static |
Gets all the current types.
- Return values
-
array | Associative array from extension to array of data about type |
◆ reset_caches()
static core_filetypes::reset_caches |
( |
| ) |
|
|
static |
Clears the type cache.
This is not needed in normal use as the set_custom_types function automatically clears the cache. Intended for use in unit tests.
◆ revert_type_to_default()
static core_filetypes::revert_type_to_default |
( |
| $extension | ) |
|
|
static |
Reverts a file type to the default.
May only be called on types that have default values. This will undelete the type if necessary or set its values. If the type is already at default values, does nothing.
- Parameters
-
string | $extension | File extension without dot, e.g. 'doc' |
- Return values
-
bool | True if anything was changed, false if it was already default |
- Exceptions
-
◆ set_custom_types()
static core_filetypes::set_custom_types |
( |
array | $types | ) |
|
|
staticprotected |
Sets the custom types into config variable, encoding into JSON.
- Parameters
-
array | $types | Array of custom types |
- Exceptions
-
◆ update_type()
static core_filetypes::update_type |
( |
| $extension, |
|
|
| $newextension, |
|
|
| $mimetype, |
|
|
| $coreicon, |
|
|
array | $groups = array(), |
|
|
| $corestring = '', |
|
|
| $customdescription = '', |
|
|
| $defaulticon = false ) |
|
static |
Updates an entry in the list of filetypes in config.
- Parameters
-
string | $extension | File extension without dot, e.g. 'doc' |
string | $newextension | New file extension (same if not changing) |
string | $mimetype | MIME type e.g. 'application/msword' |
string | $coreicon | Core icon to use e.g. 'document' |
array | $groups | Array of group strings that this type belongs to |
string | $corestring | Custom lang string name in mimetypes.php |
string | $customdescription | Custom description (plain text/multilang) |
bool | $defaulticon | True if this should be the default icon for the type |
- Exceptions
-
The documentation for this class was generated from the following file:
- lib/classes/filetypes.php