Subversion Repositories Applications.papyrus

Rev

Rev 439 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 439 Rev 556
1
<?php
1
<?php
2
/*
2
/*
3
edit.php
3
edit.php
4
Copyright (c) 2002, Hendrik Mans <hendrik@mans.de>
4
Copyright (c) 2002, Hendrik Mans <hendrik@mans.de>
5
Copyright 2002, 2003 David DELON
5
Copyright 2002, 2003 David DELON
6
Copyright 2002, 2003 Charles NEPOTE
6
Copyright 2002, 2003 Charles NEPOTE
7
Copyright 2002, 2003 Patrick PAUL
7
Copyright 2002, 2003 Patrick PAUL
8
Copyright  2003  Eric FELDSTEIN
8
Copyright  2003  Eric FELDSTEIN
9
All rights reserved.
9
All rights reserved.
10
Redistribution and use in source and binary forms, with or without
10
Redistribution and use in source and binary forms, with or without
11
modification, are permitted provided that the following conditions
11
modification, are permitted provided that the following conditions
12
are met:
12
are met:
13
1. Redistributions of source code must retain the above copyright
13
1. Redistributions of source code must retain the above copyright
14
notice, this list of conditions and the following disclaimer.
14
notice, this list of conditions and the following disclaimer.
15
2. Redistributions in binary form must reproduce the above copyright
15
2. Redistributions in binary form must reproduce the above copyright
16
notice, this list of conditions and the following disclaimer in the
16
notice, this list of conditions and the following disclaimer in the
17
documentation and/or other materials provided with the distribution.
17
documentation and/or other materials provided with the distribution.
18
3. The name of the author may not be used to endorse or promote products
18
3. The name of the author may not be used to endorse or promote products
19
derived from this software without specific prior written permission.
19
derived from this software without specific prior written permission.
20
 
20
 
21
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
*/
31
*/
32
//vérification de sécurité
32
//vérification de sécurité
33
if (!eregi("wakka.php", $_SERVER['PHP_SELF'])) {
33
if (!eregi("wakka.php", $_SERVER['PHP_SELF'])) {
34
    die ("acc&egrave;s direct interdit");
34
    die ("acc&egrave;s direct interdit");
35
}
35
}
36
echo $this->Header();
36
echo $this->Header();
37
?>
37
?>
38
<div class="page">
38
<div class="page">
39
<?php
39
<?php
40
if ($this->HasAccess("write") && $this->HasAccess("read"))
40
if ($this->HasAccess("write") && $this->HasAccess("read"))
41
{
41
{
42
	$output='';
42
	$output='';
43
	if ($_POST)
43
	if ($_POST)
44
	{
44
	{
45
		// only if saving:
45
		// only if saving:
46
		if ($_POST["submit"] == "Sauver")
46
		if ($_POST["submit"] == "Sauver")
47
		{
47
		{
48
			// check for overwriting
48
			// check for overwriting
49
			if ($this->page)
49
			if ($this->page)
50
			{
50
			{
51
				if ($this->page["id"] != $_POST["previous"])
51
				if ($this->page["id"] != $_POST["previous"])
52
				{
52
				{
53
					$error = "ALERTE : ".
53
					$error = "ALERTE : ".
54
					"Cette page a &eacute;t&eacute; modifi&eacute;e par quelqu'un d'autre pendant que vous l'&eacute;ditiez.<br />\n".
54
					"Cette page a &eacute;t&eacute; modifi&eacute;e par quelqu'un d'autre pendant que vous l'&eacute;ditiez.<br />\n".
55
					"Veuillez copier vos changements et r&eacute;&eacute;diter cette page.\n";
55
					"Veuillez copier vos changements et r&eacute;&eacute;diter cette page.\n";
56
				}
56
				}
57
			}
57
			}
58
 
58
 
59
 
59
 
60
			// store
60
			// store
61
			if (!$error)
61
			if (!$error)
62
			{
62
			{
63
				$body = str_replace("\r", "", $_POST["body"]);
63
				$body = str_replace("\r", "", $_POST["body"]);
64
				
64
				
65
				// test si la nouvelle page est differente de la précédente
65
				// test si la nouvelle page est differente de la précédente
66
				if(rtrim($body)==rtrim($this->page["body"])) {
66
				if(rtrim($body)==rtrim($this->page["body"])) {
67
					$this->SetMessage("Cette page n\'a pas &eacute;t&eacute; enregistr&eacute;e car elle n\'a subi aucune modification.");
67
					$this->SetMessage("Cette page n\'a pas &eacute;t&eacute; enregistr&eacute;e car elle n\'a subi aucune modification.");
68
					$this->Redirect($this->href());
68
					$this->Redirect($this->href());
69
				}
69
				}
70
 
70
 
71
				// add page (revisions)
71
				// add page (revisions)
72
				$this->SavePage($this->tag, $body);
72
				$this->SavePage($this->tag, $body);
73
 
73
 
74
				// now we render it internally so we can write the updated link table.
74
				// now we render it internally so we can write the updated link table.
75
				$this->ClearLinkTable();
75
				$this->ClearLinkTable();
76
				$this->StartLinkTracking();
76
				$this->StartLinkTracking();
77
				$dummy = $this->Header();
77
				$dummy = $this->Header();
78
				$dummy .= $this->Format($body);
78
				$dummy .= $this->Format($body);
79
				$dummy .= $this->Footer();
79
				$dummy .= $this->Footer();
80
				$this->StopLinkTracking();
80
				$this->StopLinkTracking();
81
				$this->WriteLinkTable();
81
				$this->WriteLinkTable();
82
				$this->ClearLinkTable();
82
				$this->ClearLinkTable();
83
 
83
 
84
				// forward
84
				// forward
85
				$this->Redirect($this->href());
85
				$this->Redirect($this->href());
86
			}
86
			}
87
		}
87
		}
88
	}
88
	}
89
 
89
 
90
	// fetch fields
90
	// fetch fields
91
	if (!isset($_POST["previous"])) $previous = $this->page["id"];
91
	if (!$previous = $_POST["previous"]) $previous = $this->page["id"];
92
	else $previous = $_POST["previous"];
-
 
93
	if (!isset($_POST["body"])) $body = $this->page["body"];
92
	if (!$body = $_POST["body"]) $body = $this->page["body"];
94
	else $body = $_POST["body"];
-
 
95
 
-
 
96
 
93
 
97
	// preview?
-
 
98
	if (!isset($_POST["submit"])) $_POST["submit"] = "";
94
	// preview?
99
	if ($_POST["submit"] == "Aperçu")
95
	if ($_POST["submit"] == "Aperçu")
100
	{
96
	{
101
		$output .=
97
		$output .=
102
			"<div class=\"prev_alert\"><strong>Aper&ccedil;u</strong></div>\n".
98
			"<div class=\"prev_alert\"><strong>Aper&ccedil;u</strong></div>\n".
103
			$this->Format($body)."\n\n".
99
			$this->Format($body)."\n\n".
104
			$this->FormOpen("edit").
100
			$this->FormOpen("edit").
105
			"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
101
			"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
106
			"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n".
102
			"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n".
107
			"<br />\n".
103
			"<br />\n".
108
			"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
104
			"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
109
			"<input name=\"submit\" type=\"submit\" value=\"R&eacute;&eacute;diter \" accesskey=\"p\" />\n".
105
			"<input name=\"submit\" type=\"submit\" value=\"R&eacute;&eacute;diter \" accesskey=\"p\" />\n".
110
			"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
106
			"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
111
			$this->FormClose()."\n";
107
			$this->FormClose()."\n";
112
	}
108
	}
113
	else
109
	else
114
	{
110
	{
115
		// display form
111
		// display form
116
		if (isset($error))
112
		if ($error)
117
		{
113
		{
118
			if (!isset($output)) $output = '';
-
 
119
			$output .= "<div class=\"error\">$error</div>\n";
114
			$output .= "<div class=\"error\">$error</div>\n";
120
		}
115
		}
121
 
116
 
122
		// append a comment?
117
		// append a comment?
123
		if (isset($_REQUEST["appendcomment"]))
118
		if ($_REQUEST["appendcomment"])
124
		{
119
		{
125
			$body = trim($body)."\n\n----\n\n--".$this->UserName()." (".strftime("%c").")";
120
			$body = trim($body)."\n\n----\n\n--".$this->UserName()." (".strftime("%c").")";
126
		}
121
		}
127
 
-
 
128
		if (!isset($output)) $output = '';
122
		require_once("ACeditor.buttonsBar.php");
129
		$output .=
123
		$output .=
130
			$this->FormOpen("edit").
124
			$this->FormOpen("edit").
131
			"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
125
			"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".$ACbuttonsBar.
132
			"<textarea onkeydown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
126
			"<textarea onkeydown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
133
			htmlspecialchars($body).
127
			htmlspecialchars($body).
134
			"\n</textarea><br />\n".
128
			"\n</textarea><br />\n".
135
			($this->config["preview_before_save"] ? "" : "<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
129
			($this->config["preview_before_save"] ? "" : "<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
136
			"<input name=\"submit\" type=\"submit\" value=\"Aper&ccedil;u\" accesskey=\"p\" />\n".
130
			"<input name=\"submit\" type=\"submit\" value=\"Aper&ccedil;u\" accesskey=\"p\" />\n".
137
			"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
131
			"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
138
			$this->FormClose();
132
			$this->FormClose();
139
	}
133
	}
140
 
134
 
141
	echo $output;
135
	echo $output;
142
}
136
}
143
else
137
else
144
{
138
{
145
	echo "<i>Vous n'avez pas acc&egrave;s en &eacute;criture &agrave; cette page !</i>\n";
139
	echo "<i>Vous n'avez pas acc&egrave;s en &eacute;criture &agrave; cette page !</i>\n";
146
}
140
}
147
?>
141
?>
148
<hr class="hr_clear" />
142
<hr class="hr_clear" />
149
</div>
143
</div>
150
<?php echo $this->Footer(); ?>
144
<?php echo $this->Footer(); ?>