[SPIP] ~2.1.12 -->2.1.25
[velocampus/web/www.git] / www / ecrire / exec / statistiques_lang.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
15 include_spip('inc/presentation');
16
17 // http://doc.spip.org/@exec_statistiques_lang_dist
18 function exec_statistiques_lang_dist()
19 {
20 if (!autoriser('voirstats')) {
21 include_spip('inc/minipres');
22 echo minipres();
23 } else statistiques_lang_ok();
24 }
25
26 // http://doc.spip.org/@statistiques_lang_ok
27 function statistiques_lang_ok()
28 {
29 global $spip_ecran, $spip_lang_right;
30
31 $commencer_page = charger_fonction('commencer_page', 'inc');
32 echo $commencer_page(_T('onglet_repartition_lang'), "statistiques_visites", "repartition-langues");
33
34 if ($spip_ecran == "large") {
35 $largeur_table = 974;
36 } else {
37 $largeur_table = 750;
38 }
39 $taille = $largeur_table - 200;
40 echo "<table class='centered' width='$largeur_table'><tr><td style='width: $largeur_table" . "px; text-align:center;' class='verdana2'>";
41 echo "<br /><br />";
42
43 echo gros_titre(_T('onglet_repartition_lang'),'', false);
44
45 //barre_onglets("repartition", "langues");
46
47 if (_request('critere') == "debut") {
48 $critere = "visites";
49 // echo gros_titre(_T('onglet_repartition_debut','', false));
50 } else {
51 $critere = "popularite";
52 // echo gros_titre(_T('onglet_repartition_actuelle','', false));
53 }
54
55 echo ($critere == "popularite") ? barre_onglets("rep_depuis", "popularite"): barre_onglets("rep_depuis", "debut");
56
57
58 //
59 // Statistiques par langue
60 //
61
62
63 echo debut_cadre_enfonce("langues-24.gif", true);
64
65 $r = sql_fetsel("SUM($critere) AS total_visites", "spip_articles");
66
67 $visites = 1;
68 if ($r)
69 $total_visites = $r['total_visites'];
70 else
71 $total_visites = 1;
72
73 $result = sql_select("lang, SUM(".$critere.") AS cnt", "spip_articles", "statut='publie' ", "lang");
74
75 $ifond = 1;
76 $visites_abs = 0;
77 $res = '';
78 while ($row = sql_fetch($result)) {
79
80 $lang = $row['lang'];
81 $visites = round($row['cnt'] / $total_visites * $taille);
82 $pourcent = round($row['cnt'] / $total_visites * 100);
83
84 if ($visites > 0) {
85
86 if ($ifond==0){
87 $ifond=1;
88 $couleur="white";
89 }else{
90 $ifond=0;
91 $couleur="eeeeee";
92 }
93
94 $res .= "\n<tr style='background-color: $couleur'>";
95 $dir=lang_dir($lang,'',' dir="rtl"');
96 $res .= "<td style='width: 100%; border-bottom: 1px solid #cccccc;'><span class='verdana2'$dir><span style='float: $spip_lang_right;'>$pourcent%</span>".traduire_nom_langue($lang)."</span></td>";
97
98 $res .= "<td style='border-bottom: 1px solid #cccccc;'>";
99 $res .= "\n<table cellpadding='0' cellspacing='0' border='0' width='".($taille+5)."'>";
100 $res .= "\n<tr><td style='align:$spip_lang_right; background-color: #eeeeee; border: 1px solid #999999; white-space: nowrap;'>";
101 if ($visites_abs > 0) $res .= "<img src='" . chemin_image('rien.gif') . "' width='$visites_abs' height='8' alt=' ' />";
102 if ($visites>0) $res .= "<img src='" . chemin_image('rien.gif') . "' class='couleur_langue' style='border: 0px;' width='$visites' height='8' alt=' ' />";
103 $res .= "</td></tr></table>\n";
104
105 $res .= "</td>";
106 $res .= "</tr>";
107 $visites_abs += $visites;
108 }
109 }
110 if ($res)
111 echo "\n<table cellpadding='2' cellspacing='0' border='0' width='100%' style='border: 1px solid #aaaaaa;'>", $res, "</table>\n";
112
113
114 //echo "<p><span class='verdana1 spip_medium'>"._T('texte_signification')."</span>";
115
116 echo fin_cadre_enfonce(true);
117
118 echo "</td></tr></table>";
119 echo fin_page();
120 }
121 ?>