/[drupal]/contributions/modules/diff/upload.inc
ViewVC logotype

Contents of /contributions/modules/diff/upload.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Tue Sep 2 18:36:44 2008 UTC (14 months, 3 weeks ago) by weitzman
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +4 -4 lines
File MIME type: text/x-php
Add back a diff that is compatible with D7 core. See http://drupal.org/node/120955
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 }

  ViewVC Help
Powered by ViewVC 1.1.2