Subversion Repositories Applications.papyrus

Rev

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

Rev 677 Rev 690
1
<?php
1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This file is part of Integrateur Wikini.                                                             |
8
// | This file is part of Integrateur Wikini.                                                             |
9
// |                                                                                                      |
9
// |                                                                                                      |
10
// | Foobar is free software; you can redistribute it and/or modify                                       |
10
// | Foobar is free software; you can redistribute it and/or modify                                       |
11
// | it under the terms of the GNU General Public License as published by                                 |
11
// | it under the terms of the GNU General Public License as published by                                 |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
13
// | (at your option) any later version.                                                                  |
13
// | (at your option) any later version.                                                                  |
14
// |                                                                                                      |
14
// |                                                                                                      |
15
// | Foobar is distributed in the hope that it will be useful,                                            |
15
// | Foobar is distributed in the hope that it will be useful,                                            |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
18
// | GNU General Public License for more details.                                                         |
18
// | GNU General Public License for more details.                                                         |
19
// |                                                                                                      |
19
// |                                                                                                      |
20
// | You should have received a copy of the GNU General Public License                                    |
20
// | You should have received a copy of the GNU General Public License                                    |
21
// | along with Foobar; if not, write to the Free Software                                                |
21
// | along with Foobar; if not, write to the Free Software                                                |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
23
// +------------------------------------------------------------------------------------------------------+
23
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id: iw_integrateur.fonct.php,v 1.13 2005-12-27 17:25:23 ddelon Exp $
24
// CVS : $Id: iw_integrateur.fonct.php,v 1.14 2006-01-09 21:58:16 ddelon Exp $
25
/**
25
/**
26
* Fonctions de l'integrateur de page Wikini
26
* Fonctions de l'integrateur de page Wikini
27
*
27
*
28
* Application permettant d'intégrer des pages wikini dans Papyrus.
28
* Application permettant d'intégrer des pages wikini dans Papyrus.
29
*
29
*
30
*@package IntegrateurWikini
30
*@package IntegrateurWikini
31
//Auteur original :
31
//Auteur original :
32
*@author        David Delon <david.delon@clapas.net>
32
*@author        David Delon <david.delon@clapas.net>
33
//Autres auteurs :
33
//Autres auteurs :
34
*@author        Aucun
34
*@author        Aucun
35
*@copyright     Tela-Botanica 2000-2004
35
*@copyright     Tela-Botanica 2000-2004
36
*@version       $Revision: 1.13 $ $Date: 2005-12-27 17:25:23 $
36
*@version       $Revision: 1.14 $ $Date: 2006-01-09 21:58:16 $
37
*
37
*
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
40
// +------------------------------------------------------------------------------------------------------+
41
 
41
 
42
 
42
 
43
 
43
 
44
 
44
 
45
/** Inclusion de la classe PEAR de gestion des URL. */
45
/** Inclusion de la classe PEAR de gestion des URL. */
46
 
46
 
47
$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
47
$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
48
 
48
 
49
require_once 'Net/URL.php';
49
require_once 'Net/URL.php';
50
 
50
 
51
// TODO : un seul fichier de configuration ?
51
// TODO : un seul fichier de configuration ?
52
/** Inclusion du fichier de configuration de cette application.*/
52
/** Inclusion du fichier de configuration de cette application.*/
53
require_once 'client/integrateur_wikini/configuration/adwi_configuration.inc.php';
53
require_once 'client/integrateur_wikini/configuration/adwi_configuration.inc.php';
54
 
54
 
55
require_once ADWI_CHEMIN_BIBLIOTHEQUE.'adwi_wikini.fonct.php';
55
require_once ADWI_CHEMIN_BIBLIOTHEQUE.'adwi_wikini.fonct.php';
56
 
56
 
57
/** Inclusion du fichier de configuration général de IntegrateurWikini.*/
57
/** Inclusion du fichier de configuration général de IntegrateurWikini.*/
58
require_once 'client'.GEN_SEP.'integrateur_wikini'.GEN_SEP.'configuration'.GEN_SEP.'iw_config.inc.php';
58
require_once 'client'.GEN_SEP.'integrateur_wikini'.GEN_SEP.'configuration'.GEN_SEP.'iw_config.inc.php';
59
 
59
 
60
/** Inclusion du fichier permettant d'encoder du texte mais pas les balises XHTML.*/
60
/** Inclusion du fichier permettant d'encoder du texte mais pas les balises XHTML.*/
61
require_once IW_CHEMIN_BIBLIO.'iw_encodage.fonct.php';
61
require_once IW_CHEMIN_BIBLIO.'iw_encodage.fonct.php';
62
/** Inclusion du fichier permettant d'inclure les données dans du XHTML.*/
62
/** Inclusion du fichier permettant d'inclure les données dans du XHTML.*/
63
require_once IW_CHEMIN_BIBLIO.'iw_affichage_xhtml.fonct.php';
63
require_once IW_CHEMIN_BIBLIO.'iw_affichage_xhtml.fonct.php';
64
 
64
 
65
global $wikini_config_defaut;
65
global $wikini_config_defaut;
66
global $wiki;
66
global $wiki;
67
global $wiki_p;
67
global $wiki_p;
68
 
68
 
69
// $_REQUEST['wiki'] est obligatoire, car wakka.php envoie un redirect si non detecté, avec perte de tout l'environnement !
69
// $_REQUEST['wiki'] est obligatoire, car wakka.php envoie un redirect si non detecté, avec perte de tout l'environnement !
70
 
70
 
71
if ( ! isset( $_REQUEST['wiki'] ) ) {
71
if ( ! isset( $_REQUEST['wiki'] ) ) {
72
	    $_REQUEST['wiki'] = $wikini_config_defaut['root_page'];
72
	    $_REQUEST['wiki'] = $wikini_config_defaut['root_page'];
73
}
73
}
74
 
74
 
75
$server=$_SERVER['PHP_SELF'];
75
$server=$_SERVER['PHP_SELF'];
76
$_SERVER['PHP_SELF']="wakka.php";
76
$_SERVER['PHP_SELF']="wakka.php";
77
 
77
 
78
// Utilise le wakkaconfig de la racine ...
78
// Utilise le wakkaconfig de la racine ...
79
// TODO : un wiki par défaut pour chaque papyrus à l'installation de Papyrus
79
// TODO : un wiki par défaut pour chaque papyrus à l'installation de Papyrus
80
// TODO : verifier bon dimensionnement des champs et clef de la table papyrus_wiki
80
// TODO : verifier bon dimensionnement des champs et clef de la table papyrus_wiki
81
// TODO : creation des tables par defaut à l'installation d'un wikini
81
// TODO : creation des tables par defaut à l'installation d'un wikini
82
// TODO : Fusion des fichiers de configuration ?
82
// TODO : Fusion des fichiers de configuration ?
83
 
83
 
84
 
84
 
85
ob_start();
85
ob_start();
86
 
86
 
87
include_once IW_CHEMIN_WIKINI_COURANT.'wakka.php';
87
include_once IW_CHEMIN_WIKINI_COURANT.'wakka.php';
88
include_once(IW_CHEMIN_WIKINI_COURANT."/formatters/tableaux.php");
88
include_once(IW_CHEMIN_WIKINI_COURANT."/formatters/tableaux.php");
89
include_once(IW_CHEMIN_WIKINI_COURANT."/actions/attach.class.php");
89
include_once(IW_CHEMIN_WIKINI_COURANT."/actions/attach.class.php");
90
 
90
 
91
ob_end_clean();
91
ob_end_clean();
92
$_SERVER['PHP_SELF']=$server;
92
$_SERVER['PHP_SELF']=$server;
93
 
93
 
94
 
94
 
95
// On surcharge la classe Wiki pour en faire ce qu'on en veut
95
// On surcharge la classe Wiki pour en faire ce qu'on en veut
96
Class Wiki_Papyrus extends Wiki {
96
Class Wiki_Papyrus extends Wiki {
97
 
97
 
98
 
98
 
99
	function Header() {
99
	function Header() {
100
 
100
 
101
		return;
101
		return;
102
	}
102
	}
103
 
103
 
104
 	function Footer() {
104
 	function Footer() {
105
 		echo  "<div class=\"footer\">";
105
 		echo  "<div class=\"footer\">";
106
		echo  $this->HasAccess("write") ? "<a href=\"".$this->href("edit")."\" title=\"Cliquez pour modifier cette page.\">Modifier cette page</a> ::\n" : "";
106
		echo  $this->HasAccess("write") ? "<a href=\"".$this->href("edit")."\" title=\"Cliquez pour modifier cette page.\">Modifier cette page</a> ::\n" : "";
107
		echo  $this->GetPageTime() ? "<a href=\"".$this->href("revisions")."\" title=\"Cliquez pour voir les derni&egrave;res modifications sur cette page.\">".$this->GetPageTime()."</a> ::\n" : "";
107
		echo  $this->GetPageTime() ? "<a href=\"".$this->href("revisions")."\" title=\"Cliquez pour voir les derni&egrave;res modifications sur cette page.\">".$this->GetPageTime()."</a> ::\n" : "";
108
		// 	if this page exists
108
		// 	if this page exists
109
		if ($this->page)
109
		if ($this->page)
110
		{
110
		{
111
		// if owner is current user
111
		// if owner is current user
112
			if ($this->UserIsOwner())
112
			if ($this->UserIsOwner())
113
			{
113
			{
114
				echo
114
				echo
115
				"Propri&eacute;taire&nbsp;: vous :: \n",
115
				"Propri&eacute;taire&nbsp;: vous :: \n",
116
				"<a href=\"",$this->href("acls")."\" title=\"Cliquez pour modifer les permissions de cette page.\">&Eacute;diter permissions</a> :: \n",
116
				"<a href=\"",$this->href("acls")."\" title=\"Cliquez pour modifer les permissions de cette page.\">&Eacute;diter permissions</a> :: \n",
117
				"<a href=\"",$this->href("deletepage")."\">Supprimer</a> :: \n";
117
				"<a href=\"",$this->href("deletepage")."\">Supprimer</a> :: \n";
118
			}
118
			}
119
			else
119
			else
120
			{
120
			{
121
				if ($owner = $this->GetPageOwner())
121
				if ($owner = $this->GetPageOwner())
122
				{
122
				{
123
					echo "Propri&eacute;taire : ",$this->Format($owner);
123
					echo "Propri&eacute;taire : ",$this->Format($owner);
124
				}
124
				}
125
				else
125
				else
126
				{
126
				{
127
					echo "Pas de propri&eacute;taire ";
127
					echo "Pas de propri&eacute;taire ";
128
					echo ($this->GetUser() ? "(<a href=\"".$this->href("claim")."\">Appropriation</a>)" : "");
128
					echo ($this->GetUser() ? "(<a href=\"".$this->href("claim")."\">Appropriation</a>)" : "");
129
				}
129
				}
130
				echo " :: \n";
130
				echo " :: \n";
131
			}
131
			}
132
		}
132
		}
133
		echo "Vous &ecirc;tes ";
133
		echo "Vous &ecirc;tes ";
134
		echo $this->Format($this->GetUserName());
134
		echo $this->Format($this->GetUserName());
135
		echo "</div>";
135
		echo "</div>";
136
 
136
 
137
 	}
137
 	}
138
 
138
 
139
	function FormOpen($method = "", $tag = "", $formMethod = "post") {
139
	function FormOpen($method = "", $tag = "", $formMethod = "post") {
140
 
140
 
141
	// Le diff ne fonctionne pas avec la methode get dans papyrus. On surcharge avec du post.
141
	// Le diff ne fonctionne pas avec la methode get dans papyrus. On surcharge avec du post.
142
 
142
 
143
		if (($method=="diff") && $formMethod=="get") {
143
		if (($method=="diff") && $formMethod=="get") {
144
			$formMethod="post";
144
			$formMethod="post";
145
		}
145
		}
146
 
146
 
147
		if ($method=="edit") {
147
		if ($method=="edit") {
148
            $result = "<form id=\"ACEditor\" name=\"ACEditor\" action=\"".$this->href($method, $tag)."\" method=\"".$formMethod."\">\n";
148
            $result = "<form id=\"ACEditor\" name=\"ACEditor\" action=\"".$this->href($method, $tag)."\" method=\"".$formMethod."\">\n";
149
            return $result;
149
            return $result;
150
		}
150
		}
151
 
151
 
152
		return parent::FormOpen($method,$tag, $formMethod);
152
		return parent::FormOpen($method,$tag, $formMethod);
153
 
153
 
154
	}
154
	}
155
	// Detournement des handlers : comme ca on peut faire ce que l'on veut ....
155
	// Detournement des handlers : comme ca on peut faire ce que l'on veut ....
156
	function Method($method) {
156
	function Method($method) {
-
 
157
 
-
 
158
		if ($method=="xml") {
-
 
159
			header("Content-type: text/xml");
-
 
160
			if ($pages = $this->LoadRecentlyChanged(50)) {
-
 
161
		
-
 
162
				$link=ereg_replace('&','&amp;',$this->Href());	            
-
 
163
			    $output = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n";
-
 
164
			    $output .= '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n";
-
 
165
			    $output .= "<channel>\n";
-
 
166
			    $output .= "<title> Derniers changements sur ". $this->config["wakka_name"]  . "</title>\n";
-
 
167
			    $output .= "<link>" .  $link . "</link>\n";
-
 
168
			    $output .= "<description> Derniers changements sur " . $this->config["wakka_name"] . " </description>\n";
-
 
169
			    $output .= "<language>fr</language>\n";
-
 
170
			    $output .= '<generator>WikiNi ' . WIKINI_VERSION . "</generator>\n";
-
 
171
			    foreach ($pages as $i => $page)
-
 
172
			    {
-
 
173
			        $output .= "<item>\n";
-
 
174
			        $output .= "<title>" . $page["tag"] . "</title>\n";
-
 
175
			        $output .= '<dc:creator>' . $page["user"] . "</dc:creator>\n";
-
 
176
			        $output .= '<pubDate>' . date("r", strtotime($page['time'])) . "</pubDate>\n";
-
 
177
			        $output .= "<description> Modification de " . $page["tag"] . " --- par " .$page["user"] /* . " le " . $day ." - ". $hh .":". $mm */ . "</description>\n";
-
 
178
			        $link=ereg_replace('&','&amp;',$this->Href("",$page["tag"]));
-
 
179
			        $output .= "<link>" . $link . "&amp;time=" . rawurlencode($page["time"]) . "</link>\n";
-
 
180
			        $output .= "</item>\n";
-
 
181
			    }
-
 
182
			    $output .= "</channel>\n";
-
 
183
			    $output .= "</rss>\n";
-
 
184
			    echo $output ;
-
 
185
 
-
 
186
			}
-
 
187
			exit;
-
 
188
			return;
-
 
189
		}
157
 
190
 
158
		if ($method=="edit") {
191
		if ($method=="edit") {
159
 
192
 
160
			$result='';
193
			$result='';
161
 
194
 
162
			if ($_POST) {
195
			if ($_POST) {
163
				if ($_POST["submit"] == "Sauver")	{
196
				if ($_POST["submit"] == "Sauver")	{
164
				// check for overwriting
197
				// check for overwriting
165
					if ($this->page) {
198
					if ($this->page) {
166
						if ($this->page["id"] != $_POST["previous"]) {
199
						if ($this->page["id"] != $_POST["previous"]) {
167
							$error = "ALERTE : ".
200
							$error = "ALERTE : ".
168
							"Cette page a &eacute;t&eacute; modifi&eacute;e par quelqu'un d'autre pendant que vous l'&eacute;ditiez.<br />\n".
201
							"Cette page a &eacute;t&eacute; modifi&eacute;e par quelqu'un d'autre pendant que vous l'&eacute;ditiez.<br />\n".
169
							"Veuillez copier vos changements et r&eacute;&eacute;diter cette page.\n";
202
							"Veuillez copier vos changements et r&eacute;&eacute;diter cette page.\n";
170
						}
203
						}
171
					}
204
					}
172
					// store
205
					// store
173
					if (!$error) {
206
					if (!$error) {
174
						$body = str_replace("\r", "", $_POST["body"]);
207
						$body = str_replace("\r", "", $_POST["body"]);
175
						// test si la nouvelle page est differente de la précédente
208
						// test si la nouvelle page est differente de la précédente
176
						if(rtrim($body)==rtrim($this->page["body"])) {
209
						if(rtrim($body)==rtrim($this->page["body"])) {
177
							$this->SetMessage("Cette page n\'a pas &eacute;t&eacute; enregistr&eacute;e car elle n\'a subi aucune modification.");
210
							$this->SetMessage("Cette page n\'a pas &eacute;t&eacute; enregistr&eacute;e car elle n\'a subi aucune modification.");
178
							$this->Redirect($this->href());
211
							$this->Redirect($this->href());
179
						}
212
						}
180
 
213
 
181
						// add page (revisions)
214
						// add page (revisions)
182
						$this->SavePage($this->tag, $body);
215
						$this->SavePage($this->tag, $body);
183
 
216
 
184
						// now we render it internally so we can write the updated link table.
217
						// now we render it internally so we can write the updated link table.
185
						$this->ClearLinkTable();
218
						$this->ClearLinkTable();
186
						$this->StartLinkTracking();
219
						$this->StartLinkTracking();
187
						$dummy = $this->Header();
220
						$dummy = $this->Header();
188
						$dummy .= $this->Format($body);
221
						$dummy .= $this->Format($body);
189
						$dummy .= $this->Footer();
222
						$dummy .= $this->Footer();
190
						$this->StopLinkTracking();
223
						$this->StopLinkTracking();
191
						$this->WriteLinkTable();
224
						$this->WriteLinkTable();
192
						$this->ClearLinkTable();
225
						$this->ClearLinkTable();
193
 
226
 
194
						// forward
227
						// forward
195
						$this->Redirect($this->href());
228
						$this->Redirect($this->href());
196
					}
229
					}
197
				}
230
				}
198
			}
231
			}
199
 
232
 
200
			// fetch fields
233
			// fetch fields
201
			if (!$previous = $_POST["previous"]) $previous = $this->page["id"];
234
			if (!$previous = $_POST["previous"]) $previous = $this->page["id"];
202
			if (!$body = $_POST["body"]) $body = $this->page["body"];
235
			if (!$body = $_POST["body"]) $body = $this->page["body"];
203
 
236
 
204
			// preview?
237
			// preview?
205
			if ($_POST["submit"] == "Aperçu")
238
			if ($_POST["submit"] == "Aperçu")
206
			{
239
			{
207
				$result .=
240
				$result .=
208
					"<div class=\"prev_alert\"><strong>Aper&ccedil;u</strong></div>\n".
241
					"<div class=\"prev_alert\"><strong>Aper&ccedil;u</strong></div>\n".
209
					$this->Format($body)."\n\n".
242
					$this->Format($body)."\n\n".
210
					$this->FormOpen("edit").
243
					$this->FormOpen("edit").
211
					"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
244
					"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
212
					"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n".
245
					"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n".
213
					"<br />\n".
246
					"<br />\n".
214
					"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
247
					"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
215
					"<input name=\"submit\" type=\"submit\" value=\"R&eacute;&eacute;diter \" accesskey=\"p\" />\n".
248
					"<input name=\"submit\" type=\"submit\" value=\"R&eacute;&eacute;diter \" accesskey=\"p\" />\n".
216
					"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
249
					"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
217
					$this->FormClose()."\n";
250
					$this->FormClose()."\n";
218
				return $result;
251
				return $result;
219
			}
252
			}
220
			else
253
			else
221
			{
254
			{
222
 
255
 
223
			    require_once(IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.buttonsBar.php");
256
			    require_once(IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.buttonsBar.php");
224
 
257
 
225
				$result .=
258
				$result .=
226
				$this->FormOpen("edit").
259
				$this->FormOpen("edit").
227
				"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".$ACbuttonsBar.
260
				"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".$ACbuttonsBar.
228
				"<textarea onkeydown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
261
				"<textarea onkeydown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
229
				htmlspecialchars($body).
262
				htmlspecialchars($body).
230
				"\n</textarea><br />\n".'<div class="boutons_wiki">'.
263
				"\n</textarea><br />\n".'<div class="boutons_wiki">'.
231
				($this->config["preview_before_save"] ? "" : "<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
264
				($this->config["preview_before_save"] ? "" : "<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
232
				"<input name=\"submit\" type=\"submit\" value=\"Aper&ccedil;u\" accesskey=\"p\" />\n".
265
				"<input name=\"submit\" type=\"submit\" value=\"Aper&ccedil;u\" accesskey=\"p\" />\n".
233
				"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" /></div>\n".
266
				"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" /></div>\n".
234
				$this->FormClose();
267
				$this->FormClose();
235
 
268
 
236
				return $result;
269
				return $result;
237
			}
270
			}
238
 
271
 
239
		}
272
		}
240
		else {
273
		else {
241
			return parent::Method($method);
274
			return parent::Method($method);
242
		}
275
		}
243
	}
276
	}
244
 
277
 
245
 
278
 
246
	// Surcharge Format a cause probleme de chemin.
279
	// Surcharge Format a cause probleme de chemin.
247
 
280
 
248
	function Format($text, $formatter = "wakka") {
281
	function Format($text, $formatter = "wakka") {
249
		return $this->IncludeBuffered(IW_CHEMIN_WIKINI_COURANT_FORMATTER.$formatter.".php", "<i>Impossible de trouver le formateur \"$formatter\"</i>", compact("text"));
282
		return $this->IncludeBuffered(IW_CHEMIN_WIKINI_COURANT_FORMATTER.$formatter.".php", "<i>Impossible de trouver le formateur \"$formatter\"</i>", compact("text"));
250
	}
283
	}
251
 
284
 
252
 
285
 
253
	// Identification
286
	// Identification
254
 
287
 
255
	function SetUser($user, $remember) {
288
	function SetUser($user, $remember) {
256
			// Appel à partir de Papyrus
289
			// Appel à partir de Papyrus
257
				if ($user=='') {
290
				if ($user=='') {
258
					$remember=1;
291
					$remember=1;
259
					$wiki_prenom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_prenom));
292
					$wiki_prenom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_prenom));
260
					$wiki_nom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_nom));
293
					$wiki_nom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_nom));
261
 
294
 
262
					$_SESSION["user"]["name"] = $wiki_prenom.$wiki_nom;
295
					$_SESSION["user"]["name"] = $wiki_prenom.$wiki_nom;
263
					$_SESSION["user"]["password"] = "wikini";
296
					$_SESSION["user"]["password"] = "wikini";
264
					$_SESSION["user"]["changescount"] = 100;
297
					$_SESSION["user"]["changescount"] = 100;
265
					$this->SetPersistentCookie("name", $user["name"], $remember);
298
					$this->SetPersistentCookie("name", $user["name"], $remember);
266
					$this->SetPersistentCookie("password", $user["password"], $remember);
299
					$this->SetPersistentCookie("password", $user["password"], $remember);
267
					$this->SetPersistentCookie("remember", $remember, $remember);
300
					$this->SetPersistentCookie("remember", $remember, $remember);
268
				}
301
				}
269
				else {
302
				else {
270
					parent::Setuser($user,$remember);
303
					parent::Setuser($user,$remember);
271
				}
304
				}
272
 
305
 
273
	}
306
	}
274
 
307
 
275
	function LoadUser($name, $password = 0) {
308
	function LoadUser($name, $password = 0) {
276
		 return true; 
309
		 return true; 
277
	}
310
	}
278
 
311
 
279
	function LogoutUser() {
312
	function LogoutUser() {
280
		$_SESSION["user"]="";
313
		$_SESSION["user"]="";
281
		$this->DeleteCookie("remember");
314
		$this->DeleteCookie("remember");
282
		parent::LogoutUser();
315
		parent::LogoutUser();
283
	}
316
	}
284
	
317
	
285
	
318
	
286
 
319
 
287
	function versChatMot($entree) {
320
	function versChatMot($entree) {
288
		$sortie = strtolower(trim(strtr($entree, "àâéêèëîïôöùûüç-", "aaeeeeiioouuuc ")));
321
		$sortie = strtolower(trim(strtr($entree, "àâéêèëîïôöùûüç-", "aaeeeeiioouuuc ")));
289
		$sortie = ucwords($sortie);
322
		$sortie = ucwords($sortie);
290
		$sortie = str_replace(" ", "",$sortie);
323
		$sortie = str_replace(" ", "",$sortie);
291
		return $sortie;
324
		return $sortie;
292
	}
325
	}
293
 
326
 
294
}
327
}
295
 
328
 
296
 
329
 
297
 
330
 
298
// Appel du fichier de traduction des textes de l'application Integrateur Wikini
331
// Appel du fichier de traduction des textes de l'application Integrateur Wikini
299
if (file_exists(IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php')) {
332
if (file_exists(IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php')) {
300
    /** Inclusion du fichier de traduction de l'application Integrateur Wikini. */
333
    /** Inclusion du fichier de traduction de l'application Integrateur Wikini. */
301
    include_once IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php';
334
    include_once IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php';
302
} else {
335
} else {
303
    /** Inclusion du fichier de traduction fr par défaut. */
336
    /** Inclusion du fichier de traduction fr par défaut. */
304
    include_once IW_CHEMIN_LANGUES.'iw_langue_fr.inc.php';
337
    include_once IW_CHEMIN_LANGUES.'iw_langue_fr.inc.php';
305
}
338
}
306
 
339
 
307
$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
340
$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
308
/**
341
/**
309
 *
342
 *
310
 * Fonction afficherPageMenuWikini()
343
 * Fonction afficherPageMenuWikini()
311
 *
344
 *
312
 * Renvoie le contenu de la page Menu de Wikini
345
 * Renvoie le contenu de la page Menu de Wikini
313
 *
346
 *
314
 * @return string
347
 * @return string
315
 * @access public
348
 * @access public
316
 */
349
 */
317
 
350
 
318
function afficherPageMenuWikini()
351
function afficherPageMenuWikini()
319
{
352
{
320
 
353
 
321
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
354
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
322
 
-
 
323
 
-
 
324
 
355
 
325
	global $wiki;
356
	global $wiki;
326
	global $wikini_config_defaut;
357
	global $wikini_config_defaut;
327
	$sortie='';
358
	$sortie='';
328
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
359
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
329
    $wiki  = new Wiki_Papyrus($wakkaConfig);
360
    $wiki  = new Wiki_Papyrus($wakkaConfig);
330
 
361
 
331
    // Suppression des slash.
362
    // Suppression des slash.
332
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
363
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
333
 
364
 
334
    // split into page/method
365
    // split into page/method
335
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
366
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
336
        list(, $page, $method) = $matches;
367
        list(, $page, $method) = $matches;
337
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
368
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
338
        list(, $page) = $matches;
369
        list(, $page) = $matches;
339
    }
370
    }
340
 
371
 
341
    $server=$_SERVER['PHP_SELF'];
372
    $server=$_SERVER['PHP_SELF'];
342
	$_SERVER['PHP_SELF']="wakka.php";
373
	$_SERVER['PHP_SELF']="wakka.php";
343
 
374
 
344
    $contenu=$wiki->LoadPage("PageMenu");
375
    $contenu=$wiki->LoadPage("PageMenu");
345
 
376
 
346
    $sortie.="<div id=\"menu_wikini\">";
377
    $sortie.="<div id=\"menu_wikini\">";
347
	$sortie.=$wiki->Format($contenu['body']);
378
	$sortie.=$wiki->Format($contenu['body']);
348
	$sortie.="</div>";
379
	$sortie.="</div>";
349
 
380
 
350
	$_SERVER['PHP_SELF']=$server;
381
	$_SERVER['PHP_SELF']=$server;
351
 
382
 
352
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
383
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
353
 
384
 
354
	return $sortie;
385
	return $sortie;
355
 
386
 
356
}
387
}
357
 
388
 
358
 
389
 
359
// +------------------------------------------------------------------------------------------------------+
390
// +------------------------------------------------------------------------------------------------------+
360
// |                                            CORPS du PROGRAMME                                        |
391
// |                                            CORPS du PROGRAMME                                        |
361
// +------------------------------------------------------------------------------------------------------+
392
// +------------------------------------------------------------------------------------------------------+
362
/** Fonction afficherPageWikini() - Fonction appelé par le gestionnaire Papyrus.
393
/** Fonction afficherPageWikini() - Fonction appelé par le gestionnaire Papyrus.
363
*
394
*
364
* Elle retourne le contenu de l'application.
395
* Elle retourne le contenu de l'application.
365
*
396
*
366
* @return  string  du code XHTML correspondant au contenu renvoyé par l'application.
397
* @return  string  du code XHTML correspondant au contenu renvoyé par l'application.
367
*/
398
*/
368
function afficherPageWikini()
399
function afficherPageWikini()
369
{
400
{
370
 
401
 
371
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
402
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
372
 
403
 
373
	// Ajout d'une feuille de style externe
404
	// Ajout d'une feuille de style externe
374
	GEN_stockerStyleExterne ('wikini', 'client/integrateur_wikini/presentations/styles/wikini.css') ;
405
	GEN_stockerStyleExterne ('wikini', 'client/integrateur_wikini/presentations/styles/wikini.css') ;
375
 
406
 
376
  // TODO
407
  // TODO
377
  // Changement du niveau d'erreur pour éviter les Notices PHP dues à Wikini
408
  // Changement du niveau d'erreur pour éviter les Notices PHP dues à Wikini
378
 
409
 
379
 
410
 
380
	global $wiki;
411
	global $wiki;
381
	global $wikini_config_defaut;
412
	global $wikini_config_defaut;
382
	$sortie='';
413
	$sortie='';
383
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
414
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
384
    $wiki  = new Wiki_Papyrus($wakkaConfig);
415
    $wiki  = new Wiki_Papyrus($wakkaConfig);
385
 
416
 
386
 
417
 
387
	if  ($GLOBALS['_GEN_commun']['pear_auth']->checkAuth()) {
418
	if  ($GLOBALS['_GEN_commun']['pear_auth']->checkAuth()) {
388
		if (!isset($_SESSION["user"]) || ($_SESSION["user"]=="")) {
419
		if (!isset($_SESSION["user"]) || ($_SESSION["user"]=="")) {
389
			$wiki->SetUser('');
420
			$wiki->SetUser('');
390
		}
421
		}
391
	}
422
	}
392
	else {
423
	else {
393
		$wiki->LogoutUser();
424
		$wiki->LogoutUser();
394
	}
425
	}
395
 
426
 
396
	// Gestion de la variable de session "linktracking"
427
	// Gestion de la variable de session "linktracking"
397
    if ( ! isset( $_SESSION['linktracking'] ) ) {
428
    if ( ! isset( $_SESSION['linktracking'] ) ) {
398
        $_SESSION['linktracking'] = 1;
429
        $_SESSION['linktracking'] = 1;
399
    }
430
    }
400
 
431
 
401
    // Suppression des slash.
432
    // Suppression des slash.
402
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
433
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
403
 
434
 
404
    // split into page/method
435
    // split into page/method
405
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
436
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
406
        list(, $page, $method) = $matches;
437
        list(, $page, $method) = $matches;
407
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
438
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
408
        list(, $page) = $matches;
439
        list(, $page) = $matches;
409
    }
440
    }
410
 
441
 
411
    // Vérification de la méthode d'affichage employée!
442
    // Vérification de la méthode d'affichage employée!
412
    if ( ! isset( $method ) ) {
443
    if ( ! isset( $method ) ) {
413
        $method = '';
444
        $method = '';
414
    }
445
    }
415
 
446
 
416
    //Récupération du contenu de la page Wikini
447
    //Récupération du contenu de la page Wikini
417
 
448
 
418
    ob_start();
449
    ob_start();
419
 
450
 
420
    $server=$_SERVER['PHP_SELF'];
451
    $server=$_SERVER['PHP_SELF'];
421
	$_SERVER['PHP_SELF']="wakka.php";
452
	$_SERVER['PHP_SELF']="wakka.php";
422
 
453
 
423
	$wiki->Run($page, $method);
454
	$wiki->Run($page, $method);
424
 
455
 
425
    $_SERVER['PHP_SELF']=$server;
456
    $_SERVER['PHP_SELF']=$server;
426
 
457
 
427
    $sortie.= ob_get_contents();
458
    $sortie.= ob_get_contents();
428
    ob_end_clean();
459
    ob_end_clean();
429
 
460
 
430
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
461
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
431
 
462
 
432
	
463
	
433
	//return remplacerEntiteHTLM("<div id=\"wikini_page\" onLoad=\"thisForm=document.ACEditor;\" ondblclick=\"document.location='".$wiki->href("edit")."';"."\">"."\n".$sortie.'</div>'."\n");
464
	//return remplacerEntiteHTLM("<div id=\"wikini_page\" onLoad=\"thisForm=document.ACEditor;\" ondblclick=\"document.location='".$wiki->href("edit")."';"."\">"."\n".$sortie.'</div>'."\n");
434
	if ($method!="edit") {
465
	if ($method!="edit") {
435
		return remplacerEntiteHTLM("<script type=\"text/javascript\" src=\"".IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.js\"></script><div id=\"wikini_page\"  ondblclick=\"document.location='".$wiki->href("edit")."';"."\">"."\n".$sortie.'</div>'."\n");
466
		return remplacerEntiteHTLM("<script type=\"text/javascript\" src=\"".IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.js\"></script><div id=\"wikini_page\"  ondblclick=\"document.location='".$wiki->href("edit")."';"."\">"."\n".$sortie.'</div>'."\n");
436
	}
467
	}
437
	else {
468
	else {
438
		return remplacerEntiteHTLM("<script type=\"text/javascript\" src=\"".IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.js\"></script><div id=\"wikini_page\">"."\n".$sortie.'</div>'."\n");
469
		return remplacerEntiteHTLM("<script type=\"text/javascript\" src=\"".IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.js\"></script><div id=\"wikini_page\">"."\n".$sortie.'</div>'."\n");
439
	}
470
	}
-
 
471
	
-
 
472
	
440
 
473
 
441
}
474
}
442
 
475
 
443
?>
476
?>