summaryrefslogtreecommitdiff
path: root/modules/upload/upload.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-10-05 15:26:17 +0000
committerDries Buytaert <dries@buytaert.net>2006-10-05 15:26:17 +0000
commit90f9bffbc032c98a6162b46e85f497de77ef3b50 (patch)
treeb5abf0c72a5ec22e4a50aa813e987d546640c42c /modules/upload/upload.module
parenta8f20420d9b623fd81f115233e02c4654c5b64f9 (diff)
downloadbrdo-90f9bffbc032c98a6162b46e85f497de77ef3b50.tar.gz
brdo-90f9bffbc032c98a6162b46e85f497de77ef3b50.tar.bz2
- Patch #82045 by chx, eaton et al: fixed nodeapi.
Diffstat (limited to 'modules/upload/upload.module')
-rw-r--r--modules/upload/upload.module54
1 files changed, 23 insertions, 31 deletions
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index fe8c7adfb..9225d5a6f 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -497,30 +497,34 @@ function upload_nodeapi(&$node, $op, $teaser) {
'#weight' => 50,
);
}
- // Manipulate so that inline references work in preview
- if (!variable_get('clean_url', 0)) {
- $previews = array();
- foreach ($node->files as $file) {
- $file = (object)$file;
- if (strpos($file->fid, 'upload') !== FALSE) {
- $previews[] = $file;
- }
- }
- // URLs to files being previewed are actually Drupal paths. When Clean
- // URLs are disabled, the two do not match. We perform an automatic
- // replacement from temporary to permanent URLs. That way, the author
- // can use the final URL in the body before having actually saved (to
- // place inline images for example).
- foreach ($previews as $file) {
- $old = file_create_filename($file->filename, file_create_path());
- $node->content['#upload_urls'][$old] = url($old);
+ }
+ }
+ break;
+ case 'alter':
+ if (isset($node->files) && user_access('view uploaded files')) {
+ // Manipulate so that inline references work in preview
+ if (!variable_get('clean_url', 0)) {
+ $previews = array();
+ foreach ($node->files as $file) {
+ if (strpos($file['fid'], 'upload') !== FALSE) {
+ $previews[] = $file;
}
- $node->content['#after_render'][] = 'upload_fix_preview_urls';
+ }
+
+ // URLs to files being previewed are actually Drupal paths. When Clean
+ // URLs are disabled, the two do not match. We perform an automatic
+ // replacement from temporary to permanent URLs. That way, the author
+ // can use the final URL in the body before having actually saved (to
+ // place inline images for example).
+ foreach ($previews as $file) {
+ $old = file_create_filename($file['filename'], file_create_path());
+ $new = url($old);
+ $node->body = str_replace($old, $new, $node->body);
+ $node->teaser = str_replace($old, $new, $node->teaser);
}
}
}
break;
-
case 'insert':
case 'update':
if (user_access('upload files')) {
@@ -566,18 +570,6 @@ function upload_nodeapi(&$node, $op, $teaser) {
}
}
-function upload_fix_preview_urls($elements, &$content) {
- if (is_array($elements['#upload_urls'])) {
- $old_list = array();
- $new_list = array();
- foreach ($elements['#upload_urls'] as $old => $new) {
- $old_list[] = $old;
- $new_list[] = $new;
- }
- $content = str_replace($old_list, $new_list, $content);
- }
-}
-
/**
* Displays file attachments in table
*/