[ Index ]
 

Code source de SPIP 1.9.2c

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/ecrire/exec/ -> auteurs.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/@exec_auteurs_dist
  18  function exec_auteurs_dist()
  19  {
  20  
  21      $tri = preg_replace('/\W/', '', _request('tri'));
  22      if (!$tri) $tri='nom'; 
  23      $statut = preg_replace('/\W/', '', _request('statut'));
  24  
  25      $result = requete_auteurs($tri, $statut);
  26      $nombre_auteurs = spip_num_rows($result);
  27      $max_par_page = 30;
  28      $debut = intval(_request('debut'));
  29      if ($debut > $nombre_auteurs - $max_par_page)
  30          $debut = max(0,$nombre_auteurs - $max_par_page);
  31  
  32      list($auteurs, $lettre)= lettres_d_auteurs($result, $debut, $max_par_page, $tri);
  33  
  34      $res = auteurs_tranches(afficher_n_auteurs($auteurs), $debut, $lettre, $tri, $statut, $max_par_page, $nombre_auteurs);
  35  
  36      if (_request('var_ajaxcharset'))
  37        ajax_retour($res);
  38      else {
  39  
  40          pipeline('exec_init',array('args'=>array('exec'=>'auteurs'),'data'=>''));
  41  
  42          bandeau_auteurs($tri, $statut);
  43  
  44          echo "<div id='auteurs'>", $res, "</div>";
  45          echo pipeline('affiche_milieu',array('args'=>array('exec'=>'auteurs'),'data'=>''));
  46          echo fin_gauche(), fin_page();
  47      }
  48  }
  49  
  50  // http://doc.spip.org/@lettres_d_auteurs
  51  function lettres_d_auteurs($query, $debut, $max_par_page, $tri)
  52  {
  53      $auteurs = $lettre = array();
  54      $lettres_nombre_auteurs =0;
  55      $lettre_prec ="";
  56      $i = 0;
  57      while ($auteur = spip_fetch_array($query)) {
  58          if ($i>=$debut AND $i<$debut+$max_par_page) {
  59              if ($auteur['statut'] == '0minirezo')
  60                  $auteur['restreint'] = spip_num_rows(spip_query("SELECT id_auteur FROM spip_auteurs_rubriques WHERE id_auteur=".$auteur['id_auteur']));
  61              $auteurs[] = $auteur;
  62          }
  63          $i++;
  64  
  65          if ($tri == 'nom') {
  66              $premiere_lettre = strtoupper(spip_substr(extraire_multi($auteur['nom']),0,1));
  67              if ($premiere_lettre != $lettre_prec) {
  68                  $lettre[$premiere_lettre] = $lettres_nombre_auteurs;
  69              }
  70              $lettres_nombre_auteurs ++;
  71              $lettre_prec = $premiere_lettre;
  72          }
  73      }
  74  
  75      return array($auteurs, $lettre);
  76  }
  77  
  78  
  79  // http://doc.spip.org/@bandeau_auteurs
  80  function bandeau_auteurs($tri, $statut)
  81  {
  82      global $options, $spip_lang_right, $connect_id_auteur,   $connect_statut,   $connect_toutes_rubriques;
  83  
  84      if ($tri=='nom') $s = ' (' . _T('info_par_nom') . ')';
  85      elseif ($tri=='statut') $s = ' (' . _T('info_par_statut') . ')';
  86      elseif ($tri=='nombre') $s = ' (' . _T('info_par_nombre_articles') . ')';
  87      else $s = ''; 
  88  
  89      if ($statut == '6forum') {
  90          $commencer_page = charger_fonction('commencer_page', 'inc');
  91          echo $commencer_page(_T('titre_page_auteurs'),"auteurs","redacteurs");
  92      } else {
  93          $commencer_page = charger_fonction('commencer_page', 'inc');
  94          echo $commencer_page(_T('info_auteurs_par_tri', array('partri' => $s)),"auteurs","redacteurs");
  95      }
  96      debut_gauche();
  97  
  98      debut_boite_info();
  99      if ($statut == '6forum') 
 100          echo "\n<p class='arial1'>"._T('info_gauche_visiteurs_enregistres'), '</p>';
 101      else 
 102          echo "\n<p class='arial1'>"._T('info_gauche_auteurs'), '</p>';
 103  
 104      if ($connect_statut == '0minirezo')
 105          echo "\n<br />". _T('info_gauche_auteurs_exterieurs');
 106  
 107      fin_boite_info();
 108  
 109      echo pipeline('affiche_gauche',array('args'=>array('exec'=>'auteurs'),'data'=>''));
 110  
 111      if ($connect_statut == '0minirezo') {
 112  
 113          if ($connect_toutes_rubriques) 
 114              $res = icone_horizontale(_T('icone_creer_nouvel_auteur'), generer_url_ecrire("auteur_infos", 'new=oui'), "auteur-24.gif", "creer.gif", false);
 115          else $res = '';
 116  
 117          $res .= icone_horizontale(_T('icone_informations_personnelles'), generer_url_ecrire("auteur_infos","id_auteur=$connect_id_auteur"), "fiche-perso-24.gif","rien.gif", false);
 118  
 119          $n = spip_num_rows(spip_query("SELECT id_auteur FROM spip_auteurs WHERE statut='6forum' LIMIT 1"));
 120          if ($n) {
 121              if ($statut == '6forum')
 122                  $res .= icone_horizontale (_T('icone_afficher_auteurs'), generer_url_ecrire("auteurs"), "auteur-24.gif", "", false);
 123              else
 124                  $res .= icone_horizontale (_T('icone_afficher_visiteurs'), generer_url_ecrire("auteurs","statut=6forum"), "auteur-24.gif", "", false);
 125          }
 126          echo bloc_des_raccourcis($res);
 127      }
 128      creer_colonne_droite();
 129      echo pipeline('affiche_droite',array('args'=>array('exec'=>'auteurs'),'data'=>''));
 130      debut_droite();
 131  
 132      echo "\n<br />";
 133      if ($statut == '6forum') 
 134          gros_titre(_T('info_visiteurs'));
 135      else
 136          gros_titre(_T('info_auteurs'));
 137      echo "\n<br />";
 138  }
 139  
 140  // http://doc.spip.org/@auteurs_tranches
 141  function auteurs_tranches($auteurs, $debut, $lettre, $tri, $statut, $max_par_page, $nombre_auteurs)
 142  {
 143      global $options, $spip_lang_right;
 144  
 145      $res ="\n<tr style='background-color: #dbe1c5'>"
 146      . "\n<td style='width: 20px'>";
 147  
 148      if ($tri=='statut')
 149            $res .= http_img_pack('admin-12.gif','', " class='lang'");
 150      else {
 151        $t =  _T('lien_trier_statut');
 152        $res .= auteurs_href(http_img_pack('admin-12.gif', $t, "class='lang'"),'tri=statut', " title=\"$t\"");
 153      }
 154  
 155      $res .= "</td><td style='width: 20px'></td><td colspan='2'>";
 156  
 157      if ($tri == '' OR $tri=='nom')
 158          $res .= '<b>'._T('info_nom').'</b>';
 159      else
 160          $res .= auteurs_href(_T('info_nom'), "tri=nom", " title='"._T('lien_trier_nom'). "'");
 161  
 162  
 163      $res .= "</td><td>";
 164  
 165      if ($statut != '6forum') {
 166          if ($tri=='nombre')
 167              $res .= '<b>'._T('info_articles').'</b>';
 168          else
 169              $res .= auteurs_href(_T('info_articles_2'), "tri=nombre", " title=\""._T('lien_trier_nombre_articles'). '"');
 170      }
 171  
 172      $res .= "</td></tr>\n";
 173  
 174      if ($nombre_auteurs > $max_par_page) {
 175          $res .= "\n<tr style='background-color: white'><td class='arial1' colspan='5'>";
 176  
 177          for ($j=0; $j < $nombre_auteurs; $j+=$max_par_page) {
 178              if ($j > 0)     $res .= " | ";
 179  
 180              if ($j == $debut)
 181                  $res .= "<b>$j</b>";
 182              else if ($j > 0)
 183                  $res .= auteurs_href($j, "tri=$tri&statut=$statut&debut=$j");
 184              else
 185                  $res .= auteurs_href('0', "tri=$tri&statut=$statut");
 186              if ($debut > $j  AND $debut < $j+$max_par_page){
 187                  $res .= " | <b>$debut</b>";
 188              }
 189          }
 190          $res .= "</td></tr>\n";
 191  
 192          if ($tri == 'nom' AND $options == 'avancees') {
 193              $res .= "\n<tr style='background-color: white'><td class='arial11' colspan='5'>";
 194              foreach ($lettre as $key => $val) {
 195                  if ($val == $debut)
 196                      $res .= "<b>$key</b>\n";
 197                  else
 198                      $res .= auteurs_href($key, "tri=$tri&statut=$statut&debut=$val") . "\n";
 199              }
 200              $res .= "</td></tr>\n";
 201          }
 202      }
 203  
 204      $nav = '';
 205      $debut_suivant = $debut + $max_par_page;
 206      if ($debut_suivant < $nombre_auteurs OR $debut > 0) {
 207          $nav = "\n<table id='bas' style='width: 100%' border='0'>"
 208          . "\n<tr style='background-color: white'><td align='left'>";
 209  
 210          if ($debut > 0) {
 211              $debut_prec = max($debut - $max_par_page, 0);
 212              $nav .= auteurs_href('&lt;&lt;&lt;',"tri=$tri&debut=$debut_prec&statut=$statut");
 213          }
 214          $nav .= "</td><td style='text-align: $spip_lang_right'>";
 215          if ($debut_suivant < $nombre_auteurs) {
 216              $nav .= auteurs_href('&gt;&gt;&gt;',"tri=$tri&debut=$debut_suivant&statut=$statut");
 217          }
 218          $nav .= "</td></tr></table>\n";
 219      }
 220  
 221      return     debut_cadre_relief('auteur-24.gif',true)
 222      . "\n<table  class='arial2' border='0' cellpadding='2' cellspacing='0' style='width: 100%; border: 1px solid #aaaaaa;'>\n"
 223      . $res
 224      . $auteurs
 225      . "</table>\n<br />"
 226      .  $nav
 227      . fin_cadre_relief(true);
 228  }
 229  
 230  // http://doc.spip.org/@auteurs_href
 231  function auteurs_href($clic, $args='', $att='')
 232  {
 233      $h = generer_url_ecrire('auteurs', $args);
 234      $a = 'auteurs';
 235  
 236      if (_SPIP_AJAX === 1 )
 237          $att .= ("\nonclick=" . ajax_action_declencheur($h,$a));
 238  
 239      return "<a href='$h#$a'$att>$clic</a>";
 240  }
 241  
 242  // http://doc.spip.org/@requete_auteurs
 243  function requete_auteurs($tri, $statut)
 244  {
 245    global $connect_statut, $spip_lang, $connect_id_auteur;
 246  
 247  //
 248  // Construire la requete
 249  //
 250  
 251  // si on n'est pas minirezo, ignorer les auteurs sans article publie
 252  // sauf les admins, toujours visibles.
 253  // limiter les statuts affiches
 254  if ($connect_statut == '0minirezo') {
 255      if ($statut) {
 256          $sql_visible = "aut.statut IN ('$statut')";
 257          $tri = 'nom';
 258      } else {
 259          $sql_visible = "aut.statut IN ('0minirezo','1comite','5poubelle')";
 260      }
 261  } else {
 262      $sql_visible = "(
 263          aut.statut = '0minirezo'
 264          OR art.statut IN ('prop', 'publie')
 265          OR aut.id_auteur=$connect_id_auteur
 266      )";
 267  }
 268  
 269  $sql_sel = '';
 270  
 271  // tri
 272  switch ($tri) {
 273  case 'nombre':
 274      $sql_order = ' compteur DESC, unom';
 275      break;
 276  
 277  case 'statut':
 278      $sql_order = ' statut, unom';
 279      break;
 280  
 281  case 'nom':
 282  default:
 283      $sql_sel = ", ".creer_objet_multi ("nom", $spip_lang);
 284      $sql_order = " multi";
 285  }
 286  
 287  
 288  
 289  //
 290  // La requete de base est tres sympa
 291  //
 292  
 293   $row = spip_query("SELECT                            aut.id_auteur AS id_auteur,                            aut.statut AS statut,                                aut.nom AS nom,                                UPPER(aut.nom) AS unom,                            count(lien.id_article) as compteur                        $sql_sel                                    FROM spip_auteurs as aut                            LEFT JOIN spip_auteurs_articles AS lien ON aut.id_auteur=lien.id_auteur    LEFT JOIN spip_articles AS art ON (lien.id_article = art.id_article)        WHERE    $sql_visible                                GROUP BY aut.id_auteur     ORDER BY        $sql_order");
 294   return $row;
 295  }
 296  
 297  // http://doc.spip.org/@afficher_n_auteurs
 298  function afficher_n_auteurs($auteurs) {
 299      global $connect_statut, $options;
 300  
 301      $res = '';
 302      $formater_auteur = charger_fonction('formater_auteur', 'inc');
 303      foreach ($auteurs as $row) {
 304  
 305          list($s, $mail, $nom, $w, $p) = $formater_auteur($row['id_auteur']);
 306          $res .= "\n<tr style='background-color: #eeeeee;'>"
 307          . "\n<td style='border-top: 1px solid #cccccc;'>"
 308          . $s
 309          . "</td><td class='arial1' style='border-top: 1px solid #cccccc;'>"
 310          . $mail
 311          . "</td><td class='verdana1' style='border-top: 1px solid #cccccc;'>"
 312          . $nom
 313          . ((isset($row['restreint']) AND $row['restreint'])
 314             ? (" &nbsp;<small>"._T('statut_admin_restreint')."</small>")
 315             : '')
 316           ."</td><td class='arial1' style='border-top: 1px solid #cccccc;'>"
 317           . $w
 318           . "</td><td class='arial1' style='border-top: 1px solid #cccccc;'>"
 319           . $p
 320          .  "</td></tr>\n";
 321      }
 322      return $res;
 323  }
 324  ?>


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