Subversion Repositories eFlore/Applications.del

Rev

Rev 2225 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2225 Rev 2226
Line 105... Line 105...
105
		$ordre = $this->parametres['ordre'];
105
		$ordre = $this->parametres['ordre'];
106
        $date_debut = "'{$date_debut}'";
106
        $date_debut = "'{$date_debut}'";
107
        $date_fin = "'{$date_fin}'";
107
        $date_fin = "'{$date_fin}'";
Line 108... Line 108...
108
 
108
 
109
		$requete =
109
		$requete =
110
			'SELECT SQL_CALC_FOUND_ROWS p.id_observation, p.id_image, '.
110
			'SELECT SQL_CALC_FOUND_ROWS p.id_observation, GROUP_CONCAT(DISTINCT p.id_image) as id_image, '.
111
			'iv.moyenne AS moyenne_votes, '.
111
			'iv.moyenne AS moyenne_votes, '.
112
			'iv.nb_votes AS nb_votes, '.
112
			'iv.nb_votes AS nb_votes, '.
113
			'iv.nb_points AS nb_points_votes, '.
113
			'iv.nb_points AS nb_points_votes, '.
114
			'GROUP_CONCAT(DISTINCT it.tag) AS del_image_tags, '.
114
			'GROUP_CONCAT(DISTINCT it.tag) AS del_image_tags, '.
Line 124... Line 124...
124
			'		ON (id_image = it.ce_image AND it.actif = 1) '.
124
			'		ON (id_image = it.ce_image AND it.actif = 1) '.
125
			'	LEFT JOIN del_commentaire AS c '.
125
			'	LEFT JOIN del_commentaire AS c '.
126
			'		ON (p.id_observation = c.ce_observation) '.
126
			'		ON (p.id_observation = c.ce_observation) '.
127
			'	LEFT JOIN del_commentaire_vote AS cv '.
127
			'	LEFT JOIN del_commentaire_vote AS cv '.
128
			'		ON (c.id_commentaire = cv.ce_proposition) '.
128
			'		ON (c.id_commentaire = cv.ce_proposition) '.
129
			'GROUP BY p.id_image, p.id_observation '.
129
			'GROUP BY p.id_observation '.
130
			'ORDER BY modif_date ' . $ordre . ' '.
130
			'ORDER BY modif_date ' . $ordre . ' '.
131
			'LIMIT '.$depart.', '.$limite.
131
			'LIMIT '.$depart.', '.$limite.
132
			' -- '.__FILE__.':'.__LINE__;
132
			' -- '.__FILE__.':'.__LINE__;
133
		return $this->bdd->recupererTous($requete);
133
		return $this->bdd->recupererTous($requete);
134
        // On récupère id_obs, id_image, votes, tags, modif_date
134
        // On récupère id_obs, id_image, votes, tags, modif_date
Line 184... Line 184...
184
		// regroupe les observations
184
		// regroupe les observations
185
		$obs = array();
185
		$obs = array();
186
		$imgCelTpl = $this->conteneur->getParametre('cel_img_url_tpl');
186
		$imgCelTpl = $this->conteneur->getParametre('cel_img_url_tpl');
187
		foreach ($this->idsObsImg as $ids) {
187
		foreach ($this->idsObsImg as $ids) {
188
			$idobs = $ids['id_observation'];
188
			$idobs = $ids['id_observation'];
189
			$idimg = $ids['id_image'];
189
			$idimg = explode(',', $ids['id_image']);
Line 190... Line 190...
190
 
190
 
Line 191... Line 191...
191
			$imgdata = $this->infosObsImg[$idimg];
191
            $obs[$idobs]['id_observation'] = $idobs;
-
 
192
 
192
 
193
            foreach ($idimg as $image){
193
			if (!isset($obs[$idobs])) {
194
                $imgInfos = null;
-
 
195
                $imgdata = null;
-
 
196
 
194
				$obs[$idobs] = array();
197
                $imgdata = $this->infosObsImg[$image];
-
 
198
                $imgInfos = $this->recupererInfosParImage($image);
195
			}
199
 
-
 
200
                if (!isset($obs[$idobs])) {
-
 
201
                    $obs[$idobs] = array();
196
 
202
                }
197
			$obs[$idobs]['id_observation'] = $idobs;
203
 
198
			$obs[$idobs]['id_plantnet'] = $imgdata['id_plantnet'];
204
                $obs[$idobs]['id_plantnet'] = $imgdata['id_plantnet'];
199
			$obs[$idobs]['auteur_courriel'] = $imgdata['courriel_utilisateur'];
205
                $obs[$idobs]['auteur_courriel'] = $imgdata['courriel_utilisateur'];
200
 
206
 
201
            $obs[$idobs]['mots_cles_cel_obs'] = $imgdata['mots_cles_cel_obs'];
207
                $obs[$idobs]['mots_cles_cel_obs'] = $imgdata['mots_cles_cel_obs'];
202
            $obs[$idobs]['programme'] = $imgdata['programme'];
208
                $obs[$idobs]['programme'] = $imgdata['programme'];
203
 
209
 
204
			$obs[$idobs]['date_observation'] = $imgdata['date_observation'];
210
                $obs[$idobs]['date_observation'] = $imgdata['date_observation'];
205
            $obs[$idobs]['date_creation'] = $imgdata['date_created'];
211
                $obs[$idobs]['date_creation'] = $imgdata['date_created'];
206
            $obs[$idobs]['date_changement'] = $ids['modif_date'];
212
                $obs[$idobs]['date_changement'] = $ids['modif_date'];
207
			$obs[$idobs]['date_publication'] = $imgdata['date_published'];
213
                $obs[$idobs]['date_publication'] = $imgdata['date_published'];
208
			$obs[$idobs]['type_donnees'] = $imgdata['type_donnees'];
214
                $obs[$idobs]['type_donnees'] = $imgdata['type_donnees'];
209
			$obs[$idobs]['identiplante_score'] = $imgdata['identiplante_score'];
215
                $obs[$idobs]['identiplante_score'] = $imgdata['identiplante_score'];
210
			$obs[$idobs]['is_identiplante_validated'] = $imgdata['is_identiplante_validated'];
216
                $obs[$idobs]['is_identiplante_validated'] = $imgdata['is_identiplante_validated'];
211
 
217
 
212
			$obs[$idobs]['nom_sel'] = $imgdata['nom_sel'];
218
                $obs[$idobs]['nom_sel'] = $imgdata['nom_sel'];
213
			$obs[$idobs]['nom_sel_nn'] = $imgdata['nom_sel_nn'];
219
                $obs[$idobs]['nom_sel_nn'] = $imgdata['nom_sel_nn'];
214
			$obs[$idobs]['nom_referentiel'] = $imgdata['nom_referentiel'];
220
                $obs[$idobs]['nom_referentiel'] = $imgdata['nom_referentiel'];
215
			$obs[$idobs]['nom_ret'] = $imgdata['nom_ret'];
221
                $obs[$idobs]['nom_ret'] = $imgdata['nom_ret'];
216
			$obs[$idobs]['nom_ret_nn'] = $imgdata['nom_ret_nn'];
222
                $obs[$idobs]['nom_ret_nn'] = $imgdata['nom_ret_nn'];
217
			$obs[$idobs]['famille'] = $imgdata['famille'];
223
                $obs[$idobs]['famille'] = $imgdata['famille'];
218
 
224
 
219
			$obs[$idobs]['zone_geo'] = $imgdata['zone_geo'];
225
                $obs[$idobs]['zone_geo'] = $imgdata['zone_geo'];
220
			$obs[$idobs]['latitude'] = $imgdata['latitude'];
226
                $obs[$idobs]['latitude'] = $imgdata['latitude'];
221
			$obs[$idobs]['longitude'] = $imgdata['longitude'];
227
                $obs[$idobs]['longitude'] = $imgdata['longitude'];
222
 
228
 
-
 
229
                if (!isset($obs[$idobs]['images'])) {
223
			if (!isset($obs[$idobs]['images'])) {
230
                    $obs[$idobs]['images'] = array();
-
 
231
                }
-
 
232
 
-
 
233
                $img_obj = array(
-
 
234
                    'id_image' => $image,
-
 
235
                    'nom_image' => $imgdata['nom_image'],
-
 
236
                    'image_updated' => $imgdata['image_updated'],
-
 
237
                    'date_shot' => $imgdata['date_shot'],
-
 
238
                    'mots_cles_cel_image' => $imgInfos[0]['mots_cles_cel_image'],
-
 
239
                    'url' => sprintf($imgCelTpl, $idimg, 'O'),
-
 
240
                    'votes' => [
-
 
241
                        'moyenne_votes' => $imgInfos[0]['moyenne_votes'],
-
 
242
                        'nb_votes' => $imgInfos[0]['nb_votes'],
-
 
243
                        'nb_points_votes' => $imgInfos[0]['nb_points_votes'],
-
 
244
                    ],
-
 
245
                    'del_tags' => explode(',', $imgInfos[0]['del_image_tags']),
-
 
246
                );
-
 
247
                // push
Line 224... Line -...
224
				$obs[$idobs]['images'] = array();
-
 
225
			}
-
 
226
 
-
 
227
			$img_obj = array(
-
 
228
				'id_image' => $idimg,
-
 
229
				'nom_image' => $imgdata['nom_image'],
-
 
230
                'image_updated' => $imgdata['image_updated'],
-
 
231
                'date_shot' => $imgdata['date_shot'],
-
 
232
                'mots_cles_cel_image' => $imgdata['mots_cles_cel_image'],
-
 
233
				'url' => sprintf($imgCelTpl, $idimg, 'O'),
-
 
234
				'votes' => [
-
 
235
                    'moyenne_votes' => $ids['moyenne_votes'],
-
 
236
                    'nb_votes' => $ids['nb_votes'],
-
 
237
                    'nb_points_votes' => $ids['nb_points_votes'],
-
 
238
                ],
-
 
239
				'del_tags' => explode(',', $ids['del_image_tags']),
-
 
240
				);
248
                $obs[$idobs]['images'][] = $img_obj;
241
			// push
249
            }
242
			$obs[$idobs]['images'][] = $img_obj;
250
 
Line 243... Line 251...
243
		}
251
		}
Line 326... Line 334...
326
		}
334
		}
327
		$ret = explode(',', implode(',', $result));
335
		$ret = explode(',', implode(',', $result));
328
		return $ret;
336
		return $ret;
329
	}
337
	}
Line -... Line 338...
-
 
338
 
-
 
339
    /**
-
 
340
     * On charge les infos spécifique à chaque image d'une obs
-
 
341
     */
-
 
342
    private function recupererInfosParImage($id_image){
-
 
343
        $requete =
-
 
344
            'SELECT SQL_CALC_FOUND_ROWS p.id_image, '.
-
 
345
            'p.mots_cles_cel_image, '.
-
 
346
            'iv.moyenne AS moyenne_votes, '.
-
 
347
            'iv.nb_votes AS nb_votes, '.
-
 
348
            'iv.nb_points AS nb_points_votes, '.
-
 
349
            'GROUP_CONCAT(DISTINCT it.tag) AS del_image_tags '.
-
 
350
            'FROM del_plantnet_images AS p '.
-
 
351
            '	LEFT JOIN del_image_stat AS iv '.
-
 
352
            '		ON (id_image = iv.ce_image AND iv.ce_protocole = 3) '.
-
 
353
            '	LEFT JOIN del_image_tag AS it '.
-
 
354
            '		ON (id_image = it.ce_image AND it.actif = 1) '.
-
 
355
            '		WHERE id_image = '. $id_image .' '.
-
 
356
            'GROUP BY p.id_image '.
-
 
357
            ' -- '.__FILE__.':'.__LINE__;
-
 
358
        return $this->bdd->recupererTous($requete);
330
 
359
    }