From b9bf2fe7519aa7aab5278fb882a139f3c823feb0 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 8 Feb 2004 18:00:10 +0000 Subject: [PATCH] the display code for inline attachments, isn't it cute? ;) git-svn-id: file:///svn/phpbb/trunk@4818 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/viewtopic.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index dee7062169..b3608a8982 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1193,6 +1193,28 @@ for ($i = 0; $i < count($post_list); ++$i) $l_bumped_by = ''; } + // Assign inline attachments, only one preg_replace... yeah baby, you got it. :D + if (sizeof($attachments[$row['post_id']])) + { + $tpl = &$attachments[$row['post_id']]; + $tpl = display_attachments(NULL, $tpl, $update_count, false, true); + $tpl_size = sizeof($tpl); + + $message = preg_replace_callback('#(.*?)#', create_function('$matches', ' + global $tpl, $user, $config, $tpl_size; + + // Flip index if we are displaying the reverse way + $index = ($config["display_order"]) ? ($tpl_size-($matches[1] + 1)) : $matches[1]; + $return = (isset($tpl[$index])) ? $tpl[$index] : sprintf($user->lang["MISSING_INLINE_ATTACHMENT"], $matches[0]); + + unset($tpl[$index]); + + return $return; + '), $message); + + unset($tpl, $tpl_size); + } + // Dump vars into template $template->assign_block_vars('postrow', array( 'POSTER_NAME' => $row['poster'], @@ -1254,10 +1276,15 @@ for ($i = 0; $i < count($post_list); ++$i) 'S_FRIEND' => ($row['friend']) ? true : false) ); - // Process Attachments for this post + // Display not already displayed Attachments for this post, we already parsed them. ;) if (sizeof($attachments[$row['post_id']])) { - display_attachments('postrow.attachment', $attachments[$row['post_id']], $update_count); + foreach ($attachments[$row['post_id']] as $attachment) + { + $template->assign_block_vars('postrow.attachment', array( + 'DISPLAY_ATTACHMENT' => $attachment) + ); + } } $prev_post_id = $row['post_id'];