");
+
+// Autre squelette qui ne s'avoue pas comme tel
+
+// http://doc.spip.org/@help_body
+function help_body($aide) {
+
+ if (!$aide) {
+ $c = _T('info_copyright_doc',
+ array('spipnet' => $GLOBALS['home_server']
+ . '/' . $GLOBALS['spip_lang']
+ . '_'));
+ return "
" .
+ _HELP_PANNEAU .
+ preg_replace(",
';
+ } elseif ($aide == 'spip') {
+ return "
+
+
+
+ |
";
+ } return '';
+}
+
+
+// Extraire la seule section demandee,
+// qui commence par son nom entouree d'une balise h2
+// et se termine par la prochaine balise h2 ou h1 ou le /body final.
+
+function help_section($aide, $contenu, $prof=2)
+{
+ $maxprof = ($prof >=2) ? "12" : "1";
+ $r = "@
\s*' . $aide
+ ."\s*(?:/.+?)?(.*?)<(?:(?:h[$maxprof])|/body)@ism";
+
+ if (preg_match($r, $contenu, $m))
+ return $m[1];
+ return '';
+}
+
+
+
+// Affichage du menu de gauche avec analyse de la section demandee
+// afin d'ouvrir le sous-menu correspondant a l'affichage a droite
+// http://doc.spip.org/@help_menu_rubrique
+function help_menu_rubrique($aide, $contenu)
+{
+ global $spip_lang;
+
+ $afficher = false;
+ $ligne = $numrub = 0;
+ $texte = $res = '';
+ preg_match_all(_SECTIONS_AIDE, $contenu, $sections, PREG_SET_ORDER);
+ foreach ($sections as $section) {
+ list(,$prof, $sujet, $bloc) = $section;
+ if ($prof == '1') {
+ if ($afficher && $texte)
+ $res .= block_parfois_visible("block$numrub", "
$titre
", "\n$texte",'', $ouvrir);
+ $afficher = $bloc ? ($bloc == 'redac') : true;
+ $texte = '';
+ if ($afficher) {
+ $numrub++;
+ $ouvrir = 0;
+ $titre = $sujet;
+ }
+ } else {
+ ++$ligne;
+ $id = "ligne$ligne";
+
+ if ($aide == $sujet) {
+ $ouvrir = 1;
+ $class = "article-actif";
+ $texte .= http_script("curr_article = '$id';");
+ } else $class = "article-inactif";
+
+ $h = generer_url_aide("aide=$sujet&frame=body&var_lang=$spip_lang");
+ $texte .= "
"
+ . $bloc
+ . "\n";
+ }
+ }
+ if ($afficher && $texte)
+ $res .= block_parfois_visible("block$numrub", "
$titre
", "\n$texte",'', $ouvrir);
+ return $res;
+}
+
+function help_frame_menu($titre, $contenu, $lang)
+{
+ global $spip_lang_rtl;
+
+ return "\n
" .$titre ."\n" .
+ '
\n" .
+ http_script('', 'jquery.js') .
+ "\n" .
+ $GLOBALS['browser_layer'] .
+ http_script('var curr_article;
+function activer_article(id) {
+ if (curr_article)
+ jQuery("#"+curr_article).removeClass("article-actif").addClass("article-inactif");
+ if (id) {
+ jQuery("#"+id).removeClass("article-inactif").addClass("article-actif");
+ curr_article = id;
+ }
+}
+') . '
+
+' .
+ $contenu .
+ '';
+}
+
+function help_frame_body($titre, $aide, $html, $lang_aide='')
+{
+ global $spip_lang_rtl;
+ $dir = $spip_lang_rtl ? " dir='rtl'" : '';
+
+ return "\n
$titre\n".
+ '
\n".
+ "\n".
+ '".
+ help_body($aide) .
+ ($aide ? $html : '').
+ '';
+}
+
+function help_frame_frame($titre, $aide, $lang)
+{
+ global $spip_lang_rtl;
+ $menu = "
\n";
+ $body = "
\n";
+
+ $seq = $spip_lang_rtl ? "$body$menu" : "$menu$body";
+ $dim = $spip_lang_rtl ? '*,160' : '160,*';
+ return "\n
$titre\n\n
";
+}
+
+// http://doc.spip.org/@help_img_cache
+function help_img_cache($img, $ext)
+{
+ header("Content-Type: image/$ext");
+ header("Expires: ".gmdate("D, d M Y H:i:s", time()+24*3600) .' GMT');
+ readfile($img);
+}
+
+// Regexp reperant le travail fait par help_replace_img
+define('_HELP_PLACE_IMG',',^(\d+:)?(([^-.]*)-([^-.]*)-([^\.]*\.(gif|jpg|png)))$,');
+
+// Distinguer la demande d'une image et la demande d'un texte.
+// Si c'est une URL d'image deguisee, on la cherche dans le cache ou on l'y met.
+// Voir les differentes localisations possibles dans help_replace_img
+//
+// http://doc.spip.org/@exec_aide_index_dist
+function exec_aide_index_dist()
+{
+ global $help_server;
+ if (!is_array($help_server)) $help_server = array($help_server);
+ if (!preg_match(_HELP_PLACE_IMG, _request('img'), $r)) {
+ aide_index_frame(_request('var_lang_r'),
+ _request('lang_r'),
+ _request('frame'),
+ strtr(_request('aide'),'<>"\'', '____'),
+ $help_server);
+ } else {
+ list (,$server, $cache, $rep, $lang, $file, $ext) = $r;
+ if ($rep=="IMG" AND $lang=="cache"
+ AND @file_exists($img = _DIR_VAR.'cache-TeX/'.preg_replace(',^TeX-,', '', $file))) {
+ help_img_cache($img, $ext);
+ } else if (@file_exists($img = _DIR_AIDE . $cache)) {
+ help_img_cache($img, $ext);
+ } else if (@file_exists($img = _DIR_RACINE . 'AIDE/aide-'.$cache)) {
+ help_img_cache($img, $ext);
+ } else {
+ $server = intval(substr($server, 0, -1));
+ if ($server = $help_server[$server]) {
+ include_spip('inc/distant');
+ sous_repertoire(_DIR_AIDE,'','',true);
+ $img = "$server/$rep/$lang/$file";
+ $contenu = recuperer_page($img);
+ if ($contenu) {
+ ecrire_fichier (_DIR_AIDE . $cache, $contenu);
+ // Bug de certains OS:
+ // le contenu est incompris au premier envoi
+ // Donc ne pas mettre d'Expire
+ header("Content-Type: image/$ext");
+ echo $contenu;
+ } else redirige_par_entete($img);
+ } else redirige_par_entete(generer_url_public('404'));
+ }
+ }
+}
+
+// Determiner la langue L, et en deduire le Path du fichier d'aide.
+// Sur le site www.spip.net/, ca donne l'URL www.spip.net/L-aide.html
+// reecrit par le htacces suivant:
+// http://zone.spip.org/trac/spip-zone/browser/_galaxie_/www.spip.net/squelettes/htaccess.txt
+
+function aide_index_frame($var_lang_r, $lang_r, $frame, $aide, $help_server)
+{
+ global $spip_lang;
+
+ if ($var_lang_r)
+ changer_langue($lang = $var_lang_r);
+ if ($lang_r)
+ # pour le cas ou on a fait appel au menu de changement de langue
+ # (aide absente dans la langue x)
+ changer_langue($lang = $lang_r);
+ else $lang = $spip_lang;
+
+ // L'aide correspondant a la langue demandee est dans un cache
+ // reposant sur la date du fichier indiquant la version de SPIP
+ // (approximatif, mais c'est deja qqch)
+
+ $path = $spip_lang . "-aide.html";
+ $md5 = md5(serialize($help_server));
+ $fichier = _DIR_AIDE . substr($md5,0,16) . "-" . $path;
+ $lastm = is_readable($fichier) ? filemtime($fichier) : 0;
+ $lastversion = @filemtime(_DIR_RESTREINT . 'inc_version.php');
+ if (!($lastm AND ($lastm >= $lastversion))) {
+ $contenu = help_fichier_contenu($spip_lang, $path, $help_server);
+ // mettre en cache (tant pis si echec)
+ sous_repertoire(_DIR_AIDE,'','',true);
+ if ($contenu) ecrire_fichier ($fichier, $contenu);
+ $lastm = time();
+ }
+ $titre = _T('info_aide_en_ligne');
+ if (!$frame) {
+ echo _DOCTYPE_AIDE, html_lang_attributes();
+ echo help_frame_frame($titre, $aide, $lang);
+ echo "\n