diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2006-12-24 13:11:54 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2006-12-24 13:11:54 +0000 |
commit | ae1cb0316e6c19d62f0579e9cef52f11df081bcf (patch) | |
tree | d5e0900486aeb6ac91b957ce2ac47a4d55cdddc7 /phpBB/includes/functions_display.php | |
parent | 9cc0b364bcc9473d0b1f4656db9008a55921918b (diff) | |
download | forums-ae1cb0316e6c19d62f0579e9cef52f11df081bcf.tar forums-ae1cb0316e6c19d62f0579e9cef52f11df081bcf.tar.gz forums-ae1cb0316e6c19d62f0579e9cef52f11df081bcf.tar.bz2 forums-ae1cb0316e6c19d62f0579e9cef52f11df081bcf.tar.xz forums-ae1cb0316e6c19d62f0579e9cef52f11df081bcf.zip |
some fixes today
- most important change is the consolidation of the display attachment functions; merging them together to have one function we need to call.
git-svn-id: file:///svn/phpbb/trunk@6803 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_display.php')
-rw-r--r-- | phpBB/includes/functions_display.php | 268 |
1 files changed, 0 insertions, 268 deletions
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 4c16029803..242eb871ae 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -689,274 +689,6 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold } /** -* Display Attachments -*/ -function display_attachments($forum_id, $blockname, &$attachment_data, &$update_count, $force_physical = false, $return = false) -{ - global $template, $cache, $user; - global $extensions, $config, $phpbb_root_path, $phpEx; - - $return_tpl = array(); - - $template->set_filenames(array( - 'attachment_tpl' => 'attachment.html') - ); - - if (!sizeof($attachment_data)) - { - return array(); - } - - if (empty($extensions) || !is_array($extensions)) - { - $extensions = $cache->obtain_attach_extensions(); - } - - // Look for missing attachment information... - $attach_ids = array(); - foreach ($attachment_data as $pos => $attachment) - { - // If is_orphan is set, we need to retrieve the attachments again... - if (!isset($attachment['extension']) && !isset($attachment['physical_filename'])) - { - $attach_ids[(int) $attachment['attach_id']] = $pos; - } - } - - if (sizeof($attach_ids)) - { - global $db; - - $attachment_data = array(); - - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', array_keys($attach_ids)); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!isset($attach_ids[$row['attach_id']])) - { - continue; - } - - $attachment_data[$attach_ids[$row['attach_id']]] = $row; - } - $db->sql_freeresult($result); - } - - // Sort correctly (please note that the attachment_data array itself get changed by this - if ($config['display_order']) - { - // Ascending sort - krsort($attachment_data); - } - else - { - // Descending sort - ksort($attachment_data); - } - - foreach ($attachment_data as $attachment) - { - if (!sizeof($attachment)) - { - continue; - } - - // We need to reset/empty the _file block var, because this function might be called more than once - $template->destroy_block_vars('_file'); - - $block_array = array(); - - // Some basics... - $attachment['extension'] = strtolower(trim($attachment['extension'])); - $filename = $phpbb_root_path . $config['upload_path'] . '/' . basename($attachment['physical_filename']); - $thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . basename($attachment['physical_filename']); - - $upload_icon = ''; - - if (isset($extensions[$attachment['extension']])) - { - if ($user->img('icon_topic_attach', '') && !$extensions[$attachment['extension']]['upload_icon']) - { - $upload_icon = $user->img('icon_topic_attach', ''); - } - else if ($extensions[$attachment['extension']]['upload_icon']) - { - $upload_icon = '<img src="' . $phpbb_root_path . $config['upload_icons_path'] . '/' . trim($extensions[$attachment['extension']]['upload_icon']) . '" alt="" />'; - } - } - - $filesize = $attachment['filesize']; - $size_lang = ($filesize >= 1048576) ? $user->lang['MB'] : ( ($filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] ); - $filesize = ($filesize >= 1048576) ? round((round($filesize / 1048576 * 100) / 100), 2) : (($filesize >= 1024) ? round((round($filesize / 1024 * 100) / 100), 2) : $filesize); - - $comment = str_replace("\n", '<br />', censor_text($attachment['attach_comment'])); - - $block_array += array( - 'UPLOAD_ICON' => $upload_icon, - 'FILESIZE' => $filesize, - 'SIZE_LANG' => $size_lang, - 'DOWNLOAD_NAME' => basename($attachment['real_filename']), - 'COMMENT' => $comment, - ); - - $denied = false; - - if (!extension_allowed($forum_id, $attachment['extension'], $extensions)) - { - $denied = true; - - $block_array += array( - 'S_DENIED' => true, - 'DENIED_MESSAGE' => sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']) - ); - } - - if (!$denied) - { - $l_downloaded_viewed = $download_link = ''; - $display_cat = $extensions[$attachment['extension']]['display_cat']; - - if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) - { - if ($attachment['thumbnail']) - { - $display_cat = ATTACHMENT_CATEGORY_THUMB; - } - else - { - if ($config['img_display_inlined']) - { - if ($config['img_link_width'] || $config['img_link_height']) - { - list($width, $height) = @getimagesize($filename); - - $display_cat = (!$width && !$height) ? ATTACHMENT_CATEGORY_IMAGE : (($width <= $config['img_link_width'] && $height <= $config['img_link_height']) ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE); - } - } - else - { - $display_cat = ATTACHMENT_CATEGORY_NONE; - } - } - } - - $download_link = (!$force_physical && $attachment['attach_id']) ? append_sid("{$phpbb_root_path}download.$phpEx", 'id=' . $attachment['attach_id'] . '&f=' . $forum_id) : $filename; - - switch ($display_cat) - { - // Images - case ATTACHMENT_CATEGORY_IMAGE: - $l_downloaded_viewed = $user->lang['VIEWED']; - - $block_array += array( - 'S_IMAGE' => true, - ); - - $update_count[] = $attachment['attach_id']; - break; - - // Images, but display Thumbnail - case ATTACHMENT_CATEGORY_THUMB: - $l_downloaded_viewed = $user->lang['VIEWED']; - $thumbnail_link = (!$force_physical && $attachment['attach_id']) ? append_sid("{$phpbb_root_path}download.$phpEx", 'id=' . $attachment['attach_id'] . '&t=1&f=' . $forum_id) : $thumbnail_filename; - - $block_array += array( - 'S_THUMBNAIL' => true, - 'THUMB_IMAGE' => $thumbnail_link, - ); - break; - - // Windows Media Streams - case ATTACHMENT_CATEGORY_WM: - $l_downloaded_viewed = $user->lang['VIEWED']; - - // Giving the filename directly because within the wm object all variables are in local context making it impossible - // to validate against a valid session (all params can differ) - $download_link = $filename; - - $block_array += array( - 'U_FORUM' => generate_board_url(), - 'S_WM_FILE' => true, - ); - - // Viewed/Heared File ... update the download count - $update_count[] = $attachment['attach_id']; - break; - - // Real Media Streams - case ATTACHMENT_CATEGORY_RM: - case ATTACHMENT_CATEGORY_QUICKTIME: - $l_downloaded_viewed = $user->lang['VIEWED']; - - $block_array += array( - 'S_RM_FILE' => ($display_cat == ATTACHMENT_CATEGORY_RM) ? true : false, - 'S_QUICKTIME_FILE' => ($display_cat == ATTACHMENT_CATEGORY_QUICKTIME) ? true : false, - 'U_FORUM' => generate_board_url(), - 'ATTACH_ID' => $attachment['attach_id'], - ); - - // Viewed/Heared File ... update the download count - $update_count[] = $attachment['attach_id']; - break; - - // Macromedia Flash Files - case ATTACHMENT_CATEGORY_FLASH: - list($width, $height) = @getimagesize($filename); - - $l_downloaded_viewed = $user->lang['VIEWED']; - - $block_array += array( - 'S_FLASH_FILE' => true, - 'WIDTH' => $width, - 'HEIGHT' => $height, - ); - - // Viewed/Heared File ... update the download count - $update_count[] = $attachment['attach_id']; - break; - - default: - $l_downloaded_viewed = $user->lang['DOWNLOADED']; - - $block_array += array( - 'S_FILE' => true, - ); - break; - } - - $l_download_count = (!isset($attachment['download_count']) || $attachment['download_count'] == 0) ? $user->lang['DOWNLOAD_NONE'] : (($attachment['download_count'] == 1) ? sprintf($user->lang['DOWNLOAD_COUNT'], $attachment['download_count']) : sprintf($user->lang['DOWNLOAD_COUNTS'], $attachment['download_count'])); - - $block_array += array( - 'U_DOWNLOAD_LINK' => $download_link, - 'L_DOWNLOADED_VIEWED' => $l_downloaded_viewed, - 'L_DOWNLOAD_COUNT' => $l_download_count - ); - } - - $template->assign_block_vars('_file', $block_array); - - $tpl = $template->assign_display('attachment_tpl'); - - if (!$return) - { - $template->assign_block_vars($blockname, array( - 'DISPLAY_ATTACHMENT' => $tpl) - ); - } - else - { - $return_tpl[] = $tpl; - } - } - - return $return_tpl; -} - -/** * Assign/Build custom bbcodes for display in screens supporting using of bbcodes * The custom bbcodes buttons will be placed within the template block 'custom_codes' */ |