[ Index ] |
|
Code source de SPIP 1.9.2c |
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 include_spip('inc/actions'); 17 include_spip('base/abstract_sql'); 18 19 // http://doc.spip.org/@inc_grouper_mots_dist 20 function inc_grouper_mots_dist($id_groupe, $cpt) { 21 global $connect_statut, $spip_lang_right, $spip_lang; 22 23 // ceci sert a la fois: 24 // - a construire le nom du parametre d'URL indiquant la tranche 25 // - a donner un ID a la balise ou greffer le retour d'Ajax 26 // tant pour la prochaine tranche que pour le retrait de mot 27 $tmp_var = "editer_mot-$id_groupe"; 28 29 $nb_aff = floor(1.5 * _TRANCHES); 30 31 if ($cpt > $nb_aff) { 32 $nb_aff = _TRANCHES; 33 $tranches = afficher_tranches_requete($cpt, $tmp_var, generer_url_ecrire('grouper_mots',"id_groupe=$id_groupe"), $nb_aff); 34 } else $tranches = ''; 35 36 37 $deb_aff = _request($tmp_var); 38 $deb_aff = ($deb_aff !== NULL ? intval($deb_aff) : 0); 39 $select = 'id_mot, id_groupe, titre, descriptif,' 40 . creer_objet_multi ("titre", $spip_lang); 41 42 $result = spip_query($q="SELECT $select FROM spip_mots WHERE id_groupe=$id_groupe ORDER BY multi" . (($deb_aff < 0) ? '' : " LIMIT $deb_aff, $nb_aff")); 43 44 $table = array(); 45 $occurrences = calculer_liens_mots($id_groupe); 46 while ($row = spip_fetch_array($result)) { 47 $table[] = afficher_groupe_mots_boucle($row, $occurrences, $cpt); 48 } 49 50 if ($connect_statut=="0minirezo") { 51 $largeurs = array('', 100, 130); 52 $styles = array('arial11', 'arial1', 'arial1'); 53 } 54 else { 55 $largeurs = array('', 100); 56 $styles = array('arial11', 'arial1'); 57 } 58 59 return http_img_pack("searching.gif", "*", "style='visibility: hidden; position: absolute; $spip_lang_right: 0px; top: -20px;' id='img_$tmp_var'") 60 . "<div class='liste'>" 61 . $tranches 62 . "<table border='0' cellspacing='0' cellpadding='3' width='100%'>" 63 . afficher_liste($largeurs, $table, $styles) 64 . "</table>" 65 . "</div>"; 66 } 67 68 // http://doc.spip.org/@afficher_groupe_mots_boucle 69 function afficher_groupe_mots_boucle($row, $occurrences, $total) 70 { 71 global $connect_statut; 72 73 $id_mot = $row['id_mot']; 74 $id_groupe = $row['id_groupe']; 75 $titre = typo($row['titre']); 76 $descriptif = entites_html($row['descriptif']); 77 78 if ($connect_statut == "0minirezo" OR $occurrences['articles'][$id_mot] > 0) { 79 $h = generer_url_ecrire('mots_edit', "id_mot=$id_mot&redirect=" . generer_url_retour('mots_tous') . "#editer_mot-$id_groupe"); 80 if ($descriptif) $descriptif = " title=\"$descriptif\""; 81 $titre = "<a href='$h' class='liste-mot'$descriptif>$titre</a>"; 82 } 83 $vals = array($titre); 84 85 $texte_lie = array(); 86 87 $na = isset($occurrences['articles'][$id_mot]) ? $occurrences['articles'][$id_mot] : 0; 88 if ($na == 1) 89 $texte_lie[] = _T('info_1_article'); 90 else if ($na > 1) 91 $texte_lie[] = $na." "._T('info_articles_02'); 92 93 $nb = isset($occurrences['breves'][$id_mot]) ? $occurrences['breves'][$id_mot] : 0; 94 if ($nb == 1) 95 $texte_lie[] = _T('info_1_breve'); 96 else if ($nb > 1) 97 $texte_lie[] = $nb." "._T('info_breves_03'); 98 99 $ns = isset($occurrences['sites'][$id_mot]) ? $occurrences['sites'][$id_mot] : 0; 100 if ($ns == 1) 101 $texte_lie[] = _T('info_1_site'); 102 else if ($ns > 1) 103 $texte_lie[] = $ns." "._T('info_sites'); 104 105 $nr = isset($occurrences['rubriques'][$id_mot]) ? $occurrences['rubriques'][$id_mot] : 0; 106 if ($nr == 1) 107 $texte_lie[] = _T('info_une_rubrique_02'); 108 else if ($nr > 1) 109 $texte_lie[] = $nr." "._T('info_rubriques_02'); 110 111 $texte_lie = join($texte_lie,", "); 112 113 $vals[] = $texte_lie; 114 115 if (autoriser('modifier','groupemots',$id_groupe)) { 116 $clic = _T('info_supprimer_mot') 117 . " <img src='" 118 . _DIR_IMG_PACK 119 . "croix-rouge.gif' alt='X' width='7' height='7' align='bottom' />"; 120 121 if ($nr OR $na OR $ns OR $nb) 122 $href = "<a href='" 123 . generer_url_ecrire("mots_tous","conf_mot=$id_mot&na=$na&nb=$nb&nr=$nr&ns=$ns&son_groupe=$id_groupe") . "#editer_mot-$id_groupe" 124 . "'>$clic</a>"; 125 else { 126 $href = generer_supprimer_mot($id_mot, $id_groupe, $clic, $total); 127 } 128 129 $vals[] = "<div style='text-align:right;'>$href</div>"; 130 } 131 132 return $vals; 133 } 134 135 // http://doc.spip.org/@generer_supprimer_mot 136 function generer_supprimer_mot($id_mot, $id_groupe, $clic, $total) 137 { 138 $cont = ($total > 1) 139 ? '' 140 : "function(r) {jQuery('#editer_mot-$id_groupe-supprimer').css('visibility','visible');}"; 141 142 return ajax_action_auteur('editer_mot', "$id_groupe,$id_mot,,,",'grouper_mots', "id_groupe=$id_groupe", array($clic,''), '', $cont); 143 } 144 145 // 146 // Calculer les nombres d'elements (articles, etc.) lies a chaque mot 147 // 148 149 // http://doc.spip.org/@calculer_liens_mots 150 function calculer_liens_mots($id_groupe) 151 { 152 153 if ($GLOBALS['connect_statut'] =="0minirezo") $aff_articles = "'prepa','prop','publie'"; 154 else $aff_articles = "'prop','publie'"; 155 156 $articles = array(); 157 $result_articles = spip_query("SELECT COUNT(*) as cnt, lien.id_mot FROM spip_mots_articles AS lien, spip_articles AS article, spip_mots AS M WHERE lien.id_mot=M.id_mot AND M.id_groupe=$id_groupe AND article.id_article=lien.id_article AND article.statut IN ($aff_articles) GROUP BY lien.id_mot"); 158 while ($row = spip_fetch_array($result_articles)){ 159 $articles[$row['id_mot']] = $row['cnt']; 160 } 161 162 163 $rubriques = array(); 164 $result_rubriques = spip_query("SELECT COUNT(*) AS cnt, lien.id_mot FROM spip_mots_rubriques AS lien, spip_mots AS M WHERE lien.id_mot=M.id_mot AND M.id_groupe=$id_groupe GROUP BY lien.id_mot"); 165 166 while ($row = spip_fetch_array($result_rubriques)){ 167 $rubriques[$row['id_mot']] = $row['cnt']; 168 } 169 170 $breves = array(); 171 $result_breves = spip_query("SELECT COUNT(*) AS cnt, lien.id_mot FROM spip_mots_breves AS lien, spip_breves AS breve, spip_mots AS M WHERE lien.id_mot=M.id_mot AND M.id_groupe=$id_groupe AND breve.id_breve=lien.id_breve AND breve.statut IN ($aff_articles) GROUP BY lien.id_mot"); 172 173 while ($row = spip_fetch_array($result_breves)){ 174 $breves[$row['id_mot']] = $row['cnt']; 175 } 176 177 $syndic = array(); 178 $result_syndic = spip_query("SELECT COUNT(*) AS cnt, lien.id_mot FROM spip_mots_syndic AS lien, spip_syndic AS syndic, spip_mots AS M WHERE lien.id_mot=M.id_mot AND M.id_groupe=$id_groupe AND syndic.id_syndic=lien.id_syndic AND syndic.statut IN ($aff_articles) GROUP BY lien.id_mot"); 179 while ($row = spip_fetch_array($result_syndic)){ 180 $sites[$row['id_mot']] = $row['cnt']; 181 182 } 183 184 return array('articles' => $articles, 185 'breves' => $breves, 186 'rubriques' => $rubriques, 187 'syndic' => $syndic); 188 } 189 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 10:20:27 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |