Subversion Repositories eFlore/Applications.bibliobota

Compare Revisions

Ignore whitespace Rev 1 → Rev 2

/trunk/presentations/images/statistique/graph_biblio_article.php
New file
0,0 → 1,192
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of Biblio Bota. |
// | |
// | Foobar is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation; either version 2 of the License, or |
// | (at your option) any later version. |
// | |
// | Foobar is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with Foobar; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: graph_biblio_article.php,v 1.1 2005-11-23 10:22:25 jp_milcent Exp $
/**
* Image créée en php sur les statistiques de BiblioBota.
*
* Réalise un graphique correspondant au nombre d'intérogation d'articles.
*
*@package BiblioBota
*@package Statistique
//Auteur original :
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2005
*@version $Revision: 1.1 $ $Date: 2005-11-23 10:22:25 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTÊTE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
/** Inclusion du fichier de configuration spécifique à l'installation de Papyrus.*/
require_once '../../../../../papyrus/configuration/pap_config_avancee.inc.php';
/** Inclusion du fichier de configuration de Papyrus.*/
require_once '../../../../../papyrus/configuration/pap_config.inc.php';
/** Inclusion du fichier de configuration de la base de données de BiblioBota.*/
require_once '../../../configuration/bb_config_bdd.inc.php';
/** Inclusion du fichier de configuration général de BiblioBota.*/
require_once '../../../configuration/bb_config.inc.php';
 
/** Inclusion d'un fichier de l'API JPGraph. */
include_once PAP_CHEMIN_RACINE.BB_CHEMIN_API_JPGRAPH.'jpgraph.php';
/** Inclusion d'un fichier de l'API JPGraph. */
include_once PAP_CHEMIN_RACINE.BB_CHEMIN_API_JPGRAPH.'jpgraph_line.php';
/** Inclusion d'un fichier de l'API JPGraph. */
include_once PAP_CHEMIN_RACINE.BB_CHEMIN_API_JPGRAPH.'jpgraph_bar.php';
/** Inclusion de la classe PEAR d'abstraction de base de donnée. */
include_once 'DB.php';
/** Inclusion de l'API Débogage du sql */
require_once PAP_CHEMIN_RACINE.BB_CHEMIN_API_DEBOGAGE.'BOG_sql.fonct.php';
 
// +------------------------------------------------------------------------------------------------------+
// | CORPS du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
$tab_mois_fr = array('Jan','Fev','Mar','Avr','Mai','Juin','Juil','Aout','Sep','Oct','Nov','Déc');
 
// +------------------------------------------------------------------------------------------------------+
// Connexion à la base de données.
$GLOBALS['db'] = DB::connect(BB_DSN) ;
if (DB::isError($GLOBALS['db'])) {
$msg_erreur_connection = 'Impossible de se connecter à la base de données.';
die(BOG_afficherErreurSql(__FILE__, __LINE__, $GLOBALS['db']->getMessage(), 'connexion à la base de données',$msg_erreur_connection));
}
 
$graph_donnees_article = array();
$graph_donnees_total = array();
$graph_etiquette_axeX = array();
 
$requete = 'SELECT min(B_SPY_DATE) as min, max(B_SPY_DATE) as max '.
'FROM biblio_spy';
$resultat =& $GLOBALS['db']->query($requete);
if (DB::isError($resultat)) {
die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete));
}
while ($ligne =& $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$tps_unix_fin = $ligne->max;
$tps_unix_debut = $ligne->min;
}
$resultat->free();
 
$i = 0;
 
//Recherche du nombre d'intérogation par mois
while ($tps_unix_debut <= $tps_unix_fin) {
$nbre_recherche_article = 0;
$nbre_recherche_article_plugin = 0;
$nbre_recherche_total = 0;
$annee_debut = date('Y', $tps_unix_debut);
//echo $annee_debut;
$mois_debut = date('n', $tps_unix_debut);
//echo $mois_debut;
if($mois_debut == 12) {
$annee_fin_mois = $annee_debut+1;
$mois_fin_mois = 1;
} else {
$annee_fin_mois = $annee_debut;
$mois_fin_mois = $mois_debut+1;
}
$tps_unix_fin_mois = mktime(0, 0, 0, $mois_fin_mois, 0, $annee_fin_mois);
$requete = 'SELECT b_spy_doc, b_spy_moteur '.
'FROM biblio_spy '.
'WHERE b_spy_date >= "'.$tps_unix_debut.'" '.
'AND b_spy_date <= "'.$tps_unix_fin_mois.'"';
$resultat =& $GLOBALS['db']->query($requete);
//echo $requete;
if (DB::isError($resultat)) {
die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete));
}
while ($ligne =& $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
if ($ligne->b_spy_moteur == 'media' && $ligne->b_spy_doc == 'bibliographie_article') {
$nbre_recherche_article++;
} elseif ($ligne->b_spy_moteur == 'media' && strstr($ligne->b_spy_doc, 'biblio-plug')) {
$nbre_recherche_article_plugin++;
}
else {
$nbre_recherche_total++;
}
}
$nbre_recherche_total = $nbre_recherche_article + $nbre_recherche_article_plugin + $nbre_recherche_total;
$graph_donnees_total[$i] = $nbre_recherche_total;
$graph_donnees_article[$i] = $nbre_recherche_article + $nbre_recherche_article_plugin;
$graph_etiquette_axeX[$i] = $tab_mois_fr[($mois_debut-1)].' '.$annee_debut;
$i++;
$resultat->free();
$tps_unix_debut = mktime(0, 0, 0, $mois_fin_mois, 1, $annee_fin_mois);
}
 
$donnees_article = array_values($graph_donnees_article);
$donnees_total = array_values($graph_donnees_total);
 
// Création de la structure du graph
$graph = new Graph(500,400,'auto');
$graph->SetMarginColor('white');
$graph->img->SetMargin(50,30,30,70);
$graph->SetScale('textint');
$graph->SetShadow();//Ombre du graph
 
// Définition du titre du graph
$graph->title->Set('Evolution du nombre de recherche d\'articles');
$graph->title->SetFont(FF_FONT1,FS_BOLD);
 
// Définition de l'axe X
// Un angle autre que 0 ou 90° ne marche pas car les polices TTF ne sont pas supportée par Sequoia
$graph->xaxis->SetTickLabels($graph_etiquette_axeX);
$graph->xaxis->SetFont(FF_FONT1,FS_NORMAL,11);
$graph->xaxis->SetLabelAngle(90);
 
// Affichage du tracé numéro 1 : organisme
$trace_01 = new LinePlot($donnees_article);
$trace_01->SetColor('brown');
//$trace_01->mark->SetType(MARK_DIAMOND);
//$trace_01->mark->SetColor('brown');
//$trace_01->value->Show();
//$trace_01->value->SetFormat('%u');
$graph->Add($trace_01);
 
// Définition de la légende
$trace_01->SetLegend ('nombre recherches articles');
$graph ->legend->Pos(0.15, 0.15, 'left', 'center');
 
// Envoi du graph au navigateur sous forme d'image.
$graph->Stroke();
 
// +------------------------------------------------------------------------------------------------------+
// | PIED du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
 
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.1 2005/03/01 17:43:05 jpm
* Ajout des fichiers fournissant des graphiques sur les statistiques de consultation de Biblio Bota.
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>