831 |
florian |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
////////////////////////////////////////////////////////////////////////////////
|
|
|
4 |
// //
|
|
|
5 |
// Copyright (C) 2006 Phorum Development Team //
|
|
|
6 |
// http://www.phorum.org //
|
|
|
7 |
// //
|
|
|
8 |
// This program is free software. You can redistribute it and/or modify //
|
|
|
9 |
// it under the terms of either the current Phorum License (viewable at //
|
|
|
10 |
// phorum.org) or the Phorum License that was distributed with this file //// //
|
|
|
11 |
// This program is distributed in the hope that it will be useful, //
|
|
|
12 |
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
|
|
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
|
|
|
14 |
// //
|
|
|
15 |
// You should have received a copy of the Phorum License //
|
|
|
16 |
// along with this program. //
|
|
|
17 |
////////////////////////////////////////////////////////////////////////////////
|
|
|
18 |
|
|
|
19 |
if(!defined("PHORUM")) return;
|
|
|
20 |
|
|
|
21 |
$previewmessage = $message;
|
|
|
22 |
|
|
|
23 |
if ($attach_count)
|
|
|
24 |
{
|
|
|
25 |
define('PREVIEW_NO_ATTACHMENT_CLICK',
|
|
|
26 |
"javascript:alert('" . $PHORUM["DATA"]["LANG"]["PreviewNoClickAttach"] . "')");
|
|
|
27 |
|
|
|
28 |
// Create the URL and formatted size for attachment files.
|
|
|
29 |
foreach ($previewmessage["attachments"] as $nr => $data) {
|
|
|
30 |
$previewmessage["attachments"][$nr]["url"] =
|
|
|
31 |
phorum_get_url(PHORUM_FILE_URL, "file={$data['file_id']}");
|
|
|
32 |
$previewmessage["attachments"][$nr]["size"] =
|
|
|
33 |
phorum_filesize($data["size"]);
|
|
|
34 |
}
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
// Format the message using the default formatting.
|
|
|
38 |
include_once("./include/format_functions.php");
|
|
|
39 |
$previewmessages = phorum_format_messages(array($previewmessage));
|
|
|
40 |
$previewmessage = array_shift($previewmessages);
|
|
|
41 |
|
|
|
42 |
// Recount the number of attachments. Formatting mods might have changed
|
|
|
43 |
// the number of attachments we have to display using default formatting.
|
|
|
44 |
$attach_count = 0;
|
|
|
45 |
if (isset($previewmessage["attachments"])) {
|
|
|
46 |
foreach ($previewmessage["attachments"] as $attachment) {
|
|
|
47 |
if ($attachment["keep"]) {
|
|
|
48 |
$attach_count ++;
|
|
|
49 |
}
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
if ($attach_count)
|
|
|
54 |
{
|
|
|
55 |
// Disable clicking on attachments in the preview (to prevent the
|
|
|
56 |
// browser from jumping to a viewing page, which might break the
|
|
|
57 |
// editing flow). This is not done in the previous loop where the
|
|
|
58 |
// URL is set, so the formatting code for things like inline
|
|
|
59 |
// attachments can be used.
|
|
|
60 |
foreach ($previewmessage["attachments"] as $nr => $data) {
|
|
|
61 |
$previewmessage["attachments"][$nr]["url"] = PREVIEW_NO_ATTACHMENT_CLICK;
|
|
|
62 |
}
|
|
|
63 |
} else {
|
|
|
64 |
unset($previewmessage["attachments"]);
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
// Fill the author name and datestamp for new postings.
|
|
|
68 |
if ($mode != "edit" && $PHORUM["DATA"]["LOGGEDIN"]) {
|
|
|
69 |
$previewmessage["author"] = $PHORUM["user"]["username"];
|
|
|
70 |
$previewmessage["datestamp"] = time();
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
// Format datestamp.
|
|
|
74 |
$previewmessage["datestamp"] = phorum_date($PHORUM["short_date"], $previewmessage["datestamp"]);
|
|
|
75 |
|
|
|
76 |
$PHORUM["DATA"]["PREVIEW"] = $previewmessage;
|
|
|
77 |
|
|
|
78 |
?>
|