--- modules/inline/inline.cvs 2006-05-04 03:03:00.000000000 +0200 +++ modules/inline/inline.module 2006-05-10 06:33:51.727387100 +0200 @@ -109,7 +109,7 @@ } function inline_nodeapi(&$node, $op, $arg) { - if(is_array($node->files) && $op == 'view') { + if((is_array($node->files) || is_array($node->attachments)) && $op == 'view') { //TODO: we should *really* us the filter hooks for this, not? $node->teaser = _inline_substitute_tags($node, 'teaser'); $node->body = _inline_substitute_tags($node, 'body'); @@ -119,34 +119,104 @@ } } +/** + * Create $file object for further use. + * For use with attachment module we're fetching some variables + * from filemanager module to accompany with regular file object + * provided by the upload module. + * + * @param object $node The currently processed node. + * @param mixed $id Either an image id or filename to display inline. + * @return object $file An object holding all necessary information + * about the attached file. + */ function _inline_fileobj(&$node, $id) { if (is_numeric($id)) { + // numeric attachment parameter + // upload module $n=1; foreach ($node->files as $file) { if ($n == $id) { + $file->url = file_create_url($file->filepath); return $file; } ++$n; } + // attachment module + $n=1; + foreach ($node->attachments as $file) { + if ($n == $id) { + if (function_exists('filemanager_url')) { + $file['url'] = filemanager_url($file); + $file['filepath'] = filemanager_create_path($file['fid']); + $file['filesize'] = $file['size']; + $attachment = filemanager_get_file_info($file['fid']); + $file['filemime'] = $attachment->mimetype; + } + return (object)$file; + } + ++$n; + } return NULL; } else { + // named attachment parameter + // upload module foreach ($node->files as $file) { if ($file->filename == $id) { - //return array($file->filename, $file->filepath); + $file->url = file_create_url($file->filepath); return $file; } } + // attachment module + foreach ($node->attachments as $file) { + if ($file['filename'] == $id) { + if (function_exists('filemanager_url')) { + $file['url'] = filemanager_url($file); + $file['filepath'] = filemanager_create_path($file['fid']); + $file['filesize'] = $file['size']; + $attachment = filemanager_get_file_info($file['fid']); + $file['filemime'] = $attachment->mimetype; + } + return (object)$file; + } + } return NULL; } } +/** + * Theme $file as inline link. + * Displays file type icon if exists in ./themes/