[SPIP] ~2.1.12 -->2.1.25
[velocampus/web/www.git] / www / ecrire / inc / formater_article.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2014 *
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 include_spip('inc/afficher_objets');
15 // Fonction appelee dans une boucle, calculer les invariants au premier appel.
16
17 // http://doc.spip.org/@inc_formater_article_dist
18 function inc_formater_article_dist($row, $own='')
19 {
20 global $spip_lang_right, $spip_display;
21 static $pret = false;
22 static $chercher_logo, $img_admin, $formater_auteur, $nb, $langue_defaut, $afficher_langue, $puce_statut;
23
24 $id_article = $row['id_article'];
25
26 if (!autoriser('voir','article',$id_article)) return '';
27
28 if (!$pret) {
29 $chercher_logo = ($spip_display != 1 AND $spip_display != 4 AND $GLOBALS['meta']['image_process'] != "non");
30 if ($chercher_logo)
31 $chercher_logo = charger_fonction('chercher_logo', 'inc');
32 $formater_auteur = charger_fonction('formater_auteur', 'inc');
33 $img_admin = http_img_pack("admin-12.gif", "", " width='12' height='12'", _T('titre_image_admin_article'));
34
35 if (($GLOBALS['meta']['multi_rubriques'] == 'oui' AND (!isset($GLOBALS['id_rubrique']))) OR $GLOBALS['meta']['multi_articles'] == 'oui') {
36 $afficher_langue = true;
37 $langue_defaut = !isset($GLOBALS['langue_rubrique'])
38 ? $GLOBALS['meta']['langue_site']
39 : $GLOBALS['langue_rubrique'];
40 }
41 $puce_statut = charger_fonction('puce_statut', 'inc');
42 $pret = true;
43 }
44
45 if ($chercher_logo) {
46 if ($logo = $chercher_logo($id_article, 'id_article', 'on')) {
47 list($fid, $dir, $nom, $format) = $logo;
48 include_spip('inc/filtres_images_mini');
49 $logo = "<span style='float: $spip_lang_right; margin-top: -2px; margin-bottom: -2px;'>" .
50 image_reduire("<img src='$fid' alt='' />", 26, 20) .
51 "</span>";
52 } else $logo = '';
53 } else $logo ='';
54
55 $titre = supprime_img($row['titre'],'');
56 $id_rubrique = $row['id_rubrique'];
57 $date = $row['date'];
58 $statut = $row['statut'];
59 $descriptif = $row['descriptif'];
60 $lang = $row['lang'];
61 $dir = "dir='" . lang_dir($lang ? changer_typo($lang) : '') . "'";
62 if ($lang AND $afficher_langue AND $lang != $GLOBALS['meta']['langue_site'])
63 $lang = " <span class='spip_xx-small' style='color: #666666' "
64 . $dir
65 . '>('
66 . traduire_nom_langue($lang)
67 . ')</span>';
68 else $lang = '';
69
70 $arg = "id_article=$id_article";
71 $url_a = generer_url_ecrire("articles", $arg);
72 if (!$row['petition'])
73 $petition = '';
74 else
75 $petition = " <a href='" . generer_url_ecrire('controle_petition', $arg) . "' class='spip_xx-small' style='color: red'>"._T('lien_petitions') . "</a>";
76
77 $lien = "<div>"
78 . $logo
79 . (acces_restreint_rubrique($id_rubrique) ? $img_admin : '')
80 . "<a href='"
81 . $url_a
82 . "'"
83 . (!$descriptif ? '': (' title="'.attribut_html(typo($descriptif)).'"'))
84 . " $dir>"
85 . typo(strlen($titre) ? $titre : _T('ecrire:info_sans_titre'))
86 . "</a>"
87 . $lang
88 . $petition
89 . "</div>";
90
91 if ($spip_display == 4) return array($lien);
92
93 $puce = $puce_statut($id_article, $statut, $id_rubrique,'article');
94
95 $auteurs = auteurs_article($id_article);
96 foreach ($auteurs as $k => $r) {
97 list(, $mail, $nom,,) = $formater_auteur($r['id_auteur']);
98 $auteurs[$k]= "$mail&nbsp;$nom";
99 }
100
101 $date = affdate_jourcourt($date);
102 if (!$date) $date = '&nbsp;';
103
104 $num = afficher_numero_edit($id_article, 'id_article', 'article');
105
106 // Afficher le numero (JMB)
107
108 return array($puce, $lien, join('<br />', $auteurs), $date, $num);
109 }
110
111 ?>