1 file.admin.inc | file_type_form_validate($form, &$form_state) |
Form validation handler for file_file_type_form().
See also
file_file_type_form_submit()
File
- core/
modules/ file/ file.admin.inc, line 246 - Admin page callbacks for the File module.
Code
function file_type_form_validate($form, &$form_state) {
include_once BACKDROP_ROOT . '/core/includes/file.mimetypes.inc';
$mimetype_mapping = file_mimetype_mapping();
$valid_mimetypes = $mimetype_mapping['mimetypes'];
$submitted_mimetypes = array_filter(array_map('trim', explode("\n", $form_state['values']['mimetypes'])));
$invalid_mimetypes = array();
foreach ($submitted_mimetypes as $mimetype) {
if (!file_match_mimetypes($mimetype, $valid_mimetypes)) {
$invalid_mimetypes[] = $mimetype;
}
}
foreach ($invalid_mimetypes as $mimetype) {
form_set_error('mimetypes', t('The mimetype %mimetype is not a valid mimetype.', array('%mimetype' => $mimetype)));
}
}