Subversion Repositories Applications.papyrus

Rev

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

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