Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1585 | Rev 1587 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1585 Rev 1586
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Classe mère du module Liste.
4
 * Classe mère du module Liste.
5
 *
5
 *
6
 * @category	PHP 5.2
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @copyright	2011 Tela-Botanica
10
 * @copyright	2011 Tela-Botanica
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @version		$Id$
13
 * @version		$Id$
14
 */
14
 */
15
class Illustrations extends aControleur {
15
class Illustrations extends aControleur {
16
 
16
 
17
	private $conteneur = null;
17
	private $conteneur = null;
18
	private $nomCourant = null;
18
	private $nomCourant = null;
19
	private $images = null;
19
	private $images = null;
20
	private $appUrls = null;
20
	private $appUrls = null;
21
	private $meta = null;
21
	private $meta = null;
22
	private $referentiel = 'bdtfx';
22
	private $referentiel = 'bdtfx';
23
	private $donnees = array();
23
	private $donnees = array();
24
 
24
 
25
	public function __construct(Conteneur $conteneur) {
25
	public function __construct(Conteneur $conteneur) {
26
		$this->conteneur = $conteneur;
26
		$this->conteneur = $conteneur;
27
		$this->nomCourant = $this->conteneur->getNomCourant();
27
		$this->nomCourant = $this->conteneur->getNomCourant();
28
		$this->referentiel = $this->conteneur->getParametre('referentiel');
28
		$this->referentiel = $this->conteneur->getParametre('referentiel');
29
		$this->images = $this->conteneur->getApiImages();
29
		$this->images = $this->conteneur->getApiImages();
30
		$this->appUrls = $this->conteneur->getAppUrls();
30
		$this->appUrls = $this->conteneur->getAppUrls();
31
		$this->meta = $this->conteneur->getApiMetaDonnees();
31
		$this->meta = $this->conteneur->getApiMetaDonnees();
32
 
32
 
33
		$this->images->setApi(Images::API_DEL);
33
		$this->images->setApi(Images::API_DEL);
34
	}
34
	}
35
 
35
 
36
	public function getDonnees() {
36
	public function getDonnees() {
37
		$this->donnees = array();
37
		$this->donnees = array();
38
		$this->getPhotos();
38
		$this->getPhotos();
39
		$dessin = $this->addDessin();
39
		$dessin = $this->addDessin();
40
		if (!empty($dessin)) {
40
		if (!empty($dessin)) {
41
			array_push($this->donnees, $dessin);
41
			array_push($this->donnees, $dessin);
42
		}
42
		}
43
		$images = $this->addSmartFloreImages();
43
		$images = $this->addSmartFloreImages();
44
		if (!empty($images)) {
44
		if (!empty($images)) {
45
			$this->donnees = $images + $this->donnees;
45
			$this->donnees = $images + $this->donnees;
46
		}
46
		}
47
 
47
 
48
		return $this->donnees;
48
		return $this->donnees;
49
	}
49
	}
50
 
50
 
51
	public function getPhotos() {
51
	public function getPhotos() {
52
		$listePhotos = $this->images->getInfosImagesGalerieMobile($this->nomCourant->getNnr());
52
		$listePhotos = $this->images->getInfosImagesGalerieMobile($this->nomCourant->getNnr());
53
		foreach($listePhotos as $index) {
53
		foreach($listePhotos as $index) {
54
			$this->formaterListePhotos($index);
54
			$this->formaterListePhotos($index);
55
		}
55
		}
56
	}
56
	}
57
 
57
 
58
	private function formaterListePhotos($images) {
58
	private function formaterListePhotos($images) {
59
		$infosImg['src'] = $images['binaire.href'];
59
		$infosImg['src'] = $images['binaire.href'];
60
 
60
 
61
		$obs = $images['observation'];
61
		$obs = $images['observation'];
62
		if ($obs['auteur.nom'] != '') {
62
		if ($obs['auteur.nom'] != '') {
63
			$infosImg['legende']['titre'] = $obs['auteur.nom'];
63
			$infosImg['legende']['titre'] = $obs['auteur.nom'];
64
			if ($obs['auteur.prenom'] != '') {
64
			if ($obs['auteur.prenom'] != '') {
65
				$infosImg['legende']['titre'] .= ' '.$obs['auteur.prenom'];
65
				$infosImg['legende']['titre'] .= ' '.$obs['auteur.prenom'];
66
			}
66
			}
67
		} else {
67
		} else {
68
			$infosImg['legende']['titre'] = "Anonyme";
68
			$infosImg['legende']['titre'] = "Anonyme";
69
		}
69
		}
70
 
70
 
71
		if ($obs['date_observation'] != '') {
71
		if ($obs['date_observation'] != '') {
72
			$infosImg['legende']['titre'] .= ", le ".$this->formaterDateImg($obs['date_observation']);
72
			$infosImg['legende']['titre'] .= ", le ".$this->formaterDateImg($obs['date_observation']);
73
		}
73
		}
74
 
74
 
75
		if ($obs['zone_geo'] != '') {
75
		if ($obs['zone_geo'] != '') {
76
			$infosImg['legende']['texte'] = $obs['zone_geo'];
76
			$infosImg['legende']['texte'] = $obs['zone_geo'];
77
			if ($obs['lieudit'] != '') {
77
			if ($obs['lieudit'] != '') {
78
				$infosImg['legende']['texte'] .= ' ('.$obs['lieudit'].')';
78
				$infosImg['legende']['texte'] .= ' ('.$obs['lieudit'].')';
79
			}
79
			}
80
		} else {
80
		} else {
81
			$infosImg['legende']['texte'] = "&nbsp;";
81
			$infosImg['legende']['texte'] = "&nbsp;";
82
		}
82
		}
83
 
83
 
84
		array_push($this->donnees, $infosImg);
84
		array_push($this->donnees, $infosImg);
85
	}
85
	}
86
 
86
 
87
	private function formaterDateImg($date) {
87
	private function formaterDateImg($date) {
88
		$dateFmt = $date;
88
		$dateFmt = $date;
89
		if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
89
		if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
90
			$dateFmt = 'inconnue';
90
			$dateFmt = 'inconnue';
91
		} else {
91
		} else {
92
			$dateFmt = strftime('%e %B %Y', strtotime($date));
92
			$dateFmt = strftime('%e %B %Y', strtotime($date));
93
		}
93
		}
94
		return $dateFmt;
94
		return $dateFmt;
95
	}
95
	}
96
 
96
 
97
	public function addDessin() {
97
	public function addDessin() {
98
		$img = array();
98
		$img = array();
99
		$projet = Config::get($this->referentiel.'.baseDessins');
99
		$projet = Config::get($this->referentiel.'.baseDessins');
100
		if ($projet != "") {
100
		if ($projet != "") {
101
			$dessin = array();
101
			$dessin = array();
102
			$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
102
			$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
103
			$this->images->setProjet($projet);
103
			$this->images->setProjet($projet);
104
			$this->images->setNnTaxon($tax);
104
			$this->images->setNnTaxon($tax);
105
			if ($this->referentiel == 'bdtfx') {
105
			if ($this->referentiel == 'bdtfx') {
106
				$costeImg = $this->images->setApi(Eflore::API_EFLORE)->getInfosImagesTaxons();
106
				$costeImg = $this->images->setApi(Eflore::API_EFLORE)->getInfosImagesTaxons();
107
				$this->images->setApi(Eflore::API_DEL);
107
				$this->images->setApi(Eflore::API_DEL);
108
				if (count($costeImg) != 0) {
108
				if (count($costeImg) != 0) {
109
					$img['src'] = $costeImg[key($costeImg)]['binaire.href'];
109
					$img['src'] = $costeImg[key($costeImg)]['binaire.href'];
110
					$img['legende']['titre'] = "Illustration de Coste";
110
					$img['legende']['titre'] = "Illustration de Coste";
111
					$img['legende']['texte'] = "&nbsp;";
111
					$img['legende']['texte'] = "&nbsp;";
112
				}
112
				}
113
			}
113
			}
114
		}
114
		}
115
 
115
 
116
		return $img;
116
		return $img;
117
	}
117
	}
118
 
118
 
119
	public function addSmartFloreImages() {
119
	public function addSmartFloreImages() {
120
		$img = [];
120
		$img = [];
121
		$tagFiche = strtoupper($this->conteneur->getParametre('referentiel'))."nt"
121
		$tagFiche = strtoupper($this->conteneur->getParametre('referentiel'))."nt"
122
			.$this->conteneur->getNomCourant()->getNomSelectionne()->get('num_taxonomique')
122
			.$this->conteneur->getNomCourant()->getNomSelectionne()->get('num_taxonomique')
123
		;
123
		;
124
		$sentier = $this->conteneur->getParametre('referentiel');
124
		$sentier = $_GET['sentier'];
125
 
125
 
126
		if ($sentier && $tagFiche) {
126
		if ($sentier && $tagFiche) {
127
			$images = $this->images->getInfosImagesParFicheEtSentier($tagFiche, $sentier);
127
			$images = $this->images->getInfosImagesParFicheEtSentier($tagFiche, $sentier);
128
 
128
 
129
			if ($images) {
129
			if ($images) {
130
				foreach ($images as $image) {
130
				foreach ($images as $image) {
131
					$retour = $this->images->getInfosImageParId($image['id']);
131
					$retour = $this->images->getInfosImageParId($image['id']);
132
					$auteur = $retour['pseudo_utilisateur'] ?? 'Auteur inconnu';
132
					$auteur = $retour['pseudo_utilisateur'] ?? 'Auteur inconnu';
133
					$img[$image['id']]['src'] = $image['url'];
133
					$img[$image['id']]['src'] = $image['url'];
134
					$img[$image['id']]['legende']['titre'] = $auteur . ' le '.$this->formaterDateImg($image['date_creation']);
134
					$img[$image['id']]['legende']['titre'] = $auteur . ' le '.$this->formaterDateImg($image['date_creation']);
135
					$img[$image['id']]['legende']['texte'] = "&nbsp;";
135
					$img[$image['id']]['legende']['texte'] = "&nbsp;";
136
				}
136
				}
137
			}
137
			}
138
		}
138
		}
139
 
139
 
140
		return $img;
140
		return $img;
141
	}
141
	}
142
}
142
}
143
?>
143
?>