1375 |
aurelien |
1 |
<?php
|
|
|
2 |
// declare(encoding='UTF-8');
|
|
|
3 |
/**
|
|
|
4 |
* Service exportant les dernières observations publiques du CEL.
|
|
|
5 |
* Encodage en entrée : utf8
|
|
|
6 |
* Encodage en sortie : utf8
|
|
|
7 |
*
|
|
|
8 |
* Cas d'utilisation et documentation :
|
|
|
9 |
* @link http://www.tela-botanica.org/wikini/eflore/wakka.php?wiki=AideCELWidget
|
|
|
10 |
*
|
|
|
11 |
* Paramètres :
|
|
|
12 |
* //TODO: décider des paramètres
|
|
|
13 |
*
|
|
|
14 |
* @author Aurélien Peronnet <aurelien@tela-botanica.org>
|
|
|
15 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
|
|
16 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
|
|
17 |
* @version $Id$
|
|
|
18 |
* @copyright Copyright (c) 2011, Tela Botanica (accueil@tela-botanica.org)
|
|
|
19 |
*/
|
|
|
20 |
class Export extends WidgetCommun {
|
|
|
21 |
|
|
|
22 |
const DS = DIRECTORY_SEPARATOR;
|
|
|
23 |
const SERVICE_DEFAUT = 'export';
|
|
|
24 |
private $export_url = null;
|
|
|
25 |
private $eflore_url_tpl = null;
|
2351 |
mathias |
26 |
/** Si spécifié, on ajoute une barre de navigation inter-applications */
|
|
|
27 |
private $bar;
|
1375 |
aurelien |
28 |
|
|
|
29 |
/**
|
|
|
30 |
* Méthode appelée par défaut pour charger ce widget.
|
|
|
31 |
*/
|
|
|
32 |
public function executer() {
|
|
|
33 |
$retour = null;
|
|
|
34 |
extract($this->parametres);
|
|
|
35 |
|
|
|
36 |
if (!isset($mode)) {
|
|
|
37 |
$mode = self::SERVICE_DEFAUT;
|
|
|
38 |
}
|
2351 |
mathias |
39 |
$this->bar = (isset($bar)) ? $bar : false;
|
1375 |
aurelien |
40 |
|
|
|
41 |
$methode = $this->traiterNomMethodeExecuter($mode);
|
|
|
42 |
if (method_exists($this, $methode)) {
|
|
|
43 |
$retour = $this->$methode();
|
|
|
44 |
} else {
|
|
|
45 |
$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
if (is_null($retour)) {
|
|
|
49 |
$contenu = 'Un problème est survenu : '.print_r($this->messages, true);
|
|
|
50 |
} else {
|
|
|
51 |
$urlWsCommune = sprintf($this->config['chemins']['baseURLServicesCelTpl'], 'LocationSearch');
|
|
|
52 |
$retour['donnees']['url_ws_autocompletion_commune'] = $urlWsCommune;
|
2351 |
mathias |
53 |
|
1383 |
aurelien |
54 |
$urlWsNomSci = sprintf($this->config['chemins']['baseURLServicesCelTpl'], 'NameSearch');
|
|
|
55 |
$retour['donnees']['url_ws_autocompletion_nom_sci'] = $urlWsNomSci;
|
2351 |
mathias |
56 |
|
1375 |
aurelien |
57 |
$retour['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
|
|
|
58 |
$retour['donnees']['url_export'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], 'CelWidgetExport');
|
2351 |
mathias |
59 |
$retour['donnees']['url_script_navigation'] = sprintf($this->config['chemins']['baseURLRessources'], 'tb/reseau/navigation.js');
|
|
|
60 |
|
|
|
61 |
$retour['donnees']['bar'] = $this->bar;
|
|
|
62 |
|
1375 |
aurelien |
63 |
$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$retour['squelette'].'.tpl.html';
|
|
|
64 |
$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']);
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
$this->envoyer($contenu);
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
private function executerAjax() {
|
|
|
71 |
$widget = $this->executerObservation();
|
|
|
72 |
$widget['squelette'] = 'export_ajax';
|
|
|
73 |
return $widget;
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
private function executerExport() {
|
|
|
77 |
$widget = array('squelette' => 'export', 'donnees' => array());
|
|
|
78 |
extract($this->parametres);
|
|
|
79 |
$max_obs = (isset($max_obs) && preg_match('/^[0-9]+,[0-9]+$/', $max_obs)) ? $max_obs : '10';
|
|
|
80 |
return $widget;
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
private function traiterParametres() {
|
|
|
84 |
$parametres_export = '?';
|
|
|
85 |
$criteres = array('utilisateur', 'commune', 'dept', 'taxon', 'commentaire', 'date', 'projet');
|
|
|
86 |
foreach($this->parametres as $nom_critere => $valeur_critere) {
|
|
|
87 |
if (in_array($nom_critere, $criteres)) {
|
|
|
88 |
$valeur_critere = str_replace(' ', '%20', $valeur_critere);
|
|
|
89 |
$parametres_export .= $nom_critere.'='.$valeur_critere.'&';
|
|
|
90 |
}
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
if ($parametres_export == '?') {
|
|
|
94 |
$parametres_export = '';
|
|
|
95 |
} else {
|
|
|
96 |
$parametres_export = rtrim($parametres_export, '&');
|
|
|
97 |
}
|
|
|
98 |
return $parametres_export;
|
|
|
99 |
}
|
|
|
100 |
}
|
|
|
101 |
?>
|