Subversion Repositories eFlore/Applications.del

Compare Revisions

No changes between revisions

Ignore whitespace Rev 1921 → Rev 1922

/trunk/services/modules/0.1/observations/ListeObservations.php
117,7 → 117,8
*/
private function getInfosObs() {
$idsObsConcat = implode(',', $this->idsObsOrdonnees);
$requete = "SELECT id_observation, nom_sel AS `determination.ns`, nt AS `determination.nt`, ".
// TODO : bizarement MYSQL 5.6 retourne plusieurs fois les mêmes enregistrements d'où le DISTINCT (normalement inutile)
$requete = "SELECT DISTINCT id_observation, nom_sel AS `determination.ns`, nt AS `determination.nt`, ".
'nom_sel_nn AS `determination.nn`, famille AS `determination.famille`, '.
'nom_referentiel AS `determination.referentiel`, ce_zone_geo AS id_zone_geo, '.
'zone_geo, lieudit, station, milieu, date_observation, do.mots_cles_texte, '.
129,6 → 130,7
' LEFT JOIN del_image AS di ON (do.id_observation = di.ce_observation) '.
"WHERE id_observation IN ($idsObsConcat) ".
' -- '.__FILE__.':'.__LINE__;
//Debug::printr($requete);
return $this->bdd->recupererTous($requete);
}
 
140,14 → 142,15
private function formaterObservations() {
$observations = array_map('array_filter', $this->infosObs);
$obsFormatees = array_flip($this->idsObsOrdonnees);// Permet de garder l'ordre de sortie !
foreach ($observations as $obs) {
foreach ($observations as &$obs) {
$this->nettoyerAuteur($obs);
 
$id = $obs['id_observation'];
$obsFormatees[$id] = $obs;
 
$image = $this->extraireInfosImage($obs);
$obsFormatees[$id]['images'][] = $image;
// ATTENTION : la requête retourne de nombreuses lignes avec les mêmes données (test de l'existence nécessaire)
if (is_array($obsFormatees[$id]) === false) {
$obsFormatees[$id] = $obs;
}
$obsFormatees[$id]['images'][] = $this->extraireInfosImage($obs);
}
return $obsFormatees;
}
Property changes:
Added: svnkit:entry:sha1-checksum
+a907dccbc2c4971fed812325a132c6ba9d675b72
\ No newline at end of property
/trunk/services/modules/0.1/observations/ObservationDetails.php
85,7 → 85,8
"IFNULL(du.nom, do.nom_utilisateur) AS `auteur.nom`",
"IFNULL(du.courriel, do.courriel_utilisateur) AS `auteur.courriel`"));
 
$requete = "SELECT $obsChamps, $imgChamps, $annuaireChamps ".
// TODO : bizarement MYSQL 5.6 retourne plusieurs fois les mêmes enregistrements d'où le DISTINCT (normalement inutile)
$requete = "SELECT DISTINCT $obsChamps, $imgChamps, $annuaireChamps ".
"FROM del_observation AS do ".
" LEFT JOIN del_image AS di ON (do.id_observation = di.ce_observation) ".
" LEFT JOIN del_utilisateur AS du ON (do.ce_utilisateur = du.id_utilisateur) ".
92,20 → 93,27
"WHERE do.id_observation = {$this->idObs} ".
'-- '.__FILE__.':'.__LINE__;
//Debug::printr($requete);
return $this->bdd->recuperer($requete);
return $this->bdd->recupererTous($requete);
}
 
private function formaterObservation($infos) {
$infos = array_filter($infos);
foreach ($infos as $info) {
$image = array_intersect_key($info, array_flip(array('id_image', 'date', 'hauteur' , 'largeur', 'nom_original')));
$urlImgTpl = $this->conteneur->getParametre('cel_img_url_tpl');
$imageFormat = 'XL';
$image['binaire.href'] = sprintf($urlImgTpl, $image['id_image'], $imageFormat);
unset($info['id_image'], $info['date'], $info['hauteur'], $info['largeur'], $info['nom_original']);
 
$image = array_intersect_key($infos, array_flip(array('id_image', 'date', 'hauteur' , 'largeur', 'nom_original')));
$urlImgTpl = $this->conteneur->getParametre('cel_img_url_tpl');
$imageFormat = 'XL';
$image['binaire.href'] = sprintf($urlImgTpl, $image['id_image'], $imageFormat);
unset($infos['id_image'], $infos['date'], $infos['hauteur'], $infos['largeur'], $infos['nom_original']);
 
$this->observation = $infos;
$this->observation['images'][$image['id_image']] = $image;
// ATTENTION : la requête retourne de nombreuses lignes avec les mêmes données (test de l'existence nécessaire)
if (!isset($this->observation)) {
$this->observation = $info;
$this->observation['images'] = array();
}
if (!isset($this->observation['images'][$image['id_image']])) {
$this->observation['images'][$image['id_image']] = $image;
}
}
}
 
private function getCommentaires() {
Property changes:
Added: svnkit:entry:sha1-checksum
+4089895a5dcb7422fbe6b5f30ea02926993bd44b
\ No newline at end of property
/trunk/services/modules/0.1/syndication/VotesParProtocole.php
File deleted
\ No newline at end of file
/trunk/services/modules/0.1/syndication/Commentaires.php
155,24 → 155,49
}
 
private function getDerniersCommentaires() {
$commentaires = array();
$idsCommentaires = $this->getIdsDerniersCommentaires();
if (!empty($idsCommentaires)) {
$idsCommentairesconcat = implode(', ', $idsCommentaires);
$requete = 'SELECT DISTINCT dc.*, '.
' dob.id_observation AS dob_id_observation, dob.ce_zone_geo AS dob_ce_zone_geo, '.
' dob.zone_geo AS dob_zone_geo, dob.date_observation AS dob_date_observation, dob.nom_sel AS dob_nom_sel, '.
' duo.prenom AS observateur_prenom, duo.nom AS observateur_nom, duo.courriel AS observateur_courriel '.
'FROM del_commentaire AS dc '.
' INNER JOIN del_observation AS dob '.
' ON dob.id_observation = dc.ce_observation '.
' LEFT JOIN del_utilisateur AS duo '.
' ON dob.ce_utilisateur = duo.id_utilisateur '.
"WHERE id_commentaire IN ($idsCommentairesconcat) ".
'ORDER BY dc.date DESC '.
'LIMIT '.$this->navigation->getDepart().','.$this->navigation->getLimite().' '.
' -- '.__FILE__.' : '.__LINE__;
$commentaires = $this->bdd->recupererTous($requete);
}
return $commentaires;
}
 
private function getIdsDerniersCommentaires() {
$clauseWhere = $this->chargerClauseWhere();
$requete = 'SELECT DISTINCT dc.*, '.
' dob.id_observation AS dob_id_observation, dob.ce_zone_geo AS dob_ce_zone_geo, '.
' dob.zone_geo AS dob_zone_geo, dob.date_observation AS dob_date_observation, dob.nom_sel AS dob_nom_sel, '.
' duo.prenom AS observateur_prenom, duo.nom AS observateur_nom, duo.courriel AS observateur_courriel '.
$requete = 'SELECT DISTINCT dc.id_commentaire '.
'FROM del_commentaire AS dc '.
' INNER JOIN del_observation AS dob '.
' ON dob.id_observation = dc.ce_observation '.
' LEFT JOIN del_utilisateur AS duo '.
' ON dob.ce_utilisateur = duo.id_utilisateur '.
' INNER JOIN del_observation AS dob ON (dc.ce_observation = dob.id_observation) '.
' LEFT JOIN del_utilisateur AS duo ON (dob.ce_utilisateur = duo.id_utilisateur) '.
'WHERE proposition_initiale != 1 '.
($clauseWhere != '' ? "AND $clauseWhere " : '').
'ORDER BY dc.date DESC '.
'LIMIT '.$this->navigation->getDepart().','.$this->navigation->getLimite().' '.
' -- '.__FILE__.' : '.__LINE__;
//echo $requete;
$resultats = $this->bdd->recupererTous($requete);
 
$elements = $this->bdd->recupererTous($requete);
return $elements;
$idsCommentaires = array();
if ($resultats != false && is_array($resultats)) {
foreach ($resultats as $infos) {
$idsCommentaires[] = $infos['id_commentaire'];
}
}
return $idsCommentaires;
}
 
/**
191,7 → 216,7
switch ($cleFiltre) {
case 'espece':
$valeurP = $this->bdd->proteger($valeur.'%');
$where[] = " dob.$champ LIKE $valeurP OR dc.$champ LIKE $valeurP ";
$where[] = " (dob.$champ LIKE $valeurP OR dc.$champ LIKE $valeurP) ";
break;
case 'auteur':
$where[] = $this->creerFiltreAuteur($valeur);
203,7 → 228,7
}
}
}
return (!empty($where)) ? implode('AND', $where) : '';
return (!empty($where)) ? implode(' AND ', $where) : '';
}
 
private function creerFiltreAuteur($auteurId) {
217,9 → 242,9
$whereAuteur = " dc.utilisateur_courriel LIKE $auteurIdMotif ";
} else {
$tableauNomPrenom = explode(' ', $auteurId, 2);
if (count($tableauNomPrenom) != 2) {
$whereAuteur = "(dc.utilisateur_nom LIKE $auteurIdMotif OR dc.utilisateur_prenom LIKE $auteurIdMotif) ";
} else {
if (count($tableauNomPrenom) == 1) {
$whereAuteur = " (dc.utilisateur_nom LIKE $auteurIdMotif OR dc.utilisateur_prenom LIKE $auteurIdMotif) ";
} else if (count($tableauNomPrenom) == 2) {
// on teste potentiellement un nom prenom ou bien un prénom nom
$nomMotif = $this->bdd->proteger($tableauNomPrenom[0].'%');
$prenomMotif = $this->bdd->proteger($tableauNomPrenom[1].'%');
227,7 → 252,7
$whereAuteur = ' ('.
"(dc.utilisateur_nom LIKE $nomMotif AND dc.utilisateur_prenom LIKE $prenomMotif) ".
'OR '.
"(dc.utilisateur_nom LIKE $nomMotif AND dc.utilisateur_prenom LIKE $prenomMotif) ".
"(dc.utilisateur_nom LIKE $prenomMotif AND dc.utilisateur_prenom LIKE $nomMotif) ".
') ';
}
}
Property changes:
Added: svnkit:entry:sha1-checksum
+9ac625ab6837ca8768dbe4ffc3ec13c73f2b5009
\ No newline at end of property
/trunk/services/modules/0.1/syndication/Tags.php
167,44 → 167,53
* Retrouver les derniers votes image
* */
private function getDerniersVotesImage() {
$clauseWhere = $this->chargerClauseWhere();
$requete = 'SELECT DISTINCT id_tag, tag, date, '.
' do.id_observation, do.nom_sel, do.zone_geo, do.date_observation, doi.id_image, '.
' duo.prenom AS auteur_prenom, duo.nom AS auteur_nom, duo.courriel AS auteur_courriel, '.
' du.prenom AS tagueur_prenom, du.nom AS tagueur_nom, du.courriel AS tagueur_courriel '.
'FROM del_image_tag AS dit '.
' INNER JOIN del_obs_image AS doi '.
' ON ce_image = id_image '.
' INNER JOIN del_observation AS do '.
' ON doi.id_observation = do.id_observation '.
' LEFT JOIN del_utilisateur AS duo '.
' ON do.ce_utilisateur = duo.id_utilisateur '.
' LEFT JOIN del_utilisateur AS du '.
' ON if((CHAR_LENGTH(dit.ce_utilisateur) <> 32),CAST(dit.ce_utilisateur AS unsigned),0) '.
' = du.id_utilisateur '.
$elements = array();
$idsTags = $this->getIdsDerniersVotesImage();
if (!empty($idsTags)) {
$idsTagsConcat = implode(', ', $idsTags);
$requete = 'SELECT DISTINCT id_tag, tag, date, '.
' do.id_observation, do.nom_sel, do.zone_geo, do.date_observation, di.id_image, '.
' duo.prenom AS auteur_prenom, duo.nom AS auteur_nom, duo.courriel AS auteur_courriel, '.
' du.prenom AS tagueur_prenom, du.nom AS tagueur_nom, du.courriel AS tagueur_courriel '.
'FROM del_image_tag AS dit '.
' INNER JOIN del_image AS di '.
' ON ce_image = id_image '.
' INNER JOIN del_observation AS do '.
' ON di.ce_observation = do.id_observation '.
' LEFT JOIN del_utilisateur AS duo '.
' ON do.ce_utilisateur = duo.id_utilisateur '.
' LEFT JOIN del_utilisateur AS du '.
' ON if((CHAR_LENGTH(dit.ce_utilisateur) <> 32),CAST(dit.ce_utilisateur AS unsigned),0) '.
' = du.id_utilisateur '.
'WHERE actif = 1 '.
" AND id_tag IN ($idsTagsConcat) ".
'ORDER BY date DESC '.
'LIMIT '.$this->navigation->getDepart().','.$this->navigation->getLimite().' '.
' -- '.__FILE__.' : '.__LINE__;
$elements = $this->bdd->recupererTous($requete);
}
return $elements;
}
 
/**
* Retrouver les ids des derniers votes image
* */
private function getIdsDerniersVotesImage() {
$requete = 'SELECT DISTINCT id_tag '.
'FROM del_image_tag '.
'WHERE actif = 1 '.
($clauseWhere != '' ? "AND $clauseWhere " : '').
// Pas de filtre pour ce service. Utiliser le principe des autres ws de syndication si on devait en rajouter.
'ORDER BY date DESC '.
'LIMIT '.$this->navigation->getDepart().','.$this->navigation->getLimite().' '.
' -- '.__FILE__.' : '.__LINE__;
$elements = $this->bdd->recupererTous($requete);
return $elements;
}
$resultats = $this->bdd->recupererTous($requete);
 
private function chargerClauseWhere() {
$where = array();
$filtres = $this->navigation->getFiltre();
if (!empty($filtres)) {
$filtrePossibles = $this->conteneur->getParametreTableau('syndication.tag_filtres');
foreach ($filtres as $cleFiltre => $valeur) {
if (in_array($cleFiltre, $filtrePossibles)) {
$champ = $this->mapping[$cleFiltre];
$valeurP = $this->bdd->proteger($valeur);
$where[] = " $champ = $valeurP ";
}
$idsTags = array();
if ($resultats != false && is_array($resultats)) {
foreach ($resultats as $infos) {
$idsTags[] = $infos['id_tag'];
}
}
 
return (!empty($where)) ? implode('AND', $where) : '';
return $idsTags;
}
}
Property changes:
Added: svnkit:entry:sha1-checksum
+0aaf0e201a3d29d801b57d08d5878bb16dbdbb41
\ No newline at end of property
/trunk/services/modules/0.1/syndication/Votes.php
New file
0,0 → 1,228
<?php
// declare(encoding='UTF-8');
/**
* Service fournissant des informations concernant les votes sur les images de DEL en fonction d'un protocole
* au format RSS1, RSS2 ou ATOM.
*
* @category DEL
* @package Services
* @subpackage Syndication
* @version 0.1
* @author Mathias CHOUET <mathias@tela-botanica.org>
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
*/
class Votes {
 
private $categorie = 'Vote protocole';
private $conteneur;
private $bdd;
private $navigation;
private $syndication;
private $mapping = array();
 
public function __construct(Conteneur $conteneur) {
$this->conteneur = $conteneur;
$this->bdd = $this->conteneur->getBdd();
$this->navigation = $this->conteneur->getNavigation();
$this->syndication = $this->conteneur->getSyndicationOutils();
$this->mapping = $this->conteneur->getParametreTableau('syndication.mapping');
}
 
public function consulter() {
if ($this->syndication->fluxAdminDemande()) {
$this->syndication->demanderAutorisationAdmin();
}
 
$donnees_brutes = $this->getDerniersVotesImage();
$commentaires_formates = $this->formaterPourRss($donnees_brutes) ;
return $commentaires_formates;
}
 
/**
* Formater les données pour mettre en page le RSS
* */
private function formaterPourRss($elements) {
$derniere_info_en_date = reset($elements);
$donnees = $this->syndication->construireDonneesCommunesAuFlux('vote', $derniere_info_en_date['date_vote']);
foreach ($elements as $element) {
$donnees['items'][] = $this->construireDonneesCommunesAuxItems($element);
}
return $donnees;
}
 
/**
* Générer les données communes & spécifiques à chaque item
* */
private function construireDonneesCommunesAuxItems($info) {
$item = array();
$date_modification_timestamp = strtotime($info['date_vote']);
$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
$item['titre'] = $this->creerTitre($info);
$item['guid'] = $this->creerGuidItem($info);
$item['lien'] = $this->creerLienItem($info);
$item['categorie'] = htmlentities($this->categorie);
$item['description'] = $this->creerDescription($info, $item);
$item['description_encodee'] = htmlspecialchars($this->creerDescription($info, $item));
$item['modifier_par'] = $this->creerVotant($info);
return $item;
}
 
private function creerGuidItem($element) {
$guid = sprintf($this->conteneur->getParametre('syndication.vote_guid_tpl'), $element['id_vote']);
return $guid;
}
 
private function creerLienItem($element) {
$lien = sprintf($this->conteneur->getParametre('img_fiche_tpl'), $element['ce_image']);
return $lien;
}
 
private function creerTitre($element) {
$noteVote = $element['valeur'];
$nomSci = htmlspecialchars($element['nom_sel']);
$votant = htmlspecialchars($this->creerVotant($element));
$observateur = htmlspecialchars($this->creerObservateur($element));
 
$titre = "Vote $noteVote par $votant pour $nomSci de $observateur";
return $titre;
}
 
private function creerDescription($donnees, $item) {
$idVote = htmlspecialchars($donnees['id_vote']);
$idObs = htmlspecialchars($donnees['id_observation']);
$idImg = htmlspecialchars($donnees['ce_image']);
$urlImg = $this->syndication->getUrlImage($donnees['ce_image']);
$miniatureUrl = $this->syndication->getUrlImage($donnees['ce_image'], 'CRS');
$nomSelActuel = htmlspecialchars($donnees['nom_sel']);
$dateObs = htmlspecialchars(str_replace(' 00:00:00', '', $donnees['date_observation']));
$lieuObs = htmlspecialchars($donnees['zone_geo']);
$protocole = htmlspecialchars($donnees['intitule']);
$votant = htmlspecialchars($this->creerVotant($donnees));
$dateVote = htmlspecialchars(strftime('%A %d %B %Y à %H:%M', strtotime($donnees['date_vote'])));
$observateur = htmlspecialchars($this->creerObservateur($donnees));
 
$description = '<style>.champ{color:grey} .gauche{float:left;padding:0 20px 0 0;} ul{list-style-type:none;padding:0;}</style>'.
'<h2>'."Vote pictoFlora #$idVote pour l'image #$idImg de l'observation #$idObs".'</h2>'.
'<div class="gauche">'.
' <a href="'.$urlImg.'">'.
' <img src="'.$miniatureUrl.'" alt="Img #'.$idImg.'"/>'.
' </a>'.
'</div>'.
'<div class="gauche">'.
" <h3>Image #$idImg de l'observation #$idObs</h3>".
' <ul>'.
' <li><span class="champ">'."Auteur de l'image :</span> $observateur</li>".
' <li><span class="champ">'."Nom saisi actuel :</span> <em>$nomSelActuel</em></li>".
' <li><span class="champ">'."Lieu :</span> $lieuObs</li>".
' <li><span class="champ">'."Date :</span> $dateObs</li>".
' </ul>'.
'</div>'.
'<div class="gauche">'.
" <h3>Vote #$idVote</h3>".
' <ul>'.
' <li><span class="champ">'."Protocole :</span> <strong>$protocole</strong></li>".
' <li><span class="champ">'."Valeur :</span> <strong>{$donnees['valeur']}</strong>/5</li>".
' <li><span class="champ">'."Votant :</span> $votant</li>".
' <li><span class="champ">'."À voté le :</span> $dateVote</li>".
' </ul>'.
'</div>';
return $description;
}
 
private function creerVotant($info) {
$votant = 'Anonyme';
if (isset($info['votant_prenom']) && isset($info['votant_nom'])) {
$votant = $info['votant_prenom'].' '.$info['votant_nom'];
}
return $votant;
}
 
private function creerObservateur($info) {
$observateur = 'Anonyme';
if ($info['observateur_prenom'] != '' && $info['observateur_nom'] != '') {
$observateur = $info['observateur_prenom'].' '.$info['observateur_nom'];
}
return $observateur;
}
 
 
 
/**
* Retrouver les derniers votes image
* */
private function getDerniersVotesImage() {
$elements = array();
$idsVotes = $this->getIdsDerniersVotesImage();
if (!empty($idsVotes)) {
$idsVotesConcat = implode(', ', $idsVotes);
$requete = 'SELECT DISTINCT id_vote, ce_image, valeur, divo.date AS date_vote, '.
' duo.prenom AS observateur_prenom, duo.nom AS observateur_nom, '.
' duv.prenom AS votant_prenom, duv.nom AS votant_nom, '.
' do.id_observation, do.nom_sel, do.zone_geo, do.date_observation, dip.intitule '.
'FROM del_image_vote AS divo '.
' INNER JOIN del_image AS di '.
' ON divo.ce_image = di.id_image '.
' INNER JOIN del_observation AS do '.
' ON di.ce_observation = do.id_observation '.
' INNER JOIN del_image_protocole AS dip '.
' ON ce_protocole = id_protocole '.
' LEFT JOIN del_utilisateur AS duo '.
' ON do.ce_utilisateur = duo.id_utilisateur '.
' LEFT JOIN del_utilisateur AS duv '.
' ON if((CHAR_LENGTH(divo.ce_utilisateur) <> 32),CAST(divo.ce_utilisateur AS unsigned),0) '.
' = duv.id_utilisateur '.
"WHERE id_vote IN ($idsVotesConcat) ".
'ORDER BY divo.date DESC '.
'LIMIT '.$this->navigation->getDepart().','.$this->navigation->getLimite().
' -- '.__FILE__.' : '.__LINE__;
$elements = $this->bdd->recupererTous($requete);
}
return $elements;
}
 
/**
* Retrouver les ids des derniers votes image
* */
private function getIdsDerniersVotesImage() {
$clauseWhere = $this->chargerClauseWhere();
$requete = 'SELECT DISTINCT id_vote '.
'FROM del_image_vote '.
($clauseWhere != '' ? "WHERE $clauseWhere " : '').
'ORDER BY date DESC '.
'LIMIT '.$this->navigation->getDepart().','.$this->navigation->getLimite().
' -- '.__FILE__.' : '.__LINE__;
$resultats = $this->bdd->recupererTous($requete);
 
$idsVotes = array();
if ($resultats != false && is_array($resultats)) {
foreach ($resultats as $infos) {
$idsVotes[] = $infos['id_vote'];
}
}
return $idsVotes;
}
 
private function chargerClauseWhere() {
$where = array();
$filtres = $this->navigation->getFiltre();
if (!empty($filtres)) {
$filtrePossibles = $this->conteneur->getParametreTableau('syndication.vote_filtres');
foreach ($filtres as $cleFiltre => $valeur) {
if (in_array($cleFiltre, $filtrePossibles)) {
$champ = $this->mapping[$cleFiltre];
$valeurP = $this->bdd->proteger($valeur);
$where[] = " $champ = $valeurP ";
}
}
}
 
return (!empty($where)) ? implode('AND', $where) : '';
}
}
/trunk/services/modules/0.1/plantnet/Changements.php
174,6 → 174,7
private function formaterInfos() {
// regroupe les observations
$obs = array();
$imgCelTpl = $this->conteneur->getParametre('cel_img_url_tpl');
foreach ($this->idsObsImg as $ids) {
$idobs = $ids['id_observation'];
$idimg = $ids['id_image'];
215,7 → 216,7
$img_obj = array(
'id_image' => $idimg,
'nom_image' => $imgdata['nom_image'],
'url' => sprintf('http://api.tela-botanica.org/img:%09dO.jpg', $idimg),
'url' => sprintf($imgCelTpl, $idimg, 'O'),
'votes' => array_map('intval', explode(',', $ids['votes'])),
'tags' => explode(',', $ids['tags']),
'mots_cles_img_cel' => $this->formaterMotsClesCel($imgdata['mots_cles_texte_image'])
283,11 → 284,6
return $ret;
}
 
 
/*-------------------------------------------------------------------------------
FORMATER ET METTRE EN FORME
--------------------------------------------------------------------------------*/
 
/**
* Formater les mots clés du cel en n'affichant que ceux faisant partie
* d'une liste définie dans le fichier de configuration
Property changes:
Added: svnkit:entry:sha1-checksum
+688f54846ca97b444ba8c783a83a3fc869a30bf3
\ No newline at end of property
/trunk/services/modules/0.1/determinations/ListeImagesDeterminationsProbables.php
58,8 → 58,8
 
// Lancement du service
$this->idsImagesOrdonnees = $this->getIdsImages();
$this->modifierEnteteTotal();
$infos = $this->chargerInfos();
$this->modifierEnteteTotal();
if ($infos) {
$this->traiterResultats($infos);
$this->completerResutlats();
112,7 → 112,7
'FROM del_image AS di '.
' LEFT JOIN del_image_stat AS ds ON (di.id_image = ds.ce_image) '.
"$whereClause ".
'ORDER BY moyenne DESC '.
'ORDER BY moyenne DESC, id_image DESC '.
"LIMIT $depart, $limite ".
' -- '.__FILE__.' : '.__LINE__;
//Debug::printr($requete);
153,8 → 153,9
' LEFT JOIN del_utilisateur AS du ON (di.ce_utilisateur = du.id_utilisateur) '.
' LEFT JOIN del_image_stat AS ds ON (di.id_image = ds.ce_image) '.
"WHERE di.id_image IN ($idImgsConcat) ".
'ORDER BY moyenne DESC '.
'ORDER BY moyenne DESC, id_image DESC '.
' -- '.__FILE__.' : '.__LINE__;
//Debug::printr($requete);
return $this->bdd->recupererTous($requete);
}
 
257,6 → 258,7
$this->resultats[$index]['determination.ns'] = $this->propositions[$id_obs]['nom_sel'];
$this->resultats[$index]['determination.nn'] = $this->propositions[$id_obs]['nom_sel_nn'];
$this->resultats[$index]['determination.nt'] = $this->propositions[$id_obs]['nt'];
$this->resultats[$index]['determination.referentiel'] = $this->propositions[$id_obs]['nom_referentiel'];
}
$this->completerUrlFicheEflore($index);
}
338,9 → 340,23
private function completerUrlFicheEflore($index) {
if (isset($this->resultats[$index]['determination.nn'])) {
$urlTpl = $this->conteneur->getParametre('determinations.url_fiche_eflore_tpl');
$nn = $this->resultats[$index]['determination.nn'];
$nn = (int) $this->resultats[$index]['determination.nn'];
$ref = $this->resultats[$index]['determination.referentiel'];
$code_ref = $this->getCodeReferentiel($ref);
if (is_int($nn) && ! isset($code_ref)) {
$code_ref = 'bdtfx';
}
$this->resultats[$index]['url_fiche_eflore'] = sprintf($urlTpl, $code_ref, $nn);
}
}
 
$this->resultats[$index]['url_fiche_eflore'] = sprintf($urlTpl, $nn);
private function getCodeReferentiel($ref) {
$code = $ref;
if ($position = strpos($ref, '_')) {
$code = substr($ref, 0, $position);
} else if ($position = strpos($ref, ':')) {
$code = substr($ref, 0, $position);
}
return $code;
}
}
Property changes:
Added: svnkit:entry:sha1-checksum
+474012b08dfb5d9bd5f4a18e3e5eeb6903cfb084
\ No newline at end of property
/trunk/services/modules/0.1/images/ListeImages.php
89,7 → 89,7
$this->sql->getLimit().
' -- '.__FILE__.':'.__LINE__;
// TODO : si le DISCTINCT dans la requête pose des pb de perf, supprimer les doublons d'id à l'aide de PHP
//Debug::printr($requete);
//Debug::printr($requete);exit();
$resultats = $this->bdd->recupererTous($requete);
$idImgs = array();
if ($resultats !== false ) {
Property changes:
Added: svnkit:entry:sha1-checksum
+d84f6381a2c4b4dcdd4e3de6e7b10fb8ad8e334d
\ No newline at end of property
/trunk/services/modules/0.1/Syndication.php
78,9 → 78,13
}
 
private function analyserRessources() {
if ($this->methode == 'consulter') {
if (isset($this->ressources[0])) {
$this->sousServiceNom = $this->ressources[0];
if ($this->methode == 'consulter' && isset($this->ressources[0])) {
if (preg_match('/^tags|votes-?-Par-?Tag|tags-?Par-?Protocole$/i', $this->ressources[0])) {
$this->sousServiceNom = 'tags';
} else if (preg_match('/^votes|votes-?Par-?Protocole$/i', $this->ressources[0])){
$this->sousServiceNom = 'votes';
} else if ($this->ressources[0] == 'commentaires') {
$this->sousServiceNom = 'commentaires';
}
}
if ($this->sousServiceNom == null) {
109,7 → 113,7
}
 
private function initialiserService() {
$classe = $this->obtenirNomClasseService($this->sousServiceNom);
$classe = $this->obtenirNomClasseService();
$chemins = array();
$chemins[] = $this->cheminCourant.$this->serviceNom.DS.$classe.'.php';
$chemins[] = $this->cheminCourant.'commun'.DS.$classe.'.php';
142,9 → 146,8
return $retour;
}
 
private function obtenirNomClasseService($mot) {
$classeNom = str_replace(' ', '', ucwords(strtolower(str_replace('-', ' ', $mot))));
return $classeNom;
private function obtenirNomClasseService() {
return str_replace(' ', '', ucwords(strtolower(str_replace('-', ' ', $this->sousServiceNom))));
}
 
private function creerResultatService($donnees) {
Property changes:
Added: svnkit:entry:sha1-checksum
+40211bf16084bd2d96250989c0bb58b4fa8dbe36
\ No newline at end of property
/trunk/services/configurations/config.defaut.ini
174,7 → 174,7
; Format d'image pour les liens du web service ListeImagesDeterminationsProbables
format_image = "L"
; Template d'URL pour la fiche eFlore d'un nom
url_fiche_eflore_tpl = "http://www.tela-botanica.org/nn%s";
url_fiche_eflore_tpl = "http://www.tela-botanica.org/%s-nn-%s";
 
[nomstaxons]
; Masque de filtrage possible pour la consultation :
268,7 → 268,7
courriel_utilisateur = auteur.courriel"
; Texte du tag "à déterminer"
tag_adeterminer = aDeterminer
;
; Permet d'indiquer le nombre de commentaire nécessaire pour que l'observation apparaisse dans l'onglet "En discussion" d'IdentiPlante.
nb_commentaires_discussion = 1
 
[images]
Property changes:
Added: svnkit:entry:sha1-checksum
+43aaff7f302ddba1504b6409428b18f0d8b0dbb6
\ No newline at end of property
/trunk/services/bibliotheque/Contexte.php
99,10 → 99,12
if (isset($this->server['QUERY_STRING']) && !empty($this->server['QUERY_STRING'])) {
$paires = explode('&', $this->server['QUERY_STRING']);
foreach ($paires as $paire) {
$nv = explode('=', $paire);
$nom = urldecode($nv[0]);
$valeur = urldecode($nv[1]);
$parametres_bruts[$nom] = $valeur;
if ($paire != '' && substr_count($paire, '=') == 1) {
$nv = explode('=', $paire);
$nom = urldecode($nv[0]);
$valeur = urldecode($nv[1]);
$parametres_bruts[$nom] = $valeur;
}
}
$parametres_bruts = $this->nettoyerParametres($parametres_bruts);
}
Property changes:
Added: svnkit:entry:sha1-checksum
+16702488d5977ffc5aaaf3430bb115a5487d24c5
\ No newline at end of property
/trunk/services/bibliotheque/Navigation.php
18,6 → 18,7
 
private $conteneur;
private $parametresUrl;
private $ressourcesUrl;
private $serviceNom;
private $filtresPossibles;
private $filtresActifs;
36,6 → 37,9
$this->parametresUrl = $contexte->getQS();
$this->serviceNom = $contexte->getRessource(1);
 
$ressources = $contexte->getRessource();
$this->ressourcesUrl = implode('/', array_slice($ressources, 1));
 
$this->filtresPossibles = $this->conteneur->getparametreTableau($this->serviceNom.'.masques_possibles');
$this->chargerFiltresActifs();
}
86,7 → 90,7
$parametres['navigation.depart'] = $depart;
$parametres['navigation.limite'] = $limite;
 
$urlServiceBase = $this->conteneur->getParametre('url_service_base').$this->serviceNom;
$urlServiceBase = $this->conteneur->getParametre('url_service_base').$this->ressourcesUrl;
$urlNavigation = $this->conteneur->getUrl($urlServiceBase);
$urlNavigation->setOption(Url::OPTION_ENCODER_VALEURS, true);
$urlNavigation->setRequete($parametres);
Property changes:
Added: svnkit:entry:sha1-checksum
+c6e827965fa2b8632258e19c6a4f96069d43d7a7
\ No newline at end of property
/trunk/services/bibliotheque/Sql.php
45,9 → 45,9
'orderby' => array());
 
private $champsPrenom = array('du.prenom', 'prenom_utilisateur');
private $champsNom = array('du.nom', 'nom_utilisateur');
private $champsNom = array('du.nom', 'nom_utilisateur');
private $champsSousRequeteObs = array('masque.genre', 'masque.famille', 'masque.ns', 'masque.commune', 'masque.milieu');
 
 
public function __construct(Conteneur $conteneur) {
$this->conteneur = $conteneur;
$this->bdd = $this->conteneur->getBdd();
83,7 → 83,7
 
private function addJoin($join) {
if (!isset($this->requete['join'][$join])) {
$this->requete['join'][] = $join;
$this->requete['join'][$join] = $join;
}
}
 
98,12 → 98,26
private function addWhere($idParam, $where) {
if (isset($this->parametres['_parametres_condition_or_'])
&& in_array($idParam, $this->parametres['_parametres_condition_or_'])) {
$this->requete['where']['OR'][] = $where;
if ($this->etreAppliImg() && in_array($idParam, $this->champsSousRequeteObs)) {
$this->requete['where']['OR_SOUS_REQUETE'][] = $where;
} else {
$this->requete['where']['OR'][] = $where;
}
} else {
$this->requete['where']['AND'][] = $where;
}
}
 
public function getWhere() {
// Sous-requete spéciale pour éviter de rechercher dans la table obs jointe à img depuis Pictoflora...
if (isset($this->requete['where']['OR_SOUS_REQUETE']) && count($this->requete['where']['OR_SOUS_REQUETE']) > 0) {
$clauseWhereSousRequete = implode(' OR ', $this->requete['where']['OR_SOUS_REQUETE']);
$sousRequete = 'di.ce_observation IN '.
"(SELECT DISTINCT id_observation FROM del_observation AS do WHERE $clauseWhereSousRequete ) ";
$this->requete['where']['OR'][] = "( $sousRequete )";
unset($this->requete['join']['LEFT JOIN del_observation AS do ON (di.ce_observation = do.id_observation) ']);
}
 
if (isset($this->requete['where']['OR']) && count($this->requete['where']['OR']) > 0) {
$this->requete['where']['AND'][] = '('.implode(' OR ', $this->requete['where']['OR']).')';
}
450,24 → 464,39
$clausesWhere = array();
foreach ($tags as $tag) {
$tagMotif = $this->bdd->proteger("%$tag%");
$sqlTpl = "CONCAT(IFNULL(do.mots_cles_texte,''),IFNULL(di.mots_cles_texte,'')) LIKE %s";
$clausesWhere[] = sprintf($sqlTpl, $tagMotif);
if ($this->etreAppliImg()) {
$sousRequete = 'SELECT DISTINCT id_observation '.
'FROM del_observation '.
"WHERE mots_cles_texte LIKE $tagMotif ";
$sql = " (di.mots_cles_texte LIKE $tagMotif OR di.id_image IN ($sousRequete) ) ";
} else {
// WARNING : la sous-requête est la meilleure solution trouvée pour contrer le fonctionnement
// étrange de l'optimiseur de MYSQL 5.6 (à retester avec Mysql 5.7 et suivant).
$sousRequete = 'SELECT DISTINCT ce_observation '.
'FROM del_image '.
"WHERE mots_cles_texte LIKE $tagMotif ".
'AND ce_observation IS NOT NULL';
$sql = " (do.mots_cles_texte LIKE $tagMotif OR do.id_observation IN ($sousRequete)) ";
}
$clausesWhere[] = $sql;
}
$whereTags = implode(' AND ', $clausesWhere);
$this->addWhere('masque.tag_cel', "($whereTags)");
} else if (isset($this->parametres['masque.tag_cel']['OR'])) {
$tags = $this->parametres['masque.tag_cel']['OR'];
$tagMotif = $this->bdd->proteger(implode('|', $tags));
$sqlTpl = "CONCAT(IFNULL(do.mots_cles_texte,''),IFNULL(di.mots_cles_texte,'')) REGEXP %s";
$tagMotif = $this->bdd->proteger(implode('|', $tags));
$tagSql = sprintf($sqlTpl, $tagMotif);
 
$this->addWhere('masque.tag_cel', $tagSql);
 
if ($this->etreAppliObs()) {
$this->addJoin('LEFT JOIN del_image AS di ON (di.ce_observation = do.id_observation) ');
}
}
if ($this->etreAppliImg()) {
$this->addJoin('LEFT JOIN del_observation AS do ON (di.ce_observation = do.id_observation) ');
}
if ($this->etreAppliObs()) {
$this->addJoin('LEFT JOIN del_image AS di ON (do.id_observation = di.ce_observation) ');
}
}
}
 
476,50 → 505,32
*/
private function ajouterContrainteTagDel() {
if (isset($this->parametres['masque.tag_del'])) {
if (isset($this->parametres['masque.tag_del']['AND'])) {
$tags = $this->parametres['masque.tag_del']['AND'];
// optimisation: en cas de "AND" on sort() l'input et le GROUP_CONCAT()
// donc nous utilisons des ".*" plutôt que de multiples conditions et "|"
sort($tags);
$tagsMotif = $this->bdd->proteger(implode('.*', $tags));
$requete = 'SELECT ce_image '.
$tagsMotif = $this->construireTagsMotif();
if (is_null($tagsMotif) === false) {
$sousRequete = 'SELECT ce_image '.
'FROM del_image_tag '.
'WHERE actif = 1 '.
'GROUP BY ce_image '.
"HAVING GROUP_CONCAT(tag_normalise ORDER BY tag_normalise) REGEXP $tagsMotif ".
' -- '.__FILE__.' : '.__LINE__;
$sql = $this->recupererSqlContrainteTag($requete);
$this->addWhere('masque.tag_del', $sql);
"HAVING GROUP_CONCAT(DISTINCT tag_normalise ORDER BY tag_normalise) REGEXP $tagsMotif ";
 
} else if (isset($this->parametres['masque.tag_del']['OR'])) {
$tags = $this->parametres['masque.tag_del']['OR'];
$tagsMotif = $this->bdd->proteger(implode('|', $tags));
$requete = 'SELECT ce_image '.
'FROM del_image_tag '.
'WHERE actif = 1 '.
'GROUP BY ce_image '.
"HAVING GROUP_CONCAT(tag_normalise) REGEXP $tagsMotif ".
' -- '.__FILE__.' : '.__LINE__;
 
$sql = $this->recupererSqlContrainteTag($requete);
$this->addWhere('masque.tag_del', $sql);
$this->addWhere('masque.tag_del', "di.id_image IN ($sousRequete)");
}
}
}
 
private function recupererSqlContrainteTag($requete) {
$resultats = $this->bdd->recupererTous($requete);
$ids = array();
foreach ($resultats as $resultat) {
$ids[] = $resultat['ce_image'];
private function construireTagsMotif() {
$tagsMotif = null;
if (isset($this->parametres['masque.tag_del']['AND'])) {
$tags = $this->parametres['masque.tag_del']['AND'];
// ATTENTION -> optimisation: en cas de "AND" on sort() l'input et le GROUP_CONCAT()
// donc nous utilisons des ".*" plutôt que de multiples conditions et "|"
sort($tags);
$tagsMotif = $this->bdd->proteger(implode('.*', $tags));
} else if (isset($this->parametres['masque.tag_del']['OR'])) {
$tags = $this->parametres['masque.tag_del']['OR'];
$tagsMotif = $this->bdd->proteger(implode('|', $tags));
}
 
if (!empty($ids)) {
$clauseIn = implode(',', $ids);
} else {
$clauseIn = 'SELECT ce_image FROM del_image_tag WHERE false';
}
return "di.id_image IN ($clauseIn)";
return $tagsMotif;
}
 
/**
Property changes:
Added: svnkit:entry:sha1-checksum
+d671d5d650c4560e1a9b099d98db1e0c78f00002
\ No newline at end of property
/trunk/services/.
Property changes:
Modified: svn:mergeinfo
Merged /branches/v1.5-carbone/services:r1893-1899,1901-1904,1906-1921