Subversion Repositories Applications.papyrus

Rev

Rev 556 | Go to most recent revision | Details | Compare with Previous | 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
// +------------------------------------------------------------------------------------------------------+
565 ddelon 24
// CVS : $Id: iw_integrateur.fonct.php,v 1.3 2005-10-21 22:22:16 ddelon Exp $
545 ddelon 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
565 ddelon 36
*@version       $Revision: 1.3 $ $Date: 2005-10-21 22:22:16 $
545 ddelon 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';
556 ddelon 88
include_once(IW_CHEMIN_WIKINI_COURANT."/formatters/tableaux.php");
89
include_once(IW_CHEMIN_WIKINI_COURANT."/actions/attach.class.php");
545 ddelon 90
 
91
ob_end_clean();
92
$_SERVER['PHP_SELF']=$server;
93
 
94
 
95
// On surcharge la classe Wiki pour en faire ce qu'on en veut
96
Class Wiki_Papyrus extends Wiki {
97
 
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
 
565 ddelon 253
 
545 ddelon 254
  // Autre possibilite : la page speciale MENU
255
 
256
	global $wiki;
257
	global $wikini_config_defaut;
258
	$sortie='';
259
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
260
    $wiki  = new Wiki_Papyrus($wakkaConfig);
261
 
262
    // Suppression des slash.
263
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
264
 
265
    // split into page/method
266
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
267
        list(, $page, $method) = $matches;
268
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
269
        list(, $page) = $matches;
270
    }
271
 
272
    $server=$_SERVER['PHP_SELF'];
273
	$_SERVER['PHP_SELF']="wakka.php";
565 ddelon 274
 
545 ddelon 275
    $contenu=$wiki->LoadPage("PageMenu");
276
 
277
    $sortie.=$wiki->Format("----");
278
	$sortie.=$wiki->Format($contenu['body']);
279
 
280
	$_SERVER['PHP_SELF']=$server;
281
 
282
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
283
 
284
	return $sortie;
285
 
286
}
287
 
288
 
289
// +------------------------------------------------------------------------------------------------------+
290
// |                                            CORPS du PROGRAMME                                        |
291
// +------------------------------------------------------------------------------------------------------+
292
/** Fonction afficherPageWikini() - Fonction appelé par le gestionnaire Papyrus.
293
*
294
* Elle retourne le contenu de l'application.
295
*
296
* @return  string  du code XHTML correspondant au contenu renvoyé par l'application.
297
*/
298
function afficherPageWikini()
299
{
300
 
301
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
302
 
303
	// Ajout d'une feuille de style externe
304
	GEN_stockerStyleExterne ('wikini', 'client/integrateur_wikini/presentations/styles/wikini.css') ;
305
 
306
  // TODO
307
  // Changement du niveau d'erreur pour éviter les Notices PHP dues à Wikini
308
 
309
 
310
	global $wiki;
311
	global $wikini_config_defaut;
312
	$sortie='';
313
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
314
    $wiki  = new Wiki_Papyrus($wakkaConfig);
315
 
316
 
317
	// Gestion de la variable de session "linktracking"
318
    if ( ! isset( $_SESSION['linktracking'] ) ) {
319
        $_SESSION['linktracking'] = 1;
320
    }
321
 
322
    // Suppression des slash.
323
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
324
 
325
    // split into page/method
326
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
327
        list(, $page, $method) = $matches;
328
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
329
        list(, $page) = $matches;
330
    }
331
 
332
    // Vérification de la méthode d'affichage employée!
333
    if ( ! isset( $method ) ) {
334
        $method = '';
335
    }
336
 
337
    //Récupération du contenu de la page Wikini
338
 
339
    ob_start();
340
 
341
    $server=$_SERVER['PHP_SELF'];
342
	$_SERVER['PHP_SELF']="wakka.php";
343
 
344
	$wiki->Run($page, $method);
345
 
346
    $_SERVER['PHP_SELF']=$server;
347
 
348
    $sortie.= ob_get_contents();
349
    ob_end_clean();
350
 
351
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
352
 
353
	//return remplacerEntiteHTLM("<div id=\"wikini_page\" onLoad=\"thisForm=document.ACEditor;\" ondblclick=\"document.location='".$wiki->href("edit")."';"."\">"."\n".$sortie.'</div>'."\n");
354
	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");
355
 
356
}
357
 
358
 
359
?>