Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 3827 Rev 3829
Line 40... Line 40...
40
		'XL'    => '1024px',
40
		'XL'    => '1024px',
41
		'X2L'   => '1280px',
41
		'X2L'   => '1280px',
42
		'X3L'   => '1600px',
42
		'X3L'   => '1600px',
43
		'O'     => 'Format original (Taille inconnue)'
43
		'O'     => 'Format original (Taille inconnue)'
44
	];
44
	];
-
 
45
	const START_DEFAUT = 0;
-
 
46
	const LIMIT_DEFAUT = 100;
45
	private $flux_rss_url = null;
47
	private $url_widget = null;
46
	private $eflore_url_tpl = null;
48
	private $eflore_url_tpl = null;
-
 
49
	private $service_images_url = null;
-
 
50
	private $flux_rss_url = null;
Line 47... Line 51...
47
 
51
 
48
	// 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)
Line 49... Line 53...
49
	private $suffixeLangue = '';
53
	private $suffixeLangue = '';
Line 58... Line 62...
58
		extract($this->parametres);
62
		extract($this->parametres);
Line 59... Line 63...
59
 
63
 
60
		if (!isset($mode)) {
64
		if (!isset($mode)) {
61
			$mode = self::SERVICE_DEFAUT;
65
			$mode = self::SERVICE_DEFAUT;
62
		}
-
 
-
 
66
		}
63
 
67
		$this->url_widget = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'photo');
64
		$this->eflore_url_tpl = $this->config['photo']['efloreUrlTpl'];
68
		$this->eflore_url_tpl = $this->config['photo']['efloreUrlTpl'];
65
		$this->service_images_url = $this->config['photo']['celUrlImages'];
69
		$this->service_images_url = $this->config['photo']['celUrlImages'];
Line 66... Line 70...
66
		$this->flux_rss_url = $this->config['photo']['fluxRssUrl'];
70
		$this->flux_rss_url = $this->config['photo']['fluxRssUrl'];
Line 105... Line 109...
105
 
109
 
106
				}
110
				}
107
			}
111
			}
108
		}
112
		}
109
		if (isset($_GET['callback'])) {
113
		if (isset($_GET['callback'])) {
Line 110... Line 114...
110
			$this->envoyerJsonp(array('contenu' => $contenu));
114
			$this->envoyerJsonp(['contenu' => $contenu]);
111
 
115
 
Line 112... Line 116...
112
		} else {
116
		} else {
113
			$this->envoyer($contenu);
117
			$this->envoyer($contenu);
Line -... Line 118...
-
 
118
 
114
 
119
		}
115
		}
120
	}
-
 
121
 
-
 
122
	// maintenir la retrocompatibilité avec l'ancien mode ajax
-
 
123
	private function executerAjax() {
-
 
124
		unset($this->parametres['mode']);
Line -... Line 125...
-
 
125
 
-
 
126
		$chaineRequete = http_build_query($this->parametres);
-
 
127
		$chaineRequete = $chaineRequete ? '?'.$chaineRequete : '';
116
	}
128
		$widget['donnees']['url_widget'] = $this->url_widget.$chaineRequete;
Line 117... Line 129...
117
 
129
 
118
	private function executerAjax() {
130
		$id = '-'.(isset($this->parametres['id']) ? $this->parametres['id'] : '1');
Line 119... Line 131...
119
		$widget = $this->executerPhoto();
131
		$widget['donnees']['id'] = $id;
Line 129... Line 141...
129
		$galerie_id = $_GET['galerie_id'];
141
		$galerie_id = $_GET['galerie_id'];
Line 130... Line 142...
130
 
142
 
131
		$widget['donnees']['url_image'] = $_GET['url_image'];
143
		$widget['donnees']['url_image'] = $_GET['url_image'];
132
		$widget['donnees']['infos_images'] = $_SESSION[$galerie_id]['infos_images'];
144
		$widget['donnees']['infos_images'] = $_SESSION[$galerie_id]['infos_images'];
133
		$widget['donnees']['urls'] = $_SESSION[$galerie_id]['urls'];
145
		$widget['donnees']['urls'] = $_SESSION[$galerie_id]['urls'];
134
		$widget['donnees']['url_widget'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'photo');
146
		$widget['donnees']['url_widget'] = $this->url_widget;
135
		$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/css/');
147
		$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/css/');
136
		$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/js/');
148
		$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/js/');
-
 
149
		$widget['donnees']['max_photo'] = $_SESSION[$galerie_id]['max_photo'];
137
		$widget['donnees']['max_photo'] = $_SESSION[$galerie_id]['max_photo'];
150
		$widget['donnees']['start'] = $_SESSION[$galerie_id]['start'];
138
		$widget['donnees']['url_ws_regenerer_img'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_IMG_LIST) . '/regenerer-miniatures?ids-img=';
151
		$widget['donnees']['url_ws_regenerer_img'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_IMG_LIST) . '/regenerer-miniatures?ids-img=';
139
		$widget['donnees']['popup_url'] = isset( $_GET['popup_url'] ) ? $_GET['popup_url'] : null;
152
		$widget['donnees']['popup_url'] = isset( $_GET['popup_url'] ) ? $_GET['popup_url'] : null;
140
		$widget['donnees']['url_base_telechargement'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], 'CelImageFormat/');
153
		$widget['donnees']['url_base_telechargement'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], 'CelImageFormat/');
Line 146... Line 159...
146
	}
159
	}
Line 147... Line 160...
147
 
160
 
148
	private function executerContact() {
161
	private function executerContact() {
Line 149... Line 162...
149
		session_start();
162
		session_start();
150
 
163
 
151
		$widget['donnees']['url_widget'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'photo');
164
		$widget['donnees']['url_widget'] = $this->url_widget;
152
		$widget['donnees']['id_image'] = $_GET['id_image'];
165
		$widget['donnees']['id_image'] = $_GET['id_image'];
153
		$widget['donnees']['nom_sci'] = $_GET['nom_sci'];
166
		$widget['donnees']['nom_sci'] = $_GET['nom_sci'];
154
		$widget['donnees']['nn'] = $_GET['nn'];
167
		$widget['donnees']['nn'] = $_GET['nn'];
Line 177... Line 190...
177
	private function executerPhoto() {
190
	private function executerPhoto() {
178
		session_start();
191
		session_start();
Line 179... Line 192...
179
 
192
 
Line -... Line 193...
-
 
193
		$widget = null;
-
 
194
 
-
 
195
		$this->parametres['start'] = $this->parametres['start'] ?? self::START_DEFAUT;
180
		$widget = null;
196
		$this->parametres['limit'] = $this->parametres['limit'] ?? self::LIMIT_DEFAUT;
Line 181... Line 197...
181
 
197
 
182
		extract($this->parametres);
198
		extract($this->parametres);
183
 
199
 
Line 192... Line 208...
192
		$icone_rss = (isset($_GET['rss']) && $_GET['rss'] != 1) ? false : true;
208
		$icone_rss = (isset($_GET['rss']) && $_GET['rss'] != 1) ? false : true;
193
		$utilise_fancybox = (isset($_GET['mode_zoom']) && $_GET['mode_zoom'] != 'fancybox') ? false : true;
209
		$utilise_fancybox = (isset($_GET['mode_zoom']) && $_GET['mode_zoom'] != 'fancybox') ? false : true;
Line 194... Line 210...
194
 
210
 
195
		list($colonne, $ligne) = explode(',', $vignette);
211
		list($colonne, $ligne) = explode(',', $vignette);
-
 
212
		$extra = (isset($extra) && $extra == 0) ? false : (!$this->config['photo']['extraActif'] ? false : ($colonne == 1 || $ligne == 1 ? false : true));
-
 
213
 
-
 
214
		$champ_recherche = $champ_recherche ? $this->obtenirBooleen($champ_recherche) : ($this->config['photo']['champRecherche'] ? $this->obtenirBooleen($this->config['photo']['champRecherche']) : false) ;
-
 
215
		$max_photo = $colonne * $ligne;
-
 
216
		if ( $extra && 2 == $colonne ) {
-
 
217
			$max_photo = $max_photo - 1;
-
 
218
		} elseif (  $extra && 2 < $colonne ) {
-
 
219
			$max_photo = $max_photo - 3;
-
 
220
		}
-
 
221
		$limit = $limit < $max_photo ? $limit : $max_photo;
196
		$extra = (isset($extra) && $extra == 0) ? false : (!$this->config['photo']['extraActif'] ? false : ($colonne == 1 || $ligne == 1 ? false : true));
222
		$this->parametres['limit'] = $limit;
197
		$parametresTraites = $this->traiterParametres();
223
		$parametresTraites = $this->traiterParametres();
198
		$this->flux_rss_url .= $parametresTraites;
224
		$this->flux_rss_url .= $parametresTraites;
199
		$url = $this->service_images_url.(!empty($parametresTraites) ? $parametresTraites : '*');
225
		$url = $this->service_images_url.(!empty($parametresTraites) ? $parametresTraites.'&' : '?');
Line 200... Line 226...
200
		$json = $this->getDao()->consulter($url);
226
		$json = $this->getDao()->consulter($url);
201
 
227
 
Line 208... Line 234...
208
			$tableau = json_decode($json, true);
234
			$tableau = json_decode($json, true);
Line 209... Line 235...
209
 
235
 
210
			if (empty($tableau['total']) || empty($tableau['images'])) {
236
			if (empty($tableau['total']) || empty($tableau['images'])) {
211
				$this->messages[] = 'Aucune photo ne correspond à vos critères';
237
				$this->messages[] = 'Aucune photo ne correspond à vos critères';
-
 
238
			} else {
-
 
239
 
-
 
240
				$parametresPhotoSuivante = $this->parametres;
-
 
241
				$parametresPhotoSuivante['start'] = $start + $limit;
-
 
242
 
212
			} else {
243
				$widget['donnees']['total'] = $tableau['total'];
213
				$widget['donnees']['id'] = $id;
244
				$widget['donnees']['id'] = $id;
214
				$widget['donnees']['titre'] = $titre;
-
 
215
				// $widget['donnees']['service_images_url'] = $this->service_images_url;
245
				$widget['donnees']['titre'] = $titre;
-
 
246
				$widget['donnees']['flux_rss_url'] = $this->flux_rss_url;
216
				$widget['donnees']['flux_rss_url'] = $this->flux_rss_url;
247
				$widget['donnees']['url_widget'] = $this->url_widget;
217
				$widget['donnees']['url_widget'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'photo');
248
				$widget['donnees']['url_widget_photos_suivantes'] = $this->url_widget.'?'.http_build_query($parametresPhotoSuivante);
218
				$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/css/');
249
				$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/css/');
219
				$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/js/');
250
				$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/js/');
-
 
251
				$widget['donnees']['colonne'] = $colonne;
220
				$widget['donnees']['colonne'] = $colonne;
252
				$widget['donnees']['ligne'] = $ligne;
221
				$widget['donnees']['extra_actif'] = $extra;
253
				$widget['donnees']['extra_actif'] = $extra;
-
 
254
				$widget['donnees']['icone_rss'] = $icone_rss;
-
 
255
				$widget['donnees']['champ_recherche'] = $champ_recherche;
-
 
256
				$widget['donnees']['start'] = $start;
222
				$widget['donnees']['icone_rss'] = $icone_rss;
257
				$widget['donnees'] ['limit'] = $limit;
223
				$widget['donnees']['utilise_fancybox'] = $utilise_fancybox;
258
				$widget['donnees']['utilise_fancybox'] = $utilise_fancybox;
Line 224... Line -...
224
				$widget['donnees']['prod'] = ($this->config['parametres']['modeServeur'] === 'prod');
-
 
225
 
-
 
226
				$max_photo = $colonne * $ligne;
-
 
227
				if ( $extra && 2 == $colonne ) {
-
 
228
					$max_photo = $max_photo - 1;
-
 
229
				} elseif (  $extra && 2 < $colonne ) {
-
 
230
					$max_photo = $max_photo - 3;
259
				$widget['donnees']['prod'] = ($this->config['parametres']['modeServeur'] === 'prod');
231
				}
260
 
232
				$num = 0;
261
				$num = 0;
Line 233... Line 262...
233
				$galerie_id = md5(http_build_query($_GET));
262
				$galerie_id = md5(http_build_query($_GET));
Line 259... Line 288...
259
					$image_size = getimagesize($url_galerie_popup);
288
					$image_size = getimagesize($url_galerie_popup);
260
					$item['width'] = $image_size[0];
289
					$item['width'] = $image_size[0];
261
					$item['height'] = $image_size[1];
290
					$item['height'] = $image_size[1];
262
					$_SESSION[$galerie_id]['urls'][] = $url_galerie_popup;
291
					$_SESSION[$galerie_id]['urls'][] = $url_galerie_popup;
263
					$_SESSION[$galerie_id]['max_photo'] = $max_photo;
292
					$_SESSION[$galerie_id]['max_photo'] = $max_photo;
-
 
293
					$_SESSION[$galerie_id]['start'] = $start;
264
					$_SESSION[$galerie_id]['infos_images'][$url_galerie_popup] = $item;
294
					$_SESSION[$galerie_id]['infos_images'][$url_galerie_popup] = $item;
265
				}
295
				}
Line 266... Line 296...
266
 
296
 
267
				$widget['squelette'] = 'photo';
297
				$widget['squelette'] = 'photo';
Line 271... Line 301...
271
		return $widget;
301
		return $widget;
272
	}
302
	}
Line 273... Line 303...
273
 
303
 
274
	private function traiterParametres() {
304
	private function traiterParametres() {
-
 
305
		$parametres_flux = '?';
-
 
306
		$criteres = [
-
 
307
			'taxon',
-
 
308
			'referentiel',
-
 
309
			'date_deb',
-
 
310
			'date_fin',
-
 
311
			'commune',
-
 
312
			'dept',
-
 
313
			'pays',
-
 
314
			'auteur',
-
 
315
			'programme',
-
 
316
			'tag',
-
 
317
			'non_standard',
275
		$parametres_flux = '?';
318
			'indesirable',
-
 
319
			'pn_smartphone_anonyme',
-
 
320
			'recherche',
-
 
321
			'date',
-
 
322
			'motcle',
-
 
323
			'projet',
-
 
324
			'num_taxon',
-
 
325
			'num_nom',
-
 
326
			'start',
-
 
327
			'limit'
Line 276... Line 328...
276
		$criteres = array('utilisateur', 'commune', 'dept', 'taxon', 'commentaire', 'date', 'tag', 'motcle', 'projet', 'num_taxon', 'num_nom', 'referentiel', 'groupe_zones_geo');
328
		];
277
 
329
 
278
		foreach($this->parametres as $nom_critere => $valeur_critere) {
330
		foreach($this->parametres as $nom_critere => $valeur_critere) {
279
			if (in_array($nom_critere, $criteres)) {
331
			if (in_array($nom_critere, $criteres)) {
Line 290... Line 342...
290
 
342
 
Line 291... Line 343...
291
		}
343
		}
292
 
344
 
-
 
345
		return $parametres_flux;
-
 
346
	}
-
 
347
 
-
 
348
	private function obtenirBooleen($var) {
-
 
349
		switch ($var) {
-
 
350
			case 'false' :
-
 
351
			case 'null' :
-
 
352
			case 'non' :
-
 
353
			case 'no' :
-
 
354
				return false;
-
 
355
			default:
-
 
356
				return boolval($var);
293
		return $parametres_flux;
357
		}
294
	}
358
	}
295
}
359
}