Subversion Repositories eFlore/Applications.bibliobota

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 jp_milcent 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This file is part of Biblio Bota.                                                                    |
9
// |                                                                                                      |
10
// | Foobar is free software; you can redistribute it and/or modify                                       |
11
// | it under the terms of the GNU General Public License as published by                                 |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
13
// | (at your option) any later version.                                                                  |
14
// |                                                                                                      |
15
// | Foobar is distributed in the hope that it will be useful,                                            |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
18
// | GNU General Public License for more details.                                                         |
19
// |                                                                                                      |
20
// | You should have received a copy of the GNU General Public License                                    |
21
// | along with Foobar; if not, write to the Free Software                                                |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
23
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id: graph_biblio_site.php,v 1.1 2005-11-23 10:22:25 jp_milcent Exp $
25
/**
26
* Image créée en php sur les statistiques de BiblioBota.
27
*
28
* Réalise un graphique correspondant au nombre d'intérogation de livres.
29
*
30
*@package BiblioBota
31
*@package Statistique
32
//Auteur original :
33
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
34
//Autres auteurs :
35
*@author        Aucun
36
*@copyright     Tela-Botanica 2000-2004
37
*@version       $Revision: 1.1 $ $Date: 2005-11-23 10:22:25 $
38
// +------------------------------------------------------------------------------------------------------+
39
*/
40
 
41
// +------------------------------------------------------------------------------------------------------+
42
// |                                            ENTÊTE du PROGRAMME                                       |
43
// +------------------------------------------------------------------------------------------------------+
44
/** Inclusion du fichier de configuration spécifique à l'installation de Papyrus.*/
45
require_once '../../../../../papyrus/configuration/pap_config_avancee.inc.php';
46
/** Inclusion du fichier de configuration de Papyrus.*/
47
require_once '../../../../../papyrus/configuration/pap_config.inc.php';
48
/** Inclusion du fichier de configuration de la base de données de BiblioBota.*/
49
require_once '../../../configuration/bb_config_bdd.inc.php';
50
/** Inclusion du fichier de configuration général de BiblioBota.*/
51
require_once '../../../configuration/bb_config.inc.php';
52
 
53
/** Inclusion d'un fichier de l'API JPGraph. */
54
include_once PAP_CHEMIN_RACINE.BB_CHEMIN_API_JPGRAPH.'jpgraph.php';
55
/** Inclusion d'un fichier de l'API JPGraph. */
56
include_once PAP_CHEMIN_RACINE.BB_CHEMIN_API_JPGRAPH.'jpgraph_line.php';
57
/** Inclusion d'un fichier de l'API JPGraph. */
58
include_once PAP_CHEMIN_RACINE.BB_CHEMIN_API_JPGRAPH.'jpgraph_bar.php';
59
/** Inclusion de la classe PEAR d'abstraction de base de donnée. */
60
include_once 'DB.php';
61
/** Inclusion de l'API Débogage du sql */
62
require_once PAP_CHEMIN_RACINE.BB_CHEMIN_API_DEBOGAGE.'BOG_sql.fonct.php';
63
 
64
// +------------------------------------------------------------------------------------------------------+
65
// |                                            CORPS du PROGRAMME                                        |
66
// +------------------------------------------------------------------------------------------------------+
67
 
68
$tab_mois_fr = array('Jan','Fev','Mar','Avr','Mai','Juin','Juil','Aout','Sep','Oct','Nov','Déc');
69
 
70
// +------------------------------------------------------------------------------------------------------+
71
// Connexion à la base de données.
72
$GLOBALS['db'] = DB::connect(BB_DSN) ;
73
if (DB::isError($GLOBALS['db'])) {
74
    $msg_erreur_connection = 'Impossible de se connecter à la base de données.';
75
    die(BOG_afficherErreurSql(__FILE__, __LINE__, $GLOBALS['db']->getMessage(), 'connexion à la base de données',$msg_erreur_connection));
76
}
77
 
78
$graph_donnees_livre = array();
79
$graph_donnees_total = array();
80
$graph_etiquette_axeX = array();
81
 
82
$requete =  'SELECT min(B_SPY_DATE) as min, max(B_SPY_DATE) as max '.
83
            'FROM biblio_spy';
84
$resultat =& $GLOBALS['db']->query($requete);
85
if (DB::isError($resultat)) {
86
    die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete));
87
}
88
while ($ligne =& $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
89
    $tps_unix_fin = $ligne->max;
90
    $tps_unix_debut = $ligne->min;
91
}
92
$resultat->free();
93
 
94
$i = 0;
95
 
96
//Recherche du nombre d'intérogation par mois
97
while ($tps_unix_debut <= $tps_unix_fin) {
98
    $nbre_recherche_site = 0;
99
    $nbre_recherche_autre = 0;
100
    $annee_debut = date('Y', $tps_unix_debut);
101
    //echo $annee_debut;
102
    $mois_debut = date('n', $tps_unix_debut);
103
    //echo $mois_debut;
104
    if($mois_debut == 12) {
105
        $annee_fin_mois = $annee_debut+1;
106
        $mois_fin_mois = 1;
107
    } else {
108
        $annee_fin_mois = $annee_debut;
109
        $mois_fin_mois = $mois_debut+1;
110
    }
111
    $tps_unix_fin_mois = mktime(0, 0, 0, $mois_fin_mois, 0, $annee_fin_mois);
112
    $requete =  'SELECT b_spy_moteur '.
113
                'FROM biblio_spy '.
114
                'WHERE b_spy_date >= "'.$tps_unix_debut.'" '.
115
                'AND b_spy_date <= "'.$tps_unix_fin_mois.'"';
116
    $resultat =& $GLOBALS['db']->query($requete);
117
    //echo $requete;
118
    if (DB::isError($resultat)) {
119
        die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete));
120
    }
121
    while ($ligne =& $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
122
        if ($ligne->b_spy_moteur == 'link') {
123
            $nbre_recherche_site++;
124
        } else {
125
            $nbre_recherche_autre++;
126
        }
127
    }
128
    $graph_donnees_total[$i] = $nbre_recherche_site + $nbre_recherche_autre;
129
    $graph_donnees_site[$i] = $nbre_recherche_site;
130
    $graph_etiquette_axeX[$i] = $tab_mois_fr[($mois_debut-1)].' '.$annee_debut;
131
    $i++;
132
    $resultat->free();
133
    $tps_unix_debut = mktime(0, 0, 0, $mois_fin_mois, 1, $annee_fin_mois);
134
}
135
 
136
$donnees_site = array_values($graph_donnees_site);
137
$donnees_total = array_values($graph_donnees_total);
138
 
139
// Création de la structure du graph
140
$graph = new Graph(500,400,'auto');
141
$graph->SetMarginColor('white');
142
$graph->img->SetMargin(50,30,30,70);
143
$graph->SetScale('textint');
144
$graph->SetShadow();//Ombre du graph
145
 
146
// Définition du titre du graph
147
$graph->title->Set('Evolution du nombre de recherche de sites web');
148
$graph->title->SetFont(FF_FONT1,FS_BOLD);
149
 
150
// Définition de l'axe X
151
// Un angle autre que 0 ou 90° ne marche pas car les polices TTF ne sont pas supportée par Sequoia
152
$graph->xaxis->SetTickLabels($graph_etiquette_axeX);
153
$graph->xaxis->SetFont(FF_FONT1,FS_NORMAL,11);
154
$graph->xaxis->SetLabelAngle(90);
155
 
156
// Affichage du tracé numéro 1 : organisme
157
$trace_01 = new LinePlot($donnees_site);
158
$trace_01->SetColor('brown');
159
//$trace_01->mark->SetType(MARK_DIAMOND);
160
//$trace_01->mark->SetColor('brown');
161
//$trace_01->value->Show();
162
//$trace_01->value->SetFormat('%u');
163
$graph->Add($trace_01);
164
 
165
// Définition de la légende
166
$trace_01->SetLegend ('nombre recherches sites');
167
$graph ->legend->Pos(0.15, 0.15, 'left', 'center');
168
 
169
// Envoi du graph au navigateur sous forme d'image.
170
$graph->Stroke();
171
 
172
// +------------------------------------------------------------------------------------------------------+
173
// |                                            PIED du PROGRAMME                                         |
174
// +------------------------------------------------------------------------------------------------------+
175
 
176
 
177
/* +--Fin du code ----------------------------------------------------------------------------------------+
178
*
179
* $Log: not supported by cvs2svn $
180
* Revision 1.1  2005/03/01 17:43:05  jpm
181
* Ajout des fichiers fournissant des graphiques sur les statistiques de consultation de Biblio Bota.
182
*
183
*
184
* +-- Fin du code ----------------------------------------------------------------------------------------+
185
*/
186
?>