[SPIP] +2.1.12
[velocampus/web/www.git] / www / ecrire / inc / meme_rubrique.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2011 *
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 // http://doc.spip.org/@inc_meme_rubrique_dist
15 function inc_meme_rubrique_dist($id_rubrique, $id, $type, $order='', $limit=NULL, $ajax=false)
16 {
17 global $spip_lang_right, $spip_lang_left;
18 include_spip('inc/presentation');
19 include_spip('inc/afficher_objets');
20
21 $table = table_objet_sql($type);
22 if (!id_table_objet($table)) {
23 spip_log("meme_rubrique: $type table inconnue");
24 $type = 'article';
25 $table = 'spip_articles';
26 }
27 $prim = 'id_' . $type;
28 if (!$limit)
29 $limit = defined('_MAX_ART_AFFICHES') ? _MAX_ART_AFFICHES : 10;
30
31 $titre = ($type!='syndic'?'titre':'nom_site');
32 $exec = array('article'=>'articles','breve'=>'breves_voir','syndic'=>'sites');
33
34 $where = (($GLOBALS['visiteur_session']['statut'] == '0minirezo')
35 ? ''
36 : "(statut = 'publie' OR statut = 'prop') AND ")
37 . "id_rubrique=$id_rubrique AND ($prim != $id)";
38
39 $select = "$prim AS id, $titre AS titre, statut";
40
41 $n = sql_countsel($table, $where);
42
43 if (!$n) return '';
44
45 if (!defined('_TRI_ARTICLES_RUBRIQUE')) define('_TRI_ARTICLES_RUBRIQUE', 'date DESC'); // surcharge possible dans mes_options.php
46 $order = ($order == '') ? _TRI_ARTICLES_RUBRIQUE : "$order DESC";
47 $voss = sql_select($select, $table, $where, '', "$order", $limit);
48
49 $limit = $n - $limit;
50 $retour = '';
51 $puce_statut = charger_fonction('puce_statut', 'inc');
52 $idom = 'rubrique_' . $type;
53
54 while($row = sql_fetch($voss)) {
55 $id = $row['id'];
56 $num = afficher_numero_edit($id, $prim, $type);
57 $statut = $row['statut'];
58
59 // Exception pour les meme-rubrique de sites
60 if ($type == "syndic") $type_statut = "site";
61 else $type_statut = $type;
62
63 $statut = $puce_statut($id, $statut, $id_rubrique, $type_statut);
64 $href = "<a class='verdana1' href='"
65 . generer_url_ecrire($exec[$type],"$prim=$id")
66 . "'>"
67 . sinon(typo($row['titre']), _T('info_sans_titre'))
68 . "</a>";
69
70 // Todo: refaire en css plus sains
71 $retour .= "\n<div>"
72 . "\n<div style='float:$spip_lang_right;width: 32%'>"
73 . $num . "</div>"
74 . "<div style='float:$spip_lang_left; padding-top:1px; width:18px;'>".$statut ."</div>"
75 . "<div style='padding-$spip_lang_left:18px;'>".$href."</div>"
76 . "<div style='clear:both; height: 3px;'></div>"
77 . "</div>";
78 }
79
80 $icone = '<b>' . _T('info_meme_rubrique') . '</b>';
81 $bouton = bouton_block_depliable(_T('info_meme_rubrique'),true,'memerub');
82
83 $retour =
84 debut_cadre('meme-rubriques',"article-24.gif",'',$bouton)
85 . debut_block_depliable(true,'memerub')
86 . $retour;
87
88
89 // $retour .= (($limit <= 0) ? '' : "<tr><td colspan='3' style='text-align: center'>+ $limit</td></tr>");
90
91 $retour .= fin_block()
92 . fin_cadre('meme-rubriques');
93
94 if ($ajax) return $retour;
95
96 // id utilise dans puce_statut_article
97 return "\n<div id='imgstatut$idom$id_rubrique'>$retour</div>";
98 }
99 ?>