Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
545 ddelon 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This file is part of Integrateur Wikini.                                                             |
9
// |                                                                                                      |
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                                 |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
13
// | (at your option) any later version.                                                                  |
14
// |                                                                                                      |
15
// | Foobar is distributed in the hope that it will be useful,                                            |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
18
// | GNU General Public License for more details.                                                         |
19
// |                                                                                                      |
20
// | You should have received a copy of the GNU General Public License                                    |
21
// | along with Foobar; if not, write to the Free Software                                                |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
23
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id: iw_integrateur.fonct.php,v 1.1 2005-10-17 13:41:34 ddelon Exp $
25
/**
26
* Fonctions de l'integrateur de page Wikini
27
*
28
* Application permettant d'intégrer des pages wikini dans Papyrus.
29
*
30
*@package IntegrateurWikini
31
//Auteur original :
32
*@author        David Delon <david.delon@clapas.net>
33
//Autres auteurs :
34
*@author        Aucun
35
*@copyright     Tela-Botanica 2000-2004
36
*@version       $Revision: 1.1 $ $Date: 2005-10-17 13:41:34 $
37
*
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
41
 
42
 
43
 
44
 
45
/** Inclusion de la classe PEAR de gestion des URL. */
46
 
47
$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
48
 
49
require_once 'Net/URL.php';
50
 
51
// TODO : un seul fichier de configuration ?
52
/** Inclusion du fichier de configuration de cette application.*/
53
require_once 'client/integrateur_wikini/configuration/adwi_configuration.inc.php';
54
 
55
require_once ADWI_CHEMIN_BIBLIOTHEQUE.'adwi_wikini.fonct.php';
56
 
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';
59
 
60
/** Inclusion du fichier permettant d'encoder du texte mais pas les balises XHTML.*/
61
require_once IW_CHEMIN_BIBLIO.'iw_encodage.fonct.php';
62
/** Inclusion du fichier permettant d'inclure les données dans du XHTML.*/
63
require_once IW_CHEMIN_BIBLIO.'iw_affichage_xhtml.fonct.php';
64
 
65
global $wikini_config_defaut;
66
global $wiki;
67
global $wiki_p;
68
 
69
// $_REQUEST['wiki'] est obligatoire, car wakka.php envoie un redirect si non detecté, avec perte de tout l'environnement !
70
 
71
if ( ! isset( $_REQUEST['wiki'] ) ) {
72
	    $_REQUEST['wiki'] = $wikini_config_defaut['root_page'];
73
}
74
 
75
$server=$_SERVER['PHP_SELF'];
76
$_SERVER['PHP_SELF']="wakka.php";
77
 
78
// Utilise le wakkaconfig de la racine ...
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
81
// TODO : creation des tables par defaut à l'installation d'un wikini
82
// TODO : Fusion des fichiers de configuration ?
83
 
84
 
85
ob_start();
86
 
87
include_once IW_CHEMIN_WIKINI_COURANT.'wakka.php';
88
 
89
ob_end_clean();
90
$_SERVER['PHP_SELF']=$server;
91
 
92
 
93
// On surcharge la classe Wiki pour en faire ce qu'on en veut
94
Class Wiki_Papyrus extends Wiki {
95
 
96
 
97
	//TODO : a gauche !
98
 
99
	function Header() {
100
 
101
		return;
102
	}
103
 
104
 	function Footer() {
105
		return;
106
 	}
107
 
108
	function FormOpen($method = "", $tag = "", $formMethod = "post") {
109
 
110
	// Le diff ne fonctionne pas avec la methode get dans papyrus. On surcharge avec du post.
111
 
112
		if (($method=="diff") && $formMethod=="get") {
113
			$formMethod="post";
114
		}
115
 
116
		if ($method=="edit") {
117
            $result = "<form id=\"ACEditor\" name=\"ACEditor\" action=\"".$this->href($method, $tag)."\" method=\"".$formMethod."\">\n";
118
            return $result;
119
		}
120
 
121
		return parent::FormOpen($method,$tag, $formMethod);
122
 
123
	}
124
	// Detournement des handlers : comme ca on peut faire ce que l'on veut ....
125
	function Method($method) {
126
 
127
		if ($method=="edit") {
128
 
129
			echo $this->Header();
130
 
131
			$result='';
132
 
133
			if ($_POST) {
134
				if ($_POST["submit"] == "Sauver")	{
135
				// check for overwriting
136
					if ($this->page) {
137
						if ($this->page["id"] != $_POST["previous"]) {
138
							$error = "ALERTE : ".
139
							"Cette page a &eacute;t&eacute; modifi&eacute;e par quelqu'un d'autre pendant que vous l'&eacute;ditiez.<br />\n".
140
							"Veuillez copier vos changements et r&eacute;&eacute;diter cette page.\n";
141
						}
142
					}
143
					// store
144
					if (!$error) {
145
						$body = str_replace("\r", "", $_POST["body"]);
146
						// test si la nouvelle page est differente de la précédente
147
						if(rtrim($body)==rtrim($this->page["body"])) {
148
							$this->SetMessage("Cette page n\'a pas &eacute;t&eacute; enregistr&eacute;e car elle n\'a subi aucune modification.");
149
							$this->Redirect($this->href());
150
						}
151
 
152
						// add page (revisions)
153
						$this->SavePage($this->tag, $body);
154
 
155
						// now we render it internally so we can write the updated link table.
156
						$this->ClearLinkTable();
157
						$this->StartLinkTracking();
158
						$dummy = $this->Header();
159
						$dummy .= $this->Format($body);
160
						$dummy .= $this->Footer();
161
						$this->StopLinkTracking();
162
						$this->WriteLinkTable();
163
						$this->ClearLinkTable();
164
 
165
						// forward
166
						$this->Redirect($this->href());
167
					}
168
				}
169
			}
170
 
171
			// fetch fields
172
			if (!$previous = $_POST["previous"]) $previous = $this->page["id"];
173
			if (!$body = $_POST["body"]) $body = $this->page["body"];
174
 
175
			// preview?
176
			if ($_POST["submit"] == "Aperçu")
177
			{
178
				$result .=
179
					"<div class=\"prev_alert\"><strong>Aper&ccedil;u</strong></div>\n".
180
					$this->Format($body)."\n\n".
181
					$this->FormOpen("edit").
182
					"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
183
					"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n".
184
					"<br />\n".
185
					"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
186
					"<input name=\"submit\" type=\"submit\" value=\"R&eacute;&eacute;diter \" accesskey=\"p\" />\n".
187
					"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
188
					$this->FormClose()."\n";
189
				return $result;
190
			}
191
			else
192
			{
193
 
194
			    require_once(IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.buttonsBar.php");
195
 
196
				$result .=
197
				$this->FormOpen("edit").
198
				"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".$ACbuttonsBar.
199
				"<textarea onkeydown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
200
				htmlspecialchars($body).
201
				"\n</textarea><br />\n".
202
				($this->config["preview_before_save"] ? "" : "<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
203
				"<input name=\"submit\" type=\"submit\" value=\"Aper&ccedil;u\" accesskey=\"p\" />\n".
204
				"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
205
				$this->FormClose();
206
 
207
				return $result;
208
			}
209
 
210
		}
211
		else {
212
			return parent::Method($method);
213
		}
214
	}
215
 
216
 
217
	// Surcharge Format a cause probleme de chemin.
218
 
219
	function Format($text, $formatter = "wakka") {
220
		return $this->IncludeBuffered(IW_CHEMIN_WIKINI_COURANT_FORMATTER.$formatter.".php", "<i>Impossible de trouver le formateur \"$formatter\"</i>", compact("text"));
221
	}
222
 
223
 
224
}
225
 
226
 
227
 
228
// Appel du fichier de traduction des textes de l'application Integrateur Wikini
229
if (file_exists(IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php')) {
230
    /** Inclusion du fichier de traduction de l'application Integrateur Wikini. */
231
    include_once IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php';
232
} else {
233
    /** Inclusion du fichier de traduction fr par défaut. */
234
    include_once IW_CHEMIN_LANGUES.'iw_langue_fr.inc.php';
235
}
236
 
237
$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
238
/**
239
 *
240
 * Fonction afficherPageMenuWikini()
241
 *
242
 * Renvoie le contenu de la page Menu de Wikini
243
 *
244
 * @return string
245
 * @access public
246
 */
247
 
248
function afficherPageMenuWikini()
249
{
250
 
251
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
252
 
253
  // TODO
254
  // Changement du niveau d'erreur pour éviter les Notices PHP dues à Wikini
255
  //  error_reporting(E_PARSE);
256
 
257
  // Autre possibilite : la page speciale MENU
258
 
259
	global $wiki;
260
	global $wikini_config_defaut;
261
	$sortie='';
262
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
263
    $wiki  = new Wiki_Papyrus($wakkaConfig);
264
 
265
    // Suppression des slash.
266
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
267
 
268
    // split into page/method
269
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
270
        list(, $page, $method) = $matches;
271
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
272
        list(, $page) = $matches;
273
    }
274
 
275
    $server=$_SERVER['PHP_SELF'];
276
	$_SERVER['PHP_SELF']="wakka.php";
277
 
278
    // Sinon Affichage Page Menu (configurable TODO ?)
279
 
280
    $contenu=$wiki->LoadPage("PageMenu");
281
 
282
    $sortie.=$wiki->Format("----");
283
	$sortie.=$wiki->Format($contenu['body']);
284
 
285
	$_SERVER['PHP_SELF']=$server;
286
 
287
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
288
 
289
	return $sortie;
290
 
291
}
292
 
293
 
294
// +------------------------------------------------------------------------------------------------------+
295
// |                                            CORPS du PROGRAMME                                        |
296
// +------------------------------------------------------------------------------------------------------+
297
/** Fonction afficherPageWikini() - Fonction appelé par le gestionnaire Papyrus.
298
*
299
* Elle retourne le contenu de l'application.
300
*
301
* @return  string  du code XHTML correspondant au contenu renvoyé par l'application.
302
*/
303
function afficherPageWikini()
304
{
305
 
306
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
307
 
308
	// Ajout d'une feuille de style externe
309
	GEN_stockerStyleExterne ('wikini', 'client/integrateur_wikini/presentations/styles/wikini.css') ;
310
 
311
  // TODO
312
  // Changement du niveau d'erreur pour éviter les Notices PHP dues à Wikini
313
 
314
 
315
	global $wiki;
316
	global $wikini_config_defaut;
317
	$sortie='';
318
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
319
    $wiki  = new Wiki_Papyrus($wakkaConfig);
320
 
321
 
322
	// Gestion de la variable de session "linktracking"
323
    if ( ! isset( $_SESSION['linktracking'] ) ) {
324
        $_SESSION['linktracking'] = 1;
325
    }
326
 
327
    // Suppression des slash.
328
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
329
 
330
    // split into page/method
331
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
332
        list(, $page, $method) = $matches;
333
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
334
        list(, $page) = $matches;
335
    }
336
 
337
    // Vérification de la méthode d'affichage employée!
338
    if ( ! isset( $method ) ) {
339
        $method = '';
340
    }
341
 
342
    //Récupération du contenu de la page Wikini
343
 
344
    ob_start();
345
 
346
    $server=$_SERVER['PHP_SELF'];
347
	$_SERVER['PHP_SELF']="wakka.php";
348
 
349
	$wiki->Run($page, $method);
350
 
351
    $_SERVER['PHP_SELF']=$server;
352
 
353
    $sortie.= ob_get_contents();
354
    ob_end_clean();
355
 
356
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
357
 
358
	//return remplacerEntiteHTLM("<div id=\"wikini_page\" onLoad=\"thisForm=document.ACEditor;\" ondblclick=\"document.location='".$wiki->href("edit")."';"."\">"."\n".$sortie.'</div>'."\n");
359
	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");
360
 
361
}
362
 
363
 
364
?>