Subversion Repositories Applications.papyrus

Rev

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