function file_entity_get_filetype_candidates in File Entity (fieldable files) 7.3
Same name and namespace in other branches
- 7.2 file_entity.pages.inc \file_entity_get_filetype_candidates()
Get the candidate filetypes for a given file.
Only filetypes for which the user has access to create entities are returned.
Parameters
array $file: An upload file array from form_state.
Return value
array An array of file type bundles that support the file's mime type.
2 calls to file_entity_get_filetype_candidates()
- file_entity_add_upload_step_filetype in ./
file_entity.pages.inc - Generate form fields for the second step in the add file wizard.
- file_entity_add_upload_submit in ./
file_entity.pages.inc - Submit handler for the add file form.
File
- ./
file_entity.pages.inc, line 471 - Supports file operations including View, Edit, and Delete.
Code
function file_entity_get_filetype_candidates($file, $selected_files = array()) {
$types = module_invoke_all('file_type', $file);
drupal_alter('file_type', $types, $file);
// If no file types are selected in field instance settings, allow all
// available types.
if (!empty($selected_files)) {
// Limit file type candidates to field allowed types.
$types = array_intersect($types, $selected_files);
}
$candidates = array();
foreach ($types as $type) {
$file->type = $type;
if (file_entity_access('create', $file)) {
$candidates[$type] = file_entity_type_get_name($file);
}
}
return $candidates;
}