Subversion Repositories eFlore/Applications.cel

Rev

Rev 524 | Rev 528 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 524 Rev 525
Line 245... Line 245...
245
		return $titre;
245
		return $titre;
246
	}
246
	}
Line 247... Line 247...
247
	
247
	
248
	private function creerDescription($donnees, $item) {
248
	private function creerDescription($donnees, $item) {
249
		$methode = 'creerDescription'.$this->service;
249
		$methode = 'creerDescription'.$this->service;
250
		$methode = (method_exists($this, $methode)) ? $methode : 'creerDescriptionSimple';
250
		$methode = (method_exists($this, $methode)) ? $methode : 'creerDescriptionComplet';
251
		$description = $this->$methode($donnees, $item);
251
		$description = $this->$methode($donnees, $item);
252
		$description = $this->nettoyerTexte($description);
252
		$description = $this->nettoyerTexte($description);
253
		return $description;
253
		return $description;
Line 315... Line 315...
315
		return $description;
315
		return $description;
316
	}
316
	}
Line 317... Line 317...
317
	
317
	
318
	private function getServiceComplet() {
318
	private function getServiceComplet() {
-
 
319
		// Construction de la requête
319
		// Construction de la requête
320
		$requete = 	(($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' ci.*, '.
320
		$requete = 	(($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' ci.*, ci_id_image, ci_nom_original, ci_meta_date_ajout, ci_meta_user_comment, ci_note_image '.
321
			'	ci_id_image, ci_nom_original, ci_meta_date_ajout, ci_meta_mots_cles, ci_meta_comment, ci_note_image '.
321
			'FROM cel_obs_images AS coi '.
322
			'FROM cel_images AS cim '.
322
			'LEFT JOIN cel_inventory AS ci '.
323
			'	LEFT JOIN cel_obs_images AS coi '.
323
				'ON (coi.coi_ce_observation = ci.ordre AND coi.coi_ce_utilisateur = ci.identifiant) '.
324
			'		ON (coi.coi_ce_image = cim.ci_id_image AND coi.coi_ce_utilisateur = cim.ci_ce_utilisateur) '.
324
			'LEFT JOIN cel_images AS cim '.
325
			'	LEFT JOIN cel_inventory AS ci '.
325
				'ON (coi.coi_ce_image = cim.ci_id_image AND coi.coi_ce_utilisateur = cim.ci_ce_utilisateur) '.  
326
			'		ON (coi.coi_ce_observation = ci.ordre AND coi.coi_ce_utilisateur = ci.identifiant) '.
326
			'WHERE ci.transmission = 1 '.
-
 
327
			'	AND ci.identifiant = cim.ci_ce_utilisateur '.
327
			(($this->etreFluxAdmin()) ? '' : 'WHERE ci.transmission = 1 ').
328
			'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby  : 'ci_meta_date_ajout DESC').' '.
328
			'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby  : 'ci_meta_date_ajout DESC').' '.
Line 329... Line 329...
329
			"LIMIT $this->start, $this->limit ";
329
			"LIMIT $this->start, $this->limit ";
330
		
330
		
331
		$elements = $this->executerRequete($requete);
331
		$elements = $this->executerRequete($requete);
-
 
332
 
332
		
333
		// Création du contenu
-
 
334
		if ($elements != false && count($elements) > 0) {
-
 
335
			$contenu = $this->executerService($elements);
-
 
336
		} else {
-
 
337
			$this->messages[] = "Aucune image disponible.";
333
		// Création du contenu
338
		}
334
		$contenu = $this->executerService($elements);
339
 
Line 335... Line 340...
335
		return $contenu;
340
		return $contenu;
-
 
341
	}
-
 
342
 
336
	}
343
	private function creerDescriptionComplet($donnees, $item) {
-
 
344
		$id_img = $donnees['ci_id_image'];
-
 
345
		$id_obs = $donnees['id'];
-
 
346
		$url_img = $this->getUrlImage($donnees['ci_id_image'], 'M');
-
 
347
		$auteur = $this->creerAuteur($donnees['identifiant'], $this->etreFluxAdmin());
-
 
348
		$mots_cles_obs = $this->decoderMotsClesObs($donnees['identifiant'], $donnees['mots_cles']);
-
 
349
		$mots_cles_image = $this->decoderMotsClesImg($donnees['identifiant'], $donnees['ci_meta_mots_cles']);
-
 
350
		$lieu = $donnees['location'].' ('.$donnees['id_location'].') > '.$donnees['lieudit'].' > '.$donnees['station'];
-
 
351
		$coordonnees = ($this->etreNull($donnees['coord_x']) && $this->etreNull($donnees['coord_y'])) ? '' : $donnees['coord_x'].'/'.$donnees['coord_y'];
-
 
352
		$date_observation = $this->formaterDate($donnees['date_observation'], '%A %d %B %Y');
-
 
353
		$date_transmission = $this->formaterDate($donnees['date_transmission']);
-
 
354
		$date_modification = $this->formaterDate($donnees['date_modification']);
337
 
355
		$date_creation = $this->formaterDate($donnees['date_creation']);
-
 
356
		$transmission = $donnees['transmission'] == 1 ? "oui ($date_transmission)" : 'non';
338
	private function creerDescriptionComplet($donnees, $item) {
357
		
339
		$url_img = $this->getUrlImage($donnees['ci_id_image'], 'M');
358
		$description = '<style>.champ{color:grey} .gauche{float:left;padding:0 20px 0 0;} ul{list-style-type:none;padding:0;}</style>'.
340
		$description .= '<style>.champ{color:grey} img{float:left;padding:0 20px 0 0;}</style>';
359
			'<h2>'."Image #$id_img liée à l'observation #$id_obs".'</h2>'.
-
 
360
			'<img class="gauche" src="'.$url_img.'" alt="'.$donnees['ci_nom_original'].'" />'.
341
		$description .= '<img src="'.$url_img.'" alt="'.$donnees['ci_nom_original'].'" />';
361
			'<div class="gauche">'.
-
 
362
			'<h3>'.'Image'.'</h3>'.
-
 
363
			'<ul>'.
-
 
364
			'<li>'.'<span class="champ">Importée le :</span> '.$item['date_maj_simple'].'</li>'.
342
		$description .= '<ul>';
365
			'<li>'.'<span class="champ">Par :</span> '.
343
		$description .= '<li>'."Image liée à l'observation ".$donnees['id'].'</li>';
366
				(($this->etreFluxAdmin()) ? '<a href="mailto:'.$auteur.'">'.$auteur.'</a>' : $auteur).
-
 
367
			'</li>'.
-
 
368
			'<li>'.'<span class="champ">Nom du fichier :</span> '.$donnees['ci_nom_original'].'</li>'.
-
 
369
			'<li>'.'<span class="champ">Note qualité :</span> '.($donnees['ci_note_image'] +1).'/5</li>'.
-
 
370
			'<li>'.'<span class="champ">Commentaires :</span> '.$donnees['ci_meta_comment'].'</li>'.
344
		$description .= '<li>'.'<span class="champ">Importée le :</span> '.$item['date_maj_simple'].'</li>';
371
			'<li>'.'<span class="champ">Mots-clés :</span> '.implode(', ', $mots_cles_image).'</li>'.
-
 
372
			'</ul>'.
-
 
373
			'</div>'.
-
 
374
			// TODO : ajouter le champ commentaire EXIF.
345
		$description .= '<li>'.'<span class="champ">Nom du fichier :</span> '.$donnees['ci_nom_original'].'</li>';
375
			'<div class="gauche">'.
346
		$description .= '<li>'.'<span class="champ">Note qualité image :</span> '.($donnees['ci_note_image'] +1).'/5</li>';
-
 
347
		// TODO :traiter le problème du champ commentaire.
376
			'<h3>'.'Observation'.'</h3>'.
348
		//$description .= '<li>'.'<span class="champ">Commentaire :</span> '.$donnees['ci_meta_user_comment'].'</li>';
377
			'<ul>'.
349
		
378
			'<li>'.'<span class="champ">Famille :</span> '.$donnees['famille'].'</li>'.
-
 
379
			'<li>'.'<span class="champ">Nom saisi :</span> '.$donnees['nom_sel'].'</li>'.
-
 
380
			'<li>'.'<span class="champ">Nom retenu :</span> '.$donnees['nom_ret'].'</li>'.
-
 
381
			'<li>'.'<span class="champ">Observée le :</span> '.$date_observation.'</li>'.
350
		$description .= '<li>'.'<span class="champ">Nom saisi :</span> '.$donnees['nom_sel'].'</li>';
382
			'<li>'.'<span class="champ">Lieu :</span> '.$lieu.'</li>'.
-
 
383
			'<li>'.'<span class="champ">Milieu :</span> '.$donnees['milieu'].'</li>'.
-
 
384
			(($this->etreFluxAdmin()) ? '<li><span class="champ">Coordonnées (Lat/Long) :</span> '.$coordonnees.'</li>' : '').
-
 
385
			'<li>'.'<span class="champ">Commentaire :</span> '.$donnees['commentaire'].'</li>'.
-
 
386
			'<li>'.'<span class="champ">Mots-clés :</span> '.implode(', ', $mots_cles_obs).'</li>'.
351
		$description .= '<li>'.'<span class="champ">Nom retenu :</span> '.$donnees['nom_ret'].'</li>';
387
			(($this->etreFluxAdmin()) ? '<li><span class="champ">Transmis (= public) :</span> '.$transmission.'</li>' : '').
-
 
388
			'<li><span class="champ">Modifiée le :</span> '.$date_modification.'</li>'.
352
		$description .= '<li>'.'<span class="champ">Observée le :</span> '.strftime('%A %d %B %Y', strtotime($donnees['date_observation'])).'</li>';
389
			'<li><span class="champ">Créée le :</span> '.$date_creation.'</li>'.
353
		$description .= '<li>'.'<span class="champ">Lieu :</span> '.$donnees['location'].' ('.$donnees['id_location'].') '.$donnees['station'].' '.$donnees['lieudit'].'</li>';
390
			'</ul>'.
354
		$description .= '</ul>';
391
			'</div>';
-
 
392
		$description = $this->nettoyerTexte($description);
-
 
393
		return $description;
-
 
394
	}
-
 
395
	
-
 
396
	private function getServiceParMotsCles() {
-
 
397
		$contenu = '';
-
 
398
		$mot_cle = $this->parametres[0];
-
 
399
 
-
 
400
		if (isset($mot_cle)) {
-
 
401
			$mot_cle_encode = $this->bdd->quote($this->encoderMotCle($mot_cle));
-
 
402
 
-
 
403
			// Construction de la requête
-
 
404
			$requete = 	'SELECT cmc_id_mot_cle_utilisateur, cmc_id_proprietaire '.
-
 
405
				'FROM cel_mots_cles_images '.
-
 
406
				"WHERE cmc_id_mot_cle_general = $mot_cle_encode ";
-
 
407
			$elements = $this->executerRequete($requete);
-
 
408
			
-
 
409
			if ($elements != false && count($elements) > 0) {
-
 
410
				// Pré-construction du where de la requête
-
 
411
				$tpl_where = '(ci_meta_mots_cles LIKE "%%%s%%" AND ci_ce_utilisateur = %s )';
-
 
412
				$requete_where = array();
-
 
413
				foreach ($elements as $occurence) {
-
 
414
					$requete_where[] = sprintf($tpl_where, $occurence['cmc_id_mot_cle_utilisateur'], $this->bdd->quote($occurence['cmc_id_proprietaire']));
-
 
415
				}
-
 
416
				
-
 
417
				// Construction de la requête
-
 
418
				$requete = 	(($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' ci.*, '.
-
 
419
					'	ci_id_image, ci_nom_original, ci_meta_date_ajout, ci_meta_mots_cles, ci_meta_comment, ci_note_image '.
-
 
420
					'FROM cel_images AS cim '.
-
 
421
					'	LEFT JOIN cel_obs_images AS coi '.
-
 
422
					'		ON (coi.coi_ce_image = cim.ci_id_image AND coi.coi_ce_utilisateur = cim.ci_ce_utilisateur) '.
-
 
423
					'	LEFT JOIN cel_inventory AS ci '.
-
 
424
					'		ON (coi.coi_ce_observation = ci.ordre AND coi.coi_ce_utilisateur = ci.identifiant) '.
-
 
425
					'WHERE '.implode(" \nOR ", $requete_where).' '.
-
 
426
					'	'.(($this->etreFluxAdmin()) ? '' : 'AND ci.transmission = 1').' '.
-
 
427
					'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby  : 'ci_meta_date_ajout DESC').' '.
-
 
428
					"LIMIT $this->start, $this->limit ";
-
 
429
				$elements = $this->executerRequete($requete);
-
 
430
				
-
 
431
				// Création du contenu
-
 
432
				$contenu = $this->executerService($elements);
-
 
433
			} else {
-
 
434
				$this->messages[] = "Aucune image ne correspond à ce mot clé.";
-
 
435
			}
-
 
436
		} else {
-
 
437
			$this->messages[] = "Le service demandé nécessite d'indiquer un mot-clé en dernier paramêtre.";
-
 
438
		}
-
 
439
		return $contenu;
-
 
440
	}
-
 
441
	
-
 
442
	private function getServiceParCommune() {
-
 
443
		$contenu = '';
-
 
444
		$commune = $this->parametres[0];
-
 
445
		if (isset($commune)) {
-
 
446
			$commune = $this->bdd->quote($commune);
-
 
447
			
-
 
448
			// Construction de la requête
-
 
449
			$requete = 	(($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' ci.*, '.
-
 
450
			'	ci_id_image, ci_nom_original, ci_meta_date_ajout, ci_meta_mots_cles, ci_meta_comment, ci_note_image '.
-
 
451
			'FROM cel_images AS cim '.
-
 
452
			'	LEFT JOIN cel_obs_images AS coi '.
-
 
453
			'		ON (coi.coi_ce_image = cim.ci_id_image AND coi.coi_ce_utilisateur = cim.ci_ce_utilisateur) '.
-
 
454
			'	LEFT JOIN cel_inventory AS ci '.
-
 
455
			'		ON (coi.coi_ce_observation = ci.ordre AND coi.coi_ce_utilisateur = ci.identifiant) '.
-
 
456
			"WHERE ci.location = $commune ".	
-
 
457
			'	'.(($this->etreFluxAdmin()) ? '' : 'AND ci.transmission = 1').' '.
-
 
458
			'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby  : 'ci_meta_date_ajout DESC').' '.
-
 
459
			"LIMIT $this->start,$this->limit ";
-
 
460
			$elements = $this->executerRequete($requete);
-
 
461
			
-
 
462
			// Création du contenu
-
 
463
			if ($elements != false && count($elements) > 0) {
-
 
464
				$contenu = $this->executerService($elements);
-
 
465
			} else {
-
 
466
				$this->messages[] = "Aucune image ne correspond à cette commune.";
-
 
467
			}
-
 
468
		} else {
-
 
469
			$this->messages[] = "Le service demandé nécessite d'indiquer une nom de commune en dernier paramêtre.";
355
		$description = $this->nettoyerTexte($description);
470
		}
356
		return $description;
471
		return $contenu;