[SPIP] +2.1.12
[velocampus/web/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-2011 *
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
22 return calculer_balise_dynamique($p,'MENU_LANG_ECRIRE', array('lang'));
23 }
24
25 // s'il n'y a qu'une langue proposee eviter definitivement la balise ?php
26 // http://doc.spip.org/@balise_MENU_LANG_ECRIRE_stat
27 function balise_MENU_LANG_ECRIRE_stat ($args, $context_compil) {
28 include_spip('inc/lang');
29 if (strpos($GLOBALS['meta']['langues_proposees'],',') === false) return '';
30 return $args;
31 }
32
33 // normalement $opt sera toujours non vide suite au test ci-dessus
34 // http://doc.spip.org/@balise_MENU_LANG_ECRIRE_dyn
35 function balise_MENU_LANG_ECRIRE_dyn($opt) {
36 return menu_lang_pour_tous('var_lang_ecrire', $opt);
37 }
38
39 // http://doc.spip.org/@menu_lang_pour_tous
40 function menu_lang_pour_tous($nom, $default) {
41 include_spip('inc/lang');
42
43 if ($GLOBALS['spip_lang'] <> $default) {
44 $opt = lang_select($default); # et remplace
45 if ($GLOBALS['spip_lang'] <> $default) {
46 $default = ''; # annule tout choix par defaut
47 if ($opt) lang_select();
48 }
49 }
50
51 $opt = liste_options_langues($nom, $default);
52 if (!$opt)
53 return '';
54
55 # lien a partir de /
56 $cible = parametre_url(self(), 'lang' , '', '&');
57 $post = generer_url_action('converser', 'redirect='. rawurlencode($cible), '&');
58
59 return array('formulaires/menu_lang',
60 3600,
61 array('nom' => $nom,
62 'url' => $post,
63 'langues' => $opt
64 )
65 );
66 }
67
68 ?>