3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2013 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
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 \***************************************************************************/
13 if (!defined("_ECRIRE_INC_VERSION")) return;
15 include_spip('inc/presentation');
17 // http://doc.spip.org/@enfants
18 function enfants($id_parent, $critere, &$nombre_vis, &$nombre_abs){
19 $result = sql_select("id_rubrique", "spip_rubriques", "id_parent=".intval($id_parent));
23 while($row = sql_fetch($result)) {
24 $id_rubrique = $row['id_rubrique'];
26 $visites = intval(sql_getfetsel("SUM(".$critere.")", "spip_articles", "id_rubrique=".intval($id_rubrique)));
27 $nombre_abs[$id_rubrique] = $visites;
28 $nombre_vis[$id_rubrique] = $visites;
29 $nombre +
= $visites +
enfants($id_rubrique, $critere, $nombre_vis, $nombre_abs);
31 if (!isset($nombre_vis[$id_parent])) $nombre_vis[$id_parent]=0;
32 $nombre_vis[$id_parent] +
= $nombre;
37 // http://doc.spip.org/@enfants_aff
38 function enfants_aff($id_parent,$decalage, $taille, $critere, $gauche=0) {
39 global $spip_lang_right, $spip_lang_left;
40 static $abs_total=null;
44 if (is_null($abs_total)){
45 $nombre_vis = array();
46 $nombre_abs = array();
47 $abs_total = enfants(0, $critere, $nombre_vis, $nombre_abs);
48 if ($abs_total<1) $abs_total=1;
54 $result = sql_select("id_rubrique, titre, descriptif", "spip_rubriques", "id_parent=$id_parent",'', '0+titre,titre');
56 while($row = sql_fetch($result)){
57 $id_rubrique = $row['id_rubrique'];
58 $titre = typo($row['titre']);
59 $descriptif = attribut_html(couper(typo($row['descriptif']),80));
61 if ($nombre_vis[$id_rubrique]>0 OR $nombre_abs[$id_rubrique]>0){
62 $largeur_rouge = floor(($nombre_vis[$id_rubrique] - $nombre_abs[$id_rubrique]) * $taille / $abs_total);
63 $largeur_vert = floor($nombre_abs[$id_rubrique] * $taille / $abs_total);
65 if ($largeur_rouge+
$largeur_vert>0){
71 else if ($niveau == 1) {
77 $out .= "<table cellpadding='2' cellspacing='0' border='0' width='100%'>";
78 $out .= "\n<tr style='background-color: $couleur'>";
79 $out .= "\n<td style='border-bottom: 1px solid #aaaaaa; padding-$spip_lang_left: ".($niveau*20+
5)."px;'>";
82 if ( $largeur_rouge > 2)
83 $out .= bouton_block_depliable("<a href='" . generer_url_entite($id_rubrique,'rubrique') . "' style='color: black;' title=\"$descriptif\">$titre</a>","incertain", "stats$id_rubrique");
85 $out .= "<div class='verdana1' style='padding-left: 18px; padding-top: 4px; padding-bottom: 3px;'>"
86 . "<a href='" . generer_url_entite($id_rubrique,'rubrique') . "' style='color: black;' title=\"$descriptif\">$titre</a>"
91 if ($niveau==0 OR 1==1){
92 $pourcent = round($nombre_vis[$id_rubrique]/$abs_total*1000)/10;
93 $out .= "\n<td class='verdana1' style='text-align: $spip_lang_right; width: 40px; border-bottom: 1px solid #aaaaaa;'>$pourcent%</td>";
96 $out .= "<td style='width: 10px; border-bottom: 1px solid #aaaaaa;'></td>";
100 $out .= "\n<td align='right' style='border-bottom: 1px solid #aaaaaa; width:" . ($taille+
5) ."px'>";
103 $out .= "\n<table cellpadding='0' cellspacing='0' border='0' width='".($decalage+
1+
$gauche)."'>";
105 if ($gauche > 0) $out .= "<td style='width: " .$gauche."px'></td>";
106 $out .= "\n<td style='border: 0px; white-space: nowrap;'>";
107 $out .= "<div style='border: 1px solid #999999; background-color: #dddddd; height: 12px; padding: 0px; margin: 0px;'>";
108 if ($visites_abs > 0) $out .= "<img src='" . chemin_image('rien.gif') . "' style='vertical-align: top; height: 12px; border: 0px; width: ".$visites_abs."px;' alt= ' '/>";
109 if ($largeur_rouge>0) $out .= "<img src='" . chemin_image('rien.gif') . "' class='couleur_cumul' style='vertical-align: top; height: 12px; border: 0px; width: " . $largeur_rouge . "px;' alt=' ' />";
110 if ($largeur_vert>0) $out .= "<img src='" . chemin_image('rien.gif') . "' class='couleur_nombre' style='vertical-align: top; width: " . $largeur_vert ."px; height: 12px; border: 0px' alt=' ' />";
112 $out .= "</td></tr></table>\n";
113 $out .= "</td></tr></table>";
117 if (isset($largeur_rouge) && ($largeur_rouge > 0)) {
119 $out .= debut_block_depliable(false,"stats$id_rubrique");
120 $out .= enfants_aff($id_rubrique,$largeur_rouge, $taille, $critere, $visites_abs+
$gauche);
124 $visites_abs = $visites_abs +
round($nombre_vis[$id_rubrique]/$abs_total*$taille);