CVS: spip/ecrire articles.php3, 1.140, 1.141 inc_lang.php3, 1.72, 1.73 inc_presentation.php3, 1.303, 1.304 naviguer.php3, 1.64, 1.65

Update of /home/spip-cvs/spip/ecrire
In directory miel:/tmp/cvs-serv4609

Modified Files:
  articles.php3 inc_lang.php3 inc_presentation.php3
  naviguer.php3
Log Message:
simplifie un peu l'usage de changer_typo()
[ NB: le plus difficile est de tester ! ]

Index: articles.php3

RCS file: /home/spip-cvs/spip/ecrire/articles.php3,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -d -r1.140 -r1.141
--- articles.php3 20 Sep 2003 12:38:29 -0000 1.140
+++ articles.php3 22 Sep 2003 21:13:12 -0000 1.141
@@ -21,9 +21,9 @@

     $langue_new = '';
     $result_lang_rub = spip_query("SELECT lang FROM spip_rubriques WHERE id_rubrique=$id_rubrique");
- if ($row = spip_fetch_array($result_lang_rub)) {
+ if ($row = spip_fetch_array($result_lang_rub))
       $langue_new = $row["lang"];
- }
+
     if (!$langue_new) $langue_new = lire_meta('langue_site');
     $langue_choisie_new = 'non';

@@ -136,19 +136,16 @@
}

-// appliquer la modification de langue
+// Appliquer la modification de langue
if (lire_meta('multi_articles') == 'oui' AND $flag_editable) {
   $row = spip_fetch_array(spip_query("SELECT lang FROM spip_rubriques WHERE id_rubrique=$rubrique_article"));
   $langue_parent = $row['lang'];

   if ($changer_lang) {
- if ($changer_lang != "herit") {
+ if ($changer_lang != "herit")
       spip_query("UPDATE spip_articles SET lang='".addslashes($changer_lang)."', langue_choisie='oui' WHERE id_article=$id_article");
- $langue_article = $changer_lang;
- } else {
+ else
       spip_query("UPDATE spip_articles SET lang='".addslashes($langue_parent)."', langue_choisie='non' WHERE id_article=$id_article");
- $langue_article = $langue_parent;
- }
   }
}

@@ -289,7 +286,6 @@
   $referers = $row["referers"];
   $extra = $row["extra"];
   $id_trad = $row["id_trad"];
- $langue_article = $row["lang"];
}

// pour l'affichage du virtuel
@@ -622,7 +618,7 @@
debut_droite();

-changer_typo($langue_article);
+changer_typo('','article'.$id_article);

// qu'est-ce que c'est que ces choses ??
@@ -1255,8 +1251,8 @@
     }

- if ($id_trad != 0) { // Afficher la liste des traductions
- //$query_trad = "SELECT id_article, titre, lang, statut FROM spip_articles WHERE id_trad = $id_trad AND id_article!=$id_article";
+ // Afficher la liste des traductions
+ if ($id_trad != 0) {
       $query_trad = "SELECT id_article, titre, lang, statut FROM spip_articles WHERE id_trad = $id_trad";
       $result_trad = spip_query($query_trad);

@@ -1312,10 +1308,9 @@

         $ret .= "<td class='arial2'>".traduire_nom_langue($lang_trad)."</td>\n";
       }
- changer_typo($langue_article);

+ // bloc traductions
       if ($ret) {
- //debut_cadre_enfonce("traductions-24.gif");
         echo "<div align='left' style='margin-top: 5px; padding: 0px; border: 1px dashed #999999; background-color: #f0f0f0;' $dir_lang>";
         echo "<table width='100%' cellspacing='0' border='0' cellpadding='3'>";
         echo "<tr bgcolor='#eeeecc'><td colspan='4'><font size=2 face='Georgia,Garamond,Times,serif'><b>"._T('trad_article_traduction')."</b></font></td></tr>";
@@ -1325,21 +1320,17 @@
         if ($flag_editable) {
           echo debut_block_invisible('ne_plus_lier');
           echo "<div style='width: 100%; padding-top: 1px; padding-bottom: 3px; padding-right: 3px; text-align=right;'>";
- //echo "<table width='100%'><tr width='100%'><td> &nbsp; </td><td align='right' width='180'>";
           $lien = $GLOBALS['clean_link'];
           $lien->delVar($nom_select);
           $lien = $lien->getUrl();
           echo "<a href='articles.php3?id_article=$id_article&supp_trad=oui' class='verdana1'>"._T('trad_delier')." <img src='img_pack/croix-rouge.gif' alt='X' width='7' height='7' border='0' align='middle'></a>";
- //icone_horizontale(_T('trad_delier'), "articles.php3?id_article=$id_article&supp_trad=oui", "traductions-24.gif", "supprimer.gif");
- //echo "</td></tr></table>";
           echo "</div>";
           echo fin_block();
         }
         echo "</div>";
-
-
- //fin_cadre_enfonce();
       }
+
+ changer_typo($langue_article);
     }

     echo debut_block_invisible('lier_traductions');

Index: inc_lang.php3

RCS file: /home/spip-cvs/spip/ecrire/inc_lang.php3,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- inc_lang.php3 14 Sep 2003 18:52:26 -0000 1.72
+++ inc_lang.php3 22 Sep 2003 21:13:12 -0000 1.73
@@ -334,15 +334,22 @@
}

// service pour que l'espace prive reflete la typo et la direction des objets affiches
-function changer_typo($lang = '') {
+function changer_typo($lang = '', $source = '') {
   global $lang_typo, $lang_dir, $dir_lang;

+ if (ereg("^(article|rubrique|breve|auteur)([0-9]+)", $source, $regs)) {
+ $r = spip_fetch_array(spip_query("SELECT lang FROM spip_".$regs[1]."s WHERE id_".$regs[1]."=".$regs[2]));
+ $lang = $r['lang'];
+ }
+
   if (!$lang)
     $lang = lire_meta('langue_site');

   $lang_typo = lang_typo($lang);
   $lang_dir = lang_dir($lang);
   $dir_lang = " dir='$lang_dir'";
+
+ spip_debug("typo '$source' *$lang $lang_typo $lang_dir");
}

// selectionner une langue

Index: inc_presentation.php3

RCS file: /home/spip-cvs/spip/ecrire/inc_presentation.php3,v
retrieving revision 1.303
retrieving revision 1.304
diff -u -d -r1.303 -r1.304
--- inc_presentation.php3 22 Sep 2003 17:41:32 -0000 1.303
+++ inc_presentation.php3 22 Sep 2003 21:13:12 -0000 1.304
@@ -389,7 +389,7 @@
       $date = $row['date'];
       $statut = $row['statut'];
       $visites = $row['visites'];
- $lang = $row['lang'];
+ if ($lang = $row['lang']) changer_typo($lang);
       $popularite = ceil(min(100,100 * $row['popularite'] / max(1, 0 + lire_meta('popularite_max'))));
       $descriptif = $row['descriptif'];
       if ($descriptif) $descriptif = ' title="'.attribut_html(typo($descriptif)).'"';
@@ -528,7 +528,7 @@
       $date_heure = $row['date_heure'];
       $titre = $row['titre'];
       $statut = $row['statut'];
- $lang = $row['lang'];
+ if ($lang = $row['lang']) changer_typo($lang);
       $id_rubrique = $row['id_rubrique'];
       switch ($statut) {
       case 'prop':
@@ -2030,7 +2030,8 @@
// Afficher la hierarchie des rubriques
//
function afficher_parents($id_rubrique) {
- global $parents, $couleur_foncee;
+ global $parents, $couleur_foncee, $lang_dir;
+
   $parents = ereg_replace("(~+)","\\1~",$parents);
   if ($id_rubrique) {
     $query = "SELECT id_rubrique, id_parent, titre, lang FROM spip_rubriques WHERE id_rubrique=$id_rubrique";
@@ -2042,7 +2043,7 @@
       $titre = $row['titre'];
       changer_typo($row['lang']);

- $parents = " <FONT SIZE=3 FACE='Verdana,Arial,Helvetica,sans-serif'><a href='naviguer.php3?coll=$id_rubrique'><font color='$couleur_foncee'>".typo($titre)."</font></a></FONT><BR>\n".$parents;
+ $parents = " <FONT SIZE=3 FACE='Verdana,Arial,Helvetica,sans-serif'><a href='naviguer.php3?coll=$id_rubrique'><font color='$couleur_foncee'><span dir='$lang_dir'>".typo($titre)."</span></font></a></FONT><BR>\n".$parents;
       if (acces_restreint_rubrique($id_rubrique))
         $parents = " <img src='img_pack/admin-12.gif' alt='' width='12' height='12' title='"._T('info_administrer_rubriques')."'> ".$parents;
       if (!$id_parent)

Index: naviguer.php3

RCS file: /home/spip-cvs/spip/ecrire/naviguer.php3,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- naviguer.php3 14 Sep 2003 23:12:27 -0000 1.64
+++ naviguer.php3 22 Sep 2003 21:13:12 -0000 1.65
@@ -11,7 +11,7 @@

function enfant($collection){
- global $les_enfants, $couleur_foncee;
+ global $les_enfants, $couleur_foncee, $lang_dir;
   $query2 = "SELECT * FROM spip_rubriques WHERE id_parent=\"$collection\" ORDER BY titre";
   $result2 = spip_query($query2);

@@ -19,15 +19,17 @@
     $id_rubrique=$row['id_rubrique'];
     $id_parent=$row['id_parent'];
     $titre=$row['titre'];
- $descriptif=propre($row['descriptif']);

     $bouton_layer = bouton_block_invisible("enfants$id_rubrique");
     $les_sous_enfants = sous_enfant($id_rubrique);

+ changer_typo($row['lang']);
+ $descriptif=propre($row['descriptif']);
+
     $les_enfants.= "<P>";
     if ($id_parent == "0") $les_enfants .= debut_cadre_relief("secteur-24.gif", true);
     else $les_enfants .= debut_cadre_relief("rubrique-24.gif", true);
- $les_enfants.= "<FONT FACE=\"Verdana,Arial,Helvetica,sans-serif\">";
+ $les_enfants.= "<span dir='$lang_dir'><FONT FACE=\"Verdana,Arial,Helvetica,sans-serif\">";

     if (strlen($les_sous_enfants) > 0){
       $les_enfants.= $bouton_layer;
@@ -39,7 +41,7 @@
     if (strlen($descriptif)>1)
       $les_enfants.="<BR><FONT SIZE=1>$descriptif</FONT>";

- $les_enfants.= "</FONT>";
+ $les_enfants.= "</FONT></span>";

     $les_enfants .= $les_sous_enfants;
     $les_enfants .= fin_cadre_relief(true);
@@ -47,6 +49,7 @@
}

function sous_enfant($collection2){
+ global $lang_dir;
   $query3 = "SELECT * FROM spip_rubriques WHERE id_parent=\"$collection2\" ORDER BY titre";
   $result3 = spip_query($query3);

@@ -56,8 +59,9 @@
       $id_rubrique2=$row['id_rubrique'];
       $id_parent2=$row['id_parent'];
       $titre2=$row['titre'];
-
- $retour.="<LI><A HREF='naviguer.php3?coll=$id_rubrique2'>$titre2</A>\n";
+ changer_typo($row['lang']);
+
+ $retour.="<LI><A HREF='naviguer.php3?coll=$id_rubrique2'><span dir='$lang_dir'>".typo($titre2)."</span></A>\n";
     }
     $retour .= "</FONT></ul>\n\n".fin_block()."\n\n";
   }
@@ -172,6 +176,23 @@
   }
}

+//
+// Appliquer le changement de langue
+//
+if ($changer_lang AND $coll>0 AND lire_meta('multi_rubriques') == 'oui' AND (lire_meta('multi_secteurs') == 'non' OR $id_parent == 0) AND $flag_editable) {
+ if ($changer_lang != "herit")
+ spip_query("UPDATE spip_rubriques SET lang='".addslashes($changer_lang)."', langue_choisie='oui' WHERE id_rubrique=$coll");
+ else {
+ if ($id_parent == 0)
+ $langue_parent = lire_meta('langue_site');
+ else {
+ $row = spip_fetch_array(spip_query("SELECT lang FROM spip_rubriques WHERE id_rubrique=$id_parent"));
+ $langue_parent = $row['lang'];
+ }
+ spip_query("UPDATE spip_rubriques SET lang='".addslashes($langue_parent)."', langue_choisie='non' WHERE id_rubrique=$coll");
+ }
+ calculer_langues_rubriques();
+}

//
// infos sur cette rubrique
@@ -248,6 +269,7 @@

fin_grand_cadre();

+changer_typo('', 'rubrique'.$coll);

debut_gauche();
@@ -377,20 +399,6 @@
// Langue de la rubrique
//
if ($coll>0 AND lire_meta('multi_rubriques') == 'oui' AND (lire_meta('multi_secteurs') == 'non' OR $id_parent == 0) AND $flag_editable) {
- if ($changer_lang) {
- if ($changer_lang != "herit") {
- spip_query("UPDATE spip_rubriques SET lang='".addslashes($changer_lang)."', langue_choisie='oui' WHERE id_rubrique=$coll");
- } else {
- if ($id_parent == 0) {
- $langue_parent = lire_meta('langue_site');
- } else {
- $row = spip_fetch_array(spip_query("SELECT lang FROM spip_rubriques WHERE id_rubrique=$id_parent"));
- $langue_parent = $row['lang'];
- }
- spip_query("UPDATE spip_rubriques SET lang='".addslashes($langue_parent)."', langue_choisie='non' WHERE id_rubrique=$coll");
- }
- calculer_langues_rubriques();
- }

   $row = spip_fetch_array(spip_query("SELECT lang, langue_choisie FROM spip_rubriques WHERE id_rubrique=$coll"));
   $langue_rubrique = $row['lang'];
@@ -400,14 +408,6 @@
     $langue_parent = $row[0];
   }
   else $langue_parent = lire_meta('langue_site');
-
-/* debut_cadre_enfonce("langues-24.gif");
- echo "<center><font face='Verdana,Arial,Helvetica,sans-serif' size='2'>";
- echo menu_langues('changer_lang', $langue_rubrique, _T('info_multi_cette_rubrique').' ', $langue_parent);
- echo "</font></center>\n";
- fin_cadre_enfonce();
-*/
-

   debut_cadre_enfonce('langues-24.gif');
   echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3 WIDTH=100% BACKGROUND=''><TR><TD BGCOLOR='#EEEECC'>";