Révision 9a28ac3f
Ajouté par Assos Assos il y a presque 4 ans
drupal7/sites/all/modules/file_entity/file_entity.admin.inc | ||
---|---|---|
1112 | 1112 |
'#maxlength' => NULL, |
1113 | 1113 |
); |
1114 | 1114 |
|
1115 |
$form['file_entity_max_filesize_extensions'] = array( |
|
1116 |
'#type' => 'textarea', |
|
1117 |
'#title' => t('Maximum upload size per extension'), |
|
1118 |
'#default_value' => variable_get('file_entity_max_filesize_extensions', ''), |
|
1119 |
'#description' => t('Set the maximum filesize for specific extensions. Enter one value per line, in the format <strong>extension|filesize</strong>. When an extension does not have a file size limit, the default maximum file size is used.'), |
|
1120 |
'#rows' => 10, |
|
1121 |
'#element_validate' => array('file_entity_max_filesize_extensions_validate'), |
|
1122 |
); |
|
1123 |
|
|
1115 | 1124 |
$form['file_entity_alt'] = array( |
1116 | 1125 |
'#type' => 'textfield', |
1117 | 1126 |
'#title' => t('Alt attribute'), |
... | ... | |
1183 | 1192 |
|
1184 | 1193 |
return system_settings_form($form); |
1185 | 1194 |
} |
1195 |
|
|
1196 |
/** |
|
1197 |
* Element validate callback for the maximum upload size / file extension field. |
|
1198 |
*/ |
|
1199 |
function file_entity_max_filesize_extensions_validate($element, &$form_state) { |
|
1200 |
$list = explode("\n", $element['#value']); |
|
1201 |
|
|
1202 |
foreach ($list as $position => $text) { |
|
1203 |
$matches = array(); |
|
1204 |
preg_match('/(.*)\|(.*)/', $text, $matches); |
|
1205 |
|
|
1206 |
$extension = $matches[1]; |
|
1207 |
$filesize = $matches[2]; |
|
1208 |
|
|
1209 |
//Validate filesize. |
|
1210 |
$element['#value'] = $filesize; |
|
1211 |
_file_generic_settings_max_filesize($element, $form_state); |
|
1212 |
|
|
1213 |
//Validate extension. |
|
1214 |
$extensions = explode(' ', $form_state['input']['file_entity_default_allowed_extensions']); |
|
1215 |
if (!in_array($extension, $extensions)) { |
|
1216 |
form_error($element, t('"!extension" was not found in the list of allowed extensions.', array('!extension' => $extension))); |
|
1217 |
} |
|
1218 |
} |
|
1219 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules