| Line 12... |
Line 12... |
| 12 |
* ===> extra = booléen (1 ou 0) [par défaut : 1]
|
12 |
* ===> extra = booléen (1 ou 0) [par défaut : 1]
|
| 13 |
* Affiche / Cache la vignette en taille plus importante au bas du widget.
|
13 |
* Affiche / Cache la vignette en taille plus importante au bas du widget.
|
| 14 |
* ===> vignette = [0-9]+,[0-9]+ [par défaut : 4,3]
|
14 |
* ===> vignette = [0-9]+,[0-9]+ [par défaut : 4,3]
|
| 15 |
* Indique le nombre de vignette par ligne et le nombre de ligne.
|
15 |
* Indique le nombre de vignette par ligne et le nombre de ligne.
|
| 16 |
*
|
16 |
*
|
| 17 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
17 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
| 18 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
18 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
| 19 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
19 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
| 20 |
* @version $Id$
|
20 |
* @version $Id$
|
| 21 |
* @copyright Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
|
21 |
* @copyright Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
|
| 22 |
*/
|
22 |
*/
|
| 23 |
class Photo extends WidgetCommun {
|
23 |
class Photo extends WidgetCommun {
|
| 24 |
|
24 |
|
| 25 |
const DS = DIRECTORY_SEPARATOR;
|
25 |
const DS = DIRECTORY_SEPARATOR;
|
| 26 |
const SERVICE_DEFAUT = 'photo';
|
26 |
const SERVICE_DEFAUT = 'photo';
|
| - |
|
27 |
const VIGNETTE_DEFAULT = '4,3';
|
| - |
|
28 |
const WS_IMG_LIST = 'celImage';
|
| - |
|
29 |
const IMAGE_FORMATS = [
|
| - |
|
30 |
'CRX2S' => '63px (Carrée, rognée)',
|
| - |
|
31 |
'CRXS' => '100px (Carrée, rognée)',
|
| - |
|
32 |
'CXS' => '100px (Carrée)',
|
| - |
|
33 |
'CS' => '300px (Carrée)',
|
| - |
|
34 |
'CRS' => '300px (Carrée, rognée)',
|
| - |
|
35 |
'XS' => '150px',
|
| - |
|
36 |
'S' => '400px',
|
| - |
|
37 |
'M' => '600px',
|
| - |
|
38 |
'L' => '800px',
|
| - |
|
39 |
'CRL' => '600px (Carrée, rognée)',
|
| - |
|
40 |
'XL' => '1024px',
|
| - |
|
41 |
'X2L' => '1280px',
|
| - |
|
42 |
'X3L' => '1600px',
|
| - |
|
43 |
'O' => 'Format original (Taille inconnue)'
|
| - |
|
44 |
];
|
| - |
|
45 |
const START_DEFAUT = 0;
|
| - |
|
46 |
const LIMIT_DEFAUT = 100;
|
| 27 |
private $flux_rss_url = null;
|
47 |
private $url_widget = null;
|
| 28 |
private $eflore_url_tpl = null;
|
48 |
private $eflore_url_tpl = null;
|
| - |
|
49 |
private $service_images_url = null;
|
| - |
|
50 |
private $flux_rss_url = null;
|
| Line 29... |
Line 51... |
| 29 |
|
51 |
|
| 30 |
// Suffixe de template pour la langue (vide par défaut, correspond à "fr" au français)
|
52 |
// Suffixe de template pour la langue (vide par défaut, correspond à "fr" au français)
|
| - |
|
53 |
private $suffixeLangue = '';
|
| - |
|
54 |
|
| - |
|
55 |
private $user = null;
|
| - |
|
56 |
|
| - |
|
57 |
private $service_del_url = null;
|
| Line 31... |
Line 58... |
| 31 |
private $suffixeLangue = '';
|
58 |
private $userCache = [];
|
| 32 |
|
59 |
|
| 33 |
/**
|
60 |
/**
|
| 34 |
* Méthode appelée par défaut pour charger ce widget.
|
61 |
* Méthode appelée par défaut pour charger ce widget.
|
| 35 |
*/
|
62 |
*/
|
| 36 |
public function executer() {
|
63 |
public function executer() {
|
| 37 |
$retour = null;
|
64 |
$retour = null;
|
| 38 |
// Pour la création de l'id du cache nous ne tenons pas compte du paramètre de l'url callback
|
65 |
// Pour la création de l'id du cache nous ne tenons pas compte du paramètre de l'url callback
|
| 39 |
unset($this->parametres['callback']);
|
66 |
unset($this->parametres['callback']);
|
| 40 |
extract($this->parametres);
|
67 |
extract($this->parametres);
|
| 41 |
|
68 |
|
| 42 |
if (!isset($mode)) {
|
69 |
if (!isset($mode)) {
|
| 43 |
$mode = self::SERVICE_DEFAUT;
|
- |
|
| - |
|
70 |
$mode = self::SERVICE_DEFAUT;
|
| 44 |
}
|
71 |
}
|
| - |
|
72 |
$this->url_widget = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'photo');
|
| 45 |
|
73 |
$this->eflore_url_tpl = $this->config['photo']['efloreUrlTpl'];
|
| 46 |
$this->eflore_url_tpl = $this->config['photo']['efloreUrlTpl'];
|
74 |
$this->service_images_url = $this->config['photo']['celUrlImages'];
|
| 47 |
$this->flux_rss_url = $this->config['photo']['fluxRssUrl'];
|
75 |
$this->flux_rss_url = $this->config['photo']['fluxRssUrl'];
|
| 48 |
|
76 |
|
| - |
|
77 |
$cache_activation = $this->config['photo.cache']['activation'];
|
| - |
|
78 |
$cache_stockage = $this->config['photo.cache']['stockageDossier'];
|
| - |
|
79 |
if (!is_dir($cache_stockage)) {
|
| 49 |
$cache_activation = $this->config['photo.cache']['activation'];
|
80 |
mkdir($cache_stockage, 0777, true);
|
| 50 |
$cache_stockage = $this->config['photo.cache']['stockageDossier'];
|
81 |
}
|
| 51 |
$ddv = $this->config['photo.cache']['dureeDeVie'];
|
82 |
$ddv = $this->config['photo.cache']['dureeDeVie'];
|
| 52 |
$cache = new Cache($cache_stockage, $ddv, $cache_activation);
|
83 |
$cache = new Cache($cache_stockage, $ddv, $cache_activation);
|
| - |
|
84 |
$id_cache = 'photo-'.hash('adler32', print_r($this->parametres, true));
|
| - |
|
85 |
$contenu = $cache->charger($id_cache);
|
| - |
|
86 |
|
| - |
|
87 |
$this->user = $this->getUserFromCookie();
|
| 53 |
$id_cache = 'photo-'.hash('adler32', print_r($this->parametres, true));
|
88 |
|
| - |
|
89 |
if (!$contenu) {
|
| 54 |
if (! $contenu = $cache->charger($id_cache)) {
|
90 |
$methode = $this->traiterNomMethodeExecuter($mode);
|
| 55 |
$methode = $this->traiterNomMethodeExecuter($mode);
|
91 |
|
| - |
|
92 |
if (method_exists($this, $methode)) {
|
| 56 |
if (method_exists($this, $methode)) {
|
93 |
$retour = $this->$methode();
|
| 57 |
$retour = $this->$methode();
|
94 |
|
| 58 |
} else {
|
- |
|
| Line -... |
Line 95... |
| - |
|
95 |
} else {
|
| 59 |
$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
|
96 |
$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
|
| 60 |
}
|
97 |
|
| 61 |
|
98 |
}
|
| - |
|
99 |
// Suffixe de template pour la langue - fr par défaut @TODO configurer ça un jour
|
| 62 |
// Suffixe de template pour la langue - fr par défaut @TODO configurer ça un jour
|
100 |
if (isset($this->parametres['lang']) && $this->parametres['lang'] !== 'fr') {
|
| Line 63... |
Line 101... |
| 63 |
if (isset($this->parametres['lang']) && $this->parametres['lang'] != "fr") {
|
101 |
$this->suffixeLangue = '_' . $this->parametres['lang'];
|
| - |
|
102 |
|
| 64 |
$this->suffixeLangue = "_" . $this->parametres['lang'];
|
103 |
}
|
| 65 |
}
|
104 |
|
| - |
|
105 |
$contenu = '';
|
| 66 |
|
106 |
|
| - |
|
107 |
if (is_null($retour)) {
|
| 67 |
$contenu = '';
|
108 |
$this->messages[] = 'Aucune image';
|
| 68 |
if (is_null($retour)) {
|
109 |
|
| 69 |
$this->messages[] = 'Aucune image';
|
110 |
} else {
|
| 70 |
} else {
|
111 |
|
| - |
|
112 |
if (isset($retour['donnees'])) {
|
| 71 |
if (isset($retour['donnees'])) {
|
113 |
$squelette = dirname(__FILE__) .self::DS. 'squelettes' .self::DS. $retour['squelette'].$this->suffixeLangue.'.tpl.html';
|
| 72 |
$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$retour['squelette']. $this->suffixeLangue . '.tpl.html';
|
114 |
$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']);
|
| 73 |
$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']);
|
115 |
$cache->sauver($id_cache, $contenu);
|
| 74 |
$cache->sauver($id_cache, $contenu);
|
116 |
|
| 75 |
} else {
|
117 |
} else {
|
| 76 |
$this->messages[] = 'Les données à transmettre au squelette sont nulles.';
|
118 |
$this->messages[] = 'Les données à transmettre au squelette sont nulles.';
|
| 77 |
}
|
119 |
}
|
| - |
|
120 |
}
|
| 78 |
}
|
121 |
}
|
| 79 |
}
|
122 |
if (isset($_GET['callback'])) {
|
| 80 |
if (isset($_GET['callback'])) {
|
123 |
$this->envoyerJsonp(['contenu' => $contenu]);
|
| - |
|
124 |
|
| - |
|
125 |
} else {
|
| - |
|
126 |
$this->envoyer($contenu);
|
| - |
|
127 |
}
|
| - |
|
128 |
|
| - |
|
129 |
// POur l'envoi du vote vers PF
|
| - |
|
130 |
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
| 81 |
$this->envoyerJsonp(array('contenu' => $contenu));
|
131 |
if (isset($_GET['action']) && $_GET['action'] === 'send_pf_vote') {
|
| 82 |
} else {
|
132 |
$this->sendVote();
|
| - |
|
133 |
}
|
| 83 |
$this->envoyer($contenu);
|
134 |
}
|
| 84 |
}
|
135 |
}
|
| - |
|
136 |
|
| - |
|
137 |
// maintenir la retrocompatibilité avec l'ancien mode ajax
|
| - |
|
138 |
private function executerAjax() {
|
| - |
|
139 |
unset($this->parametres['mode']);
|
| - |
|
140 |
|
| - |
|
141 |
$chaineRequete = http_build_query($this->parametres);
|
| - |
|
142 |
$chaineRequete = $chaineRequete ? '?'.$chaineRequete : '';
|
| - |
|
143 |
$widget['donnees']['url_widget'] = $this->url_widget.$chaineRequete;
|
| 85 |
}
|
144 |
|
| - |
|
145 |
$id = '-'.(isset($this->parametres['id']) ? $this->parametres['id'] : '1');
|
| 86 |
|
146 |
$widget['donnees']['id'] = $id;
|
| 87 |
private function executerAjax() {
|
147 |
|
| 88 |
$widget = $this->executerPhoto();
|
148 |
$widget['squelette'] = 'photo_retrocompatibilite_ajax';
|
| 89 |
$widget['squelette'] = 'photo_ajax';
|
149 |
|
| 90 |
return $widget;
|
150 |
return $widget;
|
| - |
|
151 |
}
|
| - |
|
152 |
|
| - |
|
153 |
private function executerPopup() {
|
| 91 |
}
|
154 |
session_start();
|
| 92 |
|
155 |
|
| 93 |
private function executerPopup() {
|
156 |
$protocoles = $this->getProtocoles();
|
| 94 |
session_start();
|
157 |
|
| 95 |
$galerie_id = $_GET['galerie_id'];
|
- |
|
| 96 |
$widget['donnees']['url_image'] = $_GET['url_image'];
|
158 |
$galerie_id = $_GET['galerie_id'];
|
| 97 |
$widget['donnees']['infos_images'] = $_SESSION[$galerie_id]['infos_images'];
|
159 |
$widget['donnees']['url_image'] = $_GET['url_image'];
|
| - |
|
160 |
$widget['donnees']['infos_images'] = $_SESSION[$galerie_id]['infos_images'];
|
| - |
|
161 |
$widget['donnees']['url_widget'] = $this->url_widget;
|
| - |
|
162 |
$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/css/');
|
| - |
|
163 |
$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/js/');
|
| - |
|
164 |
$widget['donnees']['max_photo'] = $_SESSION[$galerie_id]['max_photo'];
|
| - |
|
165 |
$widget['donnees']['start'] = $_SESSION[$galerie_id]['start'];
|
| - |
|
166 |
$widget['donnees']['url_ws_regenerer_img'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_IMG_LIST) . '/regenerer-miniatures?ids-img=';
|
| - |
|
167 |
$widget['donnees']['popup_url'] = isset( $_GET['popup_url'] ) ? $_GET['popup_url'] : null;
|
| - |
|
168 |
$widget['donnees']['url_base_telechargement'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], 'CelImageFormat/');
|
| - |
|
169 |
$widget['donnees']['formats_description'] = self::IMAGE_FORMATS;
|
| - |
|
170 |
$widget['donnees']['protocoles'] = $protocoles;
|
| - |
|
171 |
$widget['donnees']['del_url'] = sprintf($this->config['chemins']['baseURLServicesDelTpl'], '');
|
| - |
|
172 |
$widget['donnees']['new_cel_url'] = sprintf($this->config['chemins']['baseURLServicesNewCelTpl'], '');
|
| - |
|
173 |
|
| - |
|
174 |
if ($this->user){
|
| 98 |
$widget['donnees']['urls'] = $_SESSION[$galerie_id]['urls'];
|
175 |
$widget['donnees']['userId'] = $this->user['id'];
|
| - |
|
176 |
$widget['donnees']['token'] = $this->user['token'];
|
| 99 |
$widget['donnees']['url_widget'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'photo');
|
177 |
}
|
| 100 |
$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/css/');
|
178 |
|
| 101 |
$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/js/');
|
179 |
$widget['squelette'] = 'popup' . $this->suffixeLangue;
|
| 102 |
$widget['squelette'] = 'popup' . $this->suffixeLangue;
|
180 |
|
| 103 |
return $widget;
|
181 |
return $widget;
|
| - |
|
182 |
}
|
| - |
|
183 |
|
| 104 |
}
|
184 |
private function executerContact() {
|
| 105 |
|
185 |
session_start();
|
| 106 |
private function executerContact() {
|
186 |
|
| 107 |
session_start();
|
187 |
$widget['donnees']['url_widget'] = $this->url_widget;
|
| - |
|
188 |
$widget['donnees']['id_image'] = $_GET['id_image'];
|
| - |
|
189 |
$widget['donnees']['nom_sci'] = $_GET['nom_sci'];
|
| - |
|
190 |
$widget['donnees']['nn'] = $_GET['nn'];
|
| 108 |
$widget['donnees']['id_image'] = $_GET['id_image'];
|
191 |
$widget['donnees']['date'] = $_GET['date'];
|
| 109 |
$widget['donnees']['nom_sci'] = $_GET['nom_sci'];
|
192 |
$widget['donnees']['auteur'] = $_GET['auteur'];
|
| 110 |
$widget['donnees']['nn'] = $_GET['nn'];
|
193 |
$widget['donnees']['popup_url'] = isset( $_GET['popup_url'] ) ? $_GET['popup_url'] : null;
|
| - |
|
194 |
|
| 111 |
$widget['donnees']['date'] = $_GET['date'];
|
195 |
if (isset($_GET['lang']) && 'nl' === $_GET['lang']) {
|
| 112 |
if (isset($_GET['lang']) && 'nl' === $_GET['lang']) {
|
196 |
$widget['donnees']['sujet'] = "Afbeelding #".$_GET['id_image']." op ".$_GET['nom_sci'];
|
| 113 |
$widget['donnees']['sujet'] = "Afbeelding #".$_GET['id_image']." op ".$_GET['nom_sci'];
|
197 |
$widget['donnees']['message'] = "\n\n\n\n\n\n\n\n--\nBetreft de foto \"".$_GET['nom_sci'].'" van "'.$_GET['date'];
|
| - |
|
198 |
|
| 114 |
$widget['donnees']['message'] = "\n\n\n\n\n\n\n\n--\nBetreft de foto \"".$_GET['nom_sci'].'" van "'.$_GET['date'];
|
199 |
} else {
|
| - |
|
200 |
$widget['donnees']['sujet'] = "Image #".$_GET['id_image']." de ".$_GET['nom_sci'];
|
| 115 |
} else {
|
201 |
$widget['donnees']['message'] = "\n\n\n\n\n\n\n\n--\nConcerne l'image de \"".$_GET['nom_sci'].'" du "'.$_GET['date'];
|
| 116 |
$widget['donnees']['sujet'] = "Image #".$_GET['id_image']." de ".$_GET['nom_sci'];
|
202 |
|
| 117 |
$widget['donnees']['message'] = "\n\n\n\n\n\n\n\n--\nConcerne l'image de \"".$_GET['nom_sci'].'" du "'.$_GET['date'];
|
203 |
}
|
| - |
|
204 |
|
| 118 |
}
|
205 |
$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/css/');
|
| 119 |
$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/css/');
|
206 |
$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/js/');
|
| Line 120... |
Line -... |
| 120 |
$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/js/');
|
- |
|
| 121 |
$widget['squelette'] = 'contact';
|
- |
|
| 122 |
return $widget;
|
- |
|
| 123 |
}
|
- |
|
| 124 |
|
- |
|
| 125 |
private function decouperTitre($titre) {
|
- |
|
| 126 |
if ('nl' === $this->suffixeLangue) {
|
- |
|
| 127 |
$dic = array(' door ', ' op ');
|
- |
|
| 128 |
} else {
|
- |
|
| 129 |
$dic = array(' par ', ' le ');
|
- |
|
| 130 |
}
|
- |
|
| 131 |
|
- |
|
| 132 |
$tab_titre = explode('[nn', $titre);
|
- |
|
| 133 |
if (isset($tab_titre[1])) {
|
- |
|
| 134 |
$nom_sci = $tab_titre[0];
|
- |
|
| 135 |
$tab_titre_suite = explode($dic[0], $tab_titre[1]);
|
- |
|
| 136 |
} else {
|
- |
|
| 137 |
$nom_sci = "";
|
- |
|
| 138 |
$tab_titre_suite = explode($dic[0], $tab_titre[0]);
|
- |
|
| 139 |
}
|
- |
|
| 140 |
$nn = '[nn'.$tab_titre_suite[0];
|
- |
|
| 141 |
$tab_titre_resuite = explode($dic[1], $tab_titre_suite[1]);
|
- |
|
| 142 |
$utilisateur = $tab_titre_resuite[0];
|
- |
|
| 143 |
$tab_titre_fin = explode(' - ', $tab_titre_resuite[1]);
|
- |
|
| 144 |
$date = $tab_titre_fin[0];
|
- |
|
| 145 |
$localite = (empty($tab_titre_fin[1]) ? '' : $tab_titre_fin[1]);
|
- |
|
| 146 |
|
207 |
$widget['squelette'] = 'contact';
|
| 147 |
$titre_decoupe = array('nom_sci' => $nom_sci, 'nn' => $nn, 'date' => $date, 'auteur' => $utilisateur, 'localite' => $localite);
|
- |
|
| 148 |
return $titre_decoupe;
|
- |
|
| 149 |
}
|
208 |
|
| 150 |
|
209 |
return $widget;
|
| - |
|
210 |
}
|
| 151 |
private function executerPhoto() {
|
211 |
|
| - |
|
212 |
private function executerPhoto() {
|
| - |
|
213 |
$widget = null;
|
| - |
|
214 |
session_start();
|
| - |
|
215 |
|
| 152 |
session_start();
|
216 |
$this->parametres['start'] = $this->parametres['start'] ?? self::START_DEFAUT;
|
| - |
|
217 |
$this->parametres['limit'] = $this->parametres['limit'] ?? self::LIMIT_DEFAUT;
|
| - |
|
218 |
$limit = $this->parametres['limit'];
|
| - |
|
219 |
|
| - |
|
220 |
$hasTriedValueInConfig = false;
|
| 153 |
$_SESSION['urls'] = array();
|
221 |
while (!isset($vignette) || !preg_match('/^[0-9]+,[0-9]+$/', $vignette)) {
|
| 154 |
$widget = null;
|
222 |
$vignette = (!$hasTriedValueInConfig) ? $this->config['photo']['vignette'] : self::VIGNETTE_DEFAULT;
|
| - |
|
223 |
$hasTriedValueInConfig = true;
|
| 155 |
extract($this->parametres);
|
224 |
}
|
| 156 |
$extra = (isset($extra) && $extra == 0) ? false : ($this->config['photo']['extraActif'] ? true : false);
|
225 |
|
| 157 |
$vignette = (isset($vignette) && preg_match('/^[0-9]+,[0-9]+$/', $vignette)) ? $vignette : '4,3';
|
- |
|
| 158 |
$id = '-'.(isset($id) ? $id : '1');
|
- |
|
| Line 159... |
Line -... |
| 159 |
$titre = isset($titre) ? htmlentities(rawurldecode($titre)) : '';
|
- |
|
| 160 |
$icone_rss = (isset($_GET['rss']) && $_GET['rss'] != 1) ? false : true;
|
- |
|
| 161 |
$utilise_fancybox = (isset($_GET['mode_zoom']) && $_GET['mode_zoom'] != 'fancybox') ? false : true;
|
- |
|
| 162 |
list($colonne, $ligne) = explode(',', $vignette);
|
- |
|
| 163 |
$this->flux_rss_url .= $this->traiterParametres();
|
- |
|
| 164 |
|
226 |
$id = '-'.(isset($id) ? $id : '1');
|
| 165 |
$xml = @file_get_contents($this->flux_rss_url);
|
- |
|
| 166 |
//var_dump($xml);
|
- |
|
| 167 |
if ($xml !== false) {
|
- |
|
| 168 |
if ($xml) {
|
- |
|
| 169 |
try {
|
227 |
$titre = isset($titre) ? htmlentities(rawurldecode($titre)) : '';
|
| 170 |
$flux = new XmlFeedParser($xml);
|
- |
|
| 171 |
$widget['donnees']['id'] = $id;
|
- |
|
| 172 |
$widget['donnees']['titre'] = $titre;
|
228 |
|
| 173 |
$widget['donnees']['flux_rss_url'] = $this->flux_rss_url;
|
- |
|
| 174 |
$widget['donnees']['url_widget'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'photo');
|
- |
|
| 175 |
$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/css/');
|
- |
|
| 176 |
$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/js/');
|
229 |
$icone_rss = (isset($_GET['rss']) && $_GET['rss'] != 1) ? false : true;
|
| 177 |
$widget['donnees']['colonne'] = $colonne;
|
- |
|
| 178 |
$widget['donnees']['extra_actif'] = $extra;
|
- |
|
| 179 |
$widget['donnees']['icone_rss'] = $icone_rss;
|
- |
|
| 180 |
$widget['donnees']['utilise_fancybox'] = $utilise_fancybox;
|
230 |
$utilise_fancybox = (isset($_GET['mode_zoom']) && $_GET['mode_zoom'] != 'fancybox') ? false : true;
|
| 181 |
$widget['donnees']['prod'] = ($this->config['parametres']['modeServeur'] == "prod");
|
- |
|
| 182 |
|
231 |
|
| 183 |
$max_photo = $colonne * $ligne;
|
232 |
$champ_recherche = $champ_recherche ?? null;
|
| 184 |
$num = 0;
|
- |
|
| 185 |
$galerie_id = md5(http_build_query($_GET));
|
233 |
$champ_recherche = $champ_recherche ? $this->obtenirBooleen($champ_recherche) : ($this->config['photo']['champRecherche'] ? $this->obtenirBooleen($this->config['photo']['champRecherche']) : false) ;
|
| 186 |
$widget['donnees']['galerie_id'] = $galerie_id;
|
- |
|
| 187 |
foreach ($flux as $entree) {
|
- |
|
| 188 |
if ($num == $max_photo) {
|
- |
|
| 189 |
break;
|
- |
|
| 190 |
}
|
- |
|
| 191 |
$item = array();
|
- |
|
| 192 |
// Formatage date
|
234 |
$extra = $extra ?? null;
|
| 193 |
$date = $entree->updated ? $entree->updated : null;
|
235 |
|
| 194 |
$date = $entree->pubDate ? $entree->pubDate : $date;
|
- |
|
| 195 |
$item['date'] = strftime('%A %d %B %Y', $date);
|
- |
|
| 196 |
$item['lien'] = $entree->link;
|
236 |
// Affichage mode e-flore avec le paramètre mode_eflore
|
| 197 |
$item['url_tpl'] = preg_replace('/(XS|[SML]|X(?:[23]|)L|CR(?:|X2)S|C(?:|X)S)\.jpg$/', '%s.jpg', $entree->guid);
|
237 |
if ($_GET['mode_eflore']) {
|
| 198 |
|
- |
|
| 199 |
// Formatage titre
|
238 |
$champ_recherche = false;
|
| 200 |
$item['titre'] = str_replace('"', "", $entree->title);
|
239 |
$vignette = '5,2';
|
| 201 |
$item['infos'] = $this->decouperTitre($item['titre']);
|
240 |
|
| 202 |
$item['nn'] = '';
|
- |
|
| 203 |
$item['eflore_url'] = '#';
|
- |
|
| 204 |
if (preg_match('/\[nn([0-9]+)\]/', $entree->title, $match)) {
|
- |
|
| 205 |
$item['nn'] = $match[1];
|
- |
|
| 206 |
$item['eflore_url'] = $item['lien'] ;
|
241 |
$tags = [
|
| 207 |
}
|
- |
|
| 208 |
|
242 |
'fleur',
|
| 209 |
// Récupération du GUID - aaaaah c'est cracra si on change la config yatoukipett !! Satan is in this code !!!
|
243 |
'feuille',
|
| 210 |
if (preg_match($this->config['photo']['motif_guid'], $entree->guid, $match)) {
|
- |
|
| 211 |
$item['guid'] = (int) $match[1];
|
244 |
'fruit',
|
| 212 |
} else {
|
- |
|
| 213 |
$item['guid'] = $entree->guid;
|
- |
|
| 214 |
}
|
- |
|
| 215 |
|
- |
|
| 216 |
// Ajout aux items et si première photo à extra
|
- |
|
| 217 |
if ($num == 0) {
|
- |
|
| 218 |
$widget['donnees']['extra'] = $item;
|
245 |
'ecorce',
|
| 219 |
}
|
- |
|
| 220 |
$widget['donnees']['items'][$num++] = $item;
|
- |
|
| 221 |
//TODO: voir si l'on ne peut pas faire mieux
|
- |
|
| 222 |
$url_galerie_popup = sprintf($item['url_tpl'],'XL');
|
- |
|
| 223 |
$_SESSION[$galerie_id]['urls'][] = $url_galerie_popup;
|
- |
|
| 224 |
$_SESSION[$galerie_id]['infos_images'][$url_galerie_popup] = array('titre' => $item['titre'],
|
246 |
'port',
|
| 225 |
'date' => $item['titre'],
|
- |
|
| 226 |
'guid' => $item['guid'],
|
- |
|
| 227 |
'lien' => $item['lien']
|
- |
|
| 228 |
);
|
- |
|
| 229 |
}
|
- |
|
| 230 |
$widget['squelette'] = 'photo';
|
- |
|
| 231 |
} catch (XmlFeedParserException $e) {
|
- |
|
| 232 |
trigger_error('Flux invalide : '.$e->getMessage(), E_USER_WARNING);
|
247 |
'rameau',
|
| - |
|
248 |
];
|
| 233 |
}
|
249 |
|
| 234 |
} else {
|
250 |
foreach ($tags as $tag) {
|
| - |
|
251 |
$widget = $this->getImages($vignette, $extra, $limit, $id, $titre, $icone_rss, $utilise_fancybox,true, $tag, $widget, false);
|
| 235 |
// si on arrive ici c'est qu'il n'y a aucune image correspondant
|
252 |
$widget['donnees']['champ_recherche'] = false;
|
| - |
|
253 |
}
|
| 236 |
// à la requête, mais il n'y a rien d'invalide là-dedans
|
254 |
$widget['donnees']['tagToDisplay'] = 'fleur';
|
| - |
|
255 |
} else {
|
| 237 |
//$this->messages[] = "Fichier xml invalide.";
|
256 |
$widget = $this->getImages($vignette, $extra, $limit, $id, $titre, $icone_rss, $utilise_fancybox, false, 'non_eflore', $widget, $champ_recherche);
|
| 238 |
}
|
257 |
|
| 239 |
} else {
|
258 |
$widget['donnees']['champ_recherche'] = $champ_recherche;
|
| 240 |
$this->messages[] = "L'URI suivante est invalide : $this->flux_rss_url.\n".
|
259 |
|
| 241 |
"Veuillez vérifier les paramêtres indiqués et la présence d'images associées.";
|
260 |
}
|
| - |
|
261 |
|
| - |
|
262 |
return $widget;
|
| - |
|
263 |
}
|
| - |
|
264 |
|
| - |
|
265 |
private function traiterParametres() {
|
| - |
|
266 |
$parametres_flux = '?';
|
| 242 |
}
|
- |
|
| - |
|
267 |
$criteres = [
|
| - |
|
268 |
'taxon',
|
| - |
|
269 |
'referentiel',
|
| - |
|
270 |
'date_deb',
|
| - |
|
271 |
'date_fin',
|
| - |
|
272 |
'commune',
|
| - |
|
273 |
'dept',
|
| - |
|
274 |
'pays',
|
| - |
|
275 |
'auteur',
|
| - |
|
276 |
'programme',
|
| - |
|
277 |
'tag',
|
| - |
|
278 |
'standard',
|
| - |
|
279 |
'recherche',
|
| - |
|
280 |
'date',
|
| - |
|
281 |
'motcle',
|
| - |
|
282 |
'projet',
|
| - |
|
283 |
'num_taxon',
|
| - |
|
284 |
'num_nom',
|
| 243 |
return $widget;
|
285 |
'start',
|
| 244 |
}
|
286 |
'limit',
|
| 245 |
|
287 |
'mode_eflore',
|
| 246 |
private function traiterParametres() {
|
288 |
'famille'
|
| - |
|
289 |
];
|
| 247 |
$parametres_flux = '?';
|
290 |
|
| 248 |
$criteres = array('utilisateur', 'standard', 'commune', 'dept', 'taxon', 'commentaire', 'date', 'tag', 'motcle', 'projet', 'num_taxon', 'num_nom', 'referentiel', 'groupe_zones_geo');
|
291 |
foreach($this->parametres as $nom_critere => $valeur_critere) {
|
| 249 |
foreach($this->parametres as $nom_critere => $valeur_critere) {
|
- |
|
| 250 |
if (in_array($nom_critere, $criteres)) {
|
292 |
if (in_array($nom_critere, $criteres)) {
|
| 251 |
$valeur_critere = str_replace(' ', '%20', $valeur_critere);
|
293 |
$valeur_critere = str_replace(' ', '%20', $valeur_critere);
|
| - |
|
294 |
$parametres_flux .= $nom_critere.'='.$valeur_critere.'&';
|
| 252 |
$parametres_flux .= $nom_critere.'='.$valeur_critere.'&';
|
295 |
|
| 253 |
}
|
296 |
}
|
| - |
|
297 |
}
|
| 254 |
}
|
298 |
if ($parametres_flux === '?') {
|
| - |
|
299 |
$parametres_flux = '';
|
| 255 |
|
300 |
|
| 256 |
if ($parametres_flux == '?') {
|
301 |
} else {
|
| - |
|
302 |
$parametres_flux = rtrim($parametres_flux, '&');
|
| - |
|
303 |
|
| - |
|
304 |
}
|
| - |
|
305 |
|
| - |
|
306 |
return $parametres_flux;
|
| - |
|
307 |
}
|
| - |
|
308 |
|
| - |
|
309 |
private function obtenirBooleen($var) {
|
| - |
|
310 |
switch ($var) {
|
| - |
|
311 |
case 'false' :
|
| - |
|
312 |
case 'null' :
|
| - |
|
313 |
case 'non' :
|
| - |
|
314 |
case 'no' :
|
| - |
|
315 |
return false;
|
| - |
|
316 |
default:
|
| - |
|
317 |
return boolval($var);
|
| - |
|
318 |
}
|
| - |
|
319 |
}
|
| - |
|
320 |
|
| - |
|
321 |
private function getProtocoles(){
|
| - |
|
322 |
$protocoles = [];
|
| - |
|
323 |
$this->service_del_url = $this->config['chemins']['baseURLServicesDelTpl'];
|
| - |
|
324 |
$url = sprintf($this->service_del_url, 'protocoles');
|
| - |
|
325 |
$json = $this->getDao()->consulter($url);
|
| - |
|
326 |
|
| - |
|
327 |
if (empty($json)) {
|
| - |
|
328 |
$this->messages[] = "L'URI suivante est invalide : $url";
|
| - |
|
329 |
} else {
|
| - |
|
330 |
$protocoles= json_decode($json, true);
|
| - |
|
331 |
}
|
| - |
|
332 |
|
| - |
|
333 |
return $protocoles['resultats'];
|
| - |
|
334 |
}
|
| - |
|
335 |
|
| - |
|
336 |
private function getVotes($image){
|
| - |
|
337 |
$votes = [];
|
| - |
|
338 |
|
| - |
|
339 |
$id = $image['id_photo'];
|
| - |
|
340 |
|
| - |
|
341 |
$this->service_del_url = $this->config['chemins']['baseURLServicesDelTpl'];
|
| - |
|
342 |
$url = sprintf($this->service_del_url, 'images/'.$id.'/votes');
|
| - |
|
343 |
|
| - |
|
344 |
$json = $this->getDao()->consulter($url);
|
| - |
|
345 |
|
| - |
|
346 |
if (empty($json)) {
|
| - |
|
347 |
$this->messages[] = "L'URI suivante est invalide : $url";
|
| - |
|
348 |
} else {
|
| - |
|
349 |
foreach (json_decode($json, true)['resultats'] as $vote){
|
| - |
|
350 |
$votes[] = $vote;
|
| - |
|
351 |
}
|
| - |
|
352 |
}
|
| - |
|
353 |
|
| - |
|
354 |
return $votes;
|
| - |
|
355 |
}
|
| - |
|
356 |
|
| - |
|
357 |
public function sendVote(){
|
| - |
|
358 |
$data = json_decode(file_get_contents('php://input'), true);
|
| - |
|
359 |
|
| - |
|
360 |
$id = $data['idImage'];
|
| - |
|
361 |
$mode = $data['mode'];
|
| - |
|
362 |
$contenu = [
|
| - |
|
363 |
'utilisateur' => $data['user'],
|
| - |
|
364 |
'protocole' => $data['protocole'],
|
| - |
|
365 |
'valeur' => $data['vote']
|
| - |
|
366 |
];
|
| - |
|
367 |
|
| - |
|
368 |
switch ($mode){
|
| - |
|
369 |
case 'PUT':
|
| - |
|
370 |
case 'POST':
|
| - |
|
371 |
$this->service_del_url = $this->config['chemins']['baseURLServicesDelTpl'];
|
| - |
|
372 |
$url = sprintf($this->service_del_url, 'images/'.$id.'/votes/');
|
| - |
|
373 |
$this->send($url, $mode, $contenu);
|
| - |
|
374 |
break;
|
| - |
|
375 |
case 'DELETE':
|
| - |
|
376 |
$this->service_del_url = $this->config['chemins']['baseURLServicesDelTpl'];
|
| - |
|
377 |
$url = sprintf($this->service_del_url, 'images/'.$id.'/votes/'.$data['voteId']);
|
| - |
|
378 |
$this->send($url, $mode, $contenu);
|
| - |
|
379 |
break;
|
| - |
|
380 |
}
|
| - |
|
381 |
}
|
| - |
|
382 |
|
| - |
|
383 |
public function send($url, $mode, Array $donnees = array()){
|
| - |
|
384 |
$contenu = false;
|
| - |
|
385 |
$this->user = $this->getUserFromCookie();
|
| - |
|
386 |
$authorizationToken = $this->user['token'];
|
| - |
|
387 |
|
| - |
|
388 |
$json = json_encode($donnees);
|
| - |
|
389 |
$contexte = stream_context_create([
|
| - |
|
390 |
'http' => [
|
| - |
|
391 |
'method' => $mode,
|
| - |
|
392 |
'header' => "Content-type: application/x-www-form-urlencoded\r\n" .
|
| - |
|
393 |
"Authorization: $authorizationToken\r\n",
|
| - |
|
394 |
'content' => http_build_query($donnees, null, '&')]
|
| - |
|
395 |
]);
|
| - |
|
396 |
$flux = fopen($url, 'r', false, $contexte);
|
| - |
|
397 |
if (!$flux) {
|
| - |
|
398 |
$e = "L'ouverture de l'url '{$url}' par la méthode HTTP {$mode} a échoué! avec les données {$json} et le token {$authorizationToken}";
|
| - |
|
399 |
trigger_error($e, E_USER_WARNING);
|
| - |
|
400 |
} else {
|
| - |
|
401 |
// Contenu actuel de $url
|
| - |
|
402 |
$contenu = stream_get_contents($flux);
|
| - |
|
403 |
|
| - |
|
404 |
fclose($flux);
|
| - |
|
405 |
}
|
| - |
|
406 |
return $contenu;
|
| - |
|
407 |
}
|
| - |
|
408 |
|
| - |
|
409 |
public function formaterDates($item, $image){
|
| - |
|
410 |
$item['date_photo'] = $image['date_photo'] ?? $image['obs']['date_obs'];
|
| - |
|
411 |
$item['date_redige'] = strftime('%A %d %B %Y', strtotime($item['date_photo']));
|
| - |
|
412 |
$item['date'] = date_format(date_create($item['date_photo']),"d/m/Y");
|
| - |
|
413 |
$item['lien'] = sprintf($this->eflore_url_tpl, $image['obs']['nom_referentiel'], $image['obs']['nom_sel_nn']);
|
| - |
|
414 |
$image['url_photo'] = preg_replace('/,/', "", $image['url_photo']);
|
| - |
|
415 |
$item['url_tpl'] = preg_replace('/(O|XS|[SML]|X(?:[23]|)L|CR(?:|X2)S|C(?:|X)S)$/', '%s.jpg',$image['url_photo']);
|
| - |
|
416 |
return $item;
|
| - |
|
417 |
}
|
| - |
|
418 |
|
| - |
|
419 |
public function formaterTitre($item, $image, $auteur){
|
| - |
|
420 |
$item['titre'] = $image['obs']['nom_sel'].' [nn'.$image['obs']['nom_sel_nn'].'] par '.$auteur.' le '
|
| - |
|
421 |
.date_format(date_create($image['obs']['date_obs']),"d/m/Y").' - '.$image['obs']['localisation'];
|
| - |
|
422 |
|
| - |
|
423 |
$item['id_photo_formate'] = sprintf('%09d', $image['id_photo']);
|
| - |
|
424 |
$item['urlProfil'] = sprintf($this->config['photo']['tbProfilUrlTpl'], $image['utilisateur']['id_utilisateur'] );
|
| - |
|
425 |
return $item;
|
| - |
|
426 |
}
|
| - |
|
427 |
|
| - |
|
428 |
private function getImages($vignette, $extra, $limit, $id, $titre, $icone_rss, $utilise_fancybox, $fromEflore,
|
| - |
|
429 |
$tag, $widget, $champ_recherche){
|
| - |
|
430 |
if ($fromEflore){
|
| - |
|
431 |
$this->parametres['tag'] = $tag;
|
| - |
|
432 |
}
|
| - |
|
433 |
list($colonne, $ligne) = explode(',', $vignette);
|
| - |
|
434 |
|
| - |
|
435 |
$extra = !($extra === 0) && (($this->config['photo']['extraActif'] && (($colonne == 1 || $ligne == 1 ? false : true))));
|
| - |
|
436 |
|
| - |
|
437 |
$max_photo = $colonne * $ligne;
|
| - |
|
438 |
if ( $extra && 2 == $colonne ) {
|
| - |
|
439 |
$max_photo = $max_photo - 1;
|
| - |
|
440 |
} elseif ( $extra && 2 < $colonne ) {
|
| - |
|
441 |
$max_photo = $max_photo - 3;
|
| - |
|
442 |
}
|
| - |
|
443 |
|
| - |
|
444 |
$limit = $limit < $max_photo ? $limit : $max_photo;
|
| - |
|
445 |
$this->parametres['limit'] = $limit;
|
| - |
|
446 |
|
| - |
|
447 |
$parametresTraites = $this->traiterParametres();
|
| - |
|
448 |
$this->flux_rss_url .= $parametresTraites;
|
| - |
|
449 |
$url = $this->service_images_url.(!empty($parametresTraites) ? $parametresTraites.'&' : '?');
|
| - |
|
450 |
$json = $this->getDao()->consulter($url);
|
| - |
|
451 |
|
| - |
|
452 |
if (empty($json) || !strpos($json, 'images')) {
|
| - |
|
453 |
$this->messages[] = "L'URI suivante est invalide : $url.\n".
|
| - |
|
454 |
"Veuillez vérifier les paramêtres indiqués et la présence d'images associées.";
|
| - |
|
455 |
$this->logError("L'URI est invalide: $url");
|
| - |
|
456 |
return $widget;
|
| - |
|
457 |
}
|
| - |
|
458 |
|
| - |
|
459 |
$tableau = json_decode($json, true);
|
| - |
|
460 |
|
| - |
|
461 |
if (empty($tableau['total']) || empty($tableau['images'])) {
|
| - |
|
462 |
$this->logError('Aucune photo ne correspond à vos critères');
|
| - |
|
463 |
return $widget;
|
| - |
|
464 |
}
|
| - |
|
465 |
|
| - |
|
466 |
$parametres_photo_suivante = $parametres_photo_precedente = $this->parametres;
|
| - |
|
467 |
$start = $this->parametres['start'] ? : 0;
|
| - |
|
468 |
$parametres_photo_suivante['start'] = $start + $limit;
|
| - |
|
469 |
$parametres_photo_precedente['start'] = 0 < $start - $limit ? $start - $limit : 0;
|
| - |
|
470 |
|
| - |
|
471 |
$widget['donnees']['total'] = $tableau['total'];
|
| - |
|
472 |
$widget['donnees']['id'] = $id;
|
| - |
|
473 |
$widget['donnees']['titre'] = $titre;
|
| - |
|
474 |
$widget['donnees']['flux_rss_url'] = $this->flux_rss_url;
|
| - |
|
475 |
$widget['donnees']['url_widget'] = $this->url_widget;
|
| - |
|
476 |
$widget['donnees']['url_widget_photos_suivantes'] = $this->url_widget.'?'.http_build_query($parametres_photo_suivante);
|
| - |
|
477 |
$widget['donnees']['url_widget_photos_precedente'] = $this->url_widget.'?'.http_build_query($parametres_photo_precedente);
|
| - |
|
478 |
$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/css/');
|
| - |
|
479 |
$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/js/');
|
| - |
|
480 |
$widget['donnees']['colonne'] = $colonne;
|
| - |
|
481 |
$widget['donnees']['ligne'] = $ligne;
|
| - |
|
482 |
$widget['donnees']['extra_actif'] = $extra ?? null;
|
| - |
|
483 |
$widget['donnees']['icone_rss'] = $icone_rss ?? null;
|
| - |
|
484 |
$widget['donnees']['champ_recherche'] = $champ_recherche;
|
| - |
|
485 |
$widget['donnees']['start'] = $start;
|
| - |
|
486 |
$widget['donnees']['limit'] = $limit;
|
| - |
|
487 |
$widget['donnees']['utilise_fancybox'] = $utilise_fancybox;
|
| - |
|
488 |
$widget['donnees']['prod'] = ($this->config['parametres']['modeServeur'] === 'prod');
|
| - |
|
489 |
$widget['donnees']['filtres'] = $this->parametres;
|
| - |
|
490 |
|
| - |
|
491 |
$num = 0;
|
| - |
|
492 |
$galerie_id = md5(http_build_query($_GET));
|
| - |
|
493 |
$widget['donnees']['galerie_id'] = $galerie_id;
|
| - |
|
494 |
|
| - |
|
495 |
$_SESSION[$galerie_id]['max_photo'] = $max_photo;
|
| - |
|
496 |
$_SESSION[$galerie_id]['start'] = $start;
|
| - |
|
497 |
|
| - |
|
498 |
// *************************************** C'est cette boucle qui prend grave du temps ****************************************
|
| - |
|
499 |
// Cache pour les tailles d'images
|
| - |
|
500 |
// $imageSizeCache = [];
|
| - |
|
501 |
foreach ($tableau['images'] as $key => $image) {
|
| - |
|
502 |
if ($key == $max_photo) {
|
| - |
|
503 |
break;
|
| - |
|
504 |
}
|
| - |
|
505 |
|
| - |
|
506 |
// Utilisation du cache pour l'utilisateur -> fait gagner un peu de temps de chargement si plusieures photos du même utilisateur
|
| - |
|
507 |
$courriel = $image['utilisateur']['mail_utilisateur'];
|
| - |
|
508 |
if (!isset($this->userCache[$courriel])) {
|
| - |
|
509 |
$this->userCache[$courriel] = $this->recupererUtilisateursIdentite([$courriel])[$courriel];
|
| - |
|
510 |
}
|
| - |
|
511 |
$auteurId = $this->userCache[$courriel]['id'];
|
| - |
|
512 |
|
| - |
|
513 |
$isTelaUser = $auteurId ? true : false;
|
| - |
|
514 |
$auteurTruncatedEmail = $this->tronquerCourriel($courriel);
|
| - |
|
515 |
|
| - |
|
516 |
$auteur = trim($image['utilisateur']['nom_utilisateur']) ? $image['utilisateur']['nom_utilisateur'] : $auteurTruncatedEmail;
|
| - |
|
517 |
|
| - |
|
518 |
$item = $image;
|
| - |
|
519 |
$item = $this->formaterDates($item, $image);
|
| - |
|
520 |
$item = $this->formaterTitre($item, $image, $auteur);
|
| - |
|
521 |
|
| - |
|
522 |
$item['tag_eflore'] = $tag;
|
| - |
|
523 |
$item['is_auteur_tela'] = $isTelaUser;
|
| - |
|
524 |
|
| - |
|
525 |
if ($key == 0) {
|
| - |
|
526 |
$widget['donnees']['extra'] = $item;
|
| - |
|
527 |
}
|
| - |
|
528 |
|
| - |
|
529 |
$widget['donnees']['items'][$tag][$num++] = $item;
|
| - |
|
530 |
//
|
| - |
|
531 |
$url_galerie_popup = sprintf($item['url_tpl'], 'O');
|
| - |
|
532 |
// if (!isset($imageSizeCache[$url_galerie_popup])) {
|
| - |
|
533 |
// $imageSizeCache[$url_galerie_popup] = getimagesize($url_galerie_popup);
|
| - |
|
534 |
// }
|
| - |
|
535 |
// $image_size = $imageSizeCache[$url_galerie_popup];
|
| - |
|
536 |
// error_log(print_r($imageSizeCache, true));
|
| - |
|
537 |
// $item['width'] = $image_size[0];
|
| - |
|
538 |
// $item['height'] = $image_size[1];
|
| - |
|
539 |
|
| - |
|
540 |
// Récupération des votes et tags
|
| - |
|
541 |
$item['votes'] = $this->getVotes($item);
|
| - |
|
542 |
$item['tags_pf'] = $this->getPfTags($item);
|
| - |
|
543 |
|
| - |
|
544 |
$_SESSION[$galerie_id]['infos_images'][$url_galerie_popup] = $item;
|
| - |
|
545 |
}
|
| - |
|
546 |
|
| - |
|
547 |
if ($fromEflore) {
|
| - |
|
548 |
unset($this->parametres['tag']);
|
| - |
|
549 |
}
|
| - |
|
550 |
$widget['squelette'] = 'photo';
|
| - |
|
551 |
|
| - |
|
552 |
return $widget;
|
| - |
|
553 |
}
|
| - |
|
554 |
|
| - |
|
555 |
private function getPfTags($image){
|
| - |
|
556 |
$tags = [];
|
| - |
|
557 |
|
| - |
|
558 |
$id = $image['id_photo'];
|
| - |
|
559 |
|
| - |
|
560 |
$this->service_del_url = $this->config['chemins']['baseURLServicesDelTpl'];
|
| - |
|
561 |
$url = sprintf($this->service_del_url, 'mots-cles?image='.$id);
|
| - |
|
562 |
|
| - |
|
563 |
$json = $this->getDao()->consulter($url);
|
| - |
|
564 |
|
| - |
|
565 |
if (empty($json)) {
|
| - |
|
566 |
$this->messages[] = "L'URI suivante est invalide : $url";
|
| - |
|
567 |
} else {
|
| - |
|
568 |
foreach (json_decode($json, true)['resultats'] as $tag){
|
| - |
|
569 |
$tags[] = [
|
| - |
|
570 |
'id_mot_cle' => $tag['id_mot_cle'],
|
| - |
|
571 |
'mot_cle' => $tag['mot_cle']
|
| 257 |
$parametres_flux = '';
|
572 |
];
|
| 258 |
} else {
|
573 |
}
|