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