Projet

Général

Profil

Révision ca0757b9

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

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/date_ical/date_ical.api.php
221 221
    $tzid = 'America/New_York';
222 222
  }
223 223
}
224

  
225
/**
226
 * Add an additional custom source to be mapped by a feed.
227
 *
228
 * This is useful when you need to map fields from an iCal feed which
229
 * the Date iCal module does not currently support.
230
 *
231
 * @param array $sources
232
 *   An associative array containing the source's properties, as follows:
233
 *     name: The name that will appear in the feed importer Mapping page.
234
 *     description: The description of this field shown in the Mapping page.
235
 *     date_ical_parse_handler: The function in the ParserVcalendar class
236
 *       which should be used to parse this iCal property into a Drupal field.
237
 */
238
function hook_date_ical_mapping_sources_alter(&$sources) {
239
  // Example of what might be done with this alter hook:
240
  // Add the "ATTENDEE" iCal property to the mapping sources.
241
  $sources['ATTENDEE'] = array(
242
    'name' => t('Attendee'),
243
    'description' => t('The ATTENDEE property.'),
244
    'date_ical_parse_handler' => 'parseTextProperty',
245
  );
246
  // Add "ATTENDEE:CN" parameter to the mapping sources.
247
  $sources['ATTENDEE:CN'] = array(
248
    'name' => t('Attendee: CN'),
249
    'description' => t("The CN parameter of the ATTENDEE property: the attendee's Common Name."),
250
    'date_ical_parse_handler' => 'parsePropertyParameter',
251
  );
252
}
drupal7/sites/all/modules/date_ical/date_ical.info
21 21
; Includes for iCal feed import using Feeds
22 22
files[] = includes/DateiCalFeedsParser.inc
23 23

  
24
; Information added by Drupal.org packaging script on 2014-05-30
25
version = "7.x-3.2"
24
; Information added by Drupal.org packaging script on 2014-10-08
25
version = "7.x-3.3"
26 26
core = "7.x"
27 27
project = "date_ical"
28
datestamp = "1401492228"
28
datestamp = "1412727230"
29 29

  
drupal7/sites/all/modules/date_ical/date_ical.module
10 10
 * value of the iCal feeds created by Date iCal. It's primarily used for
11 11
 * debugging.
12 12
 */
13
define('DATE_ICAL_VERSION', '3.2');
13
define('DATE_ICAL_VERSION', '3.3');
14 14

  
15 15
/**
16 16
 * Exception class for generic exceptions thrown by this module.
......
222 222
/**
223 223
 * Reformats the provided text to be compliant with the iCal spec.
224 224
 *
225
 * If the text contains HTML tags, those tags will be stripped (with <p> tags
226
 * converted to "\n\n" and link tags converted to footnotes), and uneeded
227
 * whitespace will be cleaned up.
225
 * If the text contains HTML tags, those tags will be stripped. Paragraph,
226
 * heading, and div tags will be replaced with newlines.
228 227
 *
229 228
 * @param string $text
230 229
 *   The text to be sanitized.
231 230
 */
232 231
function date_ical_sanitize_text($text = '') {
233
  // Use Drupal's built-in HTML to Text converter, which does a mostly
234
  // adequate job of making the text iCal-compliant.
235
  $text = trim(drupal_html_to_text($text));
236
  // Replace instances of more than one space with exactly one space. This
237
  // cleans up the whitespace mess that drupal_html_to_text() leaves behind.
238
  $text = preg_replace("/  +/", " ", $text);
239
  // The call to drupal_html_to_text() above converted <p> to \n\n, and also
240
  // shoved a \n into the string every 80 characters. We don't want those
241
  // single \n's lying around, because iCalcreator will properly "fold" long
242
  // text fields for us. So, we need to remove all instances of \n which
243
  // are neither immediately preceeded, nor followed, by another \n.
244
  // However, \n's which are followed immediately by a > character should
245
  // remain, because of how drupal_html_to_text() converts <blockquote>.
246
  $text = preg_replace("/(?<!\n)\n(?![\n\>])/", " ", $text);
247
  return $text;
232
  // HTML tags may get converted to &lt; and such by the View code, so we need
233
  // to convert them back to HTML so we can remove them with strip_tags().
234
  $text = decode_entities($text);
235
  
236
  // Convert <p> tags to double newlines.
237
  $text = trim(preg_replace("/<p.*?>/i", "\n\n", $text));
238
  // Separate heading tags from the text around them in both directions.
239
  $text = trim(preg_replace("/<\\?h\d.*?>/i", "\n\n", $text));
240
  // Add a newline for each <div>.
241
  $text = trim(preg_replace("/<div.*?>/i", "\n", $text));
242
  
243
  // Strip the remaining HTML.
244
  $text = strip_tags($text);
245
  // Remove newlines added at the beginning.
246
  return trim($text);
248 247
}
249 248

  
250 249
/**
drupal7/sites/all/modules/date_ical/includes/DateiCalFeedsParser.inc
85 85
  public function configDefaults() {
86 86
    return array(
87 87
      'indefinite_count' => '52',
88
      'indefinite_message_display' => TRUE,
88 89
      'until_not_utc' => FALSE,
89 90
      'skip_days' => NULL,
90 91
    );
......
107 108
      '#description' => t('Indefinitely repeating events are not supported. The repeat count will instead be set to this number.'),
108 109
      '#default_value' => $this->config['indefinite_count'],
109 110
    );
111
    $form['indefinite_message_display'] = array(
112
      '#title' => t('Display message when RRULE is missing COUNT'),
113
      '#type' => 'checkbox',
114
      '#default_value' => $this->config['indefinite_message_display'],
115
      '#description' => t('Display a message when an indefinitely repeating rule is adjusted by the "Indefinite COUNT" setting above.'),
116
    );
110 117
    $form['until_not_utc'] = array(
111 118
      '#title' => t('RRULE UNTILs are not in UTC'),
112 119
      '#type' => 'checkbox',
......
196 203
      'description' => t('The CATEGORIES property. Catagories that describe the event, which can be imported into taxonomy terms.'),
197 204
      'date_ical_parse_handler' => 'parseMultivalueProperty',
198 205
    );
206
    
207
    // Allow other modules to add custom source fields.
208
    drupal_alter('date_ical_mapping_sources', $sources);
209
    
199 210
    return $sources;
200 211
  }
201 212
}
drupal7/sites/all/modules/date_ical/includes/date_ical_plugin_row_ical_entity.inc
248 248
          // Make sure this Node Reference actually references a node.
249 249
          if ($location_field['nid']) {
250 250
            $node = node_load($location_field['nid']);
251
            $location = check_plain($node->title);
251
            $location = $node->title;
252 252
          }
253 253
        }
254 254
        elseif ($location_info['type'] == 'addressfield') {
......
276 276
              $location_data[] = $location_field[$included_field];
277 277
            }
278 278
          }
279
          $location = check_plain(implode(', ', $location_data));
279
          $location = implode(', ', $location_data);
280 280
        }
281 281
        else {
282
          $location = check_plain($location_field['value']);
282
          $location = $location_field['value'];
283 283
        }
284 284
      }
285 285
    }
......
345 345
    $event['url'] = url($uri['path'], $uri['options']);
346 346
    $event['rrule'] = $is_field && array_key_exists('rrule', $date_field) ? $date_field['rrule'] : '';
347 347
    if ($location) {
348
      $event['location'] = $location;
348
      $event['location'] = date_ical_sanitize_text($location);
349 349
    }
350 350
    
351 351
    // For this event's UID, use either the date_id generated by the Date
drupal7/sites/all/modules/date_ical/includes/date_ical_plugin_row_ical_fields.inc
226 226
    drupal_alter('date_ical_export_html', $text_fields, $this->view, $context);
227 227
    
228 228
    // Sanitize the text fields for iCal compliance, and add them to the event.
229
    // Also strip all HTML from the summary and location fields, since they
230
    // must be plaintext, and may have been set as links by the view.
231
    $event['summary'] = date_ical_sanitize_text(strip_tags($text_fields['summary']));
232
    $event['location'] = date_ical_sanitize_text(strip_tags($text_fields['location']));
229
    $event['summary'] = date_ical_sanitize_text($text_fields['summary']);
230
    $event['location'] = date_ical_sanitize_text($text_fields['location']);
233 231
    $event['description'] = date_ical_sanitize_text($text_fields['description']);
234 232
    
235
    // Allow other modules to alter the event object, before it gets passed to
233
    // Allow other modules to alter the event object before it gets passed to
236 234
    // the style plugin to be converted into an iCal VEVENT.
237 235
    drupal_alter('date_ical_export_raw_event', $event, $this->view, $context);
238 236
    
drupal7/sites/all/modules/date_ical/libraries/ParserVcalendar.inc
33 33
  protected $totalComponents = 0;
34 34
  protected $lastComponentParsed = 0;
35 35
  
36
  /**
37
   * This is the list of iCal properties which are allowed to have more than
38
   * one entry in a single VEVENT. If we ever support parsing more than just
39
   * the first one, this listing will be useful.
40
   */
41
  protected $multi_entry_properties = array(
42
    'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION',
43
    'EXDATE', 'EXRULE', 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES',
44
    'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP'
45
  );
46
  
36 47
  /**
37 48
   * Constructor.
38 49
   */
......
123 134
          else {
124 135
            // We can safely ignore certain sources.
125 136
            $known_unknowns = array(
126
              // "Black Source 1" is from Feeds Tamper.
127
              'Blank source 1',
137
              'Blank source 1', // "Black Source 1" is from Feeds Tamper.
138
              'parent:nid', // Defined in FeedsParser
139
              'parent:uid', // Defined in FeedsParser
128 140
            );
129 141
            if (!in_array($property_key, $known_unknowns)) {
130 142
              // Only warn the user if this mapping source is in use.
......
180 192
    return $this->lastComponentParsed;
181 193
  }
182 194
  
195
  /**
196
   * Handler that parses GEO fields.
197
   *
198
   * @return array
199
   *   The latitude and longitude values, keyed by 'lat' and 'lon'.
200
   */
201
  public function parseGeofield($property_key, $vcalendar_component) {
202
    $geo = array();
203
    if (!empty($vcalendar_component->geo['value'])) {
204
      $geo['lat'] = $vcalendar_component->geo['value']['latitude'];
205
      $geo['lon'] = $vcalendar_component->geo['value']['longitude'];
206
    }
207
    return $geo;
208
  }
209
  
183 210
  /**
184 211
   * Handler that parses text fields.
185 212
   *
......
188 215
   */
189 216
  public function parseTextProperty($property_key, $vcalendar_component) {
190 217
    $text = $vcalendar_component->getProperty($property_key);
218
    // In case someone writes a hook that adds a source for a multi-entry
219
    // property and a parameter of that same property, we need to force
220
    // iCalcreator to assume it has not accessed that property, yet.
221
    // TODO: This is really just a hack. If/when multi-entry properties
222
    // become supported, this will need to be redesigned.
223
    if (in_array($property_key, $this->multi_entry_properties)) {
224
      unset($vcalendar_component->propix[$property_key]);
225
    }
226
    
191 227
    if ($text === FALSE) {
192 228
      if ($property_key == 'SUMMARY') {
193 229
        $uid = $vcalendar_component->getProperty('UID');
......
201 237
    return $text;
202 238
  }
203 239
  
204
  /**
205
   * Handler that parses GEO fields.
206
   *
207
   * @return array
208
   *   The latitude and longitude values, keyed by 'lat' and 'lon'.
209
   */
210
  public function parseGeofield($property_key, $vcalendar_component) {
211
    $geo = array();
212
    if (!empty($vcalendar_component->geo['value'])) {
213
      $geo['lat'] = $vcalendar_component->geo['value']['latitude'];
214
      $geo['lon'] = $vcalendar_component->geo['value']['longitude'];
215
    }
216
    return $geo;
217
  }
218
  
219 240
  /**
220 241
   * Handler that parses field parameters.
221 242
   *
......
225 246
  public function parsePropertyParameter($property_key, $vcalendar_component) {
226 247
    list($key, $attr) = explode(':', $property_key);
227 248
    $property = $vcalendar_component->getProperty($key, FALSE, TRUE);
249
    // See parseTextProperty() for why this is here.
250
    if (in_array($property_key, $this->multi_entry_properties)) {
251
      unset($vcalendar_component->propix[$property_key]);
252
    }
253
        
228 254
    if ($property === FALSE) {
229 255
      // If the component doesn't have this property, return NULL.
230 256
      return NULL;
......
422 448
        $rrule_data['value']['INTERVAL'] = '1';
423 449
      }
424 450
      
425
      if (!isset($rrule_data['value']['COUNT']) && !isset($rrule_data['value']['UNTIL'])) {
451
      if ((!isset($rrule_data['value']['COUNT']) && !isset($rrule_data['value']['UNTIL']))) {
426 452
        $msg = "The event with UID %uid has an indefinitely repeating RRULE, which the Date Repeat module doesn't support.
427 453
          As a workaround, Date iCal set the repeat count to @count. This value can be customized in the iCal parser settings.";
428 454
        watchdog('date_ical', $msg, array('%uid' => $uid, '@count' => $count), WATCHDOG_WARNING);
429
        drupal_set_message(
430
          t("At least one of the events in this iCal feed has an indefinitely repeating RRULE, which the Date Repeat module doesn't support.<br>
431
            As a workaround, Date iCal set the repeat count to @count. This value can be customized in the iCal parser settings.",
432
          array('@count' => $count)),
433
          'warning',
434
          FALSE
435
        );
455
        if ($this->config['indefinite_message_display']) {
456
          drupal_set_message(
457
            t("At least one of the events in this iCal feed has an indefinitely repeating RRULE, which the Date Repeat module doesn't support.<br>
458
              As a workaround, Date iCal set the repeat count to @count. This value can be customized in the iCal parser settings.",
459
            array('@count' => $count)),
460
            'warning',
461
            FALSE
462
          );
463
        }
436 464
        $rrule_data['value']['COUNT'] = $this->config['indefinite_count'];
437 465
      }
438 466
    }
drupal7/sites/all/modules/file_entity/admin_views_default/file.admin-content-file.inc
33 33
$handler->display->display_options['pager']['options']['quantity'] = '9';
34 34
$handler->display->display_options['style_plugin'] = 'table';
35 35
$handler->display->display_options['style_options']['columns'] = array(
36
  'views_bulk_operations' => 'views_bulk_operations',
37
  'filename' => 'filename',
38
  'type' => 'type',
39
  'name' => 'name',
40
  'filesize' => 'filesize',
41
  'timestamp' => 'timestamp',
42
  'edit' => 'edit',
43
  'delete' => 'delete',
36
    'views_bulk_operations' => 'views_bulk_operations',
37
    'filename' => 'filename',
38
    'type' => 'type',
39
    'name' => 'name',
40
    'filesize' => 'filesize',
41
    'timestamp' => 'timestamp',
42
    'edit' => 'edit',
43
    'delete' => 'delete',
44 44
);
45 45
$handler->display->display_options['style_options']['default'] = 'timestamp';
46 46
$handler->display->display_options['style_options']['info'] = array(
47
  'views_bulk_operations' => array(
48
    'align' => '',
49
    'separator' => '',
50
    'empty_column' => 0,
51
  ),
52
  'filename' => array(
53
    'sortable' => 1,
54
    'default_sort_order' => 'asc',
55
    'align' => '',
56
    'separator' => '',
57
    'empty_column' => 0,
58
  ),
59
  'type' => array(
60
    'sortable' => 1,
61
    'default_sort_order' => 'asc',
62
    'align' => '',
63
    'separator' => '',
64
    'empty_column' => 0,
65
  ),
66
  'name' => array(
67
    'sortable' => 1,
68
    'default_sort_order' => 'asc',
69
    'align' => '',
70
    'separator' => '',
71
    'empty_column' => 0,
72
  ),
73
  'filesize' => array(
74
    'sortable' => 1,
75
    'default_sort_order' => 'asc',
76
    'align' => '',
77
    'separator' => '',
78
    'empty_column' => 0,
79
  ),
80
  'timestamp' => array(
81
    'sortable' => 1,
82
    'default_sort_order' => 'desc',
83
    'align' => '',
84
    'separator' => '',
85
    'empty_column' => 0,
86
  ),
87
  'edit' => array(
88
    'sortable' => 0,
89
    'default_sort_order' => 'asc',
90
    'align' => '',
91
    'separator' => '',
92
    'empty_column' => 0,
93
  ),
94
  'delete' => array(
95
    'sortable' => 0,
96
    'default_sort_order' => 'asc',
97
    'align' => '',
98
    'separator' => '',
99
    'empty_column' => 0,
100
  ),
47
    'views_bulk_operations' => array(
48
        'align' => '',
49
        'separator' => '',
50
        'empty_column' => 0,
51
    ),
52
    'filename' => array(
53
        'sortable' => 1,
54
        'default_sort_order' => 'asc',
55
        'align' => '',
56
        'separator' => '',
57
        'empty_column' => 0,
58
    ),
59
    'type' => array(
60
        'sortable' => 1,
61
        'default_sort_order' => 'asc',
62
        'align' => '',
63
        'separator' => '',
64
        'empty_column' => 0,
65
    ),
66
    'name' => array(
67
        'sortable' => 1,
68
        'default_sort_order' => 'asc',
69
        'align' => '',
70
        'separator' => '',
71
        'empty_column' => 0,
72
    ),
73
    'filesize' => array(
74
        'sortable' => 1,
75
        'default_sort_order' => 'asc',
76
        'align' => '',
77
        'separator' => '',
78
        'empty_column' => 0,
79
    ),
80
    'timestamp' => array(
81
        'sortable' => 1,
82
        'default_sort_order' => 'desc',
83
        'align' => '',
84
        'separator' => '',
85
        'empty_column' => 0,
86
    ),
87
    'edit' => array(
88
        'sortable' => 0,
89
        'default_sort_order' => 'asc',
90
        'align' => '',
91
        'separator' => '',
92
        'empty_column' => 0,
93
    ),
94
    'usage' => array(
95
        'sortable' => 1,
96
        'default_sort_order' => 'asc',
97
        'align' => '',
98
        'separator' => '',
99
        'empty_column' => 0,
100
    ),
101
    'delete' => array(
102
        'sortable' => 0,
103
        'default_sort_order' => 'asc',
104
        'align' => '',
105
        'separator' => '',
106
        'empty_column' => 0,
107
    ),
101 108
);
102 109
$handler->display->display_options['style_options']['sticky'] = TRUE;
103 110
$handler->display->display_options['style_options']['empty_table'] = TRUE;
......
123 130
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0;
124 131
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10';
125 132
$handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array(
126
  'action::views_bulk_operations_archive_action' => array(
127
    'selected' => 1,
128
    'postpone_processing' => 0,
129
    'skip_confirmation' => 0,
130
    'override_label' => 1,
131
    'label' => 'Archive',
132
    'settings' => array(
133
      'scheme' => 'public',
134
      'temporary' => 1,
133
    'action::views_bulk_operations_archive_action' => array(
134
        'selected' => 1,
135
        'postpone_processing' => 0,
136
        'skip_confirmation' => 0,
137
        'override_label' => 1,
138
        'label' => 'Archive',
139
        'settings' => array(
140
            'scheme' => 'public',
141
            'temporary' => 1,
142
        ),
143
    ),
144
    'action::views_bulk_operations_delete_item' => array(
145
        'selected' => 1,
146
        'postpone_processing' => 0,
147
        'skip_confirmation' => 0,
148
        'override_label' => 1,
149
        'label' => 'Delete',
150
    ),
151
    'action::views_bulk_operations_script_action' => array(
152
        'selected' => 0,
153
        'postpone_processing' => 0,
154
        'skip_confirmation' => 0,
155
        'override_label' => 0,
156
        'label' => '',
157
    ),
158
    'action::views_bulk_operations_modify_action' => array(
159
        'selected' => 1,
160
        'postpone_processing' => 0,
161
        'skip_confirmation' => 1,
162
        'override_label' => 1,
163
        'label' => 'Change value',
164
        'settings' => array(
165
            'show_all_tokens' => 1,
166
            'display_values' => array(
167
                '_all_' => '_all_',
168
            ),
169
        ),
135 170
    ),
136
  ),
137
  'action::views_bulk_operations_delete_item' => array(
138
    'selected' => 1,
139
    'postpone_processing' => 0,
140
    'skip_confirmation' => 0,
141
    'override_label' => 1,
142
    'label' => 'Delete',
143
  ),
144
  'action::views_bulk_operations_script_action' => array(
145
    'selected' => 0,
146
    'postpone_processing' => 0,
147
    'skip_confirmation' => 0,
148
    'override_label' => 0,
149
    'label' => '',
150
  ),
151
  'action::views_bulk_operations_modify_action' => array(
152
    'selected' => 1,
153
    'postpone_processing' => 0,
154
    'skip_confirmation' => 1,
155
    'override_label' => 1,
156
    'label' => 'Change value',
157
    'settings' => array(
158
      'show_all_tokens' => 1,
159
      'display_values' => array(
160
        '_all_' => '_all_',
161
      ),
171
    'action::views_bulk_operations_argument_selector_action' => array(
172
        'selected' => 0,
173
        'skip_confirmation' => 0,
174
        'override_label' => 0,
175
        'label' => '',
176
        'settings' => array(
177
            'url' => '',
178
        ),
162 179
    ),
163
  ),
164
  'action::views_bulk_operations_argument_selector_action' => array(
165
    'selected' => 0,
166
    'skip_confirmation' => 0,
167
    'override_label' => 0,
168
    'label' => '',
169
    'settings' => array(
170
      'url' => '',
180
    'action::system_send_email_action' => array(
181
        'selected' => 0,
182
        'postpone_processing' => 0,
183
        'skip_confirmation' => 0,
184
        'override_label' => 0,
185
        'label' => '',
186
    ),
187
    'action::panelizer_set_status_action' => array(
188
        'selected' => 0,
189
        'postpone_processing' => 0,
190
        'skip_confirmation' => 0,
191
        'override_label' => 0,
192
        'label' => '',
171 193
    ),
172
  ),
173
  'action::system_send_email_action' => array(
174
    'selected' => 0,
175
    'postpone_processing' => 0,
176
    'skip_confirmation' => 0,
177
    'override_label' => 0,
178
    'label' => '',
179
  ),
180
  'action::panelizer_set_status_action' => array(
181
    'selected' => 0,
182
    'postpone_processing' => 0,
183
    'skip_confirmation' => 0,
184
    'override_label' => 0,
185
    'label' => '',
186
  ),
187 194
);
188 195
/* Field: File: Name */
189 196
$handler->display->display_options['fields']['filename']['id'] = 'filename';
190 197
$handler->display->display_options['fields']['filename']['table'] = 'file_managed';
191 198
$handler->display->display_options['fields']['filename']['field'] = 'filename';
199
$handler->display->display_options['fields']['filename']['label'] = 'Title';
192 200
/* Field: File: Type */
193 201
$handler->display->display_options['fields']['type']['id'] = 'type';
194 202
$handler->display->display_options['fields']['type']['table'] = 'file_managed';
195 203
$handler->display->display_options['fields']['type']['field'] = 'type';
196 204
$handler->display->display_options['fields']['type']['machine_name'] = 0;
205
/* Field: File: Size */
206
$handler->display->display_options['fields']['filesize']['id'] = 'filesize';
207
$handler->display->display_options['fields']['filesize']['table'] = 'file_managed';
208
$handler->display->display_options['fields']['filesize']['field'] = 'filesize';
209
$handler->display->display_options['fields']['filesize']['empty'] = '0 bytes';
197 210
/* Field: User: Name */
198 211
$handler->display->display_options['fields']['name']['id'] = 'name';
199 212
$handler->display->display_options['fields']['name']['table'] = 'users';
200 213
$handler->display->display_options['fields']['name']['field'] = 'name';
201 214
$handler->display->display_options['fields']['name']['relationship'] = 'uid';
202
$handler->display->display_options['fields']['name']['label'] = 'User';
203
/* Field: File: Size */
204
$handler->display->display_options['fields']['filesize']['id'] = 'filesize';
205
$handler->display->display_options['fields']['filesize']['table'] = 'file_managed';
206
$handler->display->display_options['fields']['filesize']['field'] = 'filesize';
215
$handler->display->display_options['fields']['name']['label'] = 'Author';
207 216
/* Field: File: Upload date */
208 217
$handler->display->display_options['fields']['timestamp']['id'] = 'timestamp';
209 218
$handler->display->display_options['fields']['timestamp']['table'] = 'file_managed';
210 219
$handler->display->display_options['fields']['timestamp']['field'] = 'timestamp';
211
$handler->display->display_options['fields']['timestamp']['label'] = 'Uploaded';
220
$handler->display->display_options['fields']['timestamp']['label'] = 'Updated';
212 221
$handler->display->display_options['fields']['timestamp']['date_format'] = 'short';
222
$handler->display->display_options['fields']['timestamp']['second_date_format'] = 'long';
223
/* Field: File: Usage link */
224
$handler->display->display_options['fields']['usage']['id'] = 'usage';
225
$handler->display->display_options['fields']['usage']['table'] = 'file_managed';
226
$handler->display->display_options['fields']['usage']['field'] = 'usage';
227
$handler->display->display_options['fields']['usage']['label'] = 'Used in';
228
$handler->display->display_options['fields']['usage']['element_label_colon'] = FALSE;
213 229
/* Field: File: Edit link */
214 230
$handler->display->display_options['fields']['edit']['id'] = 'edit';
215 231
$handler->display->display_options['fields']['edit']['table'] = 'file_managed';
216 232
$handler->display->display_options['fields']['edit']['field'] = 'edit';
217 233
$handler->display->display_options['fields']['edit']['label'] = '';
234
$handler->display->display_options['fields']['edit']['exclude'] = TRUE;
218 235
$handler->display->display_options['fields']['edit']['element_label_colon'] = FALSE;
219
/* Field: File: Usage link */
220
$handler->display->display_options['fields']['usage']['id'] = 'usage';
221
$handler->display->display_options['fields']['usage']['table'] = 'file_managed';
222
$handler->display->display_options['fields']['usage']['field'] = 'usage';
223
$handler->display->display_options['fields']['usage']['label'] = '';
224
$handler->display->display_options['fields']['usage']['element_label_colon'] = FALSE;
225 236
/* Field: File: Delete link */
226 237
$handler->display->display_options['fields']['delete']['id'] = 'delete';
227 238
$handler->display->display_options['fields']['delete']['table'] = 'file_managed';
228 239
$handler->display->display_options['fields']['delete']['field'] = 'delete';
229 240
$handler->display->display_options['fields']['delete']['label'] = '';
241
$handler->display->display_options['fields']['delete']['exclude'] = TRUE;
242
$handler->display->display_options['fields']['delete']['alter']['text'] = '<ul class="links inline">
243
<li>[edit]</li>
244
<li>[delete]</li>
245
</ul>';
230 246
$handler->display->display_options['fields']['delete']['element_label_colon'] = FALSE;
247
/* Field: Global: Custom text */
248
$handler->display->display_options['fields']['nothing']['id'] = 'nothing';
249
$handler->display->display_options['fields']['nothing']['table'] = 'views';
250
$handler->display->display_options['fields']['nothing']['field'] = 'nothing';
251
$handler->display->display_options['fields']['nothing']['label'] = 'Operations';
252
$handler->display->display_options['fields']['nothing']['alter']['text'] = '<ul class="links inline">
253
<li>[edit]</li>
254
<li>[delete]</li>
255
</ul>';
256
$handler->display->display_options['fields']['nothing']['element_label_colon'] = FALSE;
231 257
/* Filter criterion: File: Name */
232 258
$handler->display->display_options['filters']['filename']['id'] = 'filename';
233 259
$handler->display->display_options['filters']['filename']['table'] = 'file_managed';
......
241 267
$handler->display->display_options['filters']['filename']['expose']['identifier'] = 'filename';
242 268
$handler->display->display_options['filters']['filename']['expose']['remember'] = TRUE;
243 269
$handler->display->display_options['filters']['filename']['expose']['remember_roles'] = array(
244
  2 => '2',
245
  1 => 0,
246
  3 => 0,
270
    2 => '2',
271
    1 => 0,
272
    3 => 0,
247 273
);
248 274
/* Filter criterion: File: Type */
249 275
$handler->display->display_options['filters']['type']['id'] = 'type';
......
257 283
$handler->display->display_options['filters']['type']['expose']['identifier'] = 'type';
258 284
$handler->display->display_options['filters']['type']['expose']['remember'] = TRUE;
259 285
$handler->display->display_options['filters']['type']['expose']['remember_roles'] = array(
260
  2 => '2',
261
  1 => 0,
262
  3 => 0,
286
    2 => '2',
287
    1 => 0,
288
    3 => 0,
263 289
);
264 290
/* Filter criterion: User: Name */
265 291
$handler->display->display_options['filters']['uid']['id'] = 'uid';
......
275 301
$handler->display->display_options['filters']['uid']['expose']['identifier'] = 'uid';
276 302
$handler->display->display_options['filters']['uid']['expose']['remember'] = TRUE;
277 303
$handler->display->display_options['filters']['uid']['expose']['remember_roles'] = array(
278
  2 => '2',
279
  1 => 0,
280
  3 => 0,
304
    2 => '2',
305
    1 => 0,
306
    3 => 0,
281 307
);
282 308

  
283 309
/* Display: System */
drupal7/sites/all/modules/file_entity/file_entity.admin.inc
1065 1065
    '#title' => t('Default allowed file extensions'),
1066 1066
    '#default_value' => 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'),
1067 1067
    '#description' => t('Separate extensions with a space or comma and do not include the leading dot.'),
1068
    '#maxlength' => NULL,
1068 1069
  );
1069 1070

  
1070 1071
  $form['file_entity_alt'] = array(
drupal7/sites/all/modules/file_entity/file_entity.api.php
338 338
  $headers['X-Powered-By'] = 'My Module';
339 339
}
340 340

  
341
/**
342
 * React to a file being downloaded.
343
 */
344
function hook_file_transfer($uri, array $headers) {
345
  // Redirect a download for an S3 file to the actual location.
346
  if (file_uri_scheme($uri) == 's3') {
347
    $url = file_create_url($uri);
348
    drupal_goto($url);
349
  }
350
}
351

  
341 352
/**
342 353
 * Decides which file type (bundle) should be assigned to a file entity.
343 354
 *
drupal7/sites/all/modules/file_entity/file_entity.field.inc
160 160
      '#type' => 'checkbox',
161 161
      '#default_value' => $settings['loop'],
162 162
    );
163
    $element['muted'] = array(
164
      '#title' => t('Muted'),
165
      '#type' => 'checkbox',
166
      '#default_value' => $settings['muted'],
167
    );
163 168
    $element['width'] = array(
164 169
      '#type' => 'textfield',
165 170
      '#title' => t('Width'),
......
220 225
    if (isset($settings['multiple_file_behavior'])) {
221 226
      $summary[] = t('Multiple files: %multiple', array('%multiple' => $settings['multiple_file_behavior']));
222 227
    }
223

  
224 228
  }
225 229
  elseif ($display['type'] === 'file_video') {
226
    $summary_items = array();
227 230
    if (isset($settings['controls'])) {
228 231
      $summary[] = t('Controls: %controls', array('%controls' => $settings['controls'] ? 'visible' : 'hidden'));
229 232
    }
......
286 289
    foreach ($items as $delta => $item) {
287 290
      if (!isset($recursion_queue[$item['fid']])) {
288 291
        $files_display[$item['fid']] = file_load($item['fid']);
292
        if (!empty($item['description'])) {
293
          $files_display[$item['fid']]->description = $item['description'];
294
        }
289 295
      }
290 296
    }
291 297

  
......
293 299
    if ($files_display) {
294 300
      foreach ($files_display as $fid => $file) {
295 301
        $files_display[$fid]->referencing_entity = $entity;
302
        $files_display[$fid]->referencing_entity_type = $entity_type;
296 303
        $files_display[$fid]->referencing_field = $field['field_name'];
297 304
      }
298 305
      $output = file_view_multiple($files_display, $view_mode);
......
330 337
    if ($multiple_file_behavior == 'tags') {
331 338
      foreach ($items as $delta => $item) {
332 339
        if ($item['type'] == 'audio') {
333
          $source_lists[] = array($item);
340
          $source_lists[$delta] = array($item);
334 341
        }
335 342
      }
336 343
    }
337 344
    else {
338 345
      foreach ($items as $delta => $item) {
339 346
        if ($item['type'] == 'audio') {
340
          $source_lists[0][] = $item;
347
          $source_lists[0][$delta] = $item;
341 348
        }
342 349
      }
343 350
    }
......
364 371
    if ($multiple_file_behavior == 'tags') {
365 372
      foreach ($items as $delta => $item) {
366 373
        if ($item['type'] == 'video') {
367
          $source_lists[] = array($item);
374
          $source_lists[$delta] = array($item);
368 375
        }
369 376
      }
370 377
    }
371 378
    else {
372 379
      foreach ($items as $delta => $item) {
373 380
        if ($item['type'] == 'video') {
374
          $source_lists[0][] = $item;
381
          $source_lists[0][$delta] = $item;
375 382
        }
376 383
      }
377 384
    }
378 385

  
379 386
    // Render each source list as an <video> element.
380 387
    foreach ($source_lists as $delta => $sources) {
381
      $width = $settings['width'];
382
      $height = $settings['height'];
383 388
      $element[$delta] = array(
384 389
        '#theme' => 'file_entity_file_video',
385 390
        '#files' => $sources,
......
387 392
        '#autoplay' => $settings['autoplay'],
388 393
        '#loop' => $settings['loop'],
389 394
        '#muted' => $settings['muted'],
390
        '#width' => ($width && $height) ? $width : NULL,
391
        '#height' => ($width && $height) ? $height : NULL,
395
        '#width' => $settings['width'],
396
        '#height' => $settings['height'],
392 397
      );
393 398
    }
394 399
  }
drupal7/sites/all/modules/file_entity/file_entity.file.inc
59 59

  
60 60
  // Save file metadata.
61 61
  if (!empty($file->metadata)) {
62
    $query = db_insert('file_metadata')->fields(array('fid', 'name', 'value'));
62 63
    foreach ($file->metadata as $name => $value) {
63
      db_merge('file_metadata')
64
        ->fields(array(
65
          'value' => serialize($value),
66
        ))
67
        ->key(array(
68
          'fid' => $file->fid,
69
          'name' => $name,
70
        ))
71
        ->execute();
64
      $query->values(array(
65
        'fid' => $file->fid,
66
        'name' => $name,
67
        'value' => serialize($value),
68
      ));
72 69
    }
70
    $query->execute();
73 71
  }
74 72

  
75 73
  // Clear any related field caches.
......
84 82
  field_attach_update('file', $file);
85 83

  
86 84
  // Save file metadata.
85
  db_delete('file_metadata')->condition('fid', $file->fid)->execute();
87 86
  if (!empty($file->metadata)) {
87
    $query = db_insert('file_metadata')->fields(array('fid', 'name', 'value'));
88 88
    foreach ($file->metadata as $name => $value) {
89
      db_merge('file_metadata')
90
        ->fields(array(
91
          'value' => serialize($value),
92
        ))
93
        ->key(array(
94
          'fid' => $file->fid,
95
          'name' => $name,
96
        ))
97
        ->execute();
98
    }
99
  }
100

  
101
  // Save file metadata.
102
  db_delete('file_metadata')->condition('fid', $file->fid);
103
  if (!empty($file->metadata)) {
104
    foreach ($file->metadata as $name => $value) {
105
      db_merge('file_metadata')
106
        ->fields(array(
107
          'value' => serialize($value),
108
        ))
109
        ->key(array(
110
          'fid' => $file->fid,
111
          'name' => $name,
112
        ))
113
        ->execute();
89
      $query->values(array(
90
        'fid' => $file->fid,
91
        'name' => $name,
92
        'value' => serialize($value),
93
      ));
114 94
    }
95
    $query->execute();
115 96
  }
116 97

  
117
  if (file_entity_file_get_mimetype_type($file) == 'image' && module_exists('image')) {
118
    // If the image dimensions have changed, update any image field references
119
    // to this file and flush image style derivatives.
120
    if ($file->metadata['width'] != $file->metadata['width'] || $file->metadata['height'] != $file->metadata['height']) {
98
  if (module_exists('image') && file_entity_file_get_mimetype_type($file) == 'image' && $file->filesize) {
99
    // If the file has changed dimensions or a new file has been uploaded,
100
    // update any image field reference to this file and flush image style
101
    // derivatives.
102
    $file->metadata += array('width' => NULL, 'height' => NULL);
103
    $file->original->metadata += array('width' => NULL, 'height' => NULL);
104
    if ($file->filesize != $file->original->filesize || $file->metadata['width'] != $file->original->metadata['width'] || $file->metadata['height'] != $file->original->metadata['height']) {
121 105
      _file_entity_update_image_field_dimensions($file);
122 106
    }
123 107

  
......
246 230
 * @see http://drupal.org/node/1448124
247 231
 */
248 232
function _file_entity_update_image_field_dimensions($file) {
233
  // Prevent PHP notices when trying to read empty files.
234
  // @see http://drupal.org/node/681042
235
  if (!$file->filesize) {
236
    return;
237
  }
238

  
249 239
  // Do not bother proceeding if this file does not have an image mime type.
250 240
  if (file_entity_file_get_mimetype_type($file) != 'image') {
251 241
    return;
drupal7/sites/all/modules/file_entity/file_entity.file_api.inc
484 484
  return !empty($type->disabled);
485 485
}
486 486

  
487
/**
488
 * Returns an array of valid file extensions.
489
 */
490
function file_type_get_valid_extensions($type) {
491
  include_once DRUPAL_ROOT . '/includes/file.mimetypes.inc';
492
  $mapping = file_mimetype_mapping();
493

  
494
  $type_extensions = array();
495
  $type_ext_keys = array();
496
  if (!empty($type->mimetypes)) {
497
    foreach ($mapping['mimetypes'] as $ext_key => $mimetype) {
498
      if (file_entity_match_mimetypes($mimetype, $type->mimetypes)) {
499
        $type_ext_keys[] = $ext_key;
500
      }
501
    }
502

  
503
    if ($type_ext_keys) {
504
      $type_extensions = array_intersect($mapping['extensions'], $type_ext_keys);
505
      $type_extensions = array_keys($type_extensions);
506
    }
507
  }
508

  
509
  return $type_extensions;
510
}
511

  
487 512
/**
488 513
 * Updates an existing file type or creates a new one.
489 514
 *
......
596 621
 *   Type of the file_type to disable
597 622
 */
598 623
function file_type_enable($type) {
624
  ctools_include('export');
599 625
  ctools_export_crud_enable('file_type', $type);
600 626
}
601 627

  
......
607 633
 *   Type of the file_type to disable
608 634
 */
609 635
function file_type_disable($type) {
636
  ctools_include('export');
610 637
  ctools_export_crud_disable('file_type', $type);
611 638
}
612 639

  
......
699 726
  if (empty($file)) {
700 727
    $file = new stdClass();
701 728
    $file->uid = $GLOBALS['user']->uid;
702
    $file->filename = basename($uri);
729
    $file->filename = drupal_basename($uri);
703 730
    $file->uri = $uri;
704 731
    $file->filemime = file_get_mimetype($uri);
705 732
    // This is gagged because some uris will not support it.
drupal7/sites/all/modules/file_entity/file_entity.file_default_displays.inc
93 93
  $file_display->settings = '';
94 94
  $file_displays['image__teaser__file_field_file_default'] = $file_display;
95 95

  
96
  // Enhance the default image displays if the Image module is enabled.
97
  if (module_exists('image')) {
98
    // Images should be displayed as unstyled images by default.
99
    $file_display = new stdClass();
100
    $file_display->api_version = 1;
101
    $file_display->name = 'image__default__file_field_image';
102
    $file_display->weight = 49;
103
    $file_display->status = TRUE;
104
    $file_display->settings = array(
105
      'image_style' => '',
106
      'image_link' => '',
107
    );
108
    $file_displays['image__default__file_field_image'] = $file_display;
109

  
110
    // Image previews should be displayed as image thumbnails by default.
111
    $file_display = new stdClass();
112
    $file_display->api_version = 1;
113
    $file_display->name = 'image__preview__file_field_image';
114
    $file_display->weight = 49;
115
    $file_display->status = TRUE;
116
    $file_display->settings = array(
117
      'image_style' => 'thumbnail',
118
      'image_link' => '',
119
    );
120
    $file_displays['image__preview__file_field_image'] = $file_display;
121

  
122
    // Image teasers should be displayed as medium images by default.
123
    $file_display = new stdClass();
124
    $file_display->api_version = 1;
125
    $file_display->name = 'image__teaser__file_field_image';
126
    $file_display->weight = 49;
127
    $file_display->status = TRUE;
128
    $file_display->settings = array(
129
      'image_style' => 'medium',
130
      'image_link' => 'content',
131
    );
132
    $file_displays['image__teaser__file_field_image'] = $file_display;
133
  }
134

  
96 135
  $file_display = new stdClass();
97 136
  $file_display->api_version = 1;
98 137
  $file_display->name = 'video__default__file_field_file_video';
drupal7/sites/all/modules/file_entity/file_entity.info
10 10
files[] = views/views_handler_field_file_rendered.inc
11 11
files[] = views/views_handler_field_file_type.inc
12 12
files[] = views/views_handler_filter_file_type.inc
13
files[] = views/views_handler_filter_schema_type.inc
13 14
files[] = views/views_handler_field_file_filename.inc
14 15
files[] = views/views_handler_field_file_link.inc
15 16
files[] = views/views_handler_field_file_link_edit.inc
......
24 25
; We have to add a fake version so Git checkouts do not fail Media dependencies
25 26
version = 7.x-2.x-dev
26 27

  
27
; Information added by drupal.org packaging script on 2013-10-25
28
version = "7.x-2.0-alpha3"
28
; Information added by Drupal.org packaging script on 2014-10-04
29
version = "7.x-2.0-beta1"
29 30
core = "7.x"
30 31
project = "file_entity"
31
datestamp = "1382744726"
32
datestamp = "1412420930"
32 33

  
drupal7/sites/all/modules/file_entity/file_entity.install
375 375
            'permission' => 'view file',
376 376
            'module' => 'file_entity',
377 377
          ))
378
          ->condition('rid', $rid)
379
          ->condition('permission', 'view file')
378 380
          ->execute();
379 381
      }
380 382
    }
......
900 902

  
901 903
  // Migrate any existing MIME type information into {file_type}.
902 904
  if (db_table_exists('file_type_mimetypes')) {
903
    foreach (file_type_load_all(TRUE) as $type) {
904
      $mimetypes = array();
905
      $result = db_select('file_type_mimetypes', 'ftm')
905
    module_load_include('inc', 'file_entity', 'file_entity.file_api');
906
    $types = file_type_load_all(TRUE);
907
    foreach ($types as $type) {
908
      $mimetypes = db_select('file_type_mimetypes', 'ftm')
906 909
        ->fields('ftm', array('mimetype'))
907
        ->condition('type', $type->type, '=')
908
        ->execute();
909

  
910
      foreach ($result as $record) {
911
        $mimetypes[] = $record->mimetype;
912
      }
910
        ->condition('type', $type->type)
911
        ->execute()->fetchCol();
913 912

  
914 913
      if (!empty($mimetypes)) {
915 914
        $type->mimetypes = $mimetypes;
drupal7/sites/all/modules/file_entity/file_entity.module
38 38
 */
39 39
function file_entity_hook_info() {
40 40
  $hooks = array(
41
    'file_operation_info',
42
    'file_operation_info_alter',
41
    'file_operations',
43 42
    'file_type_info',
44 43
    'file_type_info_alter',
45 44
    'file_formatter_info',
......
84 83
  $info += array_fill_keys($hooks, array('group' => 'file'));
85 84
}
86 85

  
86
/**
87
 * Implements hook_module_implements_alter().
88
 */
89
function file_entity_module_implements_alter(&$implementations, $hook) {
90
  // nginx_accel_redirect_file_transfer() is an accidental hook implementation.
91
  // @see https://www.drupal.org/node/2278625
92
  if ($hook == 'file_transfer') {
93
    unset($implementations['nginx_accel_redirect']);
94
  }
95
}
96

  
87 97
/**
88 98
 * Implements hook_help().
89 99
 */
......
189 199
    'type' => MENU_DEFAULT_LOCAL_TASK,
190 200
    'weight' => -10,
191 201
  );
202
  $items['file/add/upload/file'] = array(
203
    'title' => 'File',
204
    'type' => MENU_DEFAULT_LOCAL_TASK,
205
    'weight' => -10,
206
  );
207
  $items['file/add/upload/archive'] = array(
208
    'title' => 'Archive',
209
    'page callback' => 'drupal_get_form',
210
    'page arguments' => array('file_entity_upload_archive_form'),
211
    'access arguments' => array('administer files'),
212
    'file' => 'file_entity.pages.inc',
213
    'type' => MENU_LOCAL_TASK,
214
    'weight' => -5,
215
  );
192 216
  $items['file/%file'] = array(
193 217
    'title callback' => 'entity_label',
194 218
    'title arguments' => array('file', 1),
......
1113 1137
      // Set $display['type'] to what hook_field_formatter_*() expects.
1114 1138
      $display['type'] = $field_formatter_type;
1115 1139

  
1140
      // Allow any attribute overrides (e.g. from the Media module) to be
1141
      // respected.
1142
      $item = (array) $file;
1143
      if (!empty($file->override['attributes'])) {
1144
        $item = array_merge($item, $file->override['attributes']);
1145
      }
1146

  
1116 1147
      // Set $items to what file field formatters expect. See file_field_load(),
1117 1148
      // and note that, here, $file is already a fully loaded entity.
1118
      $items = array((array) $file);
1149
      $items = array($item);
1119 1150

  
1120 1151
      // Invoke hook_field_formatter_prepare_view() and
1121 1152
      // hook_field_formatter_view(). Note that we are reusing field formatter
......
1878 1909
          $file_conditions->exists($subquery);
1879 1910
        }
1880 1911
        // Otherwise attach it to the node query itself.
1912
        elseif ($table == 'file_managed') {
1913
          // Fix for https://drupal.org/node/2073085
1914
          $db_or = db_or();
1915
          $db_or->exists($subquery);
1916
          $db_or->isNull($falias . '.' . $field);
1917
          $query->condition($db_or);
1918
        }
1881 1919
        else {
1882 1920
          $query->exists($subquery);
1883 1921
        }
......
1917 1955
    return file_get_content_headers($file);
1918 1956
  }
1919 1957

  
1920
  return NULL;
1958
  return -1;
1921 1959
}
1922 1960

  
1923 1961
/**
......
2151 2189
  return $element;
2152 2190
}
2153 2191

  
2154
/**
2155
 * Implements hook_file_default_displays_alter() on behalf of image.module.
2156
 */
2157
function image_file_default_displays_alter(&$file_displays) {
2158
  // Images should be displayed as unstyled images by default.
2159
  if (isset($file_displays['image__default__file_field_file_default'])) {
2160
    $file_displays['image__default__file_field_file_default']->status = FALSE;
2161
  }
2162

  
2163
  $file_display = new stdClass();
2164
  $file_display->api_version = 1;
2165
  $file_display->name = 'image__default__file_field_image';
2166
  $file_display->weight = 50;
2167
  $file_display->status = TRUE;
2168
  $file_display->settings = array(
2169
    'image_style' => '',
2170
    'image_link' => '',
2171
  );
2172
  $file_displays['image__default__file_field_image'] = $file_display;
2173

  
2174
  // Image previews should be displayed as image thumbnails by default.
2175
  if (isset($file_displays['image__preview__file_field_file_default'])) {
2176
    $file_displays['image__preview__file_field_file_default']->status = FALSE;
2177
  }
2178

  
2179
  $file_display = new stdClass();
2180
  $file_display->api_version = 1;
2181
  $file_display->name = 'image__preview__file_field_image';
2182
  $file_display->weight = 50;
2183
  $file_display->status = TRUE;
2184
  $file_display->settings = array(
2185
    'image_style' => 'thumbnail',
2186
    'image_link' => '',
2187
  );
2188
  $file_displays['image__preview__file_field_image'] = $file_display;
2189

  
2190
  // Image teasers should be displayed as medium images by default.
2191
  if (isset($file_displays['image__teaser__file_field_file_default'])) {
2192
    $file_displays['image__teaser__file_field_file_default']->status = FALSE;
2193
  }
2194

  
2195
  $file_display = new stdClass();
2196
  $file_display->api_version = 1;
2197
  $file_display->name = 'image__teaser__file_field_image';
2198
  $file_display->weight = 50;
2199
  $file_display->status = TRUE;
2200
  $file_display->settings = array(
2201
    'image_style' => 'medium',
2202
    'image_link' => 'content',
2203
  );
2204
  $file_displays['image__teaser__file_field_image'] = $file_display;
2205
}
2206

  
2207 2192
/**
2208 2193
 * @name pathauto_file Pathauto integration for the core file module.
2209 2194
 * @{
......
2265 2250
 */
2266 2251
function pathauto_file_update_alias(stdClass $file, $op, array $options = array()) {
2267 2252
  // Skip processing if the user has disabled pathauto for the file.
2268
  if (isset($file->path['pathauto']) && empty($file->path['pathauto'])) {
2253
  if (isset($file->path['pathauto']) && empty($file->path['pathauto']) && empty($options['force'])) {
2269 2254
    return;
2270 2255
  }
2271 2256

  
......
2482 2467
}
2483 2468

  
2484 2469
/*
2485
 * Generate a file download CSRF token.
2470
 * Generates a token to protect a file download URL.
2471
 *
2472
 * This prevents unauthorized crawling of all file download URLs since the
2473
 * {file_managed}.fid column is an auto-incrementing serial field and is easy
2474
 * to guess or attempt many at once. This can be costly both in CPU time
2475
 * and bandwidth.
2486 2476
 *
2487
 * This is essentially a duplicate of drupal_get_token, that attempts to still
2488
 * work if the user is anonymous, by using ip_address() as the identifier
2489
 * rather than session_id().
2477
 * @see image_style_path_token()
2490 2478
 *
2491 2479
 * @param object $file
2492 2480
 *   A file entity object.
2493 2481
 *
2494 2482
 * @return string
2495
 *   A CSRF token string.
2483
 *   An eight-character token which can be used to protect file downloads
2484
 *   against denial-of-service attacks.
2496 2485
 */
2497 2486
function file_entity_get_download_token($file) {
2498
  $identifier = !empty($GLOBALS['user']->uid) ? session_id() : ip_address();
2499
  return drupal_hmac_base64("file/$file->fid/download", $identifier . drupal_get_private_key() . drupal_get_hash_salt());
2487
  // Return the first eight characters.
2488
  return substr(drupal_hmac_base64("file/$file->fid/download:" . $file->uri, drupal_get_private_key() . drupal_get_hash_salt()), 0, 8);
2500 2489
}
2501 2490

  
2502 2491
/**
......
2542 2531
          foreach ($items as $delta => $item) {
2543 2532
            // If alt and title text is not specified, fall back to alt and
2544 2533
            // title text on the file.
2545
            if (empty($item['alt']) || empty($item['title'])) {
2534
            if (!empty($item['fid']) && (empty($item['alt']) || empty($item['title']))) {
2546 2535
              $file = file_load($item['fid']);
2547 2536
              foreach (array('alt', 'title') as $key) {
2548 2537
                if (empty($item[$key]) && !empty($file->{$key})) {
drupal7/sites/all/modules/file_entity/file_entity.pages.inc
37 37
  }
38 38

  
39 39
  $headers = array(
40
    'Content-Type' => 'force-download',
41
    'Content-Disposition' => 'attachment; filename="' . $file->filename . '"',
40
    'Content-Type' => mime_header_encode($file->filemime),
41
    'Content-Disposition' => 'attachment; filename="' . mime_header_encode(drupal_basename($file->uri)) . '"',
42 42
    'Content-Length' => $file->filesize,
43 43
    'Content-Transfer-Encoding' => 'binary',
44 44
    'Pragma' => 'no-cache',
45 45
    'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
46 46
    'Expires' => '0',
47
    'Accept-Ranges' => 'bytes',
48 47
  );
49 48

  
50 49
  // Let other modules alter the download headers.
51 50
  drupal_alter('file_download_headers', $headers, $file);
52 51

  
53
  file_transfer($file->uri, $headers);
52
  // Let other modules know the file is being downloaded.
53
  module_invoke_all('file_transfer', $file->uri, $headers);
54

  
55
  if (file_entity_file_is_local($file)) {
56
    // For local files, transfer the file and do not reveal the actual URL.
57
    file_transfer($file->uri, $headers);
58
  }
59
  else {
60
    // For remote files, just redirect the user to that file's actual URL.
61
    $headers['Location'] = file_create_url($file->uri);
62
    foreach ($headers as $name => $value) {
63
      drupal_add_http_header($name, $value);
64
    }
65
    drupal_send_headers();
66
    drupal_exit();
67
  }
54 68
}
55 69

  
56 70
/**
......
66 80
function file_entity_add_upload($form, &$form_state, array $options = array()) {
67 81
  $step = (isset($form_state['step']) && in_array($form_state['step'], array(1, 2, 3, 4))) ? $form_state['step'] : 1;
68 82
  $form['#step'] = $step;
83
  $form['#options'] = $options;
69 84
  switch ($step) {
70 85
    case 1:
71 86
      return file_entity_add_upload_step_upload($form, $form_state, $options);
......
143 158
function file_entity_add_upload_step_scheme($form, &$form_state, array $options = array()) {
144 159
  $file = file_load($form_state['storage']['upload']);
145 160

  
146
  $options = array();
161
  $schemes = array();
147 162
  foreach (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $info) {
148
    $options[$scheme] = check_plain($info['description']);
163
    $schemes[$scheme] = check_plain($info['description']);
164
  }
165

  
166
  // Remove any schemes not found in the instance settings.
167
  if (!empty($options['schemes'])) {
168
    $schemes = array_intersect_key($schemes, $options['schemes']);
169
  }
170

  
171
  // Determine which scheme to use as the default value.
172
  if (isset($form_state['storage']['scheme'])) {
173
    $fallback_scheme = $form_state['storage']['scheme'];
174
  }
175
  elseif (!empty($options['uri_scheme'])) {
176
    $fallback_scheme = $options['uri_scheme'];
177
  }
178
  else {
179
    $fallback_scheme = file_default_scheme();
149 180
  }
150 181

  
151 182
  $form['scheme'] = array(
152 183
    '#type' => 'radios',
153 184
    '#title' => t('Destination'),
154
    '#options' => $options,
155
    '#default_value' => isset($form_state['storage']['scheme']) ? $form_state['storage']['scheme'] : file_default_scheme(),
185
    '#options' => $schemes,
186
    '#default_value' => $fallback_scheme,
156 187
    '#required' => TRUE,
157 188
  );
158 189

  
......
179 210
  $file = file_load($form_state['storage']['upload']);
180 211
  $file->type = $form_state['storage']['type'];
181 212

  
213
  // Let users modify the filename here.
214
  $form['filename'] = array(
215
    '#type' => 'textfield',
216
    '#title' => t('Name'),
217
    '#default_value' => $file->filename,
218
    '#required' => TRUE,
219
    '#maxlength' => 255,
220
    '#weight' => -10,
221
  );
222

  
182 223
  // Add fields.
183 224
  field_attach_form('file', $file, $form, $form_state);
184 225

  
......
207 248
  foreach (file_usage_list($file) as $module => $usage) {
208 249
    $info = system_get_info('module', $module);
209 250

  
210
    // There are cases, where actual entitiy doesen't exist.
251
    // There are cases where the actual entity doesn't exist.
211 252
    // We have to handle this.
212 253
    foreach ($usage as $entity_type => $entity_ids) {
213 254
      $entity_info = entity_get_info($entity_type);
......
315 356
          $form['#step'] += ($trigger == 'edit-previous') ? -1 : 1;
316 357
          $form_state['storage']['type'] = reset($candidates_keys);
317 358
        }
318
        elseif (variable_get('file_entity_file_upload_wizard_skip_file_type', FALSE)) {
359
        elseif (!$candidates || variable_get('file_entity_file_upload_wizard_skip_file_type', FALSE)) {
319 360
          // Do not assign the file a file type.
320 361
          $form['#step'] += ($trigger == 'edit-previous') ? -1 : 1;
321 362
          $form_state['storage']['type'] = FILE_TYPE_NONE;
......
323 364
      }
324 365
      else {
325 366
        // Check if we can skip step 3.
367
        $options = $form['#options'];
326 368
        $schemes = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE);
327
        if (count($schemes) == 1) {
369

  
370
        // Remove any schemes not found in the instance settings.
371
        if (!empty($options['schemes'])) {
372
          $schemes = array_intersect_key($schemes, $options['schemes']);
373
        }
374

  
375
        if (!file_entity_file_is_writeable($file)) {
376
          // The file is read-only (remote) and must use its provided scheme.
377
          $form['#step'] += ($trigger == 'edit-previous') ? -1 : 1;
378
          $form_state['storage']['scheme'] = file_uri_scheme($file->uri);
379
        }
380
        elseif (count($schemes) == 1) {
328 381
          // There is only one possible stream wrapper for this file.
329 382
          // Skip the third page.
330 383
          $form['#step'] += ($trigger == 'edit-previous') ? -1 : 1;
331 384
          $form_state['storage']['scheme'] = key($schemes);
332 385
        }
333 386
        elseif (variable_get('file_entity_file_upload_wizard_skip_scheme', FALSE)) {
334
          // Assign the file the default scheme.
335 387
          $form['#step'] += ($trigger == 'edit-previous') ? -1 : 1;
336
          $form_state['storage']['scheme'] = file_default_scheme();
388

  
389
          // Fallback to the URI scheme specified in the field settings
390
          // otherwise use the default file scheme.
391
          if (!empty($options['uri_scheme'])) {
392
            $form_state['storage']['scheme'] = $options['uri_scheme'];
393
          }
394
          else {
395
            $form_state['storage']['scheme'] = file_default_scheme();
396
          }
337 397
        }
338 398
      }
339 399
    }
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff