| Line 1... | 
            Line 1... | 
          
          
            | 1 | 
            <?php
  | 
            1 | 
            <?php
  | 
          
          
            | 2 | 
            /**
  | 
            2 | 
            /**
  | 
          
          
            | 3 | 
            * Description :
  | 
            3 | 
            * Description :
  | 
          
          
            | 4 | 
            * Classe MetaDonnees.php fournit des informations sur le projet.
  | 
            4 | 
            * Classe MetaDonnees.php fournit des informations sur le projet.
  | 
          
          
            | 5 | 
            * Le but étant de fournir un ensemble minimal d'information comprenant : 
  | 
            5 | 
            * Le but étant de fournir un ensemble minimal d'information comprenant :
  | 
          
          
            | 6 | 
            * la version, la langue, le nom, le créateur et l'éditeur du projet.
  | 
            6 | 
            * la version, la langue, le nom, le créateur et l'éditeur du projet.
  | 
          
          
            | 7 | 
            * Si l'url finit par /meta-donnees on retourne une liste de termes (seulement les 100 premières par défaut).
  | 
            7 | 
            * Si l'url finit par /meta-donnees on retourne une liste de termes (seulement les 100 premières par défaut).
  | 
          
          
            | 8 | 
            * L'url peut contenir des paramètres optionnels passés après le ? : /meta-donnees?param1=val1¶m2=val2&...
  | 
            8 | 
            * L'url peut contenir des paramètres optionnels passés après le ? : /meta-donnees?param1=val1¶m2=val2&...
  | 
          
          
            | 9 | 
            * 
  | 
            9 | 
            *
  | 
          
          
            | 10 | 
            * Les paramètres de requête disponibles sont : masque, , recherche, 
  | 
            10 | 
            * Les paramètres de requête disponibles sont : masque, , recherche,
  | 
          
          
            | 11 | 
            * distinct, retour.format, navigation.depart et navigation.limite.
  | 
            11 | 
            * distinct, retour.format, navigation.depart et navigation.limite.
  | 
          
          
            | 12 | 
            * 
  | 
            12 | 
            *
  | 
          
          
            | 13 | 
            * Encodage en entrée : utf8
  | 
            13 | 
            * Encodage en entrée : utf8
  | 
          
          
            | 14 | 
            * Encodage en sortie : utf8
  | 
            14 | 
            * Encodage en sortie : utf8
  | 
          
          
            | 15 | 
            * @package framework-v3
  | 
            15 | 
            * @package framework-v3
  | 
          
          
            | 16 | 
            * @author Jennifer Dhé <jennifer.dhe@tela-botanica.org>
  | 
            16 | 
            * @author Jennifer Dhé <jennifer.dhe@tela-botanica.org>
  | 
          
          
            | 17 | 
            * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
  | 
            17 | 
            * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
  | 
          
          
            | Line 19... | 
            Line 19... | 
          
          
            | 19 | 
            * @version 1.0
  | 
            19 | 
            * @version 1.0
  | 
          
          
            | 20 | 
            * @copyright 1999-${year} Tela Botanica (accueil@tela-botanica.org)
  | 
            20 | 
            * @copyright 1999-${year} Tela Botanica (accueil@tela-botanica.org)
  | 
          
          
            | 21 | 
            */
  | 
            21 | 
            */
  | 
          
          
            | Line 22... | 
            Line 22... | 
          
          
            | 22 | 
             
  | 
            22 | 
             
  | 
          
          
            | 23 | 
            class MetaDonnees extends Commun {
  | 
            23 | 
            class MetaDonnees extends Commun {
  | 
          
          
            | 24 | 
            	
  | 
            24 | 
             
  | 
          
          
            | 25 | 
            	protected $requete_champ = '*';
  | 
            25 | 
            	protected $requete_champ = '*';
  | 
          
          
            | 26 | 
            	protected $requete_condition = null;
  | 
            26 | 
            	protected $requete_condition = null;
  | 
          
          
            | 27 | 
            	protected $retour_format = 'max';
  | 
            27 | 
            	protected $retour_format = 'max';
  | 
          
          
            | 28 | 
            	protected $table_retour = array();
  | 
            28 | 
            	protected $table_retour = array();
  | 
          
          
            | 29 | 
            	protected $format_reponse = 'metaDonnees';
  | 
            29 | 
            	protected $format_reponse = 'metaDonnees';
  | 
          
          
            | 30 | 
            	protected $table_ressources;
  | 
            30 | 
            	protected $table_ressources;
  | 
          
          
            | 31 | 
            		
  | 
            31 | 
             
  | 
          
          
            | 32 | 
            	
  | 
            32 | 
             
  | 
          
          
            | 33 | 
            	public function consulter($ressources, $parametres) {
  | 
            33 | 
            	public function consulter($ressources, $parametres) {
  | 
          
          
            | 34 | 
            		$this->service = 'meta-donnees';
  | 
            34 | 
            		$this->service = 'meta-donnees';
  | 
          
          
            | 35 | 
            		$resultat_formate = '';
  | 
            35 | 
            		$resultat_formate = '';
  | 
          
          
            | 36 | 
            		// on traite en premier la version dans le cas ou un langage est demandé pr une version
  | 
            36 | 
            		// on traite en premier la version dans le cas ou un langage est demandé pr une version
  | 
          
          
            | 37 | 
            		$this->traiterRessourceVersion($ressources); 
  | 
            37 | 
            		$this->traiterRessourceVersion($ressources);
  | 
          
          
            | 38 | 
            		$this->traiterParametres($parametres);
  | 
            38 | 
            		$this->traiterParametres($parametres);
  | 
          
          
            | 39 | 
            		$this->traiterRessources($ressources);
  | 
            39 | 
            		$this->traiterRessources($ressources);
  | 
          
          
            | 40 | 
            		if ($this->corps_http == '' && $this->entete_http == '') {
  | 
            40 | 
            		if ($this->corps_http == '' && $this->entete_http == '') {
  | 
          
          
            | 41 | 
            			$requete_meta  = $this->assemblerLaRequete(); 
  | 
            41 | 
            			$requete_meta  = $this->assemblerLaRequete();
  | 
          
          
            | 42 | 
            			$resultat_meta = $this->getBdd()->recupererTous($requete_meta); 
  | 
            42 | 
            			$resultat_meta = $this->getBdd()->recupererTous($requete_meta);
  | 
          
          
            | 43 | 
            			$resultat_formate = $this->testerResultat($resultat_meta, $requete_meta);
  | 
            43 | 
            			$resultat_formate = $this->testerResultat($resultat_meta, $requete_meta);
  | 
          
          
            | 44 | 
            		}
  | 
            44 | 
            		}
  | 
          
          
            | 45 | 
            		return $this->formerReponseHTTP($resultat_formate);
  | 
            45 | 
            		return $this->formerReponseHTTP($resultat_formate);
  | 
          
          
            | 46 | 
            	}
  | 
            46 | 
            	}
  | 
          
          
            | 47 | 
            	
  | 
            47 | 
             
  | 
          
          
            | 48 | 
            	
  | 
            48 | 
             
  | 
          
          
            | 49 | 
            	public function testerResultat($resultat_meta, $requete_meta) {
  | 
            49 | 
            	public function testerResultat($resultat_meta, $requete_meta) {
  | 
          
          
            | 50 | 
            		if ($resultat_meta == '') {
  | 
            50 | 
            		if ($resultat_meta == '') {
  | 
          
          
            | 51 | 
            			$e = 'La requête formée comporte une erreur!';
  | 
            51 | 
            			$e = 'La requête formée comporte une erreur!';
  | 
          
          
            | 52 | 
            			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE,$e);
  | 
            52 | 
            			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE,$e);
  | 
          
          
            | Line 58... | 
            Line 58... | 
          
          
            | 58 | 
            			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $m);
  | 
            58 | 
            			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $m);
  | 
          
          
            | 59 | 
            			Debug::printr($requete_meta);
  | 
            59 | 
            			Debug::printr($requete_meta);
  | 
          
          
            | 60 | 
            		}
  | 
            60 | 
            		}
  | 
          
          
            | 61 | 
            		return $resultat_formate;
  | 
            61 | 
            		return $resultat_formate;
  | 
          
          
            | 62 | 
            	}
  | 
            62 | 
            	}
  | 
          
          
            | 63 | 
            	
  | 
            63 | 
             
  | 
          
          
            | 64 | 
            //--------------------FONCTIONS TRAITEMENT DES PARAMETRES---------------------------------------------------------------
  | 
            64 | 
            //--------------------FONCTIONS TRAITEMENT DES PARAMETRES---------------------------------------------------------------
  | 
          
          
            | 65 | 
            	
  | 
            65 | 
             
  | 
          
          
            | 66 | 
            	public function traiterParametres($parametres) {
  | 
            66 | 
            	public function traiterParametres($parametres) {
  | 
          
          
            | 67 | 
            		if (isset($parametres) && !empty($parametres)) {
  | 
            67 | 
            		if (isset($parametres) && !empty($parametres)) {
  | 
          
          
            | 68 | 
            			foreach ($parametres as $param => $val) {
  | 
            68 | 
            			foreach ($parametres as $param => $val) {
  | 
          
          
            | 69 | 
            				switch ($param) { 
  | 
            69 | 
            				switch ($param) {
  | 
          
          
            | 70 | 
            					case 'retour_langue' : $this->rechercherLangueDispo($val);	break;
  | 
            70 | 
            					case 'retour.langue' : $this->rechercherLangueDispo($val);	break;
  | 
          
          
            | 71 | 
            					case 'retour_format' : $this->retour_format = $val;			break;
  | 
            71 | 
            					case 'retour.format' : $this->retour_format = $val;			break;
  | 
          
          
            | 72 | 
            					default				 : 
  | 
            72 | 
            					default				 :
  | 
          
          
            | 73 | 
            						$e = 'Erreur dans les paramètres de recherche de votre requête : </br> Le paramètre " '
  | 
            73 | 
            						$e = 'Erreur dans les paramètres de recherche de votre requête : </br> Le paramètre " '
  | 
          
          
            | 74 | 
            							.$param.' " n\'existe pas.';
  | 
            74 | 
            							.$param.' " n\'existe pas.';
  | 
          
          
            | 75 | 
            						$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
  | 
            75 | 
            						$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
  | 
          
          
            | 76 | 
            						break;
  | 
            76 | 
            						break;
  | 
          
          
            | 77 | 
            				}
  | 
            77 | 
            				}
  | 
          
          
            | 78 | 
            			}
  | 
            78 | 
            			}
  | 
          
          
            | 79 | 
            		}
  | 
            79 | 
            		}
  | 
          
          
            | 80 | 
            	}
  | 
            80 | 
            	}
  | 
          
          
            | 81 | 
            	
  | 
            81 | 
             
  | 
          
          
            | 82 | 
            //----------------------FONCTIONS TRAITEMENT DES RESSOURCES-------------------------------------------------------------
  | 
            82 | 
            //----------------------FONCTIONS TRAITEMENT DES RESSOURCES-------------------------------------------------------------
  | 
          
          
            | 83 | 
            	
  | 
            83 | 
             
  | 
          
          
            | 84 | 
            	public function traiterRessources($ressources) {
  | 
            84 | 
            	public function traiterRessources($ressources) {
  | 
          
          
            | 85 | 
            		// /meta-donnees (liste des meta-données. Toutes les info de la table sont affichées) ou /meta-donnees/#champ
  | 
            85 | 
            		// /meta-donnees (liste des meta-données. Toutes les info de la table sont affichées) ou /meta-donnees/#champ
  | 
          
          
            | 86 | 
            		if (isset($ressources) && !empty($ressources)) {
  | 
            86 | 
            		if (isset($ressources) && !empty($ressources)) {
  | 
          
          
            | 87 | 
            			$this->table_ressources = $ressources;
  | 
            87 | 
            			$this->table_ressources = $ressources;
  | 
          
          
            | 88 | 
            			if (isset($ressources) && !empty($ressources)) {
  | 
            88 | 
            			if (isset($ressources) && !empty($ressources)) {
  | 
          
          
            | 89 | 
            				$this->format_reponse = 'metaDonnees/champ';
  | 
            89 | 
            				$this->format_reponse = 'metaDonnees/champ';
  | 
          
          
            | 90 | 
            			}	
  | 
            90 | 
            			}
  | 
          
          
            | 91 | 
            		}
  | 
            91 | 
            		}
  | 
          
          
            | 92 | 
            	}
  | 
            92 | 
            	}
  | 
          
          
            | 93 | 
            	
  | 
            93 | 
             
  | 
          
          
            | 94 | 
            	/** Détermine quelles métadonnées doivent etre retournées : 
  | 
            94 | 
            	/** Détermine quelles métadonnées doivent etre retournées :
  | 
          
          
            | 95 | 
            	 *  - "*" : (/#projet/* /meta-donnees) Renvoi les meta-données de toutes les versions du projet
  | 
            95 | 
            	 *  - "*" : (/#projet/* /meta-donnees) Renvoi les meta-données de toutes les versions du projet
  | 
          
          
            | 96 | 
            	 *  - "numero de la version" : (/#projet/2.00/meta-donnees) Renvoi les meta-données de la version 2.00 du projet
  | 
            96 | 
            	 *  - "numero de la version" : (/#projet/2.00/meta-donnees) Renvoi les meta-données de la version 2.00 du projet
  | 
          
          
            | 97 | 
            	 *  - non renseignée : (/#projet/meta-donnees) Renvoi les meta-données de la dernière version du projet
  | 
            97 | 
            	 *  - non renseignée : (/#projet/meta-donnees) Renvoi les meta-données de la dernière version du projet
  | 
          
          
            | 98 | 
            	 *  Cette info est stockée dans par la classe RestServeur dans la variable $ressources ($ressources[0])
  | 
            98 | 
            	 *  Cette info est stockée dans par la classe RestServeur dans la variable $ressources ($ressources[0])
  | 
          
          
            | 99 | 
            	 */ 
  | 
            99 | 
            	 */
  | 
          
          
            | 100 | 
            	public function traiterRessourceVersion(&$ressources) {
  | 
            100 | 
            	public function traiterRessourceVersion(&$ressources) {
  | 
          
          
            | 101 | 
            		if (isset($ressources[0]) && !empty($ressources[0])) {
  | 
            101 | 
            		if (isset($ressources[0]) && !empty($ressources[0])) {
  | 
          
          
            | 102 | 
            			if (preg_match('/(?:[0-9]+(?:_|[.])[0-9]+|[*]| )/', $ressources[0])) {
  | 
            102 | 
            			if (preg_match('/(?:[0-9]+(?:_|[.])[0-9]+|[*]| )/', $ressources[0])) {
  | 
          
          
            | 103 | 
            				$this->version_projet = array_shift($ressources); 
  | 
            103 | 
            				$this->version_projet = array_shift($ressources);
  | 
          
          
            | 104 | 
            				if ($this->version_projet == ' ') $this->version_projet = '+';
  | 
            104 | 
            				if ($this->version_projet == ' ') $this->version_projet = '+';
  | 
          
          
            | 105 | 
            			}
  | 
            105 | 
            			}
  | 
          
          
            | 106 | 
            			switch ($this->version_projet) {
  | 
            106 | 
            			switch ($this->version_projet) {
  | 
          
          
            | 107 | 
            				case '+' : 
  | 
            107 | 
            				case '+' :
  | 
          
          
            | 108 | 
            					$this->requete_condition[] = 'version = (SELECT MAX(version) FROM '.Config::get('bdd_table_meta').')'; 
  | 
            108 | 
            					$this->requete_condition[] = 'version = (SELECT MAX(version) FROM '.Config::get('bdd_table_meta').')';
  | 
          
          
            | 109 | 
            					break;
  | 
            109 | 
            					break;
  | 
          
          
            | 110 | 
            				case '*' : 
  | 
            110 | 
            				case '*' :
  | 
          
          
            | 111 | 
            					break;
  | 
            111 | 
            					break;
  | 
          
          
            | 112 | 
            				default : 
  | 
            112 | 
            				default :
  | 
          
          
            | 113 | 
            					if (is_numeric($this->version_projet)) {
  | 
            113 | 
            					if (is_numeric($this->version_projet)) {
  | 
          
          
            | 114 | 
            						$res_version = $this->rechercherVersionsDispo($this->version_projet);
  | 
            114 | 
            						$res_version = $this->rechercherVersionsDispo($this->version_projet);
  | 
          
          
            | 115 | 
            					}
  | 
            115 | 
            					}
  | 
          
          
            | 116 | 
            					break;
  | 
            116 | 
            					break;
  | 
          
          
            | 117 | 
            			}
  | 
            117 | 
            			}
  | 
          
          
            | 118 | 
            		}
  | 
            118 | 
            		}
  | 
          
          
            | 119 | 
            		
  | 
            119 | 
             
  | 
          
          
            | 120 | 
            	}
  | 
            120 | 
            	}
  | 
          
          
            | 121 | 
            	
  | 
            121 | 
             
  | 
          
          
            | 122 | 
            	
  | 
            122 | 
             
  | 
          
          
            | 123 | 
            	/**
  | 
            123 | 
            	/**
  | 
          
          
            | 124 | 
            	 * Vérifie que le numéro de la version passée en paramètre correspond à une version existante. 
  | 
            124 | 
            	 * Vérifie que le numéro de la version passée en paramètre correspond à une version existante.
  | 
          
          
            | 125 | 
            	 * Si oui remplit la condition de la requete SQL
  | 
            125 | 
            	 * Si oui remplit la condition de la requete SQL
  | 
          
          
            | 126 | 
            	 */
  | 
            126 | 
            	 */
  | 
          
          
            | 127 | 
            	public function rechercherVersionsDispo($val) {
  | 
            127 | 
            	public function rechercherVersionsDispo($val) {
  | 
          
          
            | 128 | 
            		$val = str_replace('_', '.', $val);
  | 
            128 | 
            		$val = str_replace('_', '.', $val);
  | 
          
          
            | 129 | 
            		$req_version = 'SELECT version FROM '.Config::get('bdd_table_meta');
  | 
            129 | 
            		$req_version = 'SELECT version FROM '.Config::get('bdd_table_meta');
  | 
          
          
            | 130 | 
            		$res_version = $this->getBdd()->recupererTous($req_version);
  | 
            130 | 
            		$res_version = $this->getBdd()->recupererTous($req_version);
  | 
          
          
            | 131 | 
            		foreach ($res_version as $version) {
  | 
            131 | 
            		foreach ($res_version as $version) {
  | 
          
          
            | 132 | 
            			$versions_dispo[] = $version['version'];
  | 
            132 | 
            			$versions_dispo[] = $version['version'];
  | 
          
          
            | 133 | 
            		}
  | 
            133 | 
            		}
  | 
          
          
            | 134 | 
            		if (in_array($val, $versions_dispo)) {
  | 
            134 | 
            		if (in_array($val, $versions_dispo)) {
  | 
          
          
            | 135 | 
            			$this->requete_condition[] = 'version = '.$this->getBdd()->proteger($val); 
  | 
            135 | 
            			$this->requete_condition[] = 'version = '.$this->getBdd()->proteger($val);
  | 
          
          
            | 136 | 
            		} else {
  | 
            136 | 
            		} else {
  | 
          
          
            | 137 | 
            			$e = 'La version demandée n\'existe pas actuellement. </br>Les versions disponibles sont : '
  | 
            137 | 
            			$e = 'La version demandée n\'existe pas actuellement. </br>Les versions disponibles sont : '
  | 
          
          
            | 138 | 
            				.implode($versions_dispo);
  | 
            138 | 
            				.implode($versions_dispo);
  | 
          
          
            | 139 | 
            			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $e);
  | 
            139 | 
            			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $e);
  | 
          
          
            | 140 | 
            		}
  | 
            140 | 
            		}
  | 
          
          
            | 141 | 
            		return $res_version;
  | 
            141 | 
            		return $res_version;
  | 
          
          
            | 142 | 
            	}
  | 
            142 | 
            	}
  | 
          
          
            | 143 | 
            	
  | 
            143 | 
             
  | 
          
          
            | 144 | 
            	
  | 
            144 | 
             
  | 
          
          
            | 145 | 
            	/** Vérifie que les meta-donnees existe dans la langue passée en paramètre, Si oui remplit la condition de la requete SQL */
  | 
            145 | 
            	/** Vérifie que les meta-donnees existe dans la langue passée en paramètre, Si oui remplit la condition de la requete SQL */
  | 
          
          
            | 146 | 
            	public function rechercherLangueDispo($val) {
  | 
            146 | 
            	public function rechercherLangueDispo($val) {
  | 
          
          
            | 147 | 
            		//on recherche les langues_meta disponibles pour la version demandée : (d'ou ajout de la condition)
  | 
            147 | 
            		//on recherche les langues_meta disponibles pour la version demandée : (d'ou ajout de la condition)
  | 
          
          
            | 148 | 
            		$req_langue = 'SELECT langue_meta FROM '
  | 
            148 | 
            		$req_langue = 'SELECT langue_meta FROM '
  | 
          
          
            | 149 | 
            						.Config::get('bdd_table_meta')
  | 
            149 | 
            						.Config::get('bdd_table_meta')
  | 
          
          
            | Line 151... | 
            Line 151... | 
          
          
            | 151 | 
            		$res_langue = $this->getBdd()->recupererTous($req_langue);
  | 
            151 | 
            		$res_langue = $this->getBdd()->recupererTous($req_langue);
  | 
          
          
            | 152 | 
            		foreach ($res_langue as $langue) {
  | 
            152 | 
            		foreach ($res_langue as $langue) {
  | 
          
          
            | 153 | 
            			$langue_dispo[] = $langue['langue_meta'];
  | 
            153 | 
            			$langue_dispo[] = $langue['langue_meta'];
  | 
          
          
            | 154 | 
            		}
  | 
            154 | 
            		}
  | 
          
          
            | 155 | 
            		if (in_array($val, $langue_dispo)) {
  | 
            155 | 
            		if (in_array($val, $langue_dispo)) {
  | 
          
          
            | 156 | 
            			$this->requete_condition[] = 'langue_meta = '.$this->getBdd()->proteger($val); 
  | 
            156 | 
            			$this->requete_condition[] = 'langue_meta = '.$this->getBdd()->proteger($val);
  | 
          
          
            | 157 | 
            		} else {
  | 
            157 | 
            		} else {
  | 
          
          
            | 158 | 
            			$e = 'La langue demandée n\'existe pas actuellement. </br>Les langues disponibles sont : '
  | 
            158 | 
            			$e = 'La langue demandée n\'existe pas actuellement. </br>Les langues disponibles sont : '
  | 
          
          
            | 159 | 
            				.implode($langue_dispo);
  | 
            159 | 
            				.implode($langue_dispo);
  | 
          
          
            | 160 | 
            			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $e);
  | 
            160 | 
            			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $e);
  | 
          
          
            | 161 | 
            		}
  | 
            161 | 
            		}
  | 
          
          
            | 162 | 
            	}
  | 
            162 | 
            	}
  | 
          
          
            | 163 | 
            	
  | 
            163 | 
             
  | 
          
          
            | 164 | 
            //------------------------------Fonction d'assemblage de la requete------------------------------------------------------
  | 
            164 | 
            //------------------------------Fonction d'assemblage de la requete------------------------------------------------------
  | 
          
          
            | 165 | 
            	
  | 
            165 | 
             
  | 
          
          
            | 166 | 
            	public function assemblerLaRequete() {
  | 
            166 | 
            	public function assemblerLaRequete() {
  | 
          
          
            | 167 | 
            		$condition = '';
  | 
            167 | 
            		$condition = '';
  | 
          
          
            | 168 | 
            		if (isset($this->requete_condition)) {
  | 
            168 | 
            		if (isset($this->requete_condition)) {
  | 
          
          
            | 169 | 
            			$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
  | 
            169 | 
            			$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
  | 
          
          
            | 170 | 
            		} 
  | 
            170 | 
            		}
  | 
          
          
            | 171 | 
            		$req = 'SELECT '.$this->requete_champ.' FROM '.Config::get('bdd_table_meta').$condition;
  | 
            171 | 
            		$req = 'SELECT '.$this->requete_champ.' FROM '.Config::get('bdd_table_meta').$condition;
  | 
          
          
            | 172 | 
            		return $req;
  | 
            172 | 
            		return $req;
  | 
          
          
            | 173 | 
            	}
  | 
            173 | 
            	}
  | 
          
          
            | 174 | 
            	
  | 
            174 | 
             
  | 
          
          
            | 175 | 
            //--------------------------------------Fonction de formatage des resultats ---------------------------------------------
  | 
            175 | 
            //--------------------------------------Fonction de formatage des resultats ---------------------------------------------
  | 
          
          
            | 176 | 
            	
  | 
            176 | 
             
  | 
          
          
            | 177 | 
            	public function formaterResultat($resultat) {
  | 
            177 | 
            	public function formaterResultat($resultat) {
  | 
          
          
            | 178 | 
            		switch ($this->format_reponse) {
  | 
            178 | 
            		switch ($this->format_reponse) {
  | 
          
          
            | 179 | 
            			case 'metaDonnees/champ' : $reponse = $this->formaterMetaDonneesChamp($resultat);  	break;
  | 
            179 | 
            			case 'metaDonnees/champ' : $reponse = $this->formaterMetaDonneesChamp($resultat);  	break;
  | 
          
          
            | 180 | 
            			case 'metaDonnees'		 : $reponse = $this->formaterMetaDonnees($resultat); 		break;
  | 
            180 | 
            			case 'metaDonnees'		 : $reponse = $this->formaterMetaDonnees($resultat); 		break;
  | 
          
          
            | 181 | 
            			default					 : 															break;
  | 
            181 | 
            			default					 : 															break;
  | 
          
          
            | 182 | 
            		}
  | 
            182 | 
            		}
  | 
          
          
            | 183 | 
            		return json_encode($reponse);
  | 
            183 | 
            		return json_encode($reponse);
  | 
          
          
            | 184 | 
            	}	
  | 
            184 | 
            	}
  | 
          
          
            | 185 | 
            	
  | 
            185 | 
             
  | 
          
          
            | 186 | 
            //--------------------------------------Fonction de formatage des resultats de /metaDonnees/----------------------------
  | 
            186 | 
            //--------------------------------------Fonction de formatage des resultats de /metaDonnees/----------------------------
  | 
          
          
            | 187 | 
            	
  | 
            187 | 
             
  | 
          
          
            | 188 | 
            	public function formaterMetaDonnees($resultat) {
  | 
            188 | 
            	public function formaterMetaDonnees($resultat) {
  | 
          
          
            | 189 | 
            		foreach ($resultat as $version) {
  | 
            189 | 
            		foreach ($resultat as $version) {
  | 
          
          
            | 190 | 
            			foreach ($version as $key => $val) {
  | 
            190 | 
            			foreach ($version as $key => $val) {
  | 
          
          
            | 191 | 
            				if ($val != '') {
  | 
            191 | 
            				if ($val != '') {
  | 
          
          
            | 192 | 
            					$this->afficherDonnees($key, $val);
  | 
            192 | 
            					$this->afficherDonnees($key, $val);
  | 
          
          
            | 193 | 
            				}												
  | 
            193 | 
            				}
  | 
          
          
            | 194 | 
            			}
  | 
            194 | 
            			}
  | 
          
          
            | 195 | 
            			if ($this->retour_format == 'max' && $this->version_projet == '*') {
  | 
            195 | 
            			if ($this->retour_format == 'max' && $this->version_projet == '*') {
  | 
          
          
            | 196 | 
            				$this->table_retour['href'] = Config::get('url_service_base').Config::get('nom_projet')
  | 
            196 | 
            				$this->table_retour['href'] = Config::get('url_service_base').Config::get('nom_projet')
  | 
          
          
            | 197 | 
            											 .'/'.$version['version'].'/'.$this->service;
  | 
            197 | 
            											 .'/'.$version['version'].'/'.$this->service;
  | 
          
          
            | 198 | 
            			}	
  | 
            198 | 
            			}
  | 
          
          
            | 199 | 
            			$table[] = $this->table_retour;
  | 
            199 | 
            			$table[] = $this->table_retour;
  | 
          
          
            | 200 | 
            			$this->table_retour = array();
  | 
            200 | 
            			$this->table_retour = array();
  | 
          
          
            | 201 | 
            		}
  | 
            201 | 
            		}
  | 
          
          
            | 202 | 
            		return $table;
  | 
            202 | 
            		return $table;
  | 
          
          
            | 203 | 
            	}
  | 
            203 | 
            	}
  | 
          
          
            | 204 | 
            	
  | 
            204 | 
             
  | 
          
          
            | 205 | 
            	
  | 
            205 | 
             
  | 
          
          
            | 206 | 
            	public function afficherDonnees($key, $valeur) {
  | 
            206 | 
            	public function afficherDonnees($key, $valeur) {
  | 
          
          
            | 207 | 
            		if ($valeur != '') {
  | 
            207 | 
            		if ($valeur != '') {
  | 
          
          
            | 208 | 
            			$tab = array();
  | 
            208 | 
            			$tab = array();
  | 
          
          
            | 209 | 
            			if ($this->retour_format == 'min') {
  | 
            209 | 
            			if ($this->retour_format == 'min') {
  | 
          
          
            | 210 | 
            				if (in_array($key, array('editeur','createurs',	'contributeurs','couverture_spatiale','couverture_temporelle'))) {
  | 
            210 | 
            				if (in_array($key, array('editeur','createurs',	'contributeurs','couverture_spatiale','couverture_temporelle'))) {
  | 
          
          
            | 211 | 
            					//Pour les données comprenant plusieurs infos (...=...,...=...;...) 
  | 
            211 | 
            					//Pour les données comprenant plusieurs infos (...=...,...=...;...)
  | 
          
          
            | 212 | 
            					$tab = $this->recupererTableauResultat($valeur);
  | 
            212 | 
            					$tab = $this->recupererTableauResultat($valeur);
  | 
          
          
            | 213 | 
            					$this->afficherConcatenationValeur($key, $tab);
  | 
            213 | 
            					$this->afficherConcatenationValeur($key, $tab);
  | 
          
          
            | 214 | 
            				} else {
  | 
            214 | 
            				} else {
  | 
          
          
            | 215 | 
            					$this->table_retour[$key] = trim($valeur); 
  | 
            215 | 
            					$this->table_retour[$key] = trim($valeur);
  | 
          
          
            | 216 | 
            				}
  | 
            216 | 
            				}
  | 
          
          
            | 217 | 
            			} else {
  | 
            217 | 
            			} else {
  | 
          
          
            | 218 | 
            				if (in_array($key, array('editeur','createurs',	'contributeurs','couverture_spatiale','couverture_temporelle','langue','langue_meta'))) { 
  | 
            218 | 
            				if (in_array($key, array('editeur','createurs',	'contributeurs','couverture_spatiale','couverture_temporelle','langue','langue_meta'))) {
  | 
          
          
            | 219 | 
            					$tab = $this->recupererTableauResultat($valeur); 
  | 
            219 | 
            					$tab = $this->recupererTableauResultat($valeur);
  | 
          
          
            | 220 | 
            					$this->afficherConcatenationValeur($key, $tab);
  | 
            220 | 
            					$this->afficherConcatenationValeur($key, $tab);
  | 
          
          
            | 221 | 
            					$this->afficherDonneesMax($key,$valeur,$tab);
  | 
            221 | 
            					$this->afficherDonneesMax($key,$valeur,$tab);
  | 
          
          
            | 222 | 
            				} else {
  | 
            222 | 
            				} else {
  | 
          
          
            | 223 | 
            					$this->table_retour[$key] = trim($valeur);
  | 
            223 | 
            					$this->table_retour[$key] = trim($valeur);
  | 
          
          
            | 224 | 
            				} 
  | 
            224 | 
            				}
  | 
          
          
            | 225 | 
            			}
  | 
            225 | 
            			}
  | 
          
          
            | 226 | 
            		}
  | 
            226 | 
            		}
  | 
          
          
            | 227 | 
            	}
  | 
            227 | 
            	}
  | 
          
          
            | 228 | 
            	
  | 
            228 | 
             
  | 
          
          
            | 229 | 
            	/**
  | 
            229 | 
            	/**
  | 
          
          
            | 230 | 
            	 * Recupère à partir de la valeur du champ les différentes informations séparées par ';' (stocke ds un tableau)
  | 
            230 | 
            	 * Recupère à partir de la valeur du champ les différentes informations séparées par ';' (stocke ds un tableau)
  | 
          
          
            | 231 | 
            	 * pour éditeurs, créateurs, contributeurs,...
  | 
            231 | 
            	 * pour éditeurs, créateurs, contributeurs,...
  | 
          
          
            | 232 | 
            	 * (ex : nom=Tela Botanica,guid=urn:lsid:tela-botanica.org,courriel=accueil@tela-botanica.org,...
  | 
            232 | 
            	 * (ex : nom=Tela Botanica,guid=urn:lsid:tela-botanica.org,courriel=accueil@tela-botanica.org,...
  | 
          
          
            | 233 | 
            	 */ 
  | 
            233 | 
            	 */
  | 
          
          
            | 234 | 
            	public function recupererTableauResultat($val) {
  | 
            234 | 
            	public function recupererTableauResultat($val) {
  | 
          
          
            | 235 | 
            		$tab = array(); 
  | 
            235 | 
            		$tab = array();
  | 
          
          
            | 236 | 
            		$num_entite = 0;
  | 
            236 | 
            		$num_entite = 0;
  | 
          
          
            | 237 | 
            		// découpe chaque participant
  | 
            237 | 
            		// découpe chaque participant
  | 
          
          
            | 238 | 
            		$tab_entites = explode(';', $val); 
  | 
            238 | 
            		$tab_entites = explode(';', $val);
  | 
          
          
            | 239 | 
            		foreach ($tab_entites as $entite) {
  | 
            239 | 
            		foreach ($tab_entites as $entite) {
  | 
          
          
            | 240 | 
            			$tab[$num_entite] = array();
  | 
            240 | 
            			$tab[$num_entite] = array();
  | 
          
          
            | 241 | 
            			if ($entite != '') { // découpe les informations du participant
  | 
            241 | 
            			if ($entite != '') { // découpe les informations du participant
  | 
          
          
            | 242 | 
            				$entite_detail = explode(',', $entite); 
  | 
            242 | 
            				$entite_detail = explode(',', $entite);
  | 
          
          
            | 243 | 
            				foreach ($entite_detail as $detail) {
  | 
            243 | 
            				foreach ($entite_detail as $detail) {
  | 
          
          
            | 244 | 
            					if ($detail != '') {
  | 
            244 | 
            					if ($detail != '') {
  | 
          
          
            | 245 | 
            						if (preg_match('/^([^=]+)=([^=]*)$/', $detail, $match)) {
  | 
            245 | 
            						if (preg_match('/^([^=]+)=([^=]*)$/', $detail, $match)) {
  | 
          
          
            | 246 | 
            							$tab[$num_entite][$match[1]] = $match[2];
  | 
            246 | 
            							$tab[$num_entite][$match[1]] = $match[2];
  | 
          
          
            | 247 | 
            						} else {
  | 
            247 | 
            						} else {
  | 
          
          
            | Line 252... | 
            Line 252... | 
          
          
            | 252 | 
            			}
  | 
            252 | 
            			}
  | 
          
          
            | 253 | 
            			$num_entite++;
  | 
            253 | 
            			$num_entite++;
  | 
          
          
            | 254 | 
            		}
  | 
            254 | 
            		}
  | 
          
          
            | 255 | 
            		return $tab;
  | 
            255 | 
            		return $tab;
  | 
          
          
            | 256 | 
            	}
  | 
            256 | 
            	}
  | 
          
          
            | 257 | 
            	
  | 
            257 | 
             
  | 
          
          
            | 258 | 
            	
  | 
            258 | 
             
  | 
          
          
            | 259 | 
            	/** Retourne : 
  | 
            259 | 
            	/** Retourne :
  | 
          
          
            | 260 | 
            	 *  - le nom de l'editeur 
  | 
            260 | 
            	 *  - le nom de l'editeur
  | 
          
          
            | 261 | 
            	 *  - les coordonnées de l'éditeur sous la forme [latitude]N,[longitude]S [datum]
  | 
            261 | 
            	 *  - les coordonnées de l'éditeur sous la forme [latitude]N,[longitude]S [datum]
  | 
          
          
            | 262 | 
            	 *  - la couverture temporelle sous la forme xxxx à xxxx
  | 
            262 | 
            	 *  - la couverture temporelle sous la forme xxxx à xxxx
  | 
          
          
            | 263 | 
            	 *  - la concaténation des noms pour les contributeurs et les créateurs (machin chouette, truc bidule...)
  | 
            263 | 
            	 *  - la concaténation des noms pour les contributeurs et les créateurs (machin chouette, truc bidule...)
  | 
          
          
            | 264 | 
            	 *  - la liste des liste des couvertures spatiales (le nom et pas le code) (France, allemagne..) */
  | 
            264 | 
            	 *  - la liste des liste des couvertures spatiales (le nom et pas le code) (France, allemagne..) */
  | 
          
          
            | 265 | 
            	public function afficherConcatenationValeur($champ, $tab) {
  | 
            265 | 
            	public function afficherConcatenationValeur($champ, $tab) {
  | 
          
          
            | Line 273... | 
            Line 273... | 
          
          
            | 273 | 
            				foreach ($entite as $key => $val) {
  | 
            273 | 
            				foreach ($entite as $key => $val) {
  | 
          
          
            | 274 | 
            					if ($champ == 'couverture_spatiale') {
  | 
            274 | 
            					if ($champ == 'couverture_spatiale') {
  | 
          
          
            | 275 | 
            							$concat .= ', '.$this->ajouterSignification($champ, $val);
  | 
            275 | 
            							$concat .= ', '.$this->ajouterSignification($champ, $val);
  | 
          
          
            | 276 | 
            					} else {
  | 
            276 | 
            					} else {
  | 
          
          
            | 277 | 
            						if (strrpos($key, '.prenom') !== false) {
  | 
            277 | 
            						if (strrpos($key, '.prenom') !== false) {
  | 
          
          
            | 278 | 
            							$concat .= ', '.$val; 
  | 
            278 | 
            							$concat .= ', '.$val;
  | 
          
          
            | 279 | 
            						} elseif (strrpos($key, 'nom') !== false) {
  | 
            279 | 
            						} elseif (strrpos($key, 'nom') !== false) {
  | 
          
          
            | 280 | 
            						
  | 
            280 | 
             
  | 
          
          
            | 281 | 
            							$concat .= ' '.$val; 
  | 
            281 | 
            							$concat .= ' '.$val;
  | 
          
          
            | 282 | 
            							break;
  | 
            282 | 
            							break;
  | 
          
          
            | 283 | 
            						}
  | 
            283 | 
            						}
  | 
          
          
            | 284 | 
            					}
  | 
            284 | 
            					}
  | 
          
          
            | 285 | 
            				}
  | 
            285 | 
            				}
  | 
          
          
            | 286 | 
            			}
  | 
            286 | 
            			}
  | 
          
          
            | Line 288... | 
            Line 288... | 
          
          
            | 288 | 
            			$res = trim($res);
  | 
            288 | 
            			$res = trim($res);
  | 
          
          
            | 289 | 
            			if ($champ == 'couverture_temporelle') $res = str_replace(' ', ' à ',$res);
  | 
            289 | 
            			if ($champ == 'couverture_temporelle') $res = str_replace(' ', ' à ',$res);
  | 
          
          
            | 290 | 
            			$this->table_retour[$champ] = $res;
  | 
            290 | 
            			$this->table_retour[$champ] = $res;
  | 
          
          
            | 291 | 
            		}
  | 
            291 | 
            		}
  | 
          
          
            | 292 | 
            	}
  | 
            292 | 
            	}
  | 
          
          
            | 293 | 
            	
  | 
            293 | 
             
  | 
          
          
            | Line 294... | 
            Line 294... | 
          
          
            | 294 | 
             
  | 
            294 | 
             
  | 
          
          
            | 295 | 
            	public function afficherDonneesMax($champ,$valeur,$tab) {
  | 
            295 | 
            	public function afficherDonneesMax($champ,$valeur,$tab) {
  | 
          
          
            | 296 | 
            		switch ($champ) {
  | 
            296 | 
            		switch ($champ) {
  | 
          
          
            | 297 | 
            			case 'couverture_temporelle' : $this->afficherInfosPrecises($champ, 'start,end', $valeur, $tab); 		break;
  | 
            297 | 
            			case 'couverture_temporelle' : $this->afficherInfosPrecises($champ, 'start,end', $valeur, $tab); 		break;
  | 
          
          
            | Line 302... | 
            Line 302... | 
          
          
            | 302 | 
            			case 'contributeurs' 		 : $this->afficherInfosPrecises($champ, 'details', $valeur, $tab); 			break;
  | 
            302 | 
            			case 'contributeurs' 		 : $this->afficherInfosPrecises($champ, 'details', $valeur, $tab); 			break;
  | 
          
          
            | 303 | 
            			case 'editeur' 				 : $this->afficherEditeur($champ, $tab);									break;
  | 
            303 | 
            			case 'editeur' 				 : $this->afficherEditeur($champ, $tab);									break;
  | 
          
          
            | 304 | 
            			default 					 : $this->table_retour[$champ] = $valeur; 									break;
  | 
            304 | 
            			default 					 : $this->table_retour[$champ] = $valeur; 									break;
  | 
          
          
            | 305 | 
            		}
  | 
            305 | 
            		}
  | 
          
          
            | 306 | 
            	}
  | 
            306 | 
            	}
  | 
          
          
            | 307 | 
            	
  | 
            307 | 
             
  | 
          
          
            | 308 | 
            	
  | 
            308 | 
             
  | 
          
          
            | 309 | 
            	public function afficherEditeur($key, $tab) { 
  | 
            309 | 
            	public function afficherEditeur($key, $tab) {
  | 
          
          
            | 310 | 
            		// infos générales sur l'éditeur 
  | 
            310 | 
            		// infos générales sur l'éditeur
  | 
          
          
            | 311 | 
            		foreach ($tab[0] as $k => $val) {
  | 
            311 | 
            		foreach ($tab[0] as $k => $val) {
  | 
          
          
            | 312 | 
            			if ((strrpos($k, 'contact.') === false) && (strrpos($k, '.wgs84') === false)) {
  | 
            312 | 
            			if ((strrpos($k, 'contact.') === false) && (strrpos($k, '.wgs84') === false)) {
  | 
          
          
            | 313 | 
            				$this->table_retour[$key.'.'.$k] = $val;  
  | 
            313 | 
            				$this->table_retour[$key.'.'.$k] = $val;
  | 
          
          
            | 314 | 
            			}
  | 
            314 | 
            			}
  | 
          
          
            | 315 | 
            		} 
  | 
            315 | 
            		}
  | 
          
          
            | 316 | 
            		//on récupère dans un premier temps les tableaux des coordonnées. 
  | 
            316 | 
            		//on récupère dans un premier temps les tableaux des coordonnées.
  | 
          
          
            | 317 | 
            		$table_coordonnees = $this->recupererTableCoordonnees($tab);
  | 
            317 | 
            		$table_coordonnees = $this->recupererTableCoordonnees($tab);
  | 
          
          
            | 318 | 
            		//on affiche les informations sur les coordonnees : concaténation + détails 
  | 
            318 | 
            		//on affiche les informations sur les coordonnees : concaténation + détails
  | 
          
          
            | 319 | 
            		if ($table_coordonnees[0] != array()) {
  | 
            319 | 
            		if ($table_coordonnees[0] != array()) {
  | 
          
          
            | 320 | 
            			$this->afficherConcatenationValeur($key.'.coordonnees', $table_coordonnees);
  | 
            320 | 
            			$this->afficherConcatenationValeur($key.'.coordonnees', $table_coordonnees);
  | 
          
          
            | 321 | 
            			if (isset($table_coordonnees[0]['datum'])) {
  | 
            321 | 
            			if (isset($table_coordonnees[0]['datum'])) {
  | 
          
          
            | 322 | 
            				$this->afficherInfosPrecises($key.'.coordonnees.datum', 
  | 
            322 | 
            				$this->afficherInfosPrecises($key.'.coordonnees.datum',
  | 
          
          
            | 323 | 
            					'signification,code,href',$table_coordonnees[0]['datum'],
  | 
            323 | 
            					'signification,code,href',$table_coordonnees[0]['datum'],
  | 
          
          
            | 324 | 
            					$table_coordonnees);
  | 
            324 | 
            					$table_coordonnees);
  | 
          
          
            | 325 | 
            			}
  | 
            325 | 
            			}
  | 
          
          
            | 326 | 
            		}	
  | 
            326 | 
            		}
  | 
          
          
            | 327 | 
            		$table_contact = $this->recupererTableContact($tab); 
  | 
            327 | 
            		$table_contact = $this->recupererTableContact($tab);
  | 
          
          
            | 328 | 
            		//on affiche le premier contact en dehors de la table de détail:
  | 
            328 | 
            		//on affiche le premier contact en dehors de la table de détail:
  | 
          
          
            | 329 | 
            		if ($table_contact[0] != array()) {
  | 
            329 | 
            		if ($table_contact[0] != array()) {
  | 
          
          
            | 330 | 
            			$this->table_retour[$key.'.contact'] = ''; 
  | 
            330 | 
            			$this->table_retour[$key.'.contact'] = '';
  | 
          
          
            | 331 | 
            			foreach ($table_contact as $info => $valeur) {
  | 
            331 | 
            			foreach ($table_contact as $info => $valeur) {
  | 
          
          
            | 332 | 
            				$this->table_retour[$key.'.contact'] .= $valeur['contact.prenom']." ".$valeur['contact.nom'];
  | 
            332 | 
            				$this->table_retour[$key.'.contact'] .= $valeur['contact.prenom']." ".$valeur['contact.nom'];
  | 
          
          
            | 333 | 
            			}
  | 
            333 | 
            			}
  | 
          
          
            | 334 | 
            			//on affiche les détails des autres contacts : 
  | 
            334 | 
            			//on affiche les détails des autres contacts :
  | 
          
          
            | 335 | 
            			$this->afficherTableDetails($key.'.contact', $table_contact); 
  | 
            335 | 
            			$this->afficherTableDetails($key.'.contact', $table_contact);
  | 
          
          
            | 336 | 
            		}	
  | 
            336 | 
            		}
  | 
          
          
            | 337 | 
            	}
  | 
            337 | 
            	}
  | 
          
          
            | 338 | 
            	
  | 
            338 | 
             
  | 
          
          
            | 339 | 
            	
  | 
            339 | 
             
  | 
          
          
            | 340 | 
            	
  | 
            340 | 
             
  | 
          
          
            | 341 | 
            	public function afficherInfosPrecises($champ, $pts, $val, $tab = null) {
  | 
            341 | 
            	public function afficherInfosPrecises($champ, $pts, $val, $tab = null) {
  | 
          
          
            | 342 | 
            		//permet d'afficher les informations précises telles que les .details, .start, .end...
  | 
            342 | 
            		//permet d'afficher les informations précises telles que les .details, .start, .end...
  | 
          
          
            | 343 | 
            		$pts = explode(',', $pts);
  | 
            343 | 
            		$pts = explode(',', $pts);
  | 
          
          
            | 344 | 
            		foreach ($pts as $pt) {
  | 
            344 | 
            		foreach ($pts as $pt) {
  | 
          
          
            | 345 | 
            			switch ($pt) {
  | 
            345 | 
            			switch ($pt) {
  | 
          
          
            | 346 | 
            				case 'start'   		 : 	$this->table_retour[$champ.'.start'] = $tab['start']; 					 break;
  | 
            346 | 
            				case 'start'   		 : 	$this->table_retour[$champ.'.start'] = $tab['start']; 					 break;
  | 
          
          
            | 347 | 
            				case 'end' 			 : 	$this->table_retour[$champ.'.end'] = $tab[' end']; 						 break;
  | 
            347 | 
            				case 'end' 			 : 	$this->table_retour[$champ.'.end'] = $tab[' end']; 						 break;
  | 
          
          
            | 348 | 
            				case 'code' 		 : 	$this->table_retour[$champ.'.code'] = $val; 							 break;
  | 
            348 | 
            				case 'code' 		 : 	$this->table_retour[$champ.'.code'] = $val; 							 break;
  | 
          
          
            | 349 | 
            				case 'href' 		 : 	$this->table_retour[$champ.'.href'] = 
  | 
            349 | 
            				case 'href' 		 : 	$this->table_retour[$champ.'.href'] =
  | 
          
          
            | 350 | 
            										$this->ajouterHrefAutreProjet($champ, '', $val);  				 	 break;
  | 
            350 | 
            										$this->ajouterHrefAutreProjet($champ, '', $val);  				 	 break;
  | 
          
          
            | 351 | 
            				case 'signification' :  $this->table_retour[$champ] = $this->ajouterSignification($champ, $val); break;
  | 
            351 | 
            				case 'signification' :  $this->table_retour[$champ] = $this->ajouterSignification($champ, $val); break;
  | 
          
          
            | 352 | 
            				case 'details' 		 :  if ($champ == 'couverture_spatiale') {
  | 
            352 | 
            				case 'details' 		 :  if ($champ == 'couverture_spatiale') {
  | 
          
          
            | 353 | 
            											$this->afficherCouvertureSpatiale($champ, $tab);
  | 
            353 | 
            											$this->afficherCouvertureSpatiale($champ, $tab);
  | 
          
          
            | 354 | 
            										} else {
  | 
            354 | 
            										} else {
  | 
          
          
            | Line 356... | 
            Line 356... | 
          
          
            | 356 | 
            										}																		 break;
  | 
            356 | 
            										}																		 break;
  | 
          
          
            | 357 | 
            				default 			 :  $this->table_retour[$champ.'.'.$pt] = $tab[$pt]; 						 break;
  | 
            357 | 
            				default 			 :  $this->table_retour[$champ.'.'.$pt] = $tab[$pt]; 						 break;
  | 
          
          
            | 358 | 
            			}
  | 
            358 | 
            			}
  | 
          
          
            | 359 | 
            		}
  | 
            359 | 
            		}
  | 
          
          
            | 360 | 
            	}
  | 
            360 | 
            	}
  | 
          
          
            | 361 | 
            	
  | 
            361 | 
             
  | 
          
          
            | 362 | 
            	
  | 
            362 | 
             
  | 
          
          
            | 363 | 
            	
  | 
            363 | 
             
  | 
          
          
            | 364 | 
            	public function afficherCouvertureSpatiale($key, $tab) {
  | 
            364 | 
            	public function afficherCouvertureSpatiale($key, $tab) {
  | 
          
          
            | 365 | 
            		$res = $this->table_retour;
  | 
            365 | 
            		$res = $this->table_retour;
  | 
          
          
            | 366 | 
            		$this->table_retour = array();
  | 
            366 | 
            		$this->table_retour = array();
  | 
          
          
            | 367 | 
            		foreach ($tab as $iso) {
  | 
            367 | 
            		foreach ($tab as $iso) {
  | 
          
          
            | 368 | 
            			foreach ($iso as $val) {
  | 
            368 | 
            			foreach ($iso as $val) {
  | 
          
          
            | 369 | 
            				$this->afficherInfosPrecises($key, 'signification,code,href',$val); 
  | 
            369 | 
            				$this->afficherInfosPrecises($key, 'signification,code,href',$val);
  | 
          
          
            | 370 | 
            				$res[$key.'.detail'][] = $this->table_retour;
  | 
            370 | 
            				$res[$key.'.detail'][] = $this->table_retour;
  | 
          
          
            | 371 | 
            				$this->table_retour = array();
  | 
            371 | 
            				$this->table_retour = array();
  | 
          
          
            | 372 | 
            			}
  | 
            372 | 
            			}
  | 
          
          
            | 373 | 
            		}
  | 
            373 | 
            		}
  | 
          
          
            | 374 | 
            		$this->table_retour = $res;
  | 
            374 | 
            		$this->table_retour = $res;
  | 
          
          
            | 375 | 
            	}
  | 
            375 | 
            	}
  | 
          
          
            | 376 | 
            	
  | 
            376 | 
             
  | 
          
          
            | 377 | 
            	public function afficherTableDetails($champ, $tab) {
  | 
            377 | 
            	public function afficherTableDetails($champ, $tab) {
  | 
          
          
            | 378 | 
            		$res = $this->table_retour;
  | 
            378 | 
            		$res = $this->table_retour;
  | 
          
          
            | 379 | 
            		$this->table_retour = array();
  | 
            379 | 
            		$this->table_retour = array();
  | 
          
          
            | 380 | 
            		foreach ($tab as $num_entite => $entite) { // $t et $type valent p ou o
  | 
            380 | 
            		foreach ($tab as $num_entite => $entite) { // $t et $type valent p ou o
  | 
          
          
            | 381 | 
            			$t = '';
  | 
            381 | 
            			$t = '';
  | 
          
          
            | 382 | 
            			$type = '.'; 
  | 
            382 | 
            			$type = '.';
  | 
          
          
            | 383 | 
            			foreach ($entite as $key => $infos) {
  | 
            383 | 
            			foreach ($entite as $key => $infos) {
  | 
          
          
            | 384 | 
            				list($type, $info) = explode('.', trim($key));
  | 
            384 | 
            				list($type, $info) = explode('.', trim($key));
  | 
          
          
            | 385 | 
            				if ($type == 'contact') $type = 'p'; 
  | 
            385 | 
            				if ($type == 'contact') $type = 'p';
  | 
          
          
            | 386 | 
            				if ($type != $t) { // cherche et ajoute la signification du type
  | 
            386 | 
            				if ($type != $t) { // cherche et ajoute la signification du type
  | 
          
          
            | 387 | 
            					$this->afficherInfosPrecises('type', 'signification,code,href', trim($type));
  | 
            387 | 
            					$this->afficherInfosPrecises('type', 'signification,code,href', trim($type));
  | 
          
          
            | 388 | 
            					foreach ($this->table_retour as $k => $val) {
  | 
            388 | 
            					foreach ($this->table_retour as $k => $val) {
  | 
          
          
            | 389 | 
            						$res[$champ.'.details'][$num_entite][$type.'.'.$k] = $val;
  | 
            389 | 
            						$res[$champ.'.details'][$num_entite][$type.'.'.$k] = $val;
  | 
          
          
            | 390 | 
            					}
  | 
            390 | 
            					}
  | 
          
          
            | 391 | 
            					$table_retour = array();
  | 
            391 | 
            					$table_retour = array();
  | 
          
          
            | 392 | 
            					$this->table_retour = array(); // rempli par afficherInfosPrecises
  | 
            392 | 
            					$this->table_retour = array(); // rempli par afficherInfosPrecises
  | 
          
          
            | 393 | 
            					$t = $type;
  | 
            393 | 
            					$t = $type;
  | 
          
          
            | 394 | 
            				} 
  | 
            394 | 
            				}
  | 
          
          
            | 395 | 
            				$res[$champ.'.details'][$num_entite][$key] = $infos;
  | 
            395 | 
            				$res[$champ.'.details'][$num_entite][$key] = $infos;
  | 
          
          
            | 396 | 
            			}
  | 
            396 | 
            			}
  | 
          
          
            | 397 | 
            		}
  | 
            397 | 
            		}
  | 
          
          
            | 398 | 
            		$this->table_retour = $res;
  | 
            398 | 
            		$this->table_retour = $res;
  | 
          
          
            | 399 | 
            	}
  | 
            399 | 
            	}
  | 
          
          
            | Line 410... | 
            Line 410... | 
          
          
            | 410 | 
            			$nom = 'nom.fr';
  | 
            410 | 
            			$nom = 'nom.fr';
  | 
          
          
            | 411 | 
            			$res = $signification->$nom;
  | 
            411 | 
            			$res = $signification->$nom;
  | 
          
          
            | 412 | 
            		}
  | 
            412 | 
            		}
  | 
          
          
            | 413 | 
            		return $res ;
  | 
            413 | 
            		return $res ;
  | 
          
          
            | 414 | 
            	}
  | 
            414 | 
            	}
  | 
          
          
            | 415 | 
            	
  | 
            415 | 
             
  | 
          
          
            | Line 416... | 
            Line 416... | 
          
          
            | 416 | 
             
  | 
            416 | 
             
  | 
          
          
            | 417 | 
            	public function recupererTableContact(&$tab) {
  | 
            417 | 
            	public function recupererTableContact(&$tab) {
  | 
          
          
            | 418 | 
            		$res = array();
  | 
            418 | 
            		$res = array();
  | 
          
          
            | 419 | 
            		foreach ($tab[0] as $key => $val) {
  | 
            419 | 
            		foreach ($tab[0] as $key => $val) {
  | 
          
          
            | Line 424... | 
            Line 424... | 
          
          
            | 424 | 
            			}
  | 
            424 | 
            			}
  | 
          
          
            | 425 | 
            		}
  | 
            425 | 
            		}
  | 
          
          
            | 426 | 
            		$resultat[0] = $res;
  | 
            426 | 
            		$resultat[0] = $res;
  | 
          
          
            | 427 | 
            		return $resultat;
  | 
            427 | 
            		return $resultat;
  | 
          
          
            | 428 | 
            	}
  | 
            428 | 
            	}
  | 
          
          
            | 429 | 
            	
  | 
            429 | 
             
  | 
          
          
            | 430 | 
            	
  | 
            430 | 
             
  | 
          
          
            | 431 | 
            	public function recupererTableCoordonnees(&$tab) {
  | 
            431 | 
            	public function recupererTableCoordonnees(&$tab) {
  | 
          
          
            | 432 | 
            		$res = array();
  | 
            432 | 
            		$res = array();
  | 
          
          
            | 433 | 
            		foreach ($tab[0] as $key => $val) {
  | 
            433 | 
            		foreach ($tab[0] as $key => $val) {
  | 
          
          
            | 434 | 
            			if (strrpos($key, 'latitude') !== false || strrpos($key, 'longitude') !== false) {
  | 
            434 | 
            			if (strrpos($key, 'latitude') !== false || strrpos($key, 'longitude') !== false) {
  | 
          
          
            | 435 | 
            				list ($coord, $datum) = explode('.', $key);
  | 
            435 | 
            				list ($coord, $datum) = explode('.', $key);
  | 
          
          
            | Line 438... | 
            Line 438... | 
          
          
            | 438 | 
            			}
  | 
            438 | 
            			}
  | 
          
          
            | 439 | 
            		}
  | 
            439 | 
            		}
  | 
          
          
            | 440 | 
            		$resultat[0] = $res;
  | 
            440 | 
            		$resultat[0] = $res;
  | 
          
          
            | 441 | 
            		return $resultat;
  | 
            441 | 
            		return $resultat;
  | 
          
          
            | 442 | 
            	}
  | 
            442 | 
            	}
  | 
          
          
            | 443 | 
            	
  | 
            443 | 
             
  | 
          
          
            | 444 | 
            //-------------------------------------Fonction de formatage des resultats de /metaDonnees/#champs+champs----------------
  | 
            444 | 
            //-------------------------------------Fonction de formatage des resultats de /metaDonnees/#champs+champs----------------
  | 
          
          
            | 445 | 
            	
  | 
            445 | 
             
  | 
          
          
            | 446 | 
            	public function formaterMetaDonneesChamp($resultat) {
  | 
            446 | 
            	public function formaterMetaDonneesChamp($resultat) {
  | 
          
          
            | 447 | 
            		$this->recupererNomChamp(Config::get('bdd_table_meta'));
  | 
            447 | 
            		$this->recupererNomChamp(Config::get('bdd_table_meta'));
  | 
          
          
            | 448 | 
            		//On récupère dans un premier temps toutes les données existantes puis on pioche les champs recherchés
  | 
            448 | 
            		//On récupère dans un premier temps toutes les données existantes puis on pioche les champs recherchés
  | 
          
          
            | 449 | 
            		$table_Meta = $this->formaterMetaDonnees($resultat);
  | 
            449 | 
            		$table_Meta = $this->formaterMetaDonnees($resultat);
  | 
          
          
            | 450 | 
            		foreach ($table_Meta as $version) {
  | 
            450 | 
            		foreach ($table_Meta as $version) {
  | 
          
          
            | 451 | 
            			//on affiche les informations par defaut : la version, la langue_meta et le guid :
  | 
            451 | 
            			//on affiche les informations par defaut : la version, la langue_meta et le guid :
  | 
          
          
            | 452 | 
            			$this->afficherVersionLangueMetaGuid($version);
  | 
            452 | 
            			$this->afficherVersionLangueMetaGuid($version);
  | 
          
          
            | 453 | 
            			$tab_ress = explode(' ', $this->table_ressources[0]);
  | 
            453 | 
            			$tab_ress = explode(' ', $this->table_ressources[0]);
  | 
          
          
            | 454 | 
            			foreach ($tab_ress as $champ) {//on recupere le radical pour comparaison avec les nom des champs de la bdd : 
  | 
            454 | 
            			foreach ($tab_ress as $champ) {//on recupere le radical pour comparaison avec les nom des champs de la bdd :
  | 
          
          
            | 455 | 
            				$this->afficherChampRecherche($champ, $version);
  | 
            455 | 
            				$this->afficherChampRecherche($champ, $version);
  | 
          
          
            | 456 | 
            			}
  | 
            456 | 
            			}
  | 
          
          
            | 457 | 
            			$table[] = $this->table_retour;
  | 
            457 | 
            			$table[] = $this->table_retour;
  | 
          
          
            | 458 | 
            			$this->table_retour = array();
  | 
            458 | 
            			$this->table_retour = array();
  | 
          
          
            | 459 | 
            		}
  | 
            459 | 
            		}
  | 
          
          
            | 460 | 
            		return $table;
  | 
            460 | 
            		return $table;
  | 
          
          
            | 461 | 
            	}
  | 
            461 | 
            	}
  | 
          
          
            | 462 | 
            	
  | 
            462 | 
             
  | 
          
          
            | 463 | 
            	public function afficherChampRecherche(&$champ, &$version) {
  | 
            463 | 
            	public function afficherChampRecherche(&$champ, &$version) {
  | 
          
          
            | 464 | 
            		preg_match('/^([^.]+)(?:[.][^.]+)?$/', $champ, $match);
  | 
            464 | 
            		preg_match('/^([^.]+)(?:[.][^.]+)?$/', $champ, $match);
  | 
          
          
            | 465 | 
            		if (preg_match('/(.+)[.][*]$/', $champ, $match_2)) {
  | 
            465 | 
            		if (preg_match('/(.+)[.][*]$/', $champ, $match_2)) {
  | 
          
          
            | 466 | 
            			$this->afficherPointEtoile($match_2, $version, $champ);
  | 
            466 | 
            			$this->afficherPointEtoile($match_2, $version, $champ);
  | 
          
          
            | 467 | 
            		} elseif (array_key_exists($champ, $version)) {
  | 
            467 | 
            		} elseif (array_key_exists($champ, $version)) {
  | 
          
          
            | 468 | 
            			$this->table_retour[$champ] = $version[$champ];
  | 
            468 | 
            			$this->table_retour[$champ] = $version[$champ];
  | 
          
          
            | 469 | 
            		} elseif (in_array($match[1], $this->champs_table)) { 
  | 
            469 | 
            		} elseif (in_array($match[1], $this->champs_table)) {
  | 
          
          
            | 470 | 
            			//si le champ est vide dans cette version on retourne null (comparaison avec les champs existants)
  | 
            470 | 
            			//si le champ est vide dans cette version on retourne null (comparaison avec les champs existants)
  | 
          
          
            | 471 | 
            			$this->table_retour[$champ] = null;			
  | 
            471 | 
            			$this->table_retour[$champ] = null;
  | 
          
          
            | 472 | 
            		} else {
  | 
            472 | 
            		} else {
  | 
          
          
            | 473 | 
            			$champs = implode('</li><li>', array_keys($version));
  | 
            473 | 
            			$champs = implode('</li><li>', array_keys($version));
  | 
          
          
            | 474 | 
            			$e = 'Erreur dans votre requête : </br> Le champ "'.$champ.'" n\'existe pas'.
  | 
            474 | 
            			$e = 'Erreur dans votre requête : </br> Le champ "'.$champ.'" n\'existe pas'.
  | 
          
          
            | 475 | 
            				'. Les champs disponibles sont : <li>'.$champs.'</li>';
  | 
            475 | 
            				'. Les champs disponibles sont : <li>'.$champs.'</li>';
  | 
          
          
            | 476 | 
            			$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
  | 
            476 | 
            			$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
  | 
          
          
            | 477 | 
            		}
  | 
            477 | 
            		}
  | 
          
          
            | 478 | 
            	}
  | 
            478 | 
            	}
  | 
          
          
            | 479 | 
            	
  | 
            479 | 
             
  | 
          
          
            | 480 | 
            	public function afficherPointEtoile($match, $version, $ressource) {
  | 
            480 | 
            	public function afficherPointEtoile($match, $version, $ressource) {
  | 
          
          
            | 481 | 
            		$existe = false;
  | 
            481 | 
            		$existe = false;
  | 
          
          
            | 482 | 
            		foreach ($version as $key => $valeur) {
  | 
            482 | 
            		foreach ($version as $key => $valeur) {
  | 
          
          
            | 483 | 
            			if (strrpos($key, $match[1].'.') !== false) {
  | 
            483 | 
            			if (strrpos($key, $match[1].'.') !== false) {
  | 
          
          
            | 484 | 
            				$this->table_retour[$key] = $valeur;
  | 
            484 | 
            				$this->table_retour[$key] = $valeur;
  | 
          
          
            | 485 | 
            				$existe = true;
  | 
            485 | 
            				$existe = true;
  | 
          
          
            | 486 | 
            			}
  | 
            486 | 
            			}
  | 
          
          
            | 487 | 
            		} 
  | 
            487 | 
            		}
  | 
          
          
            | 488 | 
            		if (!$existe) {
  | 
            488 | 
            		if (!$existe) {
  | 
          
          
            | 489 | 
            			$champs = implode('</li><li>', array_keys($version));
  | 
            489 | 
            			$champs = implode('</li><li>', array_keys($version));
  | 
          
          
            | 490 | 
            			$e = 'Erreur dans votre requête : </br> Le champ " '.$ressource.' " n\'existe pas dans la version '
  | 
            490 | 
            			$e = 'Erreur dans votre requête : </br> Le champ " '.$ressource.' " n\'existe pas dans la version '
  | 
          
          
            | 491 | 
            				.$version['version'].'. Les champs disponibles sont : <li>'.$champs.'</li>';
  | 
            491 | 
            				.$version['version'].'. Les champs disponibles sont : <li>'.$champs.'</li>';
  | 
          
          
            | 492 | 
            			$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
  | 
            492 | 
            			$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
  | 
          
          
            | 493 | 
            		}
  | 
            493 | 
            		}
  | 
          
          
            | 494 | 
            	}
  | 
            494 | 
            	}
  | 
          
          
            | 495 | 
            	
  | 
            495 | 
             
  | 
          
          
            | 496 | 
            	public function afficherVersionLangueMetaGuid(&$version) {
  | 
            496 | 
            	public function afficherVersionLangueMetaGuid(&$version) {
  | 
          
          
            | 497 | 
            		$this->table_retour['version'] = $version['version']; 
  | 
            497 | 
            		$this->table_retour['version'] = $version['version'];
  | 
          
          
            | 498 | 
            		$this->table_retour['langue_meta'] = $version['langue_meta'];
  | 
            498 | 
            		$this->table_retour['langue_meta'] = $version['langue_meta'];
  | 
          
          
            | 499 | 
            		$this->table_retour['guid'] = $version['guid'];	
  | 
            499 | 
            		$this->table_retour['guid'] = $version['guid'];
  | 
          
          
            | 500 | 
            	}
  | 
            500 | 
            	}
  |