Commit 3071da20 authored by ndurand's avatar ndurand
Browse files

correction https et json

parent 7eee9b31
......@@ -305,13 +305,14 @@ class LayerAddToMapController extends BaseController {
$ticket = \Alk\Common\CasBundle\Security\Authentication\Provider\CasProvider::getPGT($carmenURL);
$jsonResp = $this->curl($carmenURL, 'GET', array('ticket'=>$ticket), array());
$jsonObj = json_decode($jsonResp);
$jsonObj = json_decode($jsonResp, true);
$edit_map_id = null;
$mapModel = false;
$mapFile = $map['map_file'];
if($jsonObj && $jsonObj->success && $jsonObj->map && $jsonObj->map->mapId ){
$edit_map_id = $jsonObj->map->mapId;
$mapModel = $jsonObj->map->mapModel;
if($jsonObj && isset($jsonObj['success']) && $jsonObj['success'] && isset($jsonObj['map']) && isset($jsonObj['map']['mapId']) ){
$edit_map_id = $jsonObj['map']['mapId'];
$mapModel = $jsonObj['map']['mapModel'];
}
if ( $edit_map_id ){
$layers = $CATALOGUE->executeQuery("select xpath('//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString/text()'::text, ".
......@@ -409,9 +410,9 @@ class LayerAddToMapController extends BaseController {
$ticket = \Alk\Common\CasBundle\Security\Authentication\Provider\CasProvider::getPGT($carmenEditMapAction);
$jsonResp = $this->curl($carmenEditMapAction, 'GET', array('ticket'=>$ticket), array());
$jsonObj = json_decode($jsonResp);
if($jsonObj && $jsonObj->success && $jsonObj->map && $jsonObj->map->mapId ){
$map_id = $jsonObj->map->mapId;
$jsonObj = json_decode($jsonResp, true);
if($jsonObj && isset($jsonObj['success']) && $jsonObj['success'] && isset($jsonObj['map']) && isset($jsonObj['map']['mapId']) ){
$map_id = $jsonObj['map']['mapId'];
//2 add layers
foreach ($tabLayers as $layer)
......@@ -439,12 +440,13 @@ class LayerAddToMapController extends BaseController {
$ticket = \Alk\Common\CasBundle\Security\Authentication\Provider\CasProvider::getPGT($carmenSaveMapAction);
$jsonResp = $this->curl($carmenSaveMapAction, 'POST', array('ticket'=>$ticket), $posts);
$jsonObj = json_decode($jsonResp);
if($jsonObj && $jsonObj->success && $jsonObj->map){
$jsonObj = json_decode($jsonResp, true);
if($jsonObj && isset($jsonObj['success']) && $jsonObj['success'] && isset($jsonObj['map'])){
//redirect to map
return $this->redirect($acces_adress_admin."/edit_map/".$mapUuid);
}
}else{
// var_dump($jsonObj);
throw new \Exception("Echec lors du chargement du modèle");
}
......@@ -871,7 +873,9 @@ class LayerAddToMapController extends BaseController {
foreach($request->query->all() as $key => $value){
$strHtml .="<input type='hidden' name=\"".$key."\" value=\"".$value."\">";
}
$strHtml .="<input type=\"button\" value=\"Parcourir les cartes modèles...\" onclick=\"LoadModelMaps('".$request->getSchemeAndHttpHost().$this->generateUrl('catalogue_geosource_tSAjoutDeCarte_MapModelList')."')\">
$hostUrl = $this->getRequestProtocol()."://".$request->getHttpHost();
$strHtml .="<input type=\"button\" value=\"Parcourir les cartes modèles...\" onclick=\"LoadModelMaps('".$hostUrl.$this->generateUrl('catalogue_geosource_tSAjoutDeCarte_MapModelList')."')\">
</form>
</div>
</body>
......@@ -880,6 +884,18 @@ class LayerAddToMapController extends BaseController {
return new Response($strHtml);
}
/**
* Pour savoir si l'url du serveur est http ou https
* @return string http | https
*/
function getRequestProtocol() {
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
return $_SERVER['HTTP_X_FORWARDED_PROTO'];
} else {
return !empty($_SERVER['HTTPS']) ? "https" : "http";
}
}
/**
* call Carmen service adding layer to model map
* @param integer $map_id map identifier
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment