Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 2317 Rev 2357
Line 67... Line 67...
67
		return $liste;
67
		return $liste;
68
	}
68
	}
Line 69... Line 69...
69
 
69
 
70
	private function construireRequeteListeUtilisateurNbrePhoto() {
70
	private function construireRequeteListeUtilisateurNbrePhoto() {
71
		$select = 	'SELECT co.courriel_utilisateur, COUNT(DISTINCT ci.id_image) AS nbre ';
71
		$select = 	'SELECT co.courriel_utilisateur, COUNT(DISTINCT ci.id_image) AS nbre ';
72
		$from = 	'FROM cel_obs co '.
72
		$from = 	'FROM cel_obs AS co '.
73
					'	LEFT JOIN cel_obs_images coi ON (coi.id_observation = co.id_observation) '.
73
					'	LEFT JOIN cel_obs_images AS coi ON (coi.id_observation = co.id_observation) '.
74
					'	LEFT JOIN cel_images ci ON (coi.id_image = ci.id_image) ';
74
					'	LEFT JOIN cel_images AS ci ON (coi.id_image = ci.id_image) ';
75
		$where = 	'WHERE transmission = 1 ';
75
		$where = 	'WHERE transmission = 1 ';
76
		$groupBy = 	'GROUP BY co.courriel_utilisateur ';
76
		$groupBy = 	'GROUP BY co.courriel_utilisateur ';
77
		$orderBy = 	'ORDER BY nbre DESC ';
77
		$orderBy = 	'ORDER BY nbre DESC ';
Line 91... Line 91...
91
			}
91
			}
92
			if (isset($taxon)) {
92
			if (isset($taxon)) {
93
				$filtres[] = "nom_ret LIKE $taxon ";
93
				$filtres[] = "nom_ret LIKE $taxon ";
94
			}
94
			}
95
			if (isset($tag)) {
95
			if (isset($tag)) {
96
				$limitation = $this->construireWhereTags();
96
				$tagP = Cel::db()->quote("%$tag%");
97
				if ($limitation != null) {
-
 
98
					$filtres[] = $limitation;
97
				$filtres[] = "ci.mots_cles_texte LIKE $tagP ";
99
				} else {
-
 
100
					$zero_images = true;
-
 
101
				}
-
 
102
			}
98
			}
103
			$where .= ((count($filtres) > 0) ? 'AND '.implode(' AND ', $filtres) : '');
99
			$where .= ((count($filtres) > 0) ? 'AND '.implode(' AND ', $filtres) : '');
Line 104... Line 100...
104
 
100
 
105
			if (isset($start)) {
101
			if (isset($start)) {
106
				$limitSql = str_replace('0,', "$start,", $limitSql);
102
				$limitSql = str_replace('0,', "$start,", $limitSql);
107
			}
103
			}
108
			if (isset($limit)) {
104
			if (isset($limit)) {
109
				$limitSql = str_replace('150', $limit, $limitSql);
105
				$limitSql = str_replace('150', $limit, $limitSql);
110
			}
106
			}
111
		}
-
 
112
		if ($zero_images) {
-
 
113
			$requete = null;
-
 
114
		} else {
107
		}
115
			$requete = $select.$from.$where.$groupBy.$orderBy.$limitSql;
-
 
116
			//echo $requete;
-
 
117
		}
108
		$requete = $select.$from.$where.$groupBy.$orderBy.$limitSql;
118
		return $requete;
109
		return $requete;
Line 119... Line -...
119
	}
-
 
120
 
-
 
121
	private function construireWhereTags() {
-
 
122
		$where = null;
-
 
123
		if (isset($this->parametres['tag'])) {
-
 
124
			$tag = $this->parametres['tag'];
-
 
125
			$tag_encode = Cel::db()->quote($this->encoderMotCle(trim($tag)));
-
 
126
 
-
 
127
			// Construction de la requête
-
 
128
			$requete = 	'SELECT cmc_id_mot_cle_utilisateur, cmc_id_proprietaire '.
-
 
129
				'FROM cel_mots_cles_images '.
-
 
130
				"WHERE cmc_id_mot_cle_general = $tag_encode ";
-
 
131
			$elements = Cel::db()->requeter($requete);
-
 
132
 
-
 
133
			if ($elements != false && count($elements) > 0) {
-
 
134
				// Pré-construction du where de la requête
-
 
135
				$tpl_where = '(ci_meta_mots_cles LIKE "%%%s%%" AND ci_ce_utilisateur = %s )';
-
 
136
				$requete_where = array();
-
 
137
				foreach ($elements as $occurence) {
-
 
138
					$requete_where[] = sprintf($tpl_where, $occurence['cmc_id_mot_cle_utilisateur'], Cel::db()->quote($occurence['cmc_id_proprietaire']));
-
 
139
				}
-
 
140
				$where = ' ('.implode(" \nOR ", $requete_where).') ';
-
 
141
			} else {
-
 
142
				$this->debug[] = "Aucune image ne correspond à ce mot clé.";
-
 
143
			}
-
 
144
		}
-
 
145
		return $where;
-
 
146
	}
110
	}
147
 
111
 
Line 148... Line 112...
148
	private function getListeTaxonsNbrePhotos() {
112
	private function getListeTaxonsNbrePhotos() {
149
		$requete = $this->construireRequeteListeTaxonNbrePhoto();
113
		$requete = $this->construireRequeteListeTaxonNbrePhoto();