Copyright (C) 2007 artoodetoo (master@1wd.ru) Included from: edit.php, filemap.php, viewtopic.php Incoming variables: $attachments: array - cache of attachments records ************************************************************************/ if (@$attachments) { $thumb_height = $pun_config['file_thumb_height']; $thumb_width = $pun_config['file_thumb_width']; $pview_height = $pun_config['file_preview_height']; $pview_width = $pun_config['file_preview_width']; $tmp = array(); foreach ($attachments as $post_attachments) { foreach ($post_attachments as $attachment) { // generate preview images just-in-time if (preg_match('/^image\\/(.*)$/i', $attachment['mime'], $regs)) { $pview_fname = require_thumb($attachment['id'], $attachment['location'], $pview_width, $pview_height, false); $thumb_fname = require_thumb($attachment['id'], $attachment['location'], $thumb_width, $thumb_height, true); $img_size = ' (' . $regs[1] . ' ' . $attachment['image_dim'] . ')'; } else { $thumb_fname = $img_size = null; } $tmp[] = "'" . $attachment['id'] . "': [" . "'" . format_time($attachment['uploaded']) . "'," . "'" . pun_htmlspecialchars($attachment['filename']) . "'," . "'" . $lang_fu['Size'] . ': ' . round($attachment['size'] / 1024, 1) . 'kb ' . $img_size . ' ' . $lang_fu['Downloads'] . ': ' . $attachment['downloads'] . "','" . $thumb_fname . "'," . intval(isset($attachment['can_download']) ? $attachment['can_download'] : $can_download) . ']'; } } JsHelper::getInstance()->addInternal('ATTACH_DATA={' . implode(',', $tmp) . '};'); unset($tmp); } JsHelper::getInstance()->add(PUN_ROOT . 'js/pop.js'); echo '<div id="pun-popup" class="punpopup"><p id="pun-title" class="popup-title">title</p><p id="pun-desc" class="popup-desc">Description</p><p id="pun-body" class="popup-body">Body</p></div>';
function handle_thumb_tag($aid) { global $db; $result = $db->query('SELECT location FROM ' . $db->prefix . 'attachments WHERE id=' . $aid) or error('Unable to fetch attachment', __FILE__, __LINE__, $db->error()); if ($db->num_rows($result)) { $width = $GLOBALS['pun_config']['file_preview_width']; $height = $GLOBALS['pun_config']['file_preview_height']; list($location) = $db->fetch_row($result); require_thumb($aid, $location, $width, $height); } return '::thumb' . $aid . '::'; // really tag not translated :) }
// in edit.php attachments has checkboxes to delete if ($basename == 'edit.php') { $check = '<br /><label><input type="checkbox" name="delete_image[]" value="' . $aid . '" />' . $lang_fu['Mark to Delete'] . '</label>'; } else { $check = null; } if ($pun_config['file_popup_info'] == 1) { $link_events = ' onmouseover="downloadPopup(event,\'' . $aid . '\')"'; $att_info = null; } else { $link_events = null; if ($is_inplace) { $att_info = '<br />' . ($attachment['size'] >= 1048576 ? round($attachment['size'] / 1048576, 0) . 'mb' : round($attachment['size'] / 1024, 0) . 'kb'); if (preg_match('/^image\\/(.*)$/i', $attachment['mime'], $regs)) { $att_info .= ',' . $regs[1] . ' ' . $attachment['image_dim'] . '<br />' . $lang_fu['Downloads'] . ': ' . $attachment['downloads']; $thumbnail = '<img src="' . PUN_ROOT . require_thumb($attachment['id'], $attachment['location'], $pun_config['file_thumb_width'], $pun_config['file_thumb_height'], true) . '">'; if ($can_download) { //$thumbnail = '<a href="'.$pun_config['o_base_url'].'/download.php?aid='.$aid.'">'.$thumbnail.'</a>'; $thumbnail = '<a href="javascript:void(0);" onclick="{a=\'::thumb' . $aid . '::\';window.prompt(\'BBcode\',a);}">' . $thumbnail . '</a>'; } $att_info .= '<br />' . $thumbnail; } else { $att_info .= '<br />' . $lang_fu['Downloads'] . ': ' . $attachment['downloads']; } } else { $att_info = null; } } if ($can_download) { echo '<li' . ($is_inplace ? ' class="att_info"' : '') . '><a href="' . $pun_config['o_base_url'] . '/download.php?aid=' . $aid . '"' . $link_events . ' class="att_filename">' . $title . '</a>' . $att_info . $check . '</li>'; } else {