Subversion Repositories eFlore/Applications.del

Rev

Rev 2225 | Show entire file | Regard 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 -... Line 190...
-
 
190
 
-
 
191
            $obs[$idobs]['id_observation'] = $idobs;
-
 
192
 
-
 
193
            foreach ($idimg as $image){
-
 
194
                $imgInfos = null;
-
 
195
                $imgdata = null;
190
 
196
 
-
 
197
                $imgdata = $this->infosObsImg[$image];
Line 191... Line 198...
191
			$imgdata = $this->infosObsImg[$idimg];
198
                $imgInfos = $this->recupererInfosParImage($image);
192
 
199
 
193
			if (!isset($obs[$idobs])) {
200
                if (!isset($obs[$idobs])) {
Line 194... Line -...
194
				$obs[$idobs] = array();
-
 
195
			}
201
                    $obs[$idobs] = array();
196
 
202
                }
Line 197... Line 203...
197
			$obs[$idobs]['id_observation'] = $idobs;
203
 
198
			$obs[$idobs]['id_plantnet'] = $imgdata['id_plantnet'];
204
                $obs[$idobs]['id_plantnet'] = $imgdata['id_plantnet'];
Line 223... Line 229...
223
			if (!isset($obs[$idobs]['images'])) {
229
                if (!isset($obs[$idobs]['images'])) {
224
				$obs[$idobs]['images'] = array();
230
                    $obs[$idobs]['images'] = array();
225
			}
231
                }
Line 226... Line 232...
226
 
232
 
227
			$img_obj = array(
233
                $img_obj = array(
228
				'id_image' => $idimg,
234
                    'id_image' => $image,
229
				'nom_image' => $imgdata['nom_image'],
235
                    'nom_image' => $imgdata['nom_image'],
230
                'image_updated' => $imgdata['image_updated'],
236
                    'image_updated' => $imgdata['image_updated'],
231
                'date_shot' => $imgdata['date_shot'],
237
                    'date_shot' => $imgdata['date_shot'],
232
                'mots_cles_cel_image' => $imgdata['mots_cles_cel_image'],
238
                    'mots_cles_cel_image' => $imgInfos[0]['mots_cles_cel_image'],
233
				'url' => sprintf($imgCelTpl, $idimg, 'O'),
239
                    'url' => sprintf($imgCelTpl, $idimg, 'O'),
234
				'votes' => [
240
                    'votes' => [
235
                    'moyenne_votes' => $ids['moyenne_votes'],
241
                        'moyenne_votes' => $imgInfos[0]['moyenne_votes'],
236
                    'nb_votes' => $ids['nb_votes'],
242
                        'nb_votes' => $imgInfos[0]['nb_votes'],
237
                    'nb_points_votes' => $ids['nb_points_votes'],
243
                        'nb_points_votes' => $imgInfos[0]['nb_points_votes'],
238
                ],
244
                    ],
239
				'del_tags' => explode(',', $ids['del_image_tags']),
245
                    'del_tags' => explode(',', $imgInfos[0]['del_image_tags']),
240
				);
246
                );
241
			// push
247
                // push
242
			$obs[$idobs]['images'][] = $img_obj;
248
                $obs[$idobs]['images'][] = $img_obj;
-
 
249
            }
-
 
250
 
243
		}
251
		}
244
		return $obs;
252
		return $obs;
Line 245... Line 253...
245
	}
253
	}
246
 
254
 
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
    }