/** * Fetches a list of attachments for display on edit or preview * * @param string Posthash of this edit/add * @param integer Start time of this edit/add * @param array Combined existing and new attachments belonging to this content * @param integer id of attachments owner * @param string Content specific values that need to be passed on to the attachment form * @param string $editorid of the message editor on the page that launched the asset manager * @param integer Number of fetched attachments, set by this function * @param mixed Who can view an attachment with no contentid (in progress), other than vbulletin->userinfo * * @return string */ public function fetch_edit_attachments(&$posthash, &$poststarttime, &$postattach, $contentid, $values, $editorid, &$attachcount, $users = null) { global $show; require_once DIR . '/includes/functions_file.php'; // $maxattachsize is redundant, never used $attachcount = 0; $attachment_js = ''; if (!$posthash or !$poststarttime) { $poststarttime = TIMENOW; $posthash = md5($poststarttime . $this->registry->userinfo['userid'] . $this->registry->userinfo['salt']); } if (empty($postattach)) { $postattach = $this->fetch_postattach($posthash, $contentid, $users); } if (!empty($postattach)) { $attachdisplaylib =& vB_Attachment_Upload_Displaybit_Library::fetch_library($this->registry, $this->contenttypeid); foreach ($postattach as $attachmentid => $attach) { $attachcount++; $attach['html'] = $attachdisplaylib->process_display_template($attach, $values); $attachments .= $attach['html']; $show['attachmentlist'] = true; $attachment_js .= $attachdisplaylib->construct_attachment_add_js($attach); } } $templater = vB_Template::create('newpost_attachment'); $templater->register('attachments', $attachments); $templater->register('attachment_js', $attachment_js); $templater->register('editorid', $editorid); $templater->register('posthash', $posthash); $templater->register('contentid', $contentid); $templater->register('poststarttime', $poststarttime); $templater->register('attachuserid', $this->registry->userinfo['userid']); $templater->register('contenttypeid', $this->contenttypeid); $templater->register('values', $values); return $templater->render(); }
$templater->register('filename', $filename); $errorlist .= $templater->render(); } $show['errors'] = true; } } } $currentattaches = $attachlib->fetch_attachments(); require_once DIR . '/includes/functions_editor.php'; $wysiwyg = is_wysiwyg_compatible(); $attachcount = 0; $totalsize = 0; $attachments = ''; $attachmentsarray = array(); $updatearray = array(); $attachdisplaylib =& vB_Attachment_Upload_Displaybit_Library::fetch_library($vbulletin, $contenttypeid); while ($attach = $db->fetch_array($currentattaches)) { $attach['extension'] = strtolower(file_extension($attach['filename'])); $attach['filename'] = fetch_censored_text(htmlspecialchars_uni($attach['filename'], false)); $attachcount++; $totalsize += intval($attach['filesize']); $attach['filesize_formatted'] = vb_number_format($attach['filesize'], 1, true); $show['thumbnail'] = $attach['hasthumbnail'] ? true : false; if ($attach['attachmentid'] == $currentattachment['attachmentid']) { $currentattachment['hasthumbnail'] = $attach['hasthumbnail']; } $assetinfo = $attach; if ($show['ajaxform'] or $show['ajaxupload']) { $show['uploadasset'] = true; $show['smallthumb'] = true; $templater = vB_Template::create('assetmanager_thumbview');