46,17 → 46,18 |
* en POST |
*/ |
function updateElement($uid, $pairs) { |
$params = Array('uid' => $uid); |
$params = Array('uid' => $uid[0]); |
// TODO: pas de range mais un utilisateur: possible |
if(!isset($_POST['range'])) { |
header('HTTP/1.0 204 No Content'); |
exit; |
} |
elseif($_POST['range'] == '*') { |
// trim() car: `POST http://url<<<"range=*"` |
elseif(trim($_POST['range']) == '*') { |
$records = Array('*'); |
} |
else { |
$records = self::rangeToList($_POST['range']); |
$records = self::rangeToList(trim($_POST['range'])); |
} |
$this->export($records, NULL, $params); |
exit; |
74,16 → 75,15 |
|
$objPHPExcel = new PHPExcel(); |
|
|
// TODO: $params['part'] pour le multi-part |
$params['widget'] = isset($params['widget']) ? $params['widget'] : 'CEL'; |
// TODO: controleUtilisateur() |
if( /* REMOVE*/ true || ! $params['uid'] || ! $this->controleUtilisateur($params['uid'])) { |
if(! $params['uid']) { // || ! $this->controleUtilisateur($params['uid'])) { |
$params['uid'] = NULL; |
} |
|
$criteres = Array(); |
if(count($records) == 1 && $records[0] == '*') { |
if(! $records || count($records) == 1 && $records[0] == '*') { |
unset($criteres['raw']); |
} |
else { |
93,11 → 93,11 |
|
$criteres['debut'] = isset($_GET['debut']) ? intval($_GET['debut']) : 0; |
$criteres['limite'] = isset($_GET['limite']) ? intval($_GET['limite']) : 0; |
$observations = $chercheur_observations->rechercherObservations($params['uid'], |
$criteres, |
$criteres['debut'], |
$criteres['limite']); |
|
$observations = $chercheur_observations |
->rechercherObservations($params['uid'], $criteres, $criteres['debut'], $criteres['limite']) |
->get(); |
|
// debug //echo ($chercheur_observations->requete_selection_observations); |
// XXX: malheureusement l'instance de JRest n'est pas accessible ici |
if(!$observations) { |
header('HTTP/1.0 204 No Content'); |
136,17 → 136,26 |
foreach ($observations as $obs) { |
$colid = 0; |
foreach($colonnes as $slug => $colonne) { |
$valeur = $obs[$slug]; |
// valeur direct depuis cel_obs ? |
if(isset($obs[$slug])) $valeur = $obs[$slug]; |
|
// pré-processeur des champs |
if(function_exists($colonne['function'])) |
$valeur = $colonne['function']($valeur); |
elseif(method_exists(__CLASS__, $colonne['function'])) |
$valeur = call_user_func(array(__CLASS__, $colonne['function']), $valeur); |
elseif($colonne['function']) { |
die("méthode {$colonne['function']} introuvable"); |
// pré-processeur de la champs |
if(function_exists($colonne['fonction'])) { |
$valeur = $colonne['fonction']($valeur); |
} elseif(method_exists(__CLASS__, $colonne['fonction'])) { |
$valeur = call_user_func(array(__CLASS__, $colonne['fonction']), $valeur); |
} elseif($colonne['fonction']) { |
die("méthode {$colonne['fonction']} introuvable"); |
} |
// fonction pour obtenir des champs (étendus) |
elseif(function_exists($colonne['fonction_data'])) { |
$valeur = $colonne['fonction_data']($obs); |
} |
elseif(method_exists(__CLASS__, $colonne['fonction_data'])) { |
$valeur = call_user_func(array(__CLASS__, $colonne['fonction_data']), $obs); |
} |
|
|
// // cette section devrait être vide: |
// // cas particuliers ingérable avec l'architecture actuelle: |
if(false && $slug == 'date_observation' && $valeur == "0000-00-00") { /* blah */ } |
175,6 → 184,7 |
static function rangeToList($in = '') { |
$inSets = explode(',', $in); |
$outSets = array(); |
|
foreach($inSets as $inSet) { |
list($start,$end) = explode('-', $inSet . '-' . $inSet); |
$outSets = array_merge($outSets,range($start,$end)); |
204,10 → 214,10 |
if(isset($fieldSets['standard'])) { |
$colonnes += Array( |
'nom_sel' => self::GenColInfo('nom_sel', 'Espèce'), |
'nom_sel_nn' => self::GenColInfo('nom_sel_nn', 'Numero nomenclatural'), |
'nom_sel_nn' => self::GenColInfo('nom_sel_nn', 'Numéro nomenclatural'), |
'nom_ret' => self::GenColInfo('nom_ret', 'Nom retenu'), |
'nom_ret_nn' => self::GenColInfo('nom_ret_nn', 'Numero nomenclatural nom retenu'), |
'nt' => self::GenColInfo('nt', 'Numero taxonomique'), |
'nom_ret_nn' => self::GenColInfo('nom_ret_nn', 'Numéro nomenclatural nom retenu'), |
'nt' => self::GenColInfo('nt', 'Numéro taxonomique'), |
'famille' => self::GenColInfo('famille', 'Famille'), |
'nom_referentiel' => self::GenColInfo('nom_referentiel', 'Referentiel taxonomique'), |
'zone_geo' => self::GenColInfo('zone_geo', 'Commune'), |
219,7 → 229,7 |
'commentaire' => self::GenColInfo('commentaire', 'Notes'), |
'latitude' => self::GenColInfo('latitude', 'Latitude', 1), |
'longitude' => self::GenColInfo('longitude', 'Longitude', 1), |
'geodatum' => self::GenColInfo('geodatum', 'Referentiel Geographique', 1), |
'geodatum' => self::GenColInfo('geodatum', 'Référentiel Géographique', 1), |
|
'ordre' => self::GenColInfo('ordre', 'Ordre', 1), |
'id_observation' => self::GenColInfo('id_observation', 'Identifiant', 1), |
232,7 → 242,10 |
'abondance' => self::GenColInfo('abondance', 'Abondance', 1), |
'certitude' => self::GenColInfo('certitude', 'Certitude', 1), |
'phenologie' => self::GenColInfo('phenologie', 'Phénologie', 1), |
|
|
//'nom-commun' => self::GenColInfo('nom-commun', 'Nom Commun', 1, NULL, 'getNomCommun') |
//'nom-commun' => self::GenColInfo('nom-commun', 'Nom Commun', 1, NULL, 'getNomCommun_v2') |
//'nom-commun' => self::GenColInfo('nom-commun', 'Nom Commun', 1, NULL, 'getNomCommun_v3') |
); |
} |
|
242,24 → 255,29 |
/* |
* Wrapper générant un tableau associatif: |
* @param $is_extra: défini si la colonne est extra (auquelle une bordure bleue entoure son nom dans la première ligne |
* @param $function: un nom optionnel d'un fonction de préprocessing |
* $function doit prendre comme argument la valeur et retourner la valeur transformée |
* @param $fonction (optionnel): un nom d'un fonction de préprocessing |
* $fonction doit prendre comme seul argument la valeur d'origine et retourner la valeur transformée |
* @param $fonction_data (optionnel): une *méthode* d'obtention de donnée |
* $fonction_data doit prendre comme premier argument les champs de l'enregistrement existant |
* $fonction_data doit retourner une valeur |
|
*/ |
static function GenColInfo($slug, $nom, $is_extra = 0, $function = NULL) { |
static function GenColInfo($slug, $nom, $is_extra = 0, $fonction = NULL, $fonction_data = NULL) { |
return Array('slug' => $slug, |
'nom' => $nom, |
'extra' => $is_extra ? 1 : 0, |
'function' => $function |
'fonction' => $fonction, |
'fonction_data' => $fonction_data |
); |
} |
|
protected function formaterDate($date_heure_mysql, $format = NULL) { |
if (!$date_heure_mysql || $date_heure_mysql == "0000-00-00 00:00:00") return "00/00/0000"; |
$timestamp = DateTime::createFromFormat("Y-m-d H:i:s", $date_heure_mysql); |
$timestamp = DateTime::createFromFormat("Y-m-d H:i:s", $date_heure_mysql)->getTimestamp(); |
if(!$timestamp) return "00/00/0000"; |
// TODO: les widget ne font malheureusement pas usage de l'heure dans le CEL |
$date_formatee = strftime('%A %d %B %Y', $timestamp->getTimestamp()); |
$date_formatee = strftime('%A %d %B %Y', $timestamp); |
if(!$date_formatee) return "00/00/0000"; |
return $date_formatee; |
} |
} |
} |