Projet

Général

Profil

Révision fc3d89c3

Ajouté par Assos Assos il y a plus de 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/media/includes/media.fields.inc
100 100

  
101 101
  // Essentially we use the media type, extended with some enhancements.
102 102
  $element_info = element_info('media');
103
  $multiselect = ($field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED);
104

  
103 105
  $element += array(
104 106
    '#type' => 'media',
105 107
    '#value_callback' => 'media_field_widget_value',
......
113 115
        'file_extensions' => isset($field_settings['file_extensions']) ? $field_settings['file_extensions'] : variable_get('file_entity_default_allowed_extensions', 'jpg jpeg gif png txt doc docx xls xlsx pdf ppt pptx pps ppsx odt ods odp mp3 mov mp4 m4a m4v mpeg avi ogg oga ogv weba webp webm'),
114 116
        'max_filesize' => isset($field_settings['max_filesize']) ? $field_settings['max_filesize'] : 0,
115 117
        'uri_scheme' => !empty($field['settings']['uri_scheme']) ? $field['settings']['uri_scheme'] : file_default_scheme(),
118
        'multiselect' => $multiselect,
116 119
      ),
117 120
    ),
118 121
    // Allows this field to return an array instead of a single value.
......
277 280
 * wrapper around the entire group so it can be replaced all at once.
278 281
 */
279 282
function media_field_widget_process_multiple($element, &$form_state, $form) {
283
    // In order to support multiple selection, we need to reconstruct the _POST
284
  // data that is checked in media_attach_file(). We need to reconstruct the
285
  // field's _POST key name, for example: field_mediafield_und_0.
286
  $upload_name_prefix = implode('_', $element['#parents']) . '_';
287
  $upload_name = $upload_name_prefix . $element['#file_upload_delta'];
288
  if (!empty($_POST['media'][$upload_name])) {
289
    $files = explode(',', $_POST['media'][$upload_name]);
290
    $count = count($files);
291
    // Supposing #file_upload_delta is always the last delta this will work
292
    for ($i = 0; $i < $count; $i++) {
293
      // For each file selected, increment the field key to be processed.
294
      // field_mediafield_und_0 becomes field_mediafield_und_1, etc.
295
      $_POST['media'][$upload_name_prefix . ($element['#file_upload_delta'] + $i)] = $files[$i];
296
      $element[] = $element[$element['#file_upload_delta']];
297
    }
298
  }
299

  
280 300
  $element_children = element_children($element, TRUE);
281 301
  $count = count($element_children);
282 302

  

Formats disponibles : Unified diff