Subversion Repositories Applications.papyrus

Rev

Rev 439 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
433 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
// +------------------------------------------------------------------------------------------------------+
442 ddelon 24
// CVS : $Id: integrateur_wikini.php,v 1.6 2005-09-14 09:12:15 ddelon Exp $
433 ddelon 25
/**
26
* 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        Jean-Pascal MILCENT <jpm@tela-botanica.org>
33
//Autres auteurs :
34
*@author        Aucun
35
*@copyright     Tela-Botanica 2000-2004
442 ddelon 36
*@version       $Revision: 1.6 $ $Date: 2005-09-14 09:12:15 $
434 ddelon 37
*
433 ddelon 38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
436 ddelon 41
 
42
 
433 ddelon 43
/** Inclusion de la classe PEAR de gestion des URL. */
44
require_once 'Net/URL.php';
436 ddelon 45
 
46
// TODO : un seul fichier de configuration ?
47
/** Inclusion du fichier de configuration de cette application.*/
48
require_once 'client/integrateur_wikini/configuration/adwi_configuration.inc.php';
49
 
50
require_once ADWI_CHEMIN_BIBLIOTHEQUE.'adwi_wikini.fonct.php';
51
 
433 ddelon 52
/** Inclusion du fichier de configuration général de IntegrateurWikini.*/
53
require_once 'client'.GEN_SEP.'integrateur_wikini'.GEN_SEP.'configuration'.GEN_SEP.'iw_config.inc.php';
54
 
55
/** Inclusion du fichier permettant d'encoder du texte mais pas les balises XHTML.*/
56
require_once IW_CHEMIN_BIBLIO.'iw_encodage.fonct.php';
57
/** Inclusion du fichier permettant d'inclure les données dans du XHTML.*/
58
require_once IW_CHEMIN_BIBLIO.'iw_affichage_xhtml.fonct.php';
59
 
436 ddelon 60
global $wikini_config_defaut;
434 ddelon 61
global $wiki;
62
global $wiki_p;
433 ddelon 63
 
436 ddelon 64
 
65
// $_REQUEST['wiki'] est obligatoire, car wakka.php envoie un redirect si non detecté, avec perte de tout l'environnement !
66
 
434 ddelon 67
if ( ! isset( $_REQUEST['wiki'] ) ) {
436 ddelon 68
	    $_REQUEST['wiki'] = $wikini_config_defaut['root_page'];
434 ddelon 69
}
70
 
71
$server=$_SERVER['PHP_SELF'];
72
$_SERVER['PHP_SELF']="wakka.php";
73
 
74
// Utilise le wakkaconfig de la racine ...
437 ddelon 75
// TODO : Prevoir de revoir la contrib menu ... qui doit être switchable, ou plutot,
76
// TODO : Customiser son menu avec papyrus ...
77
// TODO : un wiki par défaut pour chaque papyrus à l'installation de Papyrus
78
// TODO : message erreur session
79
// TODO : message erreur interwiki
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
// TODO : creation automatique des Wikis ...
434 ddelon 84
 
85
ob_start();
442 ddelon 86
 
436 ddelon 87
include_once IW_CHEMIN_WIKINI_COURANT.'wakka.php';
434 ddelon 88
ob_end_clean();
89
$_SERVER['PHP_SELF']=$server;
90
 
91
 
92
// On surcharge la classe Wiki pour en faire ce qu'on en veut
93
Class Wiki_Papyrus extends Wiki {
439 ddelon 94
 
442 ddelon 95
 
439 ddelon 96
	//TODO : a gauche !
97
 
434 ddelon 98
	function Header() {
442 ddelon 99
 
439 ddelon 100
		return;
442 ddelon 101
	}
102
 
103
 	function Footer() {
434 ddelon 104
		return;
442 ddelon 105
 	}
439 ddelon 106
 
442 ddelon 107
	function FormOpen($method = "", $tag = "", $formMethod = "post") {
108
 
439 ddelon 109
	// Le diff ne fonctionne pas avec la methode get dans papyrus. On surcharge avec du post.
110
 
111
		if (($method=="diff") && $formMethod=="get") {
112
			$formMethod="post";
113
		}
442 ddelon 114
 
115
		if ($method=="edit") {
116
            $result = "<form id=\"ACEditor\" name=\"ACEditor\" action=\"".$this->href($method, $tag)."\" method=\"".$formMethod."\">\n";
117
            return $result;
118
		}
439 ddelon 119
 
442 ddelon 120
		return Parent::FormOpen($method,$tag, $formMethod);
121
 
439 ddelon 122
	}
442 ddelon 123
	// Detournement des handlers : comme ca on peut faire ce que l'on veut ....
124
	function Method($method) {
125
 
126
		if ($method=="edit") {
127
 
128
			echo $this->Header();
129
 
130
			$result='';
131
 
132
			if ($_POST) {
133
				if ($_POST["submit"] == "Sauver")	{
134
				// check for overwriting
135
					if ($this->page) {
136
						if ($this->page["id"] != $_POST["previous"]) {
137
							$error = "ALERTE : ".
138
							"Cette page a &eacute;t&eacute; modifi&eacute;e par quelqu'un d'autre pendant que vous l'&eacute;ditiez.<br />\n".
139
							"Veuillez copier vos changements et r&eacute;&eacute;diter cette page.\n";
140
						}
141
					}
142
					// store
143
					if (!$error) {
144
						$body = str_replace("\r", "", $_POST["body"]);
145
						// test si la nouvelle page est differente de la précédente
146
						if(rtrim($body)==rtrim($this->page["body"])) {
147
							$this->SetMessage("Cette page n\'a pas &eacute;t&eacute; enregistr&eacute;e car elle n\'a subi aucune modification.");
148
							$this->Redirect($this->href());
149
						}
150
 
151
						// add page (revisions)
152
						$this->SavePage($this->tag, $body);
153
 
154
						// now we render it internally so we can write the updated link table.
155
						$this->ClearLinkTable();
156
						$this->StartLinkTracking();
157
						$dummy = $this->Header();
158
						$dummy .= $this->Format($body);
159
						$dummy .= $this->Footer();
160
						$this->StopLinkTracking();
161
						$this->WriteLinkTable();
162
						$this->ClearLinkTable();
163
 
164
						// forward
165
						$this->Redirect($this->href());
166
					}
167
				}
168
			}
169
 
170
			// fetch fields
171
			if (!$previous = $_POST["previous"]) $previous = $this->page["id"];
172
			if (!$body = $_POST["body"]) $body = $this->page["body"];
173
 
174
			// preview?
175
			if ($_POST["submit"] == "Aperçu")
176
			{
177
				$result .=
178
					"<div class=\"prev_alert\"><strong>Aper&ccedil;u</strong></div>\n".
179
					$this->Format($body)."\n\n".
180
					$this->FormOpen("edit").
181
					"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
182
					"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n".
183
					"<br />\n".
184
					"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
185
					"<input name=\"submit\" type=\"submit\" value=\"R&eacute;&eacute;diter \" accesskey=\"p\" />\n".
186
					"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
187
					$this->FormClose()."\n";
188
				return $result;
189
			}
190
			else
191
			{
192
 
193
			    require_once(IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.buttonsBar.php");
194
 
195
				$result .=
196
				$this->FormOpen("edit").
197
				"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".$ACbuttonsBar.
198
				"<textarea onkeydown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
199
				htmlspecialchars($body).
200
				"\n</textarea><br />\n".
201
				($this->config["preview_before_save"] ? "" : "<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
202
				"<input name=\"submit\" type=\"submit\" value=\"Aper&ccedil;u\" accesskey=\"p\" />\n".
203
				"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
204
				$this->FormClose();
205
 
206
				return $result;
207
			}
208
 
209
		}
210
		else {
211
			return Parent::Method($method);
212
		}
213
	}
214
 
215
 
216
	// Surcharge Format a cause probleme de chemin.
217
 
218
	function Format($text, $formatter = "wakka") {
219
		return $this->IncludeBuffered(IW_CHEMIN_WIKINI_COURANT_FORMATTER.$formatter.".php", "<i>Impossible de trouver le formateur \"$formatter\"</i>", compact("text"));
220
	}
221
 
222
 
434 ddelon 223
}
224
 
442 ddelon 225
 
226
 
433 ddelon 227
// Appel du fichier de traduction des textes de l'application Integrateur Wikini
228
if (file_exists(IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php')) {
229
    /** Inclusion du fichier de traduction de l'application Integrateur Wikini. */
230
    include_once IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php';
231
} else {
232
    /** Inclusion du fichier de traduction fr par défaut. */
233
    include_once IW_CHEMIN_LANGUES.'iw_langue_fr.inc.php';
234
}
434 ddelon 235
 
236
 
439 ddelon 237
/**
238
 * Renvoie le menu général de l'integrateur Wikini : derniers  changement etc.
239
 *
240
 * @return string
241
 * @access public
242
 */
243
 
244
function afficherContenuMenu()
245
{
246
 
247
  // TODO
248
  // Changement du niveau d'erreur pour éviter les Notices PHP dues à Wikini
249
  //  error_reporting(E_PARSE);
250
 
251
  // Autre possibilite : la page speciale MENU
252
 
253
 
254
	global $wiki;
255
	global $wikini_config_defaut;
256
	$sortie='';
257
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
258
    $wiki  = new Wiki_Papyrus($wakkaConfig);
259
 
260
    // Suppression des slash.
261
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
262
 
263
    // split into page/method
264
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
265
        list(, $page, $method) = $matches;
266
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
267
        list(, $page) = $matches;
268
    }
269
 
270
    $server=$_SERVER['PHP_SELF'];
271
	$_SERVER['PHP_SELF']="wakka.php";
272
 
273
    // Affichage par defaut :
274
 
275
	$sortie=$wiki->Format("\n----PagePrincipale\nDerniersChangements\nDerniersCommentaires----");
276
    $sortie.="<a href=\"".$wiki->href("edit",$page)."\" title=\"Cliquez pour &eacute;diter cette page.\">&Eacute;diter cette page</a>";
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
	// TODO
288
	// Retour au niveau d'erreur définit dans le fichier de config de Papyrus
289
    // error_reporting(GEN_DEBOGAGE_NIVEAU);
290
 
291
	return $sortie;
292
 
293
}
294
 
295
 
433 ddelon 296
// +------------------------------------------------------------------------------------------------------+
297
// |                                            CORPS du PROGRAMME                                        |
298
// +------------------------------------------------------------------------------------------------------+
299
/** Fonction afficherContenuCorps() - Fonction appelé par le gestionnaire Papyrus.
300
*
301
* Elle retourne le contenu de l'application.
302
*
303
* @return  string  du code XHTML correspondant au contenu renvoyé par l'application.
304
*/
305
function afficherContenuCorps()
306
{
439 ddelon 307
 
442 ddelon 308
	// Ajout d'une feuille de style externe
309
	GEN_stockerStyleExterne ('wikini', 'client/integrateur_wikini/presentations/styles/wikini.css') ;
310
 
439 ddelon 311
  // TODO
312
  // Changement du niveau d'erreur pour éviter les Notices PHP dues à Wikini
313
  //  error_reporting(E_PARSE);
436 ddelon 314
 
434 ddelon 315
	global $wiki;
436 ddelon 316
	global $wikini_config_defaut;
434 ddelon 317
	$sortie='';
433 ddelon 318
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
434 ddelon 319
    $wiki  = new Wiki_Papyrus($wakkaConfig);
320
 
439 ddelon 321
 
434 ddelon 322
	// Gestion de la variable de session "linktracking"
433 ddelon 323
    if ( ! isset( $_SESSION['linktracking'] ) ) {
324
        $_SESSION['linktracking'] = 1;
325
    }
434 ddelon 326
 
433 ddelon 327
    // Suppression des slash.
434 ddelon 328
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
329
 
433 ddelon 330
    // split into page/method
434 ddelon 331
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
433 ddelon 332
        list(, $page, $method) = $matches;
434 ddelon 333
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
433 ddelon 334
        list(, $page) = $matches;
335
    }
336
 
337
    // Vérification de la méthode d'affichage employée!
338
    if ( ! isset( $method ) ) {
339
        $method = '';
340
    }
434 ddelon 341
 
433 ddelon 342
    //Récupération du contenu de la page Wikini
343
 
434 ddelon 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
 
439 ddelon 356
	// TODO
357
	// Retour au niveau d'erreur définit dans le fichier de config de Papyrus
358
    // error_reporting(GEN_DEBOGAGE_NIVEAU);
359
 
442 ddelon 360
	//return remplacerEntiteHTLM("<div id=\"wikini_page\" onLoad=\"thisForm=document.ACEditor;\" ondblclick=\"document.location='".$wiki->href("edit")."';"."\">"."\n".$sortie.'</div>'."\n");
361
	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");
434 ddelon 362
 
433 ddelon 363
}
364
 
434 ddelon 365
 
366
// TODO : qu'affiche-t-on en pied ?
433 ddelon 367
/** Fonction afficherContenuPied() - Fonction appelé par le gestionnaire Papyrus.
368
*
369
* Elle retourne le pied de l'application.
370
*
371
* @return  string  du code XHTML correspondant au pied renvoyé par l'application.
372
*/
373
function afficherContenuPied()
374
{
375
    return inclusion_html('pied_page');
376
}
377
?>