Difference between revisions of "Core filetypes"
From MoodleDocs
John Okely (talk | contribs) m (Example code) |
David Mudrak (talk | contribs) m (Text replacement - "<code>" to "<syntaxhighlight lang="php">") |
||
(One intermediate revision by the same user not shown) | |||
Line 3: | Line 3: | ||
get_default_types returns an associative array of extension keys to a value which is an array of type, icon, groups and string (which is a lang string which will be used when displaying the type. The lang string is passed $a->EXT which is the actual extension. | get_default_types returns an associative array of extension keys to a value which is an array of type, icon, groups and string (which is a lang string which will be used when displaying the type. The lang string is passed $a->EXT which is the actual extension. | ||
− | < | + | <syntaxhighlight lang="php"> |
'php' => array('type' => 'text/plain', 'icon' => 'sourcecode'), | 'php' => array('type' => 'text/plain', 'icon' => 'sourcecode'), | ||
'pic' => array('type' => 'image/pict', 'icon' => 'image', 'groups' => array('image'), 'string' => 'image'), | 'pic' => array('type' => 'image/pict', 'icon' => 'image', 'groups' => array('image'), 'string' => 'image'), | ||
'pict' => array('type' => 'image/pict', 'icon' => 'image', 'groups' => array('image'), 'string' => 'image'), | 'pict' => array('type' => 'image/pict', 'icon' => 'image', 'groups' => array('image'), 'string' => 'image'), | ||
'png' => array('type' => 'image/png', 'icon' => 'png', 'groups' => array('image', 'web_image'), 'string' => 'image') | 'png' => array('type' => 'image/png', 'icon' => 'png', 'groups' => array('image', 'web_image'), 'string' => 'image') | ||
− | </ | + | </syntaxhighlight> |
String example (in lang/en/mimetypes.php) | String example (in lang/en/mimetypes.php) | ||
− | < | + | <syntaxhighlight lang="php"> |
$string['image'] = 'Image ({$a->MIMETYPE2})'; | $string['image'] = 'Image ({$a->MIMETYPE2})'; | ||
− | </ | + | </syntaxhighlight> |
Any groups added should add a language string to lang/en/mimetypes.php with the formate group:<groupname>. This is so that the group can be displayed in a human readable formate in the user's native language. | Any groups added should add a language string to lang/en/mimetypes.php with the formate group:<groupname>. This is so that the group can be displayed in a human readable formate in the user's native language. |
Latest revision as of 13:06, 14 July 2021
lib/classes/filetypes.php defines the filetypes included in core.
get_default_types returns an associative array of extension keys to a value which is an array of type, icon, groups and string (which is a lang string which will be used when displaying the type. The lang string is passed $a->EXT which is the actual extension.
'php' => array('type' => 'text/plain', 'icon' => 'sourcecode'),
'pic' => array('type' => 'image/pict', 'icon' => 'image', 'groups' => array('image'), 'string' => 'image'),
'pict' => array('type' => 'image/pict', 'icon' => 'image', 'groups' => array('image'), 'string' => 'image'),
'png' => array('type' => 'image/png', 'icon' => 'png', 'groups' => array('image', 'web_image'), 'string' => 'image')
String example (in lang/en/mimetypes.php)
$string['image'] = 'Image ({$a->MIMETYPE2})';
Any groups added should add a language string to lang/en/mimetypes.php with the formate group:<groupname>. This is so that the group can be displayed in a human readable formate in the user's native language.