From f745aad3db0292d9918f373c878a3fff6ba4317d Mon Sep 17 00:00:00 2001 From: Fil <fil@rezo.net> Date: Wed, 28 Apr 2004 23:49:13 +0000 Subject: [PATCH] =?UTF-8?q?oh=20l=C3=A0=20l=C3=A0,=20j'avais=20oubli=C3=A9?= =?UTF-8?q?=20pas=20mal=20de=20d=C3=A9tails,=20et=20m=C3=A9lang=C3=A9=20de?= =?UTF-8?q?ux=20variables=20:(?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bon, là ça devrait coller. --- ecrire/inc_lang.php3 | 55 ++++++++++++++++++++---------------- ecrire/inc_presentation.php3 | 2 +- ecrire/install.php3 | 4 +-- inc-calcul-squel.php3 | 2 +- spip_cookie.php3 | 16 +++++------ spip_test_dirs.php3 | 6 ++-- 6 files changed, 45 insertions(+), 40 deletions(-) diff --git a/ecrire/inc_lang.php3 b/ecrire/inc_lang.php3 index 2c00baef13..255265d99f 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 2647b7810e..ec16017d65 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 f7978e7159..4c84e9b6d0 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 aa8b1e40c7..6364179c77 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 a4a86e4920..5304217016 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 549bb931e9..e9b16b4910 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."; -- GitLab