fc442935fbd99651a13b92febe7aab48599683d0
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2011 *
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){
19 global $nombre_vis, $nombre_abs;
21 $result = sql_select("id_rubrique", "spip_rubriques", "id_parent=$id_parent");
25 while($row = sql_fetch($result)) {
26 $id_rubrique = $row['id_rubrique'];
28 $visites = intval(sql_getfetsel("SUM(".$critere.")", "spip_articles", "id_rubrique=$id_rubrique"));
29 $nombre_abs[$id_rubrique] = $visites;
30 $nombre_vis[$id_rubrique] = $visites;
31 $nombre +
= $visites +
enfants($id_rubrique, $critere);
33 if (!isset($nombre_vis[$id_parent])) $nombre_vis[$id_parent]=0;
34 $nombre_vis[$id_parent] +
= $nombre;
39 // http://doc.spip.org/@enfants_aff
40 function enfants_aff($id_parent,$decalage, $critere, $gauche=0) {
45 global $spip_lang_right, $spip_lang_left;
50 $result = sql_select("id_rubrique, titre, descriptif", "spip_rubriques", "id_parent=$id_parent",'', '0+titre,titre');
52 while($row = sql_fetch($result)){
53 $id_rubrique = $row['id_rubrique'];
54 $titre = typo($row['titre']);
55 $descriptif = attribut_html(couper(typo($row['descriptif']),80));
57 if ($nombre_vis[$id_rubrique]>0 OR $nombre_abs[$id_rubrique]>0){
58 $largeur_rouge = floor(($nombre_vis[$id_rubrique] - $nombre_abs[$id_rubrique]) * $taille / $abs_total);
59 $largeur_vert = floor($nombre_abs[$id_rubrique] * $taille / $abs_total);
61 if ($largeur_rouge+
$largeur_vert>0){
67 else if ($niveau == 1) {
73 echo "<table cellpadding='2' cellspacing='0' border='0' width='100%'>";
74 echo "\n<tr style='background-color: $couleur'>";
75 echo "\n<td style='border-bottom: 1px solid #aaaaaa; padding-$spip_lang_left: ".($niveau*20+
5)."px;'>";
78 if ( $largeur_rouge > 2)
79 echo bouton_block_depliable("<a href='" . generer_url_ecrire("naviguer","id_rubrique=$id_rubrique") . "' style='color: black;' title=\"$descriptif\">$titre</a>","incertain", "stats$id_rubrique");
81 echo "<div class='verdana1' style='padding-left: 18px; padding-top: 4px; padding-bottom: 3px;'>",
82 "<a href='" . generer_url_ecrire("naviguer","id_rubrique=$id_rubrique") . "' style='color: black;' title=\"$descriptif\">$titre</a>",
87 if ($niveau==0 OR 1==1){
88 $pourcent = round($nombre_vis[$id_rubrique]/$abs_total*1000)/10;
89 echo "\n<td class='verdana1' style='text-align: $spip_lang_right; width: 40px; border-bottom: 1px solid #aaaaaa;'>$pourcent%</td>";
91 else { echo "<td style='width: 10px; border-bottom: 1px solid #aaaaaa;'></td>"; }
94 echo "\n<td align='right' style='border-bottom: 1px solid #aaaaaa; width:" . ($taille+
5) ."px'>";
97 echo "\n<table cellpadding='0' cellspacing='0' border='0' width='".($decalage+
1+
$gauche)."'>";
99 if ($gauche > 0) echo "<td style='width: " .$gauche."px'></td>";
100 echo "\n<td style='border: 0px; white-space: nowrap;'>";
101 echo "<div style='border: 1px solid #999999; background-color: #dddddd; height: 12px; padding: 0px; margin: 0px;'>";
102 if ($visites_abs > 0) echo "<img src='" . chemin_image('rien.gif') . "' style='vertical-align: top; height: 12px; border: 0px; width: ".$visites_abs."px;' alt= ' '/>";
103 if ($largeur_rouge>0) echo "<img src='" . chemin_image('rien.gif') . "' class='couleur_cumul' style='vertical-align: top; height: 12px; border: 0px; width: " . $largeur_rouge . "px;' alt=' ' />";
104 if ($largeur_vert>0) echo "<img src='" . chemin_image('rien.gif') . "' class='couleur_nombre' style='vertical-align: top; width: " . $largeur_vert ."px; height: 12px; border: 0px' alt=' ' />";
106 echo "</td></tr></table>\n";
107 echo "</td></tr></table>";
111 if (isset($largeur_rouge) && ($largeur_rouge > 0)) {
113 echo debut_block_depliable(false,"stats$id_rubrique");
114 enfants_aff($id_rubrique,$largeur_rouge, $critere, $visites_abs+
$gauche);
118 $visites_abs = $visites_abs +
round($nombre_vis[$id_rubrique]/$abs_total*$taille);
122 // http://doc.spip.org/@exec_statistiques_repartition_dist
123 function exec_statistiques_repartition_dist()
126 global $abs_total, $nombre_vis, $taille, $spip_ecran;
128 if (!autoriser('voirstats')) {
129 include_spip('inc/minipres');
133 $taille = _request('taille');
134 $commencer_page = charger_fonction('commencer_page', 'inc');
135 echo $commencer_page(_T('titre_page_statistiques'), "statistiques_visites", "repartition");
137 echo debut_grand_cadre(true);
138 echo gros_titre(_T('titre_page_statistiques'),'',false);
139 if ($spip_ecran == "large") {
140 $largeur_table = 974;
143 $largeur_table = 750;
147 echo "\n<br /><br /><table width='$largeur_table'><tr><td class='verdana2' style='text-align: center; width: $largeur_table" . "px;'>";
148 $critere = _request('critere');
149 if ($critere == "debut") {
150 $critere = "visites";
151 echo barre_onglets("stat_depuis", "debut");
154 $critere = "popularite";
155 echo barre_onglets("stat_depuis", "popularite");
158 $abs_total=enfants(0, $critere);
159 if ($abs_total<1) $abs_total=1;
162 echo debut_cadre_relief("statistiques-24.gif",true);
163 echo "<div style='border: 1px solid #aaaaaa; border-bottom: 0px;'>";
164 enfants_aff(0,$taille, $critere);
166 "<div class='verdana3' style='text-align: left;'>",
167 _T('texte_signification'),
169 echo fin_cadre_relief(true);
170 echo "</td></tr></table>";
171 echo fin_grand_cadre(true),fin_page();