Subversion Repositories Applications.papyrus

Rev

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

Rev 920 Rev 921
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.18 2006-08-29 20:01:33 ddelon Exp $
24
// CVS : $Id: iw_integrateur.fonct.php,v 1.19 2006-08-29 20:22:41 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.18 $ $Date: 2006-08-29 20:01:33 $
36
*@version       $Revision: 1.19 $ $Date: 2006-08-29 20:22:41 $
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 PAP_CHEMIN_API_PEAR.'Net/URL.php';
49
require_once PAP_CHEMIN_API_PEAR.'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
//echo IW_CHEMIN_WIKINI_COURANT.'wakka.php';
84
//echo IW_CHEMIN_WIKINI_COURANT.'wakka.php';
85
if (!file_exists(IW_CHEMIN_WIKINI_COURANT.'wakka.php')) {
85
if (!file_exists(IW_CHEMIN_WIKINI_COURANT.'wakka.php')) {
86
	if (GEN_DEBOGAGE) {
86
	if (GEN_DEBOGAGE) {
87
            $GLOBALS['_GEN_commun']['debogage_info'] .=
87
            $GLOBALS['_GEN_commun']['debogage_info'] .=
88
                'ERREUR Papyrus : le fichier '.IW_CHEMIN_WIKINI_COURANT.'wakka.php n\'existe pas.<br />'.
88
                'ERREUR Papyrus : le fichier '.IW_CHEMIN_WIKINI_COURANT.'wakka.php n\'existe pas.<br />'.
89
                'Identifiant : '. $id_fichier .'<br />'.
89
                'Identifiant : '. $id_fichier .'<br />'.
90
                'Ligne n° : '. __LINE__ .'<br />'.
90
                'Ligne n° : '. __LINE__ .'<br />'.
91
                'Fichier : '. __FILE__;
91
                'Fichier : '. __FILE__;
92
    }
92
    }
93
    return  ;
93
    return  ;
94
}
94
}
95
ob_start();
95
ob_start();
96
include_once IW_CHEMIN_WIKINI_COURANT.'wakka.php';
96
include_once IW_CHEMIN_WIKINI_COURANT.'wakka.php';
97
include_once(IW_CHEMIN_WIKINI_COURANT."/formatters/tableaux.php");
97
include_once(IW_CHEMIN_WIKINI_COURANT."/formatters/tableaux.php");
98
include_once(IW_CHEMIN_WIKINI_COURANT."/actions/attach.class.php");
98
include_once(IW_CHEMIN_WIKINI_COURANT."/actions/attach.class.php");
99
 
99
 
100
ob_end_clean();
100
ob_end_clean();
101
$_SERVER['PHP_SELF']=$server;
101
$_SERVER['PHP_SELF']=$server;
102
 
102
 
103
 
103
 
104
// On surcharge la classe Wiki pour en faire ce qu'on en veut
104
// On surcharge la classe Wiki pour en faire ce qu'on en veut
105
Class Wiki_Papyrus extends Wiki {
105
Class Wiki_Papyrus extends Wiki {
106
 
106
 
107
 
107
 
108
	function Header() {
108
	function Header() {
109
 
109
 
110
		return;
110
		return;
111
	}
111
	}
112
 
112
 
113
 	function Footer() {
113
 	function Footer() {
114
 		echo  "<div class=\"footer\">";
114
 		echo  "<div class=\"footer\">";
115
		echo  $this->HasAccess("write") ? "<a href=\"".$this->href("edit")."\" title=\"Cliquez pour modifier cette page.\">Modifier cette page</a> ::\n" : "";
115
		echo  $this->HasAccess("write") ? "<a href=\"".$this->href("edit")."\" title=\"Cliquez pour modifier cette page.\">Modifier cette page</a> ::\n" : "";
116
		echo  $this->GetPageTime() ? "<a href=\"".$this->href("revisions")."\" title=\"Cliquez pour voir les derni&egrave;res modifications sur cette page.\">".$this->GetPageTime()."</a> ::\n" : "";
116
		echo  $this->GetPageTime() ? "<a href=\"".$this->href("revisions")."\" title=\"Cliquez pour voir les derni&egrave;res modifications sur cette page.\">".$this->GetPageTime()."</a> ::\n" : "";
117
		// 	if this page exists
117
		// 	if this page exists
118
		if ($this->page)
118
		if ($this->page)
119
		{
119
		{
120
		// if owner is current user
120
		// if owner is current user
121
			if ($this->UserIsOwner())
121
			if ($this->UserIsOwner())
122
			{
122
			{
123
				echo
123
				echo
124
				"Propri&eacute;taire&nbsp;: vous :: \n",
124
				"Propri&eacute;taire&nbsp;: vous :: \n",
125
				"<a href=\"",$this->href("acls")."\" title=\"Cliquez pour modifer les permissions de cette page.\">&Eacute;diter permissions</a> :: \n",
125
				"<a href=\"",$this->href("acls")."\" title=\"Cliquez pour modifer les permissions de cette page.\">&Eacute;diter permissions</a> :: \n",
126
				"<a href=\"",$this->href("deletepage")."\">Supprimer</a> :: \n";
126
				"<a href=\"",$this->href("deletepage")."\">Supprimer</a> :: \n";
127
			}
127
			}
128
			else
128
			else
129
			{
129
			{
130
				if ($owner = $this->GetPageOwner())
130
				if ($owner = $this->GetPageOwner())
131
				{
131
				{
132
					echo "Propri&eacute;taire : ",$this->Format($owner);
132
					echo "Propri&eacute;taire : ",$this->Format($owner);
133
				}
133
				}
134
				else
134
				else
135
				{
135
				{
136
					echo "Pas de propri&eacute;taire ";
136
					echo "Pas de propri&eacute;taire ";
137
					echo ($this->GetUser() ? "(<a href=\"".$this->href("claim")."\">Appropriation</a>)" : "");
137
					echo ($this->GetUser() ? "(<a href=\"".$this->href("claim")."\">Appropriation</a>)" : "");
138
				}
138
				}
139
				echo " :: \n";
139
				echo " :: \n";
140
			}
140
			}
141
		}
141
		}
142
		echo "Vous &ecirc;tes ";
142
		echo "Vous &ecirc;tes ";
143
		echo $this->Format($this->GetUserName());
143
		echo $this->Format($this->GetUserName());
144
		echo "</div>";
144
		echo "</div>";
145
 
145
 
146
 	}
146
 	}
147
 
147
 
148
	function FormOpen($method = "", $tag = "", $formMethod = "post") {
148
	function FormOpen($method = "", $tag = "", $formMethod = "post") {
149
 
149
 
150
	// Le diff ne fonctionne pas avec la methode get dans papyrus. On surcharge avec du post.
150
	// Le diff ne fonctionne pas avec la methode get dans papyrus. On surcharge avec du post.
151
 
151
 
152
		if (($method=="diff") && $formMethod=="get") {
152
		if (($method=="diff") && $formMethod=="get") {
153
			$formMethod="post";
153
			$formMethod="post";
154
		}
154
		}
155
 
155
 
156
		if ($method=="edit") {
156
		if ($method=="edit") {
157
            $result = "<form id=\"ACEditor\" name=\"ACEditor\" action=\"".$this->href($method, $tag)."\" method=\"".$formMethod."\">\n";
157
            $result = "<form id=\"ACEditor\" name=\"ACEditor\" action=\"".$this->href($method, $tag)."\" method=\"".$formMethod."\">\n";
158
            return $result;
158
            return $result;
159
		}
159
		}
160
 
160
 
161
		return parent::FormOpen($method,$tag, $formMethod);
161
		return parent::FormOpen($method,$tag, $formMethod);
162
 
162
 
163
	}
163
	}
164
	// Detournement des handlers : comme ca on peut faire ce que l'on veut ....
164
	// Detournement des handlers : comme ca on peut faire ce que l'on veut ....
165
	function Method($method) {
165
	function Method($method) {
166
 
166
 
167
		if ($method=="xml") {
167
		if ($method=="xml") {
168
			header("Content-type: text/xml");
168
			header("Content-type: text/xml");
169
			if ($pages = $this->LoadRecentlyChanged(50)) {
169
			if ($pages = $this->LoadRecentlyChanged(50)) {
170
		
170
		
171
				$link=ereg_replace('&','&amp;',$this->Href());	            
171
				$link=ereg_replace('&','&amp;',$this->Href());	            
172
			    $output = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n";
172
			    $output = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n";
173
			    $output .= '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n";
173
			    $output .= '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n";
174
			    $output .= "<channel>\n";
174
			    $output .= "<channel>\n";
175
			    $output .= "<title> Derniers changements sur ". $this->config["wakka_name"]  . "</title>\n";
175
			    $output .= "<title> Derniers changements sur ". $this->config["wakka_name"]  . "</title>\n";
176
			    $output .= "<link>" .  $link . "</link>\n";
176
			    $output .= "<link>" .  $link . "</link>\n";
177
			    $output .= "<description> Derniers changements sur " . $this->config["wakka_name"] . " </description>\n";
177
			    $output .= "<description> Derniers changements sur " . $this->config["wakka_name"] . " </description>\n";
178
			    $output .= "<language>fr</language>\n";
178
			    $output .= "<language>fr</language>\n";
179
			    $output .= '<generator>WikiNi ' . WIKINI_VERSION . "</generator>\n";
179
			    $output .= '<generator>WikiNi ' . WIKINI_VERSION . "</generator>\n";
180
			    foreach ($pages as $i => $page)
180
			    foreach ($pages as $i => $page)
181
			    {
181
			    {
182
			        $output .= "<item>\n";
182
			        $output .= "<item>\n";
183
			        $output .= "<title>" . $page["tag"] . "</title>\n";
183
			        $output .= "<title>" . $page["tag"] . "</title>\n";
184
			        $output .= '<dc:creator>' . $page["user"] . "</dc:creator>\n";
184
			        $output .= '<dc:creator>' . $page["user"] . "</dc:creator>\n";
185
			        $output .= '<pubDate>' . date("r", strtotime($page['time'])) . "</pubDate>\n";
185
			        $output .= '<pubDate>' . date("r", strtotime($page['time'])) . "</pubDate>\n";
186
			        $output .= "<description> Modification de " . $page["tag"] . " --- par " .$page["user"] /* . " le " . $day ." - ". $hh .":". $mm */ . "</description>\n";
186
			        $output .= "<description> Modification de " . $page["tag"] . " --- par " .$page["user"] /* . " le " . $day ." - ". $hh .":". $mm */ . "</description>\n";
187
			        $link=ereg_replace('&','&amp;',$this->Href("",$page["tag"]));
187
			        $link=ereg_replace('&','&amp;',$this->Href("",$page["tag"]));
188
			        $output .= "<link>" . $link . "&amp;time=" . rawurlencode($page["time"]) . "</link>\n";
188
			        $output .= "<link>" . $link . "&amp;time=" . rawurlencode($page["time"]) . "</link>\n";
189
			        $output .= "</item>\n";
189
			        $output .= "</item>\n";
190
			    }
190
			    }
191
			    $output .= "</channel>\n";
191
			    $output .= "</channel>\n";
192
			    $output .= "</rss>\n";
192
			    $output .= "</rss>\n";
193
			    echo $output ;
193
			    echo $output ;
194
 
194
 
195
			}
195
			}
196
			exit;
196
			exit;
197
			return;
197
			return;
198
		}
198
		}
199
 
199
 
200
		if ($method=="edit") {
200
		if ($method=="edit") {
201
			
201
			
202
			if ($this->HasAccess("write") && $this->HasAccess("read")) {
202
			if ($this->HasAccess("write") && $this->HasAccess("read")) {
203
		
203
		
204
				$result='';
204
				$result='';
205
		
205
		
206
				if ($_POST) {
206
				if ($_POST) {
207
					if ($_POST["submit"] == "Sauver")	{
207
					if ($_POST["submit"] == "Sauver")	{
208
					// check for overwriting
208
					// check for overwriting
209
						if ($this->page) {
209
						if ($this->page) {
210
							if ($this->page["id"] != $_POST["previous"]) {
210
							if ($this->page["id"] != $_POST["previous"]) {
211
								$error = "ALERTE : ".
211
								$error = "ALERTE : ".
212
								"Cette page a &eacute;t&eacute; modifi&eacute;e par quelqu'un d'autre pendant que vous l'&eacute;ditiez.<br />\n".
212
								"Cette page a &eacute;t&eacute; modifi&eacute;e par quelqu'un d'autre pendant que vous l'&eacute;ditiez.<br />\n".
213
								"Veuillez copier vos changements et r&eacute;&eacute;diter cette page.\n";
213
								"Veuillez copier vos changements et r&eacute;&eacute;diter cette page.\n";
214
							}
214
							}
215
						}
215
						}
216
						// store
216
						// store
217
						if (!$error) {
217
						if (!$error) {
218
							$body = str_replace("\r", "", $_POST["body"]);
218
							$body = str_replace("\r", "", $_POST["body"]);
219
							// test si la nouvelle page est differente de la précédente
219
							// test si la nouvelle page est differente de la précédente
220
							if(rtrim($body)==rtrim($this->page["body"])) {
220
							if(rtrim($body)==rtrim($this->page["body"])) {
221
								$this->SetMessage("Cette page n\'a pas &eacute;t&eacute; enregistr&eacute;e car elle n\'a subi aucune modification.");
221
								$this->SetMessage("Cette page n\'a pas &eacute;t&eacute; enregistr&eacute;e car elle n\'a subi aucune modification.");
222
								$this->Redirect($this->href());
222
								$this->Redirect($this->href());
223
							}
223
							}
224
		
224
		
225
							// add page (revisions)
225
							// add page (revisions)
226
							$this->SavePage($this->tag, $body);
226
							$this->SavePage($this->tag, $body);
227
		
227
		
228
							// now we render it internally so we can write the updated link table.
228
							// now we render it internally so we can write the updated link table.
229
							$this->ClearLinkTable();
229
							$this->ClearLinkTable();
230
							$this->StartLinkTracking();
230
							$this->StartLinkTracking();
231
							$dummy = $this->Header();
231
							$dummy = $this->Header();
232
							$dummy .= $this->Format($body);
232
							$dummy .= $this->Format($body);
233
							$dummy .= $this->Footer();
233
							$dummy .= $this->Footer();
234
							$this->StopLinkTracking();
234
							$this->StopLinkTracking();
235
							$this->WriteLinkTable();
235
							$this->WriteLinkTable();
236
							$this->ClearLinkTable();
236
							$this->ClearLinkTable();
237
		
237
		
238
							// forward
238
							// forward
239
							$this->Redirect($this->href());
239
							$this->Redirect($this->href());
240
						}
240
						}
241
					}
241
					}
242
				}
242
				}
243
		
243
		
244
				// fetch fields
244
				// fetch fields
245
				if (!$previous = $_POST["previous"]) $previous = $this->page["id"];
245
				if (!$previous = $_POST["previous"]) $previous = $this->page["id"];
246
				if (!$body = $_POST["body"]) $body = $this->page["body"];
246
				if (!$body = $_POST["body"]) $body = $this->page["body"];
247
		
247
		
248
				// preview?
248
				// preview?
249
				if ($_POST["submit"] == "Aperçu")
249
				if ($_POST["submit"] == "Aperçu")
250
				{
250
				{
251
					$result .=
251
					$result .=
252
						"<div class=\"prev_alert\"><strong>Aper&ccedil;u</strong></div>\n".
252
						"<div class=\"prev_alert\"><strong>Aper&ccedil;u</strong></div>\n".
253
						$this->Format($body)."\n\n".
253
						$this->Format($body)."\n\n".
254
						$this->FormOpen("edit").
254
						$this->FormOpen("edit").
255
						"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
255
						"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
256
						"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n".
256
						"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n".
257
						"<br />\n".
257
						"<br />\n".
258
						"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
258
						"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
259
						"<input name=\"submit\" type=\"submit\" value=\"R&eacute;&eacute;diter \" accesskey=\"p\" />\n".
259
						"<input name=\"submit\" type=\"submit\" value=\"R&eacute;&eacute;diter \" accesskey=\"p\" />\n".
260
						"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
260
						"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
261
						$this->FormClose()."\n";
261
						$this->FormClose()."\n";
262
					return $result;
262
					return $result;
263
				}
263
				}
264
				else
264
				else
265
				{
265
				{
266
					$ACbuttonsBar='';
266
					$ACbuttonsBar='';
267
				    require_once(IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.buttonsBar.php");
267
				    require_once(IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.buttonsBar.php");
268
		
268
		
269
					$result .=
269
					$result .=
270
					$this->FormOpen("edit").
270
					$this->FormOpen("edit").
271
					"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".$ACbuttonsBar.
271
					"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".$ACbuttonsBar.
272
					"<textarea onkeydown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
272
					"<textarea onkeydown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
273
					htmlspecialchars($body).
273
					htmlspecialchars($body).
274
					"\n</textarea><br />\n".'<div class="boutons_wiki">'.
274
					"\n</textarea><br />\n".'<div class="boutons_wiki">'.
275
					($this->config["preview_before_save"] ? "" : "<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
275
					($this->config["preview_before_save"] ? "" : "<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
276
					"<input name=\"submit\" type=\"submit\" value=\"Aper&ccedil;u\" accesskey=\"p\" />\n".
276
					"<input name=\"submit\" type=\"submit\" value=\"Aper&ccedil;u\" accesskey=\"p\" />\n".
277
					"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" /></div>\n".
277
					"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" /></div>\n".
278
					$this->FormClose();
278
					$this->FormClose();
279
		
279
		
280
					return $result;
280
					return $result;
281
				}
281
				}
282
		
282
		
283
			}
283
			}
284
			else {
284
			else {
285
				echo "<i>Vous n'avez pas acc&egrave;s en &eacute;criture &agrave; cette page !</i>\n";
285
				echo "<i>Vous n'avez pas acc&egrave;s en &eacute;criture &agrave; cette page !</i>\n";
286
				
286
				
287
			}
287
			}
288
		}
288
		}
289
		else {
289
		else {
290
			return parent::Method($method);
290
			return parent::Method($method);
291
		}
291
		}
292
	}
292
	}
293
 
293
 
294
 
294
 
295
	// Surcharge Format a cause probleme de chemin.
295
	// Surcharge Format a cause probleme de chemin.
296
 
296
 
297
	function Format($text, $formatter = "wakka") {
297
	function Format($text, $formatter = "wakka") {
298
		return $this->IncludeBuffered(IW_CHEMIN_WIKINI_COURANT_FORMATTER.$formatter.".php", "<i>Impossible de trouver le formateur \"$formatter\"</i>", compact("text"));
298
		return $this->IncludeBuffered(IW_CHEMIN_WIKINI_COURANT_FORMATTER.$formatter.".php", "<i>Impossible de trouver le formateur \"$formatter\"</i>", compact("text"));
299
	}
299
	}
300
 
300
 
301
 
301
 
302
	// Identification
302
	// Identification
303
 
303
 
304
	function SetUser($user, $remember) {
304
	function SetUser($user, $remember) {
305
			// Appel à partir de Papyrus
305
			// Appel à partir de Papyrus
306
				if ($user=='initwiki') {
306
				if ($user=='initwiki') {
307
					$remember=1;
307
					$remember=1;
308
					$wiki_prenom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_prenom));
308
					$wiki_prenom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_prenom));
309
					$wiki_nom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_nom));
309
					$wiki_nom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_nom));
310
					$_SESSION["user"]=array("name"=>$wiki_prenom.$wiki_nom,"password"=>"wikini","changescount"=> 100);
310
					$_SESSION["user"]=array("name"=>$wiki_prenom.$wiki_nom,"password"=>"wikini","changescount"=> 100);
311
					$this->SetPersistentCookie("name", $user["name"], $remember);
311
					$this->SetPersistentCookie("name", $user["name"], $remember);
312
					$this->SetPersistentCookie("password", $user["password"], $remember);
312
					$this->SetPersistentCookie("password", $user["password"], $remember);
313
					$this->SetPersistentCookie("remember", $remember, $remember);
313
					$this->SetPersistentCookie("remember", $remember, $remember);
314
				}
314
				}
315
				else {
315
				else {
316
					parent::Setuser($user,$remember);
316
					parent::Setuser($user,$remember);
317
				}
317
				}
318
 
318
 
319
	}
319
	}
320
 
320
 
321
	function LoadUser($name, $password = 0) {
321
	function LoadUser($name, $password = 0) {
322
		 return true; 
322
		 return true; 
323
	}
323
	}
324
 
324
 
325
	function LogoutUser() {
325
	function LogoutUser() {
326
		$_SESSION["user"]="";
326
		$_SESSION["user"]="";
327
		$this->DeleteCookie("remember");
327
		$this->DeleteCookie("remember");
328
		parent::LogoutUser();
328
		parent::LogoutUser();
329
	}
329
	}
330
	
330
	
331
	
331
	
332
 
332
 
333
	function versChatMot($entree) {
333
	function versChatMot($entree) {
334
		$sortie = strtolower(trim(strtr($entree, "àâéêèëîïôöùûüç-", "aaeeeeiioouuuc ")));
334
		$sortie = strtolower(trim(strtr($entree, "àâéêèëîïôöùûüç-", "aaeeeeiioouuuc ")));
335
		$sortie = ucwords($sortie);
335
		$sortie = ucwords($sortie);
336
		$sortie = str_replace(" ", "",$sortie);
336
		$sortie = str_replace(" ", "",$sortie);
337
		return $sortie;
337
		return $sortie;
338
	}
338
	}
339
 
339
 
340
}
340
}
341
 
341
 
342
 
342
 
343
 
343
 
344
// Appel du fichier de traduction des textes de l'application Integrateur Wikini
344
// Appel du fichier de traduction des textes de l'application Integrateur Wikini
345
if (file_exists(IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php')) {
345
if (file_exists(IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php')) {
346
    /** Inclusion du fichier de traduction de l'application Integrateur Wikini. */
346
    /** Inclusion du fichier de traduction de l'application Integrateur Wikini. */
347
    include_once IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php';
347
    include_once IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php';
348
} else {
348
} else {
349
    /** Inclusion du fichier de traduction fr par défaut. */
349
    /** Inclusion du fichier de traduction fr par défaut. */
350
    include_once IW_CHEMIN_LANGUES.'iw_langue_fr.inc.php';
350
    include_once IW_CHEMIN_LANGUES.'iw_langue_fr.inc.php';
351
}
351
}
352
 
352
 
353
$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
353
$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
354
/**
354
/**
355
 *
355
 *
356
 * Fonction afficherPageMenuWikini()
356
 * Fonction afficherPageMenuWikini()
357
 *
357
 *
358
 * Renvoie le contenu de la page Menu de Wikini
358
 * Renvoie le contenu de la page Menu de Wikini
359
 *
359
 *
360
 * @return string
360
 * @return string
361
 * @access public
361
 * @access public
362
 */
362
 */
363
 
363
 
364
function afficherPageMenuWikini()
364
function afficherPageMenuWikini()
365
{
365
{
366
 
366
 
367
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
367
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
368
 
368
 
369
	global $wiki;
369
	global $wiki;
370
	global $wikini_config_defaut;
370
	global $wikini_config_defaut;
371
	$sortie='';
371
	$sortie='';
372
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
372
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
373
    if (!class_exists('Wiki_Papyrus')) return ;
373
    if (!class_exists('Wiki_Papyrus')) return ;
374
    $wiki  = new Wiki_Papyrus($wakkaConfig);
374
    $wiki  = new Wiki_Papyrus($wakkaConfig);
375
 
375
 
376
    // Suppression des slash.
376
    // Suppression des slash.
377
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
377
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
378
 
378
 
379
    // split into page/method
379
    // split into page/method
380
    $matches='';
380
    $matches='';
381
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
381
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
382
        list(, $page, $method) = $matches;
382
        list(, $page, $method) = $matches;
383
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
383
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
384
        list(, $page) = $matches;
384
        list(, $page) = $matches;
385
    }
385
    }
386
 
386
 
387
    $server=$_SERVER['PHP_SELF'];
387
    $server=$_SERVER['PHP_SELF'];
388
	$_SERVER['PHP_SELF']="wakka.php";
388
	$_SERVER['PHP_SELF']="wakka.php";
389
 
389
 
390
    $contenu=$wiki->LoadPage("PageMenu");
390
    $contenu=$wiki->LoadPage("PageMenu");
391
 
391
 
392
    $sortie.="<div id=\"menu_wikini\">";
392
    $sortie.="<div id=\"menu_wikini\">";
393
	$sortie.=$wiki->Format($contenu['body']);
393
	$sortie.=$wiki->Format($contenu['body']);
394
	$sortie.="</div>";
394
	$sortie.="</div>";
395
 
395
 
396
	$_SERVER['PHP_SELF']=$server;
396
	$_SERVER['PHP_SELF']=$server;
397
 
397
 
398
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
398
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
399
 
399
 
400
	return $sortie;
400
	return $sortie;
401
 
401
 
402
}
402
}
403
 
403
 
404
 
404
 
405
// +------------------------------------------------------------------------------------------------------+
405
// +------------------------------------------------------------------------------------------------------+
406
// |                                            CORPS du PROGRAMME                                        |
406
// |                                            CORPS du PROGRAMME                                        |
407
// +------------------------------------------------------------------------------------------------------+
407
// +------------------------------------------------------------------------------------------------------+
408
/** Fonction afficherPageWikini() - Fonction appelé par le gestionnaire Papyrus.
408
/** Fonction afficherPageWikini() - Fonction appelé par le gestionnaire Papyrus.
409
*
409
*
410
* Elle retourne le contenu de l'application.
410
* Elle retourne le contenu de l'application.
411
*
411
*
412
* @return  string  du code XHTML correspondant au contenu renvoyé par l'application.
412
* @return  string  du code XHTML correspondant au contenu renvoyé par l'application.
413
*/
413
*/
414
function afficherPageWikini()
414
function afficherPageWikini()
415
{
415
{
416
	
416
	
417
 
417
 
418
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
418
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
419
 
419
 
420
	// Ajout d'une feuille de style externe
420
	// Ajout d'une feuille de style externe
421
	GEN_stockerStyleExterne ('wikini', 'client/integrateur_wikini/presentations/styles/wikini.css') ;
421
	GEN_stockerStyleExterne ('wikini', 'client/integrateur_wikini/presentations/styles/wikini.css') ;
422
 
422
 
423
	global $wiki;
423
	global $wiki;
424
	global $wikini_config_defaut;
424
	global $wikini_config_defaut;
425
	$sortie='';
425
	$sortie='';
426
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
426
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
427
    if (!class_exists ('Wiki_Papyrus')) return ; 
427
    if (!class_exists ('Wiki_Papyrus')) return ; 
428
    $wiki  = new Wiki_Papyrus($wakkaConfig);
428
    $wiki  = new Wiki_Papyrus($wakkaConfig);
429
 
429
 
430
	if  ($GLOBALS['_GEN_commun']['pear_auth']->checkAuth()) {
430
	if  ($GLOBALS['_GEN_commun']['pear_auth']->checkAuth()) {
431
		if (!isset($_SESSION["user"]) || ($_SESSION["user"]=="")) {
431
	//	if (!isset($_SESSION["user"]) || ($_SESSION["user"]=="")) {
432
			$wiki->SetUser('initwiki');
432
			$wiki->SetUser('initwiki');
433
		}
433
	//	}
434
	}
434
	}
435
	else {
435
	else {
436
		$wiki->LogoutUser();
436
		$wiki->LogoutUser();
437
	}
437
	}
438
 
438
 
439
	// Gestion de la variable de session "linktracking"
439
	// Gestion de la variable de session "linktracking"
440
    if ( ! isset( $_SESSION['linktracking'] ) ) {
440
    if ( ! isset( $_SESSION['linktracking'] ) ) {
441
        $_SESSION['linktracking'] = 1;
441
        $_SESSION['linktracking'] = 1;
442
    }
442
    }
443
 
443
 
444
    // Suppression des slash.
444
    // Suppression des slash.
445
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
445
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
446
 
446
 
447
    // split into page/method
447
    // split into page/method
448
    $matches='';
448
    $matches='';
449
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
449
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
450
        list(, $page, $method) = $matches;
450
        list(, $page, $method) = $matches;
451
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
451
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
452
        list(, $page) = $matches;
452
        list(, $page) = $matches;
453
    }
453
    }
454
 
454
 
455
    // Vérification de la méthode d'affichage employée!
455
    // Vérification de la méthode d'affichage employée!
456
    if ( ! isset( $method ) ) {
456
    if ( ! isset( $method ) ) {
457
        $method = '';
457
        $method = '';
458
    }
458
    }
459
 
459
 
460
    //Récupération du contenu de la page Wikini
460
    //Récupération du contenu de la page Wikini
461
 
461
 
462
    ob_start();
462
    ob_start();
463
 
463
 
464
    $server=$_SERVER['PHP_SELF'];
464
    $server=$_SERVER['PHP_SELF'];
465
	$_SERVER['PHP_SELF']="wakka.php";
465
	$_SERVER['PHP_SELF']="wakka.php";
466
 
466
 
467
	$wiki->Run($page, $method);
467
	$wiki->Run($page, $method);
468
 
468
 
469
    $_SERVER['PHP_SELF']=$server;
469
    $_SERVER['PHP_SELF']=$server;
470
 
470
 
471
    $sortie.= ob_get_contents();
471
    $sortie.= ob_get_contents();
472
    ob_end_clean();
472
    ob_end_clean();
473
 
473
 
474
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
474
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
475
 
475
 
476
	if ($method!="edit") {
476
	if ($method!="edit") {
477
		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");
477
		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");
478
	}
478
	}
479
	else {
479
	else {
480
		return remplacerEntiteHTLM("<script type=\"text/javascript\" src=\"".IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.js\"></script><div id=\"wikini_page\">"."\n".$sortie.'</div>'."\n");
480
		return remplacerEntiteHTLM("<script type=\"text/javascript\" src=\"".IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.js\"></script><div id=\"wikini_page\">"."\n".$sortie.'</div>'."\n");
481
	}
481
	}
482
	
482
	
483
	
483
	
484
}
484
}
485
 
485
 
486
?>
486
?>