Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 522 Rev 525
Line 9... Line 9...
9
 * @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
9
 * @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
10
 * @version $Id$
10
 * @version $Id$
11
 * @copyright © 2010, Jean-Pascal MILCENT
11
 * @copyright © 2010, Jean-Pascal MILCENT
12
 */
12
 */
13
abstract class Cel {
13
abstract class Cel {
-
 
14
	const TYPE_OBS = 'observation';
-
 
15
	const TYPE_IMG = 'image';
14
 
16
	
15
	public $config;
17
	public $config;
16
	public $parametres;
18
	public $parametres;
17
	protected $bdd;
19
	protected $bdd;
18
	protected $messages = array();
20
	protected $messages = array();
19
	protected $debug = array();
21
	protected $debug = array();
Line 274... Line 276...
274
		$id = sprintf('%09s', $id).$format;
276
		$id = sprintf('%09s', $id).$format;
275
		$url = sprintf($url_tpl, $id); 
277
		$url = sprintf($url_tpl, $id); 
276
		return $url;
278
		return $url;
277
	}
279
	}
Line 278... Line -...
278
	
-
 
279
	protected function encoderMotCle($mot_cle) {
-
 
280
		return md5(mb_strtolower($mot_cle));
-
 
281
	}
-
 
282
	
280
	
283
	protected function creerAuteur($courriel, $pourAdmin = false) {
281
	protected function creerAuteur($courriel, $pourAdmin = false) {
284
		$auteur = ($pourAdmin) ? $courriel : $this->tronquerCourriel($courriel);
282
		$auteur = ($pourAdmin) ? $courriel : $this->tronquerCourriel($courriel);
285
		return $auteur;
283
		return $auteur;
Line 314... Line 312...
314
			$etre_null = true;
312
			$etre_null = true;
315
		}
313
		}
316
		return $etre_null;
314
		return $etre_null;
317
	}
315
	}
Line -... Line 316...
-
 
316
	
-
 
317
	protected function formaterDate($date, $format = '%A %d %B %Y à %H:%M') {
-
 
318
		return strftime($format, strtotime($date));
-
 
319
	}
-
 
320
	
-
 
321
	protected function encoderMotCle($mot_cle) {
-
 
322
		return md5(mb_strtolower($mot_cle));
-
 
323
	}
-
 
324
	
-
 
325
	protected function decoderMotsClesObs($utilisateur_id, $mots_cles) {
-
 
326
		return $this->decoderMotsCles($utilisateur_id, $mots_cles, self::TYPE_OBS);
-
 
327
	}
-
 
328
	
-
 
329
	protected function decoderMotsClesImg($utilisateur_id, $mots_cles) {
-
 
330
		return $this->decoderMotsCles($utilisateur_id, $mots_cles, self::TYPE_IMG);
-
 
331
	}
-
 
332
	
-
 
333
	private function decoderMotsCles($utilisateur_id, $mots_cles, $type) {
-
 
334
		$mots = array();
-
 
335
		if (! $this->etreNull($mots_cles)) {
-
 
336
			$utilisateur_id = $this->bdd->quote($utilisateur_id);
-
 
337
			
-
 
338
			$mots_cles = $this->protegerMotsCles($mots_cles, $type);
-
 
339
			
-
 
340
			$table = ($type == self::TYPE_IMG) ? 'cel_mots_cles_images' : 'cel_mots_cles_obs' ;
-
 
341
			
-
 
342
			$requete = 'SELECT cmc_mot_cle '.
-
 
343
				"FROM $table ".
-
 
344
				"WHERE cmc_id_mot_cle_utilisateur IN ($mots_cles) ".
-
 
345
				"AND cmc_id_proprietaire = $utilisateur_id ";
-
 
346
			
-
 
347
			$elements = $this->executerRequete($requete);
-
 
348
			
-
 
349
			foreach ($elements as $mot) {
-
 
350
				$mots[] = $mot['cmc_mot_cle'];
-
 
351
			}
-
 
352
		}
-
 
353
		return $mots;
-
 
354
	}
-
 
355
	
-
 
356
	private function protegerMotsCles($mots_cles, $type) {
-
 
357
		$separateur = ($type == self::TYPE_IMG) ? ',' : ';' ;
-
 
358
		$mots_cles_a_proteger = explode($separateur,rtrim(trim($mots_cles), $separateur));
-
 
359
		foreach ($mots_cles_a_proteger as $mot) {
-
 
360
			$mots_cles_proteges[] = $this->bdd->quote($mot);
-
 
361
		}
-
 
362
		$mots_cles = implode(',', $mots_cles_proteges);
-
 
363
		return $mots_cles;
-
 
364
	}
318
	
365
	
319
	//+----------------------------------------------------------------------------------------------------------------+
366
	//+----------------------------------------------------------------------------------------------------------------+
Line 320... Line 367...
320
	// GESTION DES SQUELETTES PHP
367
	// GESTION DES SQUELETTES PHP
321
 
368