diff --git a/ecrire/inc_lang.php3 b/ecrire/inc_lang.php3 index 2c00baef135efce4e4df43ea430de7808c1a9a99..255265d99f4a4fa6162a6c05f21a15657365cafd 100644 --- a/ecrire/inc_lang.php3 +++ b/ecrire/inc_lang.php3 @@ -392,15 +392,18 @@ function lang_dselect ($rien='') { // -// Afficher un menu de selection de langue / var_lang = langue interface privee, var_multi = langue de l'article -// -function menu_langues($nom_select = 'changer_lang', $default = '', $texte = '', $herit = '') { +// Afficher un menu de selection de langue +// - 'var_lang_ecrire' = langue interface privee, +// - 'var_lang' = langue de l'article, espace public +// - 'changer_lang' = langue de l'article, espace prive +// +function menu_langues($nom_select = 'var_lang', $default = '', $texte = '', $herit = '') { global $couleur_foncee, $couleur_claire, $flag_ecrire; if ($default == '') $default = $GLOBALS['spip_lang']; - if ($nom_select == 'changer_lang') + if ($nom_select == 'var_lang_ecrire') $langues = explode(',', $GLOBALS['all_langs']); else $langues = explode(',', lire_meta('langues_multilingue')); @@ -410,26 +413,39 @@ function menu_langues($nom_select = 'changer_lang', $default = '', $texte = '', if (!$couleur_foncee) $couleur_foncee = '#044476'; $lien = $GLOBALS['clean_link']; - if ($flag_ecrire) { - $lien = rawurlencode('ecrire/'.$lien->getUrl()); - $dir = '../'; + + if ($nom_select == 'changer_lang') { + $lien->delvar('changer_lang'); + $lien->delvar('url'); + $post = $lien->getUrl(); + $cible = ''; } else { - $lien = rawurlencode($lien->getUrl()); - $dir = ''; + if ($flag_ecrire) { + $cible = 'ecrire/'.$lien->getUrl(); + $post = '../spip_cookie.php3'; + } else { + $cible = $lien->getUrl(); + $post = 'spip_cookie.php3'; + } } - $ret = "<form action='${dir}spip_cookie.php3' method='post' style='margin:0px; padding:0px;'>"; - $ret .= "<input type='hidden' name='url' value='$lien'>"; - $ret .= $texte; + $ret = "<form action='$post' method='post' style='margin:0px; padding:0px;'>"; + if ($cible) + $ret .= "<input type='hidden' name='url' value='$cible'>"; + if ($texte) + $ret .= $texte; if (!$flag_ecrire) $style = "class='forml' style='vertical-align: top; margin-bottom: 5px; width: 120px;'"; - else if ($nom_select == 'changer_lang') + else if ($nom_select == 'var_lang_ecrire') $style = "class='verdana1' style='background-color: $couleur_claire; color: black;'"; else $style = "class='fondl'"; - $ret .= "\n<select name='$nom_select' $style onChange=\"document.location.href='${dir}spip_cookie.php3?url=$lien&$nom_select='+this.options[this.selectedIndex].value\">\n"; + $postcomplet = new Link($post); + if ($cible) $postcomplet->addvar('url', $cible); + + $ret .= "\n<select name='$nom_select' $style onChange=\"document.location.href='".$postcomplet->geturl()."&$nom_select='+this.options[this.selectedIndex].value\">\n"; sort($langues); while (list(, $l) = each ($langues)) { @@ -451,15 +467,6 @@ function menu_langues($nom_select = 'changer_lang', $default = '', $texte = '', return $ret; } -// menu dans l'espace public -function gerer_menu_langues() { - global $var_lang; - if ($var_lang) { - if (changer_langue($var_lang)) { - spip_setcookie('spip_lang_public', $var_lang, time() + 24 * 3600); - } - } -} // // Selection de langue haut niveau @@ -477,7 +484,7 @@ function utiliser_langue_visiteur() { if ($GLOBALS['auteur_session']['lang']) changer_langue($GLOBALS['auteur_session']['lang']); - if (!$flag_ecrire AND $cookie_lang = $HTTP_COOKIE_VARS['spip_lang']) + if ($cookie_lang = $HTTP_COOKIE_VARS['spip_lang']) changer_langue($cookie_lang); } diff --git a/ecrire/inc_presentation.php3 b/ecrire/inc_presentation.php3 index 2647b7810e6e28e11562664202dade3587f3797b..ec16017d651d3e04db314eeb89c31652b8e9ac67 100644 --- a/ecrire/inc_presentation.php3 +++ b/ecrire/inc_presentation.php3 @@ -1619,7 +1619,7 @@ function debut_page($titre = "", $rubrique = "asuivre", $sous_rubrique = "asuivr echo "<td> </td>"; echo "<td align='center'>"; - echo menu_langues(); + echo menu_langues('var_lang_ecrire'); echo "</td>"; } diff --git a/ecrire/install.php3 b/ecrire/install.php3 index f7978e7159719bc665dd2ce39623fa2a529b4188..4c84e9b6d047e042fefb092843ebe94a6d83ec98 100644 --- a/ecrire/install.php3 +++ b/ecrire/install.php3 @@ -4,7 +4,7 @@ include ("inc_version.php3"); include_ecrire ("inc_presentation.php3"); -gerer_menu_langues(); +utiliser_langue_visiteur(); if (@file_exists("inc_connect.php3")) { install_debut_html(); @@ -368,7 +368,7 @@ else if ($etape == 'dirs') { header("Location: ../spip_test_dirs.php3"); } else if (!$etape) { - $menu_langues = menu_langues(); + $menu_langues = menu_langues('var_lang_ecrire'); if (!$menu_langues) header("Location: ../spip_test_dirs.php3"); else { install_debut_html(); diff --git a/inc-calcul-squel.php3 b/inc-calcul-squel.php3 index aa8b1e40c70814daa2a210fe4569d71028b1097f..6364179c77b248c5d2d7b275578a954190baade4 100644 --- a/inc-calcul-squel.php3 +++ b/inc-calcul-squel.php3 @@ -1335,7 +1335,7 @@ function calculer_champ($id_champ, $id_boucle, $nom_var) $milieu = ' $'.$nom_var.' = "<"."?php include_ecrire(\"inc_lang.php3\"); - echo menu_langues(\"changer_lang\", \$menu_lang); + echo menu_langues(\"var_lang_ecrire\", \$menu_lang); ?".">"; '; diff --git a/spip_cookie.php3 b/spip_cookie.php3 index a4a86e4920a1d5046184688d2a290427a4070258..5304217016af2e2d12a7785eb8433290ef8ba91f 100644 --- a/spip_cookie.php3 +++ b/spip_cookie.php3 @@ -1,8 +1,6 @@ <?php include ("ecrire/inc_version.php3"); - -include_ecrire ("inc_meta.php3"); include_ecrire ("inc_session.php3"); // determiner ou l'on veut retomber @@ -186,18 +184,18 @@ if ($var_lang) { } // changer de langue espace prive (ou login) -if ($changer_lang) { +if ($var_lang_ecrire) { include_ecrire('inc_lang.php3'); include_ecrire("inc_session.php3"); verifier_visiteur(); - if (changer_langue($changer_lang)) { - spip_setcookie('spip_lang_ecrire', $changer_lang, time() + 365 * 24 * 3600); - spip_setcookie('spip_lang', $changer_lang, time() + 365 * 24 * 3600); + if (changer_langue($var_lang_ecrire)) { + spip_setcookie('spip_lang_ecrire', $var_lang_ecrire, time() + 365 * 24 * 3600); + spip_setcookie('spip_lang', $var_lang_ecrire, time() + 365 * 24 * 3600); - if ($changer_lang AND $auteur_session) { - spip_query ("UPDATE spip_auteurs SET lang = '".addslashes($changer_lang)."' WHERE id_auteur = ".$auteur_session['id_auteur']); - $auteur_session['lang'] = $changer_lang; + if ($var_lang_ecrire AND $auteur_session) { + spip_query ("UPDATE spip_auteurs SET lang = '".addslashes($var_lang_ecrire)."' WHERE id_auteur = ".$auteur_session['id_auteur']); + $auteur_session['lang'] = $var_lang_ecrire; ajouter_session($auteur_session, $spip_session); // enregistrer dans le fichier de session } } diff --git a/spip_test_dirs.php3 b/spip_test_dirs.php3 index 549bb931e9aa430d8d3f17cd5ca803f8dc4c4615..e9b16b49103a95af1f6b0b643b19b0a110c776b0 100644 --- a/spip_test_dirs.php3 +++ b/spip_test_dirs.php3 @@ -4,7 +4,7 @@ include("ecrire/inc_version.php3"); include_ecrire("inc_presentation.php3"); -gerer_menu_langues(); +utiliser_langue_visiteur(); function bad_dirs($bad_dirs, $test_dir, $install) { install_debut_html(); @@ -19,7 +19,7 @@ function bad_dirs($bad_dirs, $test_dir, $install) { if ($test_dir) $bad_url .= '?test_dir='.$test_dir; echo "<FONT FACE=\"Verdana,Arial,Helvetica,sans-serif\" SIZE=3>$titre</FONT>\n<p>"; - echo "<div align='right'>". menu_langues()."</div><p>"; + echo "<div align='right'>". menu_langues('var_lang_ecrire')."</div><p>"; echo _T('dirs_repertoires_suivants', array('bad_dirs' => $bad_dirs)); echo "<B>". _T('login_recharger')." $continuer."; @@ -46,7 +46,7 @@ function absent_dirs($bad_dirs, $test_dir) { if ($test_dir) $bad_url .= '?test_dir='.$test_dir; echo "<FONT FACE=\"Verdana,Arial,Helvetica,sans-serif\" SIZE=3>$titre</FONT>\n<p>"; - echo "<div align='right'>". menu_langues()."</div><p>"; + echo "<div align='right'>". menu_langues('var_lang_ecrire')."</div><p>"; echo _T('dirs_repertoires_absents', array('bad_dirs' => $bad_dirs)); echo "<B>". _T('login_recharger')." $continuer.";