Subversion Repositories Sites.tela-botanica.org

Rev

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

Rev Author Line No. Line
7 david 1
<?php
2
 
3
/***************************************************************************\
4
 *  SPIP, Systeme de publication pour l'internet                           *
5
 *                                                                         *
6
 *  Copyright (c) 2001-2005                                                *
7
 *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
8
 *                                                                         *
9
 *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
10
 *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
11
\***************************************************************************/
12
 
13
define('_ECRIRE_AIDE', 1);
14
include ("inc_version.php3");
15
include_ecrire ("inc_presentation.php3");
16
 
17
 
18
// Eviter les calculs evitables (surtout en client/serveur sans cache !)
19
$lastmodified = filemtime("aide_index.php3");
20
$headers_only = http_last_modified($lastmodified, time() + 24 * 3600);
21
if ($headers_only) exit;
22
 
23
include_ecrire ("inc_filtres.php3");
24
include_ecrire ("inc_layer.php3");
25
include_ecrire ("inc_texte.php3");
26
 
27
 
28
// Recuperer les infos de langue (preferences auteur), si possible
29
if (_FILE_CONNECT) {
30
	include_ecrire ("inc_session.php3");
31
	verifier_visiteur();
32
}
33
include_ecrire ("inc_lang.php3");
34
utiliser_langue_visiteur();
35
if ($var_lang) changer_langue($var_lang);
36
if ($lang) changer_langue($lang); # pour le cas ou on a fait appel au menu de changement de langue (aide absente dans la langue x)
37
 
38
/////////////////////////////
39
// La frame de base
40
//
41
function help_frame ($aide) {
42
	global $spip_lang;
43
 
44
	echo "</head>\n";
45
 
46
	$frame_menu = "<frame src=\"aide_index.php3?aide=$aide&var_lang=$spip_lang&frame=menu\" name=\"gauche\" scrolling=\"auto\" noresize>\n";
47
	$frame_body = "<frame src=\"aide_index.php3?aide=$aide&var_lang=$spip_lang&frame=body\" name=\"droite\" scrolling=\"auto\" noresize>\n";
48
 
49
	if ($GLOBALS['spip_lang_rtl']) {
50
		echo '<frameset cols="*,160" border="0" frameborder="0" framespacing="0">';
51
		echo $frame_body.$frame_menu;
52
	}
53
	else {
54
		echo '<frameset cols="160,*" border="0" frameborder="0" framespacing="0">';
55
		echo $frame_menu.$frame_body;
56
	}
57
	echo '</frameset>';
58
	echo "\n</html>";
59
}
60
 
61
 
62
 
63
/////////////////////////////
64
// Le contenu demande
65
//
66
 
67
// Erreur aide non disponible
68
function erreur_aide_indisponible() {
69
	include_ecrire('inc_presentation.php3');
70
	install_debut_html(_T('forum_titre_erreur'));
71
	echo "<div>"._T('aide_non_disponible')."</div>";
72
	echo "<div align='right'>".menu_langues('var_lang_ecrire')."</div>";
73
	install_fin_html();
74
	exit;
75
}
76
 
77
// Selection de l'aide correspondant a la langue demandee
78
function fichier_aide($lang_aide = '') {
79
	global $help_server;
80
 
81
	if (!$lang_aide) $lang_aide = $GLOBALS['spip_lang'];
82
 
83
	// fichier local ?
84
	if (@file_exists($fichier_aide = "../AIDE/aide-$lang_aide-aide.html")) {
85
		return array(spip_file_get_contents($fichier_aide), $lang_aide);
86
	}
87
 
88
	// fichier local ? si reduction ISO du code langue oc_prv_ni => oc
89
	else if (ereg("(.*)_", $lang_aide, $regs)
90
		AND (@file_exists($fichier_aide = "../AIDE/aide-".$regs[1]."-aide.html")))
91
			return array(spip_file_get_contents($fichier_aide), $regs[1]);
92
 
93
	// Aide internet
94
	else {
95
		// en cache ?
96
		if (!@file_exists($fichier_aide = _DIR_CACHE . "aide-$lang_aide-aide.html")) {
97
			if ($help_server) {
98
				include_ecrire('inc_sites.php3');
99
				if (ecrire_fichier(_DIR_CACHE . 'aide-test', "test")
100
				AND ($contenu = recuperer_page("$help_server/$lang_aide-aide.html")))
101
					ecrire_fichier ($fichier_aide, $contenu);
102
			}
103
		}
104
 
105
		lire_fichier($fichier_aide, $contenu);
106
 
107
		if (strlen($contenu) > 500) {
108
			return array($contenu, $lang_aide);
109
		}
110
 
111
		// Pas d'aide meme sur internet : n'existe pas dans la langue
112
 
113
		// Hack: comportement special sur le serveur d'aide SPIP.NET
114
		// (definir la constante SPIP.NET_...)
115
		if (defined('SPIP.NET_PAS_DE_BOUCLE_AIDE')) {
116
			$GLOBALS['clean_link'] = new Link("../aide/?aide=$aide");
117
		}
118
 
119
		erreur_aide_indisponible();
120
	}
121
 
122
	return false;
123
}
124
 
125
 
126
function help_body($aide, $html) {
127
	global $help_server;
128
 
129
 
130
	// Recuperation du contenu de l'aide demandee
131
	if ($aide) {
132
		$html = analyse_aide($html, $aide);
133
 
134
		if (!$html) {
135
			erreur_aide_indisponible();
136
		}
137
	} else {
138
		// panneau d'accueil
139
		$html = '<CENTER>
140
			<img src="'._DIR_IMG_PACK.
141
			'logo-spip.gif" alt="SPIP" width="267" height="170" border="0">
142
			<p />
143
			<div align="center" style="font-variant: small-caps;">
144
			Syst&egrave;me de publication pour l\'Internet
145
			</div></CENTER>
146
			<div style="position:absolute; bottom: 10px; right:20px;
147
			font-size: 12px; ">'.
148
		preg_replace(",<a ,i", "<a target='_new' ",_T('info_copyright_doc')).
149
			'</div>';
150
	}
151
 
152
	// Recherche des images de l'aide
153
	$suite = $html;
154
	$html = "";
155
	while (preg_match("@(<img([^<>]* +)? src=['\"])"
156
		. "((AIDE|IMG)/([-_a-zA-Z0-9]*/?)([^'\"<>]*))@i",
157
	$suite, $r)) {
158
 
159
		$image = $r[3];
160
		$image_plat = str_replace('/', '-', $image);
161
		$f = "aide_index.php3?img=$image_plat";
162
 
163
		$p = strpos($suite, $r[0]);
164
		$html .= substr($suite, 0, $p) . $r[1].$f;
165
		$suite = substr($suite, $p + strlen($r[0]));
166
	}
167
 
168
	$html .= $suite;
169
 
170
?>
171
<style type="text/css"><!--
172
.spip_cadre {
173
	width : 100%;
174
	background-color: #FFFFFF;
175
	padding: 5px;
176
}
177
.spip_quote {
178
	margin-left : 40px;
179
	margin-top : 10px;
180
	margin-bottom : 10px;
181
	border : solid 1px #aaaaaa;
182
	background-color: #dddddd;
183
	padding: 5px;
184
}
185
 
186
a {text-decoration: none;}
187
a:hover {color:#FF9900; text-decoration: underline;}
188
 
189
body {
190
	font-family: Georgia, Garamond, Times New Roman, serif;
191
}
192
h3.spip {
193
	font-family: Verdana,Arial,Sans,sans-serif;
194
	font-weight: bold;
195
	font-size: 115%;
196
	text-align: center;
197
}
198
 
199
table.spip {
200
}
201
 
202
table.spip tr.row_first {
203
	background-color: #FCF4D0;
204
}
205
 
206
table.spip tr.row_odd {
207
	background-color: #C0C0C0;
208
}
209
 
210
table.spip tr.row_even {
211
	background-color: #F0F0F0;
212
}
213
 
214
table.spip td {
215
	padding: 1px;
216
	text-align: left;
217
	vertical-align: center;
218
}
219
 
220
--></style>
221
</head>
222
<?php
223
 
224
	echo '<body bgcolor="#FFFFFF" text="#000000" TOPMARGIN="24" LEFTMARGIN="24" MARGINWIDTH="24" MARGINHEIGHT="24"';
225
	if ($spip_lang_rtl)
226
		echo " dir='rtl'";
227
	echo " lang='$lang_aide'>";
228
 
229
	if ($aide == 'spip') {
230
		echo '<TABLE BORDER=0 WIDTH=100% HEIGHT=60%>
231
<TR WIDTH=100% HEIGHT=60%>
232
<TD WIDTH=100% HEIGHT=60% ALIGN="center" VALIGN="middle">
233
 
234
<CENTER>
235
<img src="aide_index.php3?img=AIDE--logo-spip.gif" alt="SPIP" width="300" height="170" border="0">
236
</CENTER>
237
</TD></TR></TABLE>';
238
	}
239
 
240
	// Il faut que la langue de typo() soit celle de l'aide en ligne
241
	changer_typo($lang_aide);
242
 
243
	$html = justifier($html."<p>");
244
	// Remplacer les liens externes par des liens ouvrants (a cause des frames)
245
	$html = ereg_replace('<a href="(http://[^"]+)"([^>]*)>', '<a href="\\1"\\2 target="_blank">', $html);
246
 
247
	echo $html;
248
 
249
}
250
 
251
 
252
/////////////////////////////////////
253
// Recuperer une image dans le cache
254
//
255
function help_img($regs) {
256
	global $help_server;
257
 
258
	list ($cache, $rep, $lang, $file, $ext) = $regs;
259
 
260
	header("Content-Type: image/$ext");
261
	if (@file_exists($img = _DIR_CACHE . 'aide-'.$cache)) {
262
		readfile($img);
263
	} else if (@file_exists($img = '../AIDE/aide-'.$cache)) {
264
		readfile($img);
265
	} else if ($help_server) {
266
		include_ecrire('inc_sites.php3');
267
		if (ecrire_fichier(_DIR_CACHE . 'aide-test', "test")
268
		AND ($contenu =
269
		recuperer_page("$help_server/$rep/$lang/$file"))) {
270
			echo $contenu;
271
			ecrire_fichier (_DIR_CACHE . 'aide-'.$cache, $contenu);
272
		} else
273
			header ("Location: $help_server/$rep/$lang/$file");
274
	}
275
	exit;
276
}
277
 
278
///////////////////////////////////////
279
// Le menu de gauche
280
//
281
function help_menu($aide, $html) {
282
	global $spip_lang_left, $spip_lang_rtl, $spip_lang_right;
283
 
284
$triangle = "url(" . _DIR_IMG_PACK . 'triangle'.$spip_lang_rtl.'.gif) ';
285
 
286
echo '<style type="text/css">
287
<!--
288
	a {text-decoration: none; }
289
	A:Hover {text-decoration: underline;}
290
 
291
	.article-inactif {
292
		float: '.$spip_lang_left.';
293
		text-align: '.$spip_lang_left.';
294
		width: 80%;
295
		background: ' . $triangle . $spip_lang_left.' center no-repeat;
296
		margin: 2px;
297
		padding: 0px;
298
		padding-'.$spip_lang_left.': 20px;
299
		font-family: Arial, Sans, sans-serif;
300
		font-size: 12px;
301
	}
302
	.article-actif {
303
		float: '.$spip_lang_right.';
304
		text-align: '.$spip_lang_right.';
305
		width: 80%;
306
		background: ' . $triangle . $spip_lang_right.' center no-repeat;
307
		margin: 4px;
308
		padding: 0px;
309
		padding-'.$spip_lang_right.': 20px;
310
		font-family: Arial, Sans, sans-serif;
311
		font-size: 12px;
312
		font-weight: bold;
313
		color: black;
314
	}
315
	.article-actif:hover {
316
		text-decoration: none;
317
	}
318
	.rubrique {
319
		width: 90%;
320
		margin: 0px;
321
		margin-top: 6px;
322
		margin-bottom: 4px;
323
		padding: 4px;
324
		font-family: Trebuchet MS, Arial, Sans, sans-serif;
325
		font-size: 13px;
326
		font-weight: bold;
327
		color: black;
328
		background-color: #EEEECC;
329
		-moz-border-radius: 4px;
330
	}
331
-->
332
</style>
333
<script type="text/javascript"><!--
334
var curr_article;
335
function activer_article(id) {
336
	if (curr_article)
337
		document.getElementById(curr_article).className = "article-inactif";
338
	if (id) {
339
		document.getElementById(id).className = "article-actif";
340
		curr_article = id;
341
	}
342
}
343
//--></script>
344
';
345
 
346
afficher_script_layer();
347
echo '
348
</head>
349
<body bgcolor="#FFFFFF" text="#000000" link="#E86519" vlink="#6E003A" alink="#FF9900" TOPMARGIN="5" LEFTMARGIN="5" MARGINWIDTH="5" MARGINHEIGHT="5"';
350
 
351
	if ($spip_lang_rtl)
352
		echo " dir='rtl'";
353
	echo " lang='$lang_aide'>";
354
 
355
 
356
	// Recuperation et analyse de la structure de l'aide demandee
357
	$sections = analyse_aide($html);
358
	foreach ($sections as $section) {
359
		if ($section[1] == '1') {
360
			if ($rubrique_vue)
361
				fin_rubrique();
362
			rubrique($section[3].$section[5]);
363
			$rubrique_vue = true;
364
		} else
365
			article($section[5], $section[3]);
366
	}
367
	fin_rubrique();
368
}
369
 
370
 
371
function rubrique($titre, $statut = "redac") {
372
	global $ligne_rubrique;
373
	global $block_rubrique;
374
	global $titre_rubrique;
375
	global $afficher_rubrique, $ouvrir_rubrique;
376
	global $larubrique;
377
 
378
	global $aide_statut;
379
 
380
	$afficher_rubrique = 0;
381
 
382
	if (($statut == "admin" AND $aide_statut == "admin") OR ($statut == "redac")) {
383
		$larubrique++;
384
		$titre_rubrique = $titre;
385
		$ligne_rubrique = array();
386
		$block_rubrique = "block$larubrique";
387
		$afficher_rubrique = 1;
388
		$ouvrir_rubrique = 0;
389
	}
390
}
391
 
392
function fin_rubrique() {
393
	global $ligne_rubrique;
394
	global $block_rubrique;
395
	global $titre_rubrique;
396
	global $afficher_rubrique, $ouvrir_rubrique;
397
	global $texte;
398
 
399
	if ($afficher_rubrique && count($ligne_rubrique)) {
400
		echo "<div class='rubrique'>";
401
		if ($ouvrir_rubrique)
402
			echo bouton_block_visible($block_rubrique);
403
		else
404
			echo bouton_block_invisible($block_rubrique);
405
		echo $titre_rubrique;
406
		echo "</div>\n";
407
		if ($ouvrir_rubrique)
408
			echo debut_block_visible($block_rubrique);
409
		else
410
			echo debut_block_invisible($block_rubrique);
411
		echo "\n";
412
		reset($ligne_rubrique);
413
		while (list(, $ligne) = each($ligne_rubrique)) {
414
			echo $texte[$ligne];
415
		}
416
		echo fin_block();
417
		echo "\n\n";
418
	}
419
}
420
 
421
function article($titre, $lien, $statut = "redac") {
422
	global $aide;
423
	global $ligne;
424
	global $ligne_rubrique;
425
	global $rubrique;
426
	global $texte;
427
	global $afficher_rubrique, $ouvrir_rubrique;
428
	global $aide_statut;
429
	global $spip_lang;
430
 
431
	if ($afficher_rubrique AND (($statut == "admin" AND $aide_statut == "admin") OR ($statut == "redac"))) {
432
		$ligne_rubrique[] = ++$ligne;
433
 
434
		$texte[$ligne] = '';
435
		$id = "ligne$ligne";
436
		$url = "aide_index.php3?aide=$lien&frame=body&var_lang=$spip_lang";
437
		if ($aide == $lien) {
438
			$ouvrir_rubrique = 1;
439
			$class = "article-actif";
440
			$texte[$ligne] .= "<script type='text/javascript'><!--\ncurr_article = '$id';\n// --></script>\n";
441
		}
442
		else {
443
			$class = "article-inactif";
444
		}
445
		$texte[$ligne] .= "<a class='$class' id='$id' href='$url' target='droite' ".
446
			"onClick=\"activer_article('$id');return true;\">$titre</a><br style='clear:both;'>\n";
447
	}
448
}
449
 
450
 
451
function analyse_aide($html, $aide=false) {
452
 
453
	preg_match_all(',<h([12])( class="spip")?'. '>([^/]+?)(/(.+?))?</h\1>,ism',
454
	$html, $regs, PREG_SET_ORDER);
455
 
456
	if ($aide) {
457
		unset ($regs);
458
		$preg = ',<h2( class="spip")?'
459
		. ">$aide/(.+?)</h2>(.*)$,ism";
460
		preg_match($preg, $html, $regs);
461
		$regs = preg_replace(',<h[12].*,ism', '', $regs[3]);
462
	}
463
 
464
	return $regs;
465
}
466
 
467
 
468
//
469
// Distribuer le travail
470
//
471
if (preg_match(',^([^-.]*)-([^-.]*)-([^\.]*\.(gif|jpg|png))$,', $img, $regs))
472
	help_img($regs);
473
else {
474
	list($html, $l, $url_aide) = fichier_aide();
475
 
476
	// On n'a pas d'aide
477
	if (!$html) {
478
		// Renvoyer sur l'aide en ligne du serveur externe
479
		if ($help_server)
480
			@Header("Location: $help_server/?lang=$spip_lang");
481
		// Sinon message d'erreur
482
		else {
483
			erreur_aide_indisponible();
484
		}
485
	} else {
486
		echo debut_entete(_T('info_aide_en_ligne'),
487
				  "Content-Type: text/html; charset=utf-8");
488
		if ($frame == 'menu')
489
			help_menu($aide, $html);
490
		else if ($frame == 'body')
491
			help_body($aide, $html);
492
		else
493
			help_frame($aide);
494
	}
495
}
496
 
497
?>