| 1 |
<?php |
<?php |
| 2 |
// $Id: filefield_paths.module,v 1.19.2.15 2009/04/17 03:53:22 deciphered Exp $ |
// $Id: filefield_paths.module,v 1.19.2.16 2009/04/19 22:49:05 deciphered Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 457 |
|
|
| 458 |
// Cleanup temporary paths |
// Cleanup temporary paths |
| 459 |
if ($ffp['#settings']) { |
if ($ffp['#settings']) { |
| 460 |
foreach ($ffp['#settings'] as $field) { |
foreach ($ffp['#settings'] as $name => $field) { |
| 461 |
$paths = explode('/', $field['filepath']['value']); |
$paths = explode('/', $field['filepath']['value']); |
| 462 |
|
filefield_paths_cleanup_temp($paths); |
| 463 |
|
|
| 464 |
while ($paths) { |
// Check for ImageFields |
| 465 |
if (@rmdir(file_directory_path() .'/'. implode('/', $paths)) === TRUE) { |
$imagefield = FALSE; |
| 466 |
array_pop($paths); |
foreach ($ffp['#files'] as $file) { |
| 467 |
continue; |
if ($file['name'] == $name) { |
| 468 |
|
if ($file['widget'] == 'imagefield') { |
| 469 |
|
$imagefield = TRUE; |
| 470 |
|
} |
| 471 |
|
break; |
| 472 |
} |
} |
| 473 |
break; |
} |
| 474 |
|
// Cleanup ImageFields temporary thumbnail paths |
| 475 |
|
if ($imagefield) { |
| 476 |
|
array_unshift($paths, 'imagefield_thumbs'); |
| 477 |
|
filefield_paths_cleanup_temp($paths); |
| 478 |
} |
} |
| 479 |
} |
} |
| 480 |
} |
} |
| 483 |
} |
} |
| 484 |
} |
} |
| 485 |
|
|
| 486 |
|
function filefield_paths_cleanup_temp($paths) { |
| 487 |
|
while ($paths) { |
| 488 |
|
if (@rmdir(file_directory_path() .'/'. implode('/', $paths)) === TRUE) { |
| 489 |
|
array_pop($paths); |
| 490 |
|
continue; |
| 491 |
|
} |
| 492 |
|
break; |
| 493 |
|
} |
| 494 |
|
} |
| 495 |
|
|
| 496 |
function filefield_paths_get_fields(&$node, $op = NULL) { |
function filefield_paths_get_fields(&$node, $op = NULL) { |
| 497 |
$ffp = array(); |
$ffp = array(); |
| 498 |
|
|
| 602 |
} |
} |
| 603 |
|
|
| 604 |
// Move ImageField thumbnail |
// Move ImageField thumbnail |
| 605 |
if ($file['widget'] == 'imagefield' && |
if ($file['widget'] == 'imagefield' && file_exists($thumbnail_source = imagefield_file_admin_thumb_path(array('filepath' => $file['filepath']['old'])))) { |
| 606 |
file_exists($thumnail_source = imagefield_file_admin_thumb_path(array('filepath' => $file['filepath']['old'])))) { |
file_delete($thumbnail_source); |
|
file_move($thumnail_source, imagefield_file_admin_thumb_path($file['field']), FILE_EXISTS_RENAME); |
|
| 607 |
} |
} |
| 608 |
|
|
| 609 |
// Store new filename in file Array |
// Store new filename in file Array |