//Autres auteurs : *@author Aucun *@copyright Tela-Botanica 2000-2007 *@version $Revision$ $Date$ // +------------------------------------------------------------------------------------------------------+ */ // +------------------------------------------------------------------------------------------------------+ // | ENTÊTE du PROGRAMME | // +------------------------------------------------------------------------------------------------------+ $GLOBALS['_GEN_commun']['info_applette_nom_fonction'] = 'afficherStatDistribution'; $GLOBALS['_GEN_commun']['info_applette_balise'] = '\{\{[Ss]tatDistribution(?:\s*(?:(format="[^"]+")|(niveau="[^"]+")|))+\s*\}\}';//; // -------------------------------------------------------------------------------------------------------- //Utilisation de la bibliothèque Papyrus pap_meta.fonct.php inclue par Papyrus //Utilisation de la bibliothèque PEAR NET_URL inclue par Papyrus /** Inclusion du fichier de configuration de cette application.*/ require_once GEN_CHEMIN_CLIENT.'stat_distribution'.GEN_SEP.'configuration'.GEN_SEP.'stdi_configuration.inc.php'; // Inclusion des fichiers de traduction de l'applette CATEG de Papyrus if (file_exists(STDI_CHEMIN_LANGUE.'stdi_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php')) { /** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/ require_once STDI_CHEMIN_LANGUE.'stdi_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php'; } else { /** Inclusion du fichier de traduction par défaut.*/ require_once STDI_CHEMIN_LANGUE.'stdi_langue_'.STDI_I18N_DEFAUT.'.inc.php'; } // +------------------------------------------------------------------------------------------------------+ // | CORPS du PROGRAMME | // +------------------------------------------------------------------------------------------------------+ // En attendant de pouvoir utiliser le nouveaux système d'appllet de la branche principale de Papyrus function afficherContenuCorps() { $tab_applette_arguments[1] = 'format='.$GLOBALS['_GEN_commun']['info_application']->format; $tab_applette_arguments[2] = 'niveau='.$GLOBALS['_GEN_commun']['info_application']->niveau; return afficherStatDistribution($tab_applette_arguments, $GLOBALS['_GEN_commun']); } /** Fonction afficherStatDistribution() - Retourne les stats de distribution. * * Cette fonction Retourne les statistiques de distribution des inscrits à Tela Botanica sous différentes formes. * * @param array contient les arguments de la fonction. * @param array tableau global de Papyrus. * @return string HTML les stats de distribution. */ function afficherStatDistribution($tab_applette_arguments, $_GEN_commun) { // Initialisation des variables $sortie = ''; //+----------------------------------------------------------------------------------------------------------------+ // Gestion des arguments $tab_arguments = $tab_applette_arguments; unset($tab_arguments[0]); foreach($tab_arguments as $argument) { $tab_parametres = explode('=', $argument); $options[$tab_parametres[0]] = trim($tab_parametres[1], '"'); } //+----------------------------------------------------------------------------------------------------------------+ // Gestion des erreurs de paramètrage $GLOBALS['_STAT_DISTRIBUTION_']['erreur'] = ''; if (!isset($options['format'])) { $GLOBALS['_STAT_DISTRIBUTION_']['erreur'] = STDI_LG_ERREUR_FORMAT; } if (!isset($options['niveau'])) { $GLOBALS['_STAT_DISTRIBUTION_']['erreur'] = STDI_LG_ERREUR_NIVEAU; } //+----------------------------------------------------------------------------------------------------------------+ // Récupération des données switch ($options['niveau']) { case 'europe' : $tab_legende_fr = array(); $tab_legende_ss_fr = array(); $tab_donnees_fr = array() ; $tab_donnees_ss_fr = array() ; $total_autre = 0; $requete = 'SELECT CP_ID_Pays, CP_Intitule_pays, COUNT(CP_ID_Pays) AS nbre '. 'FROM annuaire_tela, carto_PAYS '. 'WHERE U_COUNTRY = CP_ID_Pays '. 'AND CP_ID_Continent = 4 '. 'GROUP BY CP_ID_Pays '. 'ORDER BY nbre DESC'; $GLOBALS['_STAT_DISTRIBUTION_']['titre'] = 'Répartition des inscrits à Tela Botanica en Europe'; break; case 'monde' : $requete = 'SELECT CC_ID_Continent, CC_Intitule_continent, COUNT(CC_ID_Continent) AS nbre '. 'FROM annuaire_tela, carto_PAYS, carto_CONTINENT '. 'WHERE U_COUNTRY = CP_ID_Pays '. 'AND CP_ID_Continent = CC_ID_Continent '. 'GROUP BY CC_ID_Continent '; $GLOBALS['_STAT_DISTRIBUTION_']['titre'] = 'Répartition des inscrits à Tela Botanica dans le monde'; break; } $resultat = $GLOBALS['db']->query($requete) ; while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { switch ($options['niveau']) { case 'europe' : $id = $ligne->CP_ID_Pays; $legende_libelle = $ligne->CP_Intitule_pays.' (%1.2f%%)'; $libelle = $ligne->CP_Intitule_pays.' ['.$id.']'; $nbre = $ligne->nbre; if ($id != 'fr' && $id != 'FR') { $tab_donnees_ss_fr[] = $nbre; $tab_legende_ss_fr[] = $legende_libelle; $total_autre += $nbre; $tab_donnees_fr[1] += $nbre; $tab_legende_fr[1] = 'Autres pays européens (%1.2f%%)'; } else { $tab_donnees_fr[0] = $nbre; $tab_legende_fr[0] = $legende_libelle; } break; case 'monde' : $id = $ligne->CC_ID_Continent; $legende_libelle = '['.$id.'] '.$ligne->CC_Intitule_continent.' (%1.2f%%)'; $libelle = $ligne->CC_Intitule_continent.' ['.$id.']'; $nbre = $ligne->nbre; $tab_donnees[$id] = $ligne->nbre; if (!isset($legende[$id])) { $tab_legende[$id] = $legende_libelle; } break; } $GLOBALS['_STAT_DISTRIBUTION_']['tab_donnees'][$id]['libelle'] = $libelle; $GLOBALS['_STAT_DISTRIBUTION_']['tab_donnees'][$id]['nombre'] = $nbre; $total += $nbre; } foreach ($GLOBALS['_STAT_DISTRIBUTION_']['tab_donnees'] as $id => $val) { $GLOBALS['_STAT_DISTRIBUTION_']['tab_donnees'][$id]['pourcentage'] = round($val['nombre']/$total*100, 2).' %'; } //+----------------------------------------------------------------------------------------------------------------+ // Extrait les variables et les ajoutes à l'espace de noms local // Gestion des squelettes extract($GLOBALS['_STAT_DISTRIBUTION_']); // Démarre le buffer ob_start(); // Inclusion du fichier include(STDI_CHEMIN_SQUELETTE.STDI_SQUELETTE_LISTE); // Récupérer le contenu du buffer $sortie = ob_get_contents(); // Arrête et détruit le buffer ob_end_clean(); //+----------------------------------------------------------------------------------------------------------------+ // Sortie return $sortie; } // +------------------------------------------------------------------------------------------------------+ // | LISTE DES FONCTIONS | // +------------------------------------------------------------------------------------------------------+ /* +--Fin du code ----------------------------------------------------------------------------------------+ * * $Log$ * * +-- Fin du code ----------------------------------------------------------------------------------------+ */ ?>