Révision f419e8de
Ajouté par Assos Assos il y a plus de 6 ans
drupal7/sites/all/modules/file_entity/file_entity.pages.inc | ||
---|---|---|
256 | 256 |
* Page callback to show file usage information. |
257 | 257 |
*/ |
258 | 258 |
function file_entity_usage_page($file) { |
259 |
drupal_set_title(t('<em>Usage of @type</em> @title', array('@type' => $file->type, '@title' => $file->filename)), PASS_THROUGH); |
|
260 |
|
|
259 | 261 |
$rows = array(); |
260 | 262 |
$occured_entities = array(); |
261 | 263 |
|
... | ... | |
355 | 357 |
// This var is set to TRUE when we are ready to save the file. |
356 | 358 |
$save = FALSE; |
357 | 359 |
$trigger = $form_state['triggering_element']['#id']; |
360 |
$triggered_next = $trigger == 'edit-next' || (strpos($trigger, 'edit-next--') === 0); |
|
361 |
$triggered_previous = $trigger == 'edit-previous' || (strpos($trigger, 'edit-previous--') === 0); |
|
362 |
$step_delta = ($triggered_previous) ? -1 : 1; |
|
358 | 363 |
|
359 | 364 |
$steps_to_check = array(2, 3); |
360 |
if ($trigger == 'edit-previous') {
|
|
365 |
if ($triggered_previous) {
|
|
361 | 366 |
// If the previous button was hit, |
362 | 367 |
// the step checking order should be reversed 3, 2. |
363 | 368 |
$steps_to_check = array_reverse($steps_to_check); |
... | ... | |
365 | 370 |
|
366 | 371 |
foreach ($steps_to_check as $step) { |
367 | 372 |
// Check if we can skip step 2 and 3. |
368 |
if (($form['#step'] == $step - 1 && $trigger == 'edit-next') || ($form['#step'] == $step + 1 && $trigger == 'edit-previous')) {
|
|
373 |
if (($form['#step'] == $step - 1 && $triggered_next) || ($form['#step'] == $step + 1 && $triggered_previous)) {
|
|
369 | 374 |
$file = file_load($form_state['storage']['upload']); |
370 | 375 |
if ($step == 2) { |
371 | 376 |
// Check if we can skip step 2. |
... | ... | |
374 | 379 |
$candidates_keys = array_keys($candidates); |
375 | 380 |
// There is only one possible filetype for this file. |
376 | 381 |
// Skip the second page. |
377 |
$form['#step'] += ($trigger == 'edit-previous') ? -1 : 1;
|
|
382 |
$form['#step'] += $step_delta;
|
|
378 | 383 |
$form_state['storage']['type'] = reset($candidates_keys); |
379 | 384 |
} |
380 | 385 |
elseif (!$candidates || variable_get('file_entity_file_upload_wizard_skip_file_type', FALSE)) { |
381 | 386 |
// Do not assign the file a file type. |
382 |
$form['#step'] += ($trigger == 'edit-previous') ? -1 : 1;
|
|
387 |
$form['#step'] += $step_delta;
|
|
383 | 388 |
$form_state['storage']['type'] = FILE_TYPE_NONE; |
384 | 389 |
} |
385 | 390 |
} |
... | ... | |
395 | 400 |
|
396 | 401 |
if (!file_entity_file_is_writeable($file)) { |
397 | 402 |
// The file is read-only (remote) and must use its provided scheme. |
398 |
$form['#step'] += ($trigger == 'edit-previous') ? -1 : 1;
|
|
403 |
$form['#step'] += $step_delta;
|
|
399 | 404 |
$form_state['storage']['scheme'] = file_uri_scheme($file->uri); |
400 | 405 |
} |
401 | 406 |
elseif (count($schemes) == 1) { |
402 | 407 |
// There is only one possible stream wrapper for this file. |
403 | 408 |
// Skip the third page. |
404 |
$form['#step'] += ($trigger == 'edit-previous') ? -1 : 1;
|
|
409 |
$form['#step'] += $step_delta;
|
|
405 | 410 |
$form_state['storage']['scheme'] = key($schemes); |
406 | 411 |
} |
407 | 412 |
elseif (variable_get('file_entity_file_upload_wizard_skip_scheme', FALSE)) { |
408 |
$form['#step'] += ($trigger == 'edit-previous') ? -1 : 1;
|
|
413 |
$form['#step'] += $step_delta;
|
|
409 | 414 |
|
410 | 415 |
// Fallback to the URI scheme specified in the field settings |
411 | 416 |
// otherwise use the default file scheme. |
... | ... | |
421 | 426 |
} |
422 | 427 |
|
423 | 428 |
// We have the filetype, check if we can skip step 4. |
424 |
if (($form['#step'] == 3 && $trigger == 'edit-next')) {
|
|
429 |
if ($form['#step'] == 3 && $triggered_next) {
|
|
425 | 430 |
$file = file_load($form_state['storage']['upload']); |
426 | 431 |
$form_state['file'] = $file; |
427 | 432 |
if (!field_info_instances('file', $form_state['storage']['type'])) { |
... | ... | |
436 | 441 |
|
437 | 442 |
// Form id's can vary depending on how many other forms are displayed, so we |
438 | 443 |
// need to do string comparissons. e.g edit-submit--2. |
439 |
if (strpos($trigger, 'edit-next') !== FALSE) {
|
|
444 |
if ($triggered_next) {
|
|
440 | 445 |
$form_state['step'] = $form['#step'] + 1; |
441 | 446 |
} |
442 |
elseif (strpos($trigger, 'edit-previous') !== FALSE) {
|
|
447 |
elseif ($triggered_previous) {
|
|
443 | 448 |
$form_state['step'] = $form['#step'] - 1; |
444 | 449 |
} |
445 | 450 |
elseif (strpos($trigger, 'edit-submit') !== FALSE) { |
Formats disponibles : Unified diff
Weekly update of contrib modules