summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/node/node.module6
-rw-r--r--modules/upload/upload.module54
2 files changed, 26 insertions, 34 deletions
diff --git a/modules/node/node.module b/modules/node/node.module
index a400483df..1c2d000d2 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -658,6 +658,9 @@ function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
unset($node->teaser);
}
+ // Allow modules to modify the fully-built node.
+ node_invoke_nodeapi($node, 'alter', $teaser, $page);
+
return theme('node', $node, $teaser, $page);
}
@@ -718,9 +721,6 @@ function node_build_content($node, $teaser = FALSE, $page = FALSE) {
// Allow modules to make their own additions to the node.
node_invoke_nodeapi($node, 'view', $teaser, $page);
- // Allow modules to modify the fully-built node.
- node_invoke_nodeapi($node, 'alter', $teaser, $page);
-
return $node;
}
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
*/