Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 1475 Rev 1476
Line 22... Line 22...
22
 
22
 
23
	const DS = DIRECTORY_SEPARATOR;
23
	const DS = DIRECTORY_SEPARATOR;
24
	const PROJET_DEFAUT = 'defaut';
24
	const PROJET_DEFAUT = 'defaut';
25
	const WS_SAISIE = "CelWidgetSaisie";
25
	const WS_SAISIE = "CelWidgetSaisie";
26
	const WS_NOM = "noms";
-
 
27
	const NS_PROJET = "bdtfx";
26
	const WS_NOM = "noms";
28
	const NS_PROJET_VERSION = "1.01";
27
	private $NS_PROJET_VERSION = "1.01";
-
 
28
	const EFLORE_API_VERSION = "0.1";
Line -... Line 29...
-
 
29
	private $NS_PROJET = "bdtfx";
29
	const EFLORE_API_VERSION = "0.1";
30
 
30
 
31
	private $projetsVersions = array();
Line 31... Line 32...
31
	private $projet = null;
32
	private $projet = null;
32
	private $configProjet = null;
33
	private $configProjet = null;
Line 38... Line 39...
38
		$retour = null;
39
		$retour = null;
39
		extract($this->parametres);
40
		extract($this->parametres);
Line 40... Line 41...
40
 
41
 
41
		$this->projet = isset($projet) ? $projet : self::PROJET_DEFAUT;
42
		$this->projet = isset($projet) ? $projet : self::PROJET_DEFAUT;
-
 
43
		$this->chargerConfigProjet();
Line 42... Line 44...
42
		$this->chargerConfigProjet();
44
		$this->chargerProjetsVersion();
43
 
45
 
44
		$service = isset($service) ? $service : 'widget';
46
		$service = isset($service) ? $service : 'widget';
45
		$methode = $this->traiterNomMethodeExecuter($service);
47
		$methode = $this->traiterNomMethodeExecuter($service);
Line 78... Line 80...
78
			}
80
			}
79
		} else {
81
		} else {
80
			$this->debug[] = "Le fichier ini '$fichier_config' du projet n'existe pas.";
82
			$this->debug[] = "Le fichier ini '$fichier_config' du projet n'existe pas.";
81
		}
83
		}
82
	}
84
	}
-
 
85
	
-
 
86
	private function chargerProjetsVersion() {
-
 
87
		foreach ($this->configProjet as $config => $valeur) {
-
 
88
			if(strstr($config,'.version')) {
-
 
89
				$this->projetsVersions[str_replace('.version', '', $config)] = $valeur;
-
 
90
			}
-
 
91
		}
-
 
92
	}
Line 83... Line 93...
83
 
93
 
-
 
94
	public function executerWidget() {
-
 
95
		$referentiel_impose = false;
-
 
96
		if(isset($_GET['referentiel']) && $_GET['referentiel'] != '') {
-
 
97
			$this->NS_PROJET = isset($_GET['referentiel']) && $_GET['referentiel'] != '' ? $_GET['referentiel'] : $this->NS_PROJET;
-
 
98
			$this->NS_PROJET_VERSION = $this->projetsVersions[$this->NS_PROJET];
-
 
99
			$referentiel_impose = true;
-
 
100
		}
84
	public function executerWidget() {
101
		
85
		$widget['squelette'] = $this->projet;
102
		$widget['squelette'] = $this->projet;
86
		$widget['donnees'] = array();
103
		$widget['donnees'] = array();
87
		$widget['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
104
		$widget['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
Line 88... Line 105...
88
		$widget['donnees']['url_ws_saisie'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_SAISIE);
105
		$widget['donnees']['url_ws_saisie'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_SAISIE);
89
 
106
 
90
		// cas du projet par défaut ou bien d'un projet n'ayant pas de squelette spécifique
107
		// cas du projet par défaut ou bien d'un projet n'ayant pas de squelette spécifique
91
		if ($this->projet == 'defaut' || !$this->projetASquelette()) {
108
		if ($this->projet == 'defaut' || !$this->projetASquelette()) {
-
 
109
			$urlWsNsTpl = $this->config['chemins']['baseURLServicesEfloreTpl'];
92
			$urlWsNsTpl = $this->config['chemins']['baseURLServicesEfloreTpl'];
110
			$urlWsNs = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, $this->NS_PROJET, self::WS_NOM);
-
 
111
			$urlWsNsSansRef = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, '{referentiel}', self::WS_NOM);
93
			$urlWsNs = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, self::NS_PROJET, self::WS_NOM);
112
			$widget['donnees']['url_ws_autocompletion_ns'] = $urlWsNs;
-
 
113
			$widget['donnees']['url_ws_autocompletion_ns_tpl'] = $urlWsNsSansRef;
94
			$widget['donnees']['url_ws_autocompletion_ns'] = $urlWsNs;
114
			$widget['donnees']['ns_referentiel'] = $this->NS_PROJET.':'.$this->NS_PROJET_VERSION;
-
 
115
			$widget['donnees']['ns_projet'] = $this->NS_PROJET;
-
 
116
			$widget['donnees']['ns_version'] = $this->NS_PROJET_VERSION;
95
			$widget['donnees']['ns_referentiel'] = self::NS_PROJET.':'.self::NS_PROJET_VERSION;
117
			$widget['donnees']['referentiel_impose'] = $referentiel_impose;
96
			$widget['donnees']['ns_version'] = self::NS_PROJET_VERSION;
118
			$widget['donnees']['projets_versions'] = $this->projetsVersions;
97
			if(self::especeEstImposee()) {
119
			if(self::especeEstImposee()) {
98
				$nom = self::executerChargementInfosTaxon($_GET['num_nom']);
120
				$nom = self::executerChargementInfosTaxon($_GET['num_nom']);
99
				$widget['donnees']['espece_imposee'] = true;
121
				$widget['donnees']['espece_imposee'] = true;
Line 178... Line 200...
178
	private function especeEstImposee() {
200
	private function especeEstImposee() {
179
		return isset($_GET['num_nom']) && $_GET['num_nom'] != '';
201
		return isset($_GET['num_nom']) && $_GET['num_nom'] != '';
180
	}
202
	}
Line 181... Line 203...
181
	
203
	
182
	private function executerChargementInfosTaxon($num_nom) {
204
	private function executerChargementInfosTaxon($num_nom) {
183
		$url_service_infos = sprintf($this->config['chemins']['infosTaxonUrl'], $num_nom);
205
		$url_service_infos = sprintf($this->config['chemins']['infosTaxonUrl'], $this->NS_PROJET, $num_nom);
184
		$infos = json_decode(file_get_contents($url_service_infos));
206
		$infos = json_decode(file_get_contents($url_service_infos));
185
		$resultat = array();
207
		$resultat = array();
186
		if(isset($infos) && !empty($infos)) {
208
		if(isset($infos) && !empty($infos)) {
187
			$infos = (array)$infos;
209
			$infos = (array)$infos;