[SPIP] ~v3.0.20-->v3.0.25
[lhc/web/clavette_www.git] / www / ecrire / balise / menu_lang_ecrire.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2016 *
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 if (!defined('_ECRIRE_INC_VERSION')) return;
14
15 // #MENU_LANG_ECRIRE affiche le menu des langues de l'espace privé
16 // et preselectionne celle la globale $lang
17 // ou de l'arguemnt fourni: #MENU_LANG_ECRIRE{#ENV{malangue}}
18
19 // http://doc.spip.org/@balise_MENU_LANG_ECRIRE
20 function balise_MENU_LANG_ECRIRE ($p) {
21 return calculer_balise_dynamique($p,'MENU_LANG_ECRIRE', array('lang'));
22 }
23
24 // s'il n'y a qu'une langue proposee eviter definitivement la balise ?php
25 // http://doc.spip.org/@balise_MENU_LANG_ECRIRE_stat
26 function balise_MENU_LANG_ECRIRE_stat ($args, $context_compil) {
27 include_spip('inc/lang');
28 if (strpos($GLOBALS['meta']['langues_proposees'],',') === false) return '';
29 return $args;
30 }
31
32 // normalement $opt sera toujours non vide suite au test ci-dessus
33 // http://doc.spip.org/@balise_MENU_LANG_ECRIRE_dyn
34 function balise_MENU_LANG_ECRIRE_dyn($opt) {
35 return menu_lang_pour_tous('var_lang_ecrire', $opt);
36 }
37
38 // http://doc.spip.org/@menu_lang_pour_tous
39 function menu_lang_pour_tous($nom, $default) {
40 include_spip('inc/lang');
41
42 if ($GLOBALS['spip_lang'] <> $default) {
43 $opt = lang_select($default); # et remplace
44 if ($GLOBALS['spip_lang'] <> $default) {
45 $default = ''; # annule tout choix par defaut
46 if ($opt) lang_select();
47 }
48 }
49
50 # lien a partir de /
51 $cible = parametre_url(self(), 'lang' , '', '&');
52 $post = generer_url_action('converser', 'redirect='. rawurlencode($cible), '&');
53
54 return array('formulaires/menu_lang',
55 3600,
56 array('nom' => $nom,
57 'url' => $post,
58 'name' => $nom,
59 'default' => $default,
60 )
61 );
62 }
63
64 ?>