Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

Ignore whitespace Rev 1083 → Rev 1084

/trunk/metier/api_0.1/Graphiques.php
11,7 → 11,7
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
* @version $Id$
*/
class Graphiques extends Eflore {
class Graphiques extends Eflore {
 
private $bdnt;
private $num_nom;
18,9 → 18,18
private $type_graph;
private $classe;
private $code;
private $codes = array ("VEL", "VET", "VEHA", "VEC", "VER", "VEHE", "VETX", "VEN", "VES","VEMO");
// pour chaque code, [0] est le min (départ de recherche des valeurs)
// et [1] est le max (fin)
static $codes = array ("VEL" => array(1,9),
"VET" => array(1,9),
"VEHA" => array(1,9),
"VEC" => array(1,9),
"VER" => array(1,9),
"VETX" => array(1,9),
"VEN" => array(1,9),
"VEMO" => array(1,9),
"VEHE" => array(1,12),
"VES" => array(0,9) );
 
public function setType_graph($tg) {
$this->type_graph = $tg;
41,31 → 50,39
public function setNum_nom($nn){
$this->num_nom = $nn;
}
 
// TODO: array_map() // XXX: PHP-5.3
static function _build_range() {
$ret = array();
foreach (self::$codes as $classe => $val) {
foreach(range($val[0], $val[1]) as $i) {
$ret[] = $classe . ':' . $i;
}
}
return implode(',', $ret);
}
 
// TODO: array_map() // XXX: PHP-5.3
static function _split_data($tab) {
$ret = array();
foreach ($tab as $k => $v) {
list($new_k, $sub_k) = explode(':', $k);
$ret[$new_k][$sub_k] = $v;
}
return $ret;
}
 
public function getLegendeGraphique() {
$legende = array();
foreach ($this->codes as $cod){
$i = ($cod == "VES") ? 0 : 1 ;
$max = ($cod == "VEHE") ? 12 : 9 ;
while ($i < $max+1){
$this->setClasse($cod);
$this->setCode($i);
$url = $this->getUrlLegende();
$legende[$cod][$i] = $this->chargerDonnees($url);
$i++;
}
}
return $legende;
// eg: VEL:1,VEL:2,VEL:3,...VER:9,VETX:1,...
$ressources = self::_build_range();
$url = Eflore::s_formaterUrl(Config::get('legendeGraphiqueTpl'),
$this->ajouterParametreParDefaut(array('params' => $ressources)),
FALSE);
$data = $this->chargerDonnees($url);
return self::_split_data($data);
}
public function getUrlLegende() {
$tpl = Config::get('legendeGraphiqueTpl');
$params = array( 'code' => $this->code, 'classe' => $this->classe );
$url = $this->formaterUrl($tpl, $params);
return $url ;
}
public function getGraphique() {
$url = $this->getUrlInformation();
return $this->chargerDonnees($url);
/trunk/metier/api_0.1/Eflore.php
60,7 → 60,7
return $tpl;
}
 
private function ajouterParametreParDefaut(Array $parametres) {
public function ajouterParametreParDefaut(Array $parametres) {
$parametres['projet'] = isset($parametres['projet']) ? $parametres['projet'] : $this->projet;
return $parametres;
}
113,12 → 113,12
}
 
 
static function s_formaterUrl($tpl, Array $parametres) {
static function s_formaterUrl($tpl, Array $parametres, $enc = TRUE) {
foreach($parametres as $key => $value) {
if(is_array($value)) {
$value = implode(',', $value);
}
$tpl = str_replace('{'.$key.'}',rawurlencode($value), $tpl);
$tpl = str_replace('{'.$key.'}',$enc ? rawurlencode($value) : $value, $tpl);
}
return $tpl;
}
/trunk/configurations/config.defaut.ini
213,7 → 213,7
informationsCatminat = "{ref:informationsTpl}?masque.cat={catminat}&navigation.limite={limite}&navigation.depart={depart}"
 
graphiqueTpl = "{ref:baseUrlApiEflore}/graphiques/{type_graph}/{bdnt}.nn:{num_nom}"
legendeGraphiqueTpl = "{ref:baseUrlApiEflore}/ontologies/{classe}:{code}"
legendeGraphiqueTpl = "{ref:baseUrlApiEflore}/ontologies/{params}"
 
syntaxonsTpl = "{ref:baseUrlApiEflore}/syntaxons";
syntaxonsSuperieurs = "{ref:syntaxonsTpl}/{code}/relations/niveaux-sup?retour.champs=physio_biotype,repartition_france,ref_der_biblio&masque.retenu=true";