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;
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
* Méthode appelée par défaut pour charger ce widget.
|
|
|
29 |
*/
|
|
|
30 |
public function executer() {
|
|
|
31 |
$retour = null;
|
|
|
32 |
extract($this->parametres);
|
|
|
33 |
|
|
|
34 |
if (!isset($mode)) {
|
|
|
35 |
$mode = self::SERVICE_DEFAUT;
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
$methode = $this->traiterNomMethodeExecuter($mode);
|
|
|
39 |
if (method_exists($this, $methode)) {
|
|
|
40 |
$retour = $this->$methode();
|
|
|
41 |
} else {
|
|
|
42 |
$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
if (is_null($retour)) {
|
|
|
46 |
$contenu = 'Un problème est survenu : '.print_r($this->messages, true);
|
|
|
47 |
} else {
|
|
|
48 |
$urlWsCommune = sprintf($this->config['chemins']['baseURLServicesCelTpl'], 'LocationSearch');
|
|
|
49 |
$retour['donnees']['url_ws_autocompletion_commune'] = $urlWsCommune;
|
1383 |
aurelien |
50 |
$urlWsNomSci = sprintf($this->config['chemins']['baseURLServicesCelTpl'], 'NameSearch');
|
|
|
51 |
$retour['donnees']['url_ws_autocompletion_nom_sci'] = $urlWsNomSci;
|
1375 |
aurelien |
52 |
$retour['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
|
|
|
53 |
$retour['donnees']['url_export'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], 'CelWidgetExport');
|
|
|
54 |
$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$retour['squelette'].'.tpl.html';
|
|
|
55 |
$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']);
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
$this->envoyer($contenu);
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
private function executerAjax() {
|
|
|
62 |
$widget = $this->executerObservation();
|
|
|
63 |
$widget['squelette'] = 'export_ajax';
|
|
|
64 |
return $widget;
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
private function executerExport() {
|
|
|
68 |
$widget = array('squelette' => 'export', 'donnees' => array());
|
|
|
69 |
extract($this->parametres);
|
|
|
70 |
$max_obs = (isset($max_obs) && preg_match('/^[0-9]+,[0-9]+$/', $max_obs)) ? $max_obs : '10';
|
|
|
71 |
return $widget;
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
private function traiterParametres() {
|
|
|
75 |
$parametres_export = '?';
|
|
|
76 |
$criteres = array('utilisateur', 'commune', 'dept', 'taxon', 'commentaire', 'date', 'projet');
|
|
|
77 |
foreach($this->parametres as $nom_critere => $valeur_critere) {
|
|
|
78 |
if (in_array($nom_critere, $criteres)) {
|
|
|
79 |
$valeur_critere = str_replace(' ', '%20', $valeur_critere);
|
|
|
80 |
$parametres_export .= $nom_critere.'='.$valeur_critere.'&';
|
|
|
81 |
}
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
if ($parametres_export == '?') {
|
|
|
85 |
$parametres_export = '';
|
|
|
86 |
} else {
|
|
|
87 |
$parametres_export = rtrim($parametres_export, '&');
|
|
|
88 |
}
|
|
|
89 |
return $parametres_export;
|
|
|
90 |
}
|
|
|
91 |
}
|
|
|
92 |
?>
|