| 1 |
<?php
|
| 2 |
// $Id: upload.inc,v 1.3.2.1.2.1 2008/04/08 14:01:57 weitzman Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_diff() for file attachments.
|
| 6 |
*/
|
| 7 |
function upload_diff(&$old_node, &$new_node) {
|
| 8 |
$result = array();
|
| 9 |
$old_files = array();
|
| 10 |
if (isset($old_node->files)) {
|
| 11 |
foreach ($old_node->files as $file) {
|
| 12 |
$old_files[] = $file->filename;
|
| 13 |
}
|
| 14 |
}
|
| 15 |
$new_files = array();
|
| 16 |
if (isset($new_node->files)) {
|
| 17 |
foreach ($new_node->files as $key => $file) {
|
| 18 |
if (is_array($file)) {
|
| 19 |
// During editing the files are stored as arrays, not objects.
|
| 20 |
if ($file['remove']) {
|
| 21 |
// It looks better if a blank line is inserted for removed files.
|
| 22 |
$new_files[] = '';
|
| 23 |
}
|
| 24 |
else {
|
| 25 |
$new_files[] = $file['filename'];
|
| 26 |
}
|
| 27 |
}
|
| 28 |
else {
|
| 29 |
$new_files[] = $file->filename;
|
| 30 |
}
|
| 31 |
}
|
| 32 |
}
|
| 33 |
$result['attachments'] = array(
|
| 34 |
'#name' => t('Attachments'),
|
| 35 |
'#old' => $old_files,
|
| 36 |
'#new' => $new_files,
|
| 37 |
'#weight' => 30,
|
| 38 |
'#format' => array(
|
| 39 |
'show_header' => FALSE,
|
| 40 |
)
|
| 41 |
);
|
| 42 |
return $result;
|
| 43 |
}
|