433 |
ddelon |
1 |
<div class="page">
|
|
|
2 |
<?php
|
|
|
3 |
if ($this->HasAccess("write") && $this->HasAccess("read"))
|
|
|
4 |
{
|
|
|
5 |
if ($_POST)
|
|
|
6 |
{
|
|
|
7 |
// only if saving:
|
|
|
8 |
if ($_POST["submit"] == "Sauver")
|
|
|
9 |
{
|
|
|
10 |
// check for overwriting
|
|
|
11 |
if ($this->page)
|
|
|
12 |
{
|
|
|
13 |
if ($this->page["id"] != $_POST["previous"])
|
|
|
14 |
{
|
|
|
15 |
$error = "ALERTE : ".
|
|
|
16 |
"Cette page a été modifiée par quelqu'un d'autre pendant que vous l'éditiez.<br />\n".
|
|
|
17 |
"Veuillez copier vos changements et re-editer cette page.\n";
|
|
|
18 |
}
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
// store
|
|
|
23 |
if (!$error)
|
|
|
24 |
{
|
|
|
25 |
$body = str_replace("\r", "", $_POST["body"]);
|
|
|
26 |
|
|
|
27 |
// add page (revisions)
|
|
|
28 |
$this->SavePage($this->tag, $body);
|
|
|
29 |
|
|
|
30 |
// now we render it internally so we can write the updated link table.
|
|
|
31 |
$this->ClearLinkTable();
|
|
|
32 |
$this->StartLinkTracking();
|
|
|
33 |
$dummy = $this->Header();
|
|
|
34 |
$dummy .= $this->Format($body);
|
|
|
35 |
$dummy .= $this->Footer();
|
|
|
36 |
$this->StopLinkTracking();
|
|
|
37 |
$this->WriteLinkTable();
|
|
|
38 |
$this->ClearLinkTable();
|
|
|
39 |
|
|
|
40 |
// forward
|
|
|
41 |
$this->Redirect($this->href());
|
|
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
// fetch fields
|
|
|
47 |
if (!$previous = $_POST["previous"]) $previous = $this->page["id"];
|
|
|
48 |
if (!$body = $_POST["body"]) $body = $this->page["body"];
|
|
|
49 |
|
|
|
50 |
// preview?
|
|
|
51 |
if ($_POST["submit"] == "Aperçu")
|
|
|
52 |
{
|
|
|
53 |
$previewButtons =
|
|
|
54 |
"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
|
|
|
55 |
"<input name=\"submit\" type=\"submit\" value=\"Re-Editer\" accesskey=\"p\" />\n".
|
|
|
56 |
"<input type=\"button\" value=\"Annulation\" onClick=\"document.location='".$this->href("")."';\" />\n";
|
|
|
57 |
|
|
|
58 |
$output .= "<div class=\"prev_alert\"><strong>Aperçu</strong></div>\n";
|
|
|
59 |
|
|
|
60 |
$output .=
|
|
|
61 |
$this->FormOpen("edit")."\n".
|
|
|
62 |
"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
|
|
|
63 |
"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n";
|
|
|
64 |
|
|
|
65 |
$output .= $this->Format($body);
|
|
|
66 |
|
|
|
67 |
$output .=
|
|
|
68 |
"<br />\n".
|
|
|
69 |
$previewButtons.
|
|
|
70 |
$this->FormClose()."\n";
|
|
|
71 |
}
|
|
|
72 |
else
|
|
|
73 |
{
|
|
|
74 |
// display form
|
|
|
75 |
if ($error)
|
|
|
76 |
{
|
|
|
77 |
$output .= "<div class=\"error\">$error</div>\n";
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
// append a comment?
|
|
|
81 |
if ($_REQUEST["appendcomment"])
|
|
|
82 |
{
|
|
|
83 |
$body = trim($body)."\n\n----\n\n--".$this->UserName()." (".strftime("%c").")";
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
$output .=
|
|
|
87 |
$this->FormOpen("edit").
|
|
|
88 |
"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
|
|
|
89 |
"<textarea onKeyDown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
|
|
|
90 |
htmlspecialchars($body).
|
|
|
91 |
"\n</textarea><br />\n".
|
|
|
92 |
($this->config["preview_before_save"] ? "" : "<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
|
|
|
93 |
"<input name=\"submit\" type=\"submit\" value=\"Aperçu\" accesskey=\"p\" />\n".
|
|
|
94 |
"<input type=\"button\" value=\"Annulation\" onClick=\"document.location='".$this->href("")."';\" />\n".
|
|
|
95 |
$this->FormClose();
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
echo $output;
|
|
|
100 |
}
|
|
|
101 |
else
|
|
|
102 |
{
|
|
|
103 |
echo "<i>Vous n'avez pas accès en écriture à cette page !</i>\n";
|
|
|
104 |
}
|
|
|
105 |
?>
|
|
|
106 |
</div>
|