[SPIP] ~v3.0.20-->v3.0.25
[lhc/web/clavette_www.git] / www / plugins-dist / statistiques / prive / squelettes / contenu / stats_lang_fonctions.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2016 *
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
17 // http://code.spip.net/@statistiques_lang_ok
18 function affiche_stats_lang($critere) {
19 global $spip_lang_right;
20
21 $taille = 450;
22 //
23 // Statistiques par langue
24 //
25
26 $out = "";
27 $r = sql_fetsel("SUM($critere) AS total_visites", "spip_articles");
28
29 $visites = 1;
30 // attention a '0.0'
31 if ($r and $r['total_visites'] > 0) {
32 $total_visites = $r['total_visites'];
33 } else {
34 $total_visites = 1;
35 }
36
37 $result = sql_select("lang, SUM(".$critere.") AS cnt", "spip_articles", "statut='publie' ", "lang");
38
39 $out .= "\n<table cellpadding='2' cellspacing='0' border='0' width='100%' style='border: 1px solid #aaaaaa;'>";
40 $ifond = 1;
41
42 $visites_abs = 0;
43 while ($row = sql_fetch($result)) {
44
45 $lang = $row['lang'];
46 if ($row['cnt']) {
47 $visites = round($row['cnt'] / $total_visites * $taille);
48 $pourcent = round($row['cnt'] / $total_visites * 100);
49 }
50
51 if ($visites > 0) {
52
53 if ($ifond==0){
54 $ifond=1;
55 $couleur="white";
56 }
57 else{
58 $ifond=0;
59 $couleur="eeeeee";
60 }
61
62 $out .= "\n<tr style='background-color: $couleur'>";
63 $dir=lang_dir($lang,'',' dir="rtl"');
64 $out .= "<td style='width: 100%; border-bottom: 1px solid #cccccc;'><p $dir><span style='float: $spip_lang_right;'>$pourcent%</span>".traduire_nom_langue($lang)."</p></td>";
65
66 $out .= "<td style='border-bottom: 1px solid #cccccc;'>";
67 $out .= "\n<table cellpadding='0' cellspacing='0' border='0' width='".($taille+5)."'>";
68 $out .= "\n<tr><td style='align:$spip_lang_right; background-color: #eeeeee; border: 1px solid #999999; white-space: nowrap;'>";
69 if ($visites_abs > 0)
70 $out .= "<img src='" . chemin_image('rien.gif') . "' width='$visites_abs' height='10' alt=' ' />";
71 if ($visites>0)
72 $out .= "<img src='" . chemin_image('rien.gif') . "' class='couleur_langue' style='border: 0px;' width='$visites' height='8' alt=' ' />";
73 $out .= "</td></tr></table>\n";
74
75 $out .= "</td>";
76 $out .= "</tr>";
77 $visites_abs += $visites;
78 }
79 }
80 $out .= "</table>\n";
81 return $out;
82 }
83 ?>