[Mapbender-commits] r9094 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Oct 15 02:32:56 PDT 2014
Author: armin11
Date: 2014-10-15 02:32:55 -0700 (Wed, 15 Oct 2014)
New Revision: 9094
Modified:
trunk/mapbender/http/classes/class_iso19139.php
Log:
Bugfix for php 5.4 handling of json_decode and json_encode was changed
Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php 2014-10-15 09:32:17 UTC (rev 9093)
+++ trunk/mapbender/http/classes/class_iso19139.php 2014-10-15 09:32:55 UTC (rev 9094)
@@ -280,10 +280,13 @@
$e = new mb_exception("class_iso19139.php: customcat: ".$category);
}*/
$this->downloadLinks = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource[gmd:function/gmd:CI_OnLineFunctionCode/@codeListValue="download"]/gmd:linkage/gmd:URL');
+ //$e = new mb_exception("class_iso19139.php: count of downloadlinks: ".count($this->downloadLinks));
//$this->downloadLinks = array_values($this->downloadLinks);
//$dump = var_export($this->downloadLinks, true);
//$e = new mb_exception("type of this->downloadLinks: ".gettype($this->downloadLinks)." - count: ".count($this->downloadLinks)."- obj: - ".$dump);
- $this->downloadLinks = (array)$this->downloadLinks[0];
+ //$this->downloadLinks = (array)$this->downloadLinks[0];
+ //$e = new mb_exception("class_iso19139.php: count of downloadlinks: ".count($this->downloadLinks));
+ //$e = new mb_exception("class_iso19139.php: downloadlinks[0]: ".$this->downloadLinks[0]);
/*<gmd:extent><gmd:EX_Extent><gmd:geographicElement><gmd:EX_GeographicBoundingBox><gmd:westBoundLongitude><gco:Decimal>5</gco:Decimal></gmd:westBoundLongitude><gmd:eastBoundLongitude><gco:Decimal>10</gco:Decimal></gmd:eastBoundLongitude><gmd:southBoundLatitude><gco:Decimal>48</gco:Decimal></gmd:southBoundLatitude><gmd:northBoundLatitude><gco:Decimal>52</gco:Decimal></gmd:northBoundLatitude></gmd:EX_GeographicBoundingBox></gmd:geographicElement></gmd:EX_Extent></gmd:extent>*/
//esri
/*<gmd:extent><gmd:EX_Extent><gmd:geographicElement><gmd:EX_GeographicBoundingBox><gmd:westBoundLongitude><gco:Decimal>11.1414</gco:Decimal></gmd:westBoundLongitude><gmd:eastBoundLongitude><gco:Decimal>11.7284</gco:Decimal></gmd:eastBoundLongitude><gmd:southBoundLatitude><gco:Decimal>58.8838</gco:Decimal></gmd:southBoundLatitude><gmd:northBoundLatitude><gco:Decimal>59.2562</gco:Decimal></gmd:northBoundLatitude></gmd:EX_GeographicBoundingBox></gmd:geographicElement><gmd:temporalElement><gmd:EX_TemporalExtent><gmd:extent><gml:TimePeriod gml:id="idNummer1"><gml:beginPosition>1999-05-05</gml:beginPosition><gml:endPosition>2012-04-04</gml:endPosition></gml:TimePeriod></gmd:extent></gmd:EX_TemporalExtent></gmd:temporalElement></gmd:EX_Extent></gmd:extent>*/
@@ -1416,7 +1419,7 @@
//$e = new mb_exception("class_Iso19139.php: sql for keywords: ".$sql);
$res = db_query($sql);
if (!$res) {
- $e = new mb_exception("class_Iso19139:"._mb("Cannot insert new keywords into keyword table!"));
+ $e = new mb_notice("class_Iso19139:"._mb("Cannot insert new keywords into keyword table - will insert only new relations!"));
} else {
//insert relations for keywords
$sqlInsert = "";
@@ -1597,14 +1600,33 @@
}
private function jsonEncodeDownloadLinks($dlArray) {
- $dummy->downloadLinks = $dlArray;
- return json_encode($dummy);
+ $dummy = new stdClass();
+ //TODO - check array conversion of json_encode under php > 5.4
+ //$dummy->downloadLinks = (string)$dlArray[0];
+ //return json_encode($dummy, JSON_FORCE_OBJECT);
+ $json = '{"downloadLinks":[';
+ $i = 0;
+ //TODO solve the php 5.4 json_encode array problem
+ foreach ($dlArray as $link) {
+ $json .= '{"'.$i.'":'.json_encode((string)$link).'},';
+ $i++;
+ }
+ $json = rtrim($json,",");
+ $json .= "]}";
+ return $json;
}
//TODO - maybe we will encode more things than only the url ;-)
private function jsonDecodeDownloadLinks($dlJson) {
- $dummy = json_decode($dlJson);
- $dummy = $dummy->downloadLinks;
- return $dummy;
+ $downloadLinks = json_decode($dlJson);
+ //new for php 5.4
+ $dlArray = array();
+ $i = 0;
+ foreach ($downloadLinks->downloadLinks as $downloadLink) {
+ $dlArray[] = urldecode($downloadLink->{$i});
+ $i++;
+ }
+ //$dummy = $dummy->downloadLinks;
+ return $dlArray;
}
public function updateMetadataById($metadataId) {
@@ -1616,7 +1638,8 @@
$sql .= "abstract = $9, searchtext = $10, type = $11, tmp_reference_1 = $12, tmp_reference_2 = $13, export2csw = $14, datasetid = $15, ";
$sql .= "datasetid_codespace = $16, randomid = $17, harvestresult = $20, harvestexception = $21, lineage = $22, inspire_top_consistence = $23, ";
$sql .= "spatial_res_type = $24, spatial_res_value = $25, update_frequency = $26, format = $27, inspire_charset = $28, ref_system = $29, the_geom = $30, datalinks = $31, inspire_whole_area = $32, inspire_actual_coverage = $33, inspire_download = $34, bounding_geom = $35 WHERE metadata_id = $19";
-
+ //$e= new mb_exception("class_iso19139.php: downloadLinks json".$this->jsonEncodeDownloadLinks($this->downloadLinks));
+ //$e= new mb_exception("class_iso19139.php: downloadLinks[0]".$this->downloadLinks[0]);
$v = array(
$this->href,
$this->format,
More information about the Mapbender_commits
mailing list