[SPIP] +spip v3.0.17
[lhc/web/clavette_www.git] / www / prive / squelettes / contenu / aide_fonctions.php
1 <?php
2
3 if (!defined('_ECRIRE_INC_VERSION')) return;
4
5 function aide_changer_langue($var_lang_r, $lang_r) {
6 if ($var_lang_r)
7 changer_langue($lang = $var_lang_r);
8 if ($lang_r)
9 # pour le cas ou on a fait appel au menu de changement de langue
10 # (aide absente dans la langue x)
11 changer_langue($lang = $lang_r);
12 else $lang = $GLOBALS['spip_lang'];
13
14 return $lang;
15 }
16
17 function aide_contenu(){
18 static $contenu = null;
19 if ($contenu) return $contenu;
20
21 global $help_server;
22 if (!is_array($help_server)) $help_server = array($help_server);
23 $path = $GLOBALS['spip_lang'] . "-aide.html";
24
25 include_spip('inc/aider');
26 list($contenu, $lastm) = aide_fichier($path, $help_server);
27
28 if (strpos($contenu,"aide_index")!==false){
29 $contenu = preg_replace(",target=['\"][^'\"]*['\"],Uims","class='ajax'",$contenu);
30 $contenu = str_replace("aide_index","aide",$contenu);
31 }
32 return $contenu;
33 }
34
35 function aide_extrait_section($aide){
36 return aide_section($aide,aide_contenu());
37 }
38 /*
39 function aide_cache_image($help_server, $cache, $rep, $lang, $file, $ext) {
40 if ($rep=="IMG" AND $lang=="cache"
41 AND @file_exists($img = _DIR_VAR.'cache-TeX/'.preg_replace(',^TeX-,', '', $file))) {
42 return $img;
43 }
44 else if (@file_exists($img = _DIR_AIDE . $cache)) {
45 return $img;
46 }
47 else if (@file_exists($img = _DIR_RACINE . 'AIDE/aide-'.$cache)) {
48 return $img;
49 }
50 else {
51 include_spip('inc/distant');
52 sous_repertoire(_DIR_AIDE,'','',true);
53 $img = "$help_server/$rep/$lang/$file";
54 recuperer_page($img,$f=_DIR_AIDE . $cache);
55 return $f;
56 }
57 }
58 */
59
60 // Affichage du menu de gauche avec analyse de la section demandee
61 // afin d'ouvrir le sous-menu correspondant a l'affichage a droite
62 // http://doc.spip.org/@help_menu_rubrique
63 function aide_menu($aide) {
64 $contenu = aide_contenu();
65 preg_match_all(_SECTIONS_AIDE, $contenu, $sections, PREG_SET_ORDER);
66
67 return $sections;
68
69 global $spip_lang;
70
71 $afficher = false;
72 $ligne = $numrub = 0;
73 $texte = $res = '';
74 foreach ($sections as $section) {
75 list(,$prof, $sujet, $bloc) = $section;
76 if ($prof == '1') {
77 if ($afficher && $texte)
78 $res .= block_parfois_visible("block$numrub", "<div class='rubrique'>$titre</div>", "\n$texte",'', $ouvrir);
79 $afficher = $bloc ? ($bloc == 'redac') : true;
80 $texte = '';
81 if ($afficher) {
82 $numrub++;
83 $ouvrir = 0;
84 $titre = $sujet;
85 }
86 } else {
87 ++$ligne;
88 $id = "ligne$ligne";
89
90 if ($aide == $sujet) {
91 $ouvrir = 1;
92 $class = "article-actif";
93 $texte .= http_script("curr_article = '$id';");
94 } else $class = "article-inactif";
95
96 $h = generer_url_aide("aide=$sujet&frame=body&var_lang=$spip_lang");
97 $texte .= "<a class='$class' target='droite' id='$id' href='$h' onclick=\"activer_article('$id');return true;\">"
98 . $bloc
99 . "</a><br style='clear:both;' />\n";
100 }
101 }
102 if ($afficher && $texte)
103 $res .= block_parfois_visible("block$numrub", "<div class='rubrique'>$titre</div>", "\n$texte",'', $ouvrir);
104 return $res;
105 }