[ Index ]
 

Code source de SPIP 1.9.2c

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/ecrire/inc/ -> referencer_traduction.php (source)

   1  <?php
   2  
   3  /***************************************************************************\
   4   *  SPIP, Systeme de publication pour l'internet                           *
   5   *                                                                         *
   6   *  Copyright (c) 2001-2007                                                *
   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  include_spip('inc/presentation');
  16  
  17  // http://doc.spip.org/@inc_referencer_traduction_dist
  18  function inc_referencer_traduction_dist($id_article, $flag, $id_rubrique, $id_trad, $trad_err='')
  19  {
  20      global $connect_statut, $couleur_claire, $options, $connect_toutes_rubriques, $spip_lang_right, $spip_display, $dir_lang;
  21  
  22      if (! (($GLOBALS['meta']['multi_articles'] == 'oui')
  23          OR (($GLOBALS['meta']['multi_rubriques'] == 'oui') 
  24              AND ($GLOBALS['meta']['gerer_trad'] == 'oui'))) )
  25          return '';
  26  
  27      $langue_article = spip_fetch_array(spip_query("SELECT lang FROM spip_articles WHERE id_article=$id_article"));
  28  
  29      $langue_article = $langue_article['lang'];
  30  
  31      $reponse = '';
  32      // Choix langue article
  33      if ($GLOBALS['meta']['multi_articles'] == 'oui' AND $flag) {
  34  
  35          $row = spip_fetch_array(spip_query("SELECT lang FROM spip_rubriques WHERE id_rubrique=$id_rubrique"));
  36          $langue_parent = $row['lang'];
  37  
  38          if (!$langue_parent)
  39              $langue_parent = $GLOBALS['meta']['langue_site'];
  40          if (!$langue_article)
  41              $langue_article = $langue_parent;
  42  
  43          if ($menu = menu_langues('changer_lang', $langue_article, _T('info_multi_cet_article').' ', $langue_parent, 'ajax')) {
  44              $menu = ajax_action_post('referencer_traduction', "$id_article,$id_rubrique","articles","id_article=$id_article", $menu, _T('bouton_changer'), " class='visible_au_chargement fondo'");
  45  
  46              $reponse .= debut_cadre_couleur('',true)
  47              . "\n<div style='text-align: center;'>"
  48              . $menu
  49              . "</div>\n"
  50              . fin_cadre_couleur(true);
  51          }
  52      }
  53  
  54      if ($trad_err)
  55          $reponse .= "<div><span style='color: red' size='2' face='verdana,arial,helvetica,sans-serif'>"._T('trad_deja_traduit'). "</span></div>";
  56  
  57          // Afficher la liste des traductions
  58      $table = !$id_trad ? array() : articles_traduction($id_article, $id_trad);
  59  
  60          // bloc traductions
  61      if (count($table) > 0) {
  62  
  63          $largeurs = array(7, 12, '', 100);
  64          $styles = array('', '', 'arial2', 'arial2');
  65  
  66          $t = afficher_liste($largeurs, $table, $styles);
  67          if ($spip_display != 4)
  68            $t = "\n<table width='100%' cellpadding='2' cellspacing='0' border='0'>"
  69              . $t
  70              . "</table>\n";
  71  
  72          $liste = "\n<div class='liste'>"
  73          . bandeau_titre_boite2( '<b>' . _T('trad_article_traduction') . '</b>','', 'white', 'black', false)
  74          . $t
  75          . "</div>";
  76      } else $liste = '';
  77  
  78      // changer les globales $dir_lang etc
  79      changer_typo($langue_article);
  80  
  81      // Participation aux Traductions pas pour Mal-voyant. A completer
  82      if ($spip_display == 4) $form =''; else {
  83      $form = "<table width='100%'><tr>";
  84  
  85      if ($flag AND $options == "avancees" AND !$table) {
  86              // Formulaire pour lier a un article
  87          $form .= "<td style='width: 60%' class='arial2'>"
  88          . ajax_action_post("referencer_traduction",
  89                  $id_article,
  90                  'articles',
  91                  "id_article=$id_article",
  92                  (_T('trad_lier') .
  93                   "\n<input type='text' class='fondl' name='lier_trad' size='5' />\n"),
  94                  _T('bouton_valider'),
  95                  " class='fondl'")
  96          . "</td>\n"
  97          . "<td style='width: 10px'> &nbsp; </td>"
  98          . "<td style='width: 2px; background: url(" . _DIR_IMG_PACK . "tirets-separation.gif)'>". http_img_pack('rien.gif', " ", "width='2' height='2'") . "</td>"
  99          . "<td style='width: 10px'> &nbsp; </td>";
 100      }
 101  
 102      $form .= "<td>"
 103      . icone_horizontale(_T('trad_new'), generer_url_ecrire("articles_edit","new=oui&lier_trad=$id_article&id_rubrique=$id_rubrique"), "traductions-24.gif", "creer.gif", false)
 104      . "</td>";
 105  
 106      if ($flag AND $options == "avancees" AND $table) {
 107          $clic = _T('trad_delier');
 108          $form .= "<td style='width: 10px'> &nbsp; </td>"
 109          . "<td style='width: 2px; background: url(" . _DIR_IMG_PACK . "tirets-separation.gif)'>". http_img_pack('rien.gif', " ", "width='2' height='2'") . "</td>"
 110          . "<td style='width: 10px'> &nbsp; </td>"
 111          . "<td>"
 112            // la 1ere occurrence de clic ne sert pas en Ajax
 113          . icone_horizontale($clic, ajax_action_auteur("referencer_traduction","$id_article,-$id_trad",'articles', "id_article=$id_article",array($clic)), "traductions-24.gif", "supprimer.gif", false)
 114          . "</td>\n";
 115      }
 116  
 117      $form .= "</tr></table>";
 118      }
 119      if ($GLOBALS['meta']['gerer_trad'] == 'oui')
 120          $bouton = _T('titre_langue_trad_article');
 121      else
 122          $bouton = _T('titre_langue_article');
 123  
 124      if ($langue_article)
 125          $bouton .= "&nbsp; (".traduire_nom_langue($langue_article).")";
 126  
 127      if ($flag === 'ajax')
 128          $res = debut_cadre_enfonce('langues-24.gif', true, "", 
 129                  bouton_block_visible('languearticle,lier_traductions')
 130                  . $bouton)
 131              . debut_block_visible('languearticle')
 132              . $reponse
 133              . fin_block()
 134              . $liste
 135              . debut_block_visible('lier_traductions')
 136              . $form
 137              . fin_block()
 138              . fin_cadre_enfonce(true);
 139      else $res =  debut_cadre_enfonce('langues-24.gif', true, "",
 140                  bouton_block_invisible('languearticle,lier_traductions')
 141                  . $bouton)
 142              . debut_block_invisible('languearticle')
 143              . $reponse
 144              . fin_block()
 145              . $liste
 146              . debut_block_invisible('lier_traductions')
 147              . $form
 148              . fin_block()
 149              . fin_cadre_enfonce(true);
 150      return ajax_action_greffe("referencer_traduction-$id_article", $res);
 151  }
 152  
 153  
 154  // http://doc.spip.org/@articles_traduction
 155  function articles_traduction($id_article, $id_trad)
 156  {
 157      global $connect_toutes_rubriques, $dir_lang;
 158  
 159      $result_trad = spip_query("SELECT id_article, id_rubrique, titre, lang, statut FROM spip_articles WHERE id_trad = $id_trad");
 160      
 161      $table= array();
 162  
 163      while ($row = spip_fetch_array($result_trad)) {
 164          $vals = array();
 165          $id_article_trad = $row["id_article"];
 166          $id_rubrique_trad = $row["id_rubrique"];
 167          $titre_trad = $row["titre"];
 168          $lang_trad = $row["lang"];
 169          $statut_trad = $row["statut"];
 170  
 171          changer_typo($lang_trad);
 172          $titre_trad = "<span $dir_lang>$titre_trad</span>";
 173  
 174          $vals[] = http_img_pack("puce-".puce_statut($statut_trad).'.gif', "", " class='puce'");
 175          
 176          if ($id_article_trad == $id_trad) {
 177              $vals[] = http_img_pack('langues-12.gif', "", " class='lang'");
 178              $titre_trad = "<b>$titre_trad</b>";
 179          } else {
 180            if (!$connect_toutes_rubriques)
 181              $vals[] = http_img_pack('langues-off-12.gif', "", " class='lang'");
 182            else 
 183              $vals[] = ajax_action_auteur("referencer_traduction", "$id_article,$id_trad,$id_article_trad", 'articles', "id_article=$id_article", array(http_img_pack('langues-off-12.gif', _T('trad_reference'), "class='lang'"), ' title="' . _T('trad_reference') . '"'));
 184          }
 185  
 186          $s = typo($titre_trad);
 187          if ($id_article_trad != $id_article) 
 188              $s = "<a href='" . generer_url_ecrire("articles","id_article=$id_article_trad") . "'>$s</a>";
 189          if ($id_article_trad == $id_trad)
 190              $s .= " "._T('trad_reference');
 191  
 192          $vals[] = $s;
 193          $vals[] = traduire_nom_langue($lang_trad);
 194          $table[] = $vals;
 195      }
 196  
 197      return $table;
 198  }
 199  ?>


Généré le : Wed Nov 21 10:20:27 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics