Subversion Repositories Applications.papyrus

Rev

Rev 497 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 497 Rev 545
Line 19... Line 19...
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: integrateur_wikini.php,v 1.10 2005-10-01 11:13:43 ddelon Exp $
24
// CVS : $Id: integrateur_wikini.php,v 1.11 2005-10-17 13:41:34 ddelon Exp $
25
/**
25
/**
26
* Integrateur de page Wikini
26
* 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
*
Line 31... Line 31...
31
//Auteur original :
31
//Auteur original :
32
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
32
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
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.10 $ $Date: 2005-10-01 11:13:43 $
36
*@version       $Revision: 1.11 $ $Date: 2005-10-17 13:41:34 $
37
*
37
*
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
40
// +------------------------------------------------------------------------------------------------------+
Line 41... Line -...
41
 
-
 
42
 
-
 
43
 
-
 
44
 
-
 
45
/** Inclusion de la classe PEAR de gestion des URL. */
-
 
46
 
-
 
47
 
-
 
48
$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
-
 
49
 
-
 
50
require_once 'Net/URL.php';
-
 
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
 
-
 
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
 
-
 
66
global $wikini_config_defaut;
-
 
67
global $wiki;
-
 
68
global $wiki_p;
-
 
69
 
-
 
70
// $_REQUEST['wiki'] est obligatoire, car wakka.php envoie un redirect si non detecté, avec perte de tout l'environnement !
-
 
71
 
-
 
72
if ( ! isset( $_REQUEST['wiki'] ) ) {
-
 
73
	    $_REQUEST['wiki'] = $wikini_config_defaut['root_page'];
-
 
74
}
-
 
75
 
-
 
76
$server=$_SERVER['PHP_SELF'];
-
 
77
$_SERVER['PHP_SELF']="wakka.php";
-
 
78
 
-
 
79
// Utilise le wakkaconfig de la racine ...
-
 
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 ...
-
 
89
 
-
 
90
ob_start();
-
 
91
 
-
 
92
include_once IW_CHEMIN_WIKINI_COURANT.'wakka.php';
-
 
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 {
-
 
99
	
-
 
100
    
-
 
101
	//TODO : a gauche !
-
 
102
	
-
 
103
	function Header() {
-
 
104
		
-
 
105
		return;
-
 
106
	}	
-
 
107
 
-
 
108
 	function Footer() {
-
 
109
		return;
-
 
110
 	}
-
 
111
	
-
 
112
	function FormOpen($method = "", $tag = "", $formMethod = "post") {
-
 
113
	
-
 
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
		}
-
 
119
	
-
 
120
		if ($method=="edit") {
-
 
121
            $result = "<form id=\"ACEditor\" name=\"ACEditor\" action=\"".$this->href($method, $tag)."\" method=\"".$formMethod."\">\n";
-
 
122
            return $result;
-
 
123
		}
-
 
124
		
-
 
125
		return parent::FormOpen($method,$tag, $formMethod);
-
 
126
		
-
 
127
	}
-
 
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 {
-
 
216
			return parent::Method($method);
-
 
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
	
-
 
228
}
-
 
229
 
-
 
230
		
-
 
231
		
-
 
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
}
41
 
240
 
42
 
241
$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
43
 
242
/**
44
/**
243
 * Renvoie le menu général de l'integrateur Wikini : derniers  changement etc.
45
 * Renvoie le menu général de l'integrateur Wikini : derniers  changement etc.
244
 *
46
 *
Line 245... Line -...
245
 * @return string
-
 
246
 * @access public
-
 
247
 */
-
 
248
   
-
 
249
function afficherContenuMenu()
-
 
250
{
-
 
251
	
47
 * @return string
252
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
-
 
253
 
-
 
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'];
-
 
Line 264... Line -...
264
    $wiki  = new Wiki_Papyrus($wakkaConfig);
-
 
265
 
-
 
266
    // Suppression des slash.
-
 
267
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
-
 
268
 
-
 
269
    // split into page/method
-
 
Line 270... Line -...
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
 
48
 * @access public
276
    $server=$_SERVER['PHP_SELF'];
49
 */
277
	$_SERVER['PHP_SELF']="wakka.php";
-
 
278
	
50
   
279
    // Sinon Affichage Page Menu (configurable TODO ?) 
-
 
280
    
-
 
281
    $contenu=$wiki->LoadPage("PageMenu");
-
 
282
    
-
 
283
    $sortie.=$wiki->Format("----");
-
 
284
	$sortie.=$wiki->Format($contenu['body']);   
-
 
285
 
-
 
286
	$_SERVER['PHP_SELF']=$server;
51
require_once 'client/integrateur_wikini/bibliotheque/iw_integrateur.fonct.php';
Line 287... Line 52...
287
	
52
 
288
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
53
 
Line 301... Line 66...
301
*
66
*
302
* @return  string  du code XHTML correspondant au contenu renvoyé par l'application.
67
* @return  string  du code XHTML correspondant au contenu renvoyé par l'application.
303
*/
68
*/
304
function afficherContenuCorps()
69
function afficherContenuCorps()
305
{
70
{
306
 
-
 
307
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
-
 
308
	
-
 
309
	// Ajout d'une feuille de style externe
71
	return afficherPageWikini();
310
	GEN_stockerStyleExterne ('wikini', 'client/integrateur_wikini/presentations/styles/wikini.css') ;
-
 
Line 311... Line -...
311
	
-
 
312
  // TODO
-
 
313
  // Changement du niveau d'erreur pour éviter les Notices PHP dues à Wikini
-
 
314
   	
-
 
315
   
-
 
316
	global $wiki;
-
 
317
	global $wikini_config_defaut;
-
 
318
	$sortie='';
-
 
319
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
-
 
320
    $wiki  = new Wiki_Papyrus($wakkaConfig);
-
 
321
 
-
 
322
 
-
 
323
	// Gestion de la variable de session "linktracking"
-
 
324
    if ( ! isset( $_SESSION['linktracking'] ) ) {
-
 
325
        $_SESSION['linktracking'] = 1;
-
 
326
    }
-
 
327
 
-
 
328
    // Suppression des slash.
-
 
329
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
-
 
330
 
-
 
331
    // split into page/method
-
 
332
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
-
 
333
        list(, $page, $method) = $matches;
-
 
334
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
-
 
335
        list(, $page) = $matches;
-
 
336
    }
-
 
337
    
-
 
338
    // Vérification de la méthode d'affichage employée!
-
 
339
    if ( ! isset( $method ) ) {
-
 
340
        $method = '';
-
 
341
    }
-
 
342
		
-
 
343
    //Récupération du contenu de la page Wikini
-
 
344
    
-
 
345
    ob_start();
-
 
346
    
-
 
347
    $server=$_SERVER['PHP_SELF'];
-
 
348
	$_SERVER['PHP_SELF']="wakka.php";
-
 
349
    
-
 
350
	$wiki->Run($page, $method);
-
 
351
    
-
 
352
    $_SERVER['PHP_SELF']=$server;
-
 
353
    
-
 
354
    $sortie.= ob_get_contents();
-
 
355
    ob_end_clean();
-
 
356
 
-
 
357
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
-
 
358
 
-
 
359
	//return remplacerEntiteHTLM("<div id=\"wikini_page\" onLoad=\"thisForm=document.ACEditor;\" ondblclick=\"document.location='".$wiki->href("edit")."';"."\">"."\n".$sortie.'</div>'."\n");
-
 
360
	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"); 
-
 
361
		
72
	
362
}
-
 
363
 
-
 
364
 
73
}
365
// TODO : qu'affiche-t-on en pied ?
74
// TODO : qu'affiche-t-on en pied ?
366
/** Fonction afficherContenuPied() - Fonction appelé par le gestionnaire Papyrus.
75
/** Fonction afficherContenuPied() - Fonction appelé par le gestionnaire Papyrus.
367
*
76
*
368
* Elle retourne le pied de l'application.
77
* Elle retourne le pied de l'application.