[Mapbender-commits] r9063 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Sep 10 04:01:22 PDT 2014
Author: armin11
Date: 2014-09-10 04:01:22 -0700 (Wed, 10 Sep 2014)
New Revision: 9063
Modified:
trunk/mapbender/http/classes/class_administration.php
trunk/mapbender/http/classes/class_map.php
trunk/mapbender/http/classes/class_wmc.php
trunk/mapbender/http/classes/class_wmcToXml.php
trunk/mapbender/http/classes/class_wms.php
Log:
new possibility to handle metadataurl and dataurl elements in wms and wmc
Modified: trunk/mapbender/http/classes/class_administration.php
===================================================================
--- trunk/mapbender/http/classes/class_administration.php 2014-09-08 15:34:59 UTC (rev 9062)
+++ trunk/mapbender/http/classes/class_administration.php 2014-09-10 11:01:22 UTC (rev 9063)
@@ -1483,6 +1483,32 @@
}
}
+
+ function getInspireDownloadOptionsForLayers($layerIdArray) {
+ $v = array();
+ $t = array();
+ $sql = "SELECT layer_id, f_get_download_options_for_layer(layer_id) as options from layer where layer_id in(";
+ $c = 1;
+ for($i=0; $i<count($layerIdArray); $i++){
+ if($i>0){ $sql .= ",";}
+ $sql .= "$".$c;
+ $c++;
+ array_push($v, $layerIdArray[$i]);
+ array_push($t, 'i');
+ }
+ $sql .= ");";
+ $res = db_prep_query($sql,$v,$t);
+ if($res){
+ while($row = db_fetch_array($res)){
+ $downloadOptions[$row['layer_id']] = $row['options'];
+ }
+ return $downloadOptions;
+ }
+ else{
+ return false;
+ }
+ }
+
// deprecated! use User->isWmsAccessible
function getWmsPermission($wms_id, $user_id) {
$array_guis = $this->getGuisByPermission($user_id,true);
Modified: trunk/mapbender/http/classes/class_map.php
===================================================================
--- trunk/mapbender/http/classes/class_map.php 2014-09-08 15:34:59 UTC (rev 9062)
+++ trunk/mapbender/http/classes/class_map.php 2014-09-10 11:01:22 UTC (rev 9063)
@@ -520,6 +520,7 @@
for ($i=0; $i < count($jsMapObject->wms); $i++){
$currentWms = $jsMapObject->wms[$i];
+ $e = new mb_notice("class_map.php: json map object: ".json_encode($jsMapObject));
$wms = new wms();
//
@@ -571,12 +572,12 @@
$newLayer->layer_uid = $currentLayer->layer_uid;
$newLayer->layer_name = $currentLayer->layer_name;
$newLayer->layer_title = $currentLayer->layer_title;
- $newLayer->layer_dataurl_href = $currentLayer->layer_dataurl_href;
+ $newLayer->layer_dataurl[0]->href = $currentLayer->layer_dataurl;
$newLayer->layer_pos = $currentLayer->layer_pos;
$newLayer->layer_queryable = $currentLayer->layer_queryable;
$newLayer->layer_minscale = $currentLayer->layer_minscale;
$newLayer->layer_maxscale = $currentLayer->layer_maxscale;
- $newLayer->layer_metadataurl = $currentLayer->metadataurl;
+ $newLayer->layer_metadataurl[0]->href = $currentLayer->layer_metadataurl;
$newLayer->gui_layer_wms_id = $currentLayer->gui_layer_wms_id;
// $newLayer->gui_layer_wms_id = $wms->objLayer[0]->layer_uid;
$newLayer->gui_layer_status = $currentLayer->gui_layer_status;
Modified: trunk/mapbender/http/classes/class_wmc.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc.php 2014-09-08 15:34:59 UTC (rev 9062)
+++ trunk/mapbender/http/classes/class_wmc.php 2014-09-10 11:01:22 UTC (rev 9063)
@@ -1432,8 +1432,8 @@
// is currently parsed.
//
$extension = false; $general = false; $layerlist = false;
- $layer = false; $formatlist = false; $dataurl = false;
- $metadataurl = false; $stylelist = false;
+ $layer = false; $formatlist = false; $layer_dataurl = false;
+ $layer_metadataurl = false; $stylelist = false;
//
// reset WMC data
@@ -1659,6 +1659,8 @@
}
$currentLayer["format"] = array();
$currentLayer["style"] = array();
+ //$currentLayer["layer_metadataurl"] = array();
+ //$currentLayer["layer_dataurl"] = array();
$layer = true;
}
if ($layer) {
@@ -1688,20 +1690,20 @@
$formatlist = false;
}
}
- elseif ($metadataurl) {
+ elseif ($layer_metadataurl) {
if ($tag == "ONLINERESOURCE") {
- $currentLayer["metadataurl"] = $attributes["xlink:href"];
+ $currentLayer["layer_metadataurl"] = $attributes["xlink:href"];
}
if ($tag == "METADATAURL" && $type == "close") {
- $metadataurl = false;
+ $layer_metadataurl = false;
}
}
- elseif ($dataurl) {
+ elseif ($layer_dataurl) {
if ($tag == "ONLINERESOURCE") {
- $currentLayer["dataurl"] = $attributes["xlink:href"];
+ $currentLayer["layer_dataurl"] = $attributes["xlink:href"];
}
if ($tag == "DATAURL" && $type == "close") {
- $dataurl = false;
+ $layer_dataurl = false;
}
}
elseif ($stylelist) {
@@ -1811,10 +1813,10 @@
$extension = true;
}
if ($tag == "METADATAURL" && $type == "open") {
- $metadataurl = true;
+ $layer_metadataurl = true;
}
if ($tag == "DATAURL" && $type == "open") {
- $dataurl = true;
+ $layer_dataurl = true;
}
if ($tag == "FORMATLIST" && $type == "open") {
$formatlist = true;
Modified: trunk/mapbender/http/classes/class_wmcToXml.php
===================================================================
--- trunk/mapbender/http/classes/class_wmcToXml.php 2014-09-08 15:34:59 UTC (rev 9062)
+++ trunk/mapbender/http/classes/class_wmcToXml.php 2014-09-10 11:01:22 UTC (rev 9063)
@@ -313,14 +313,11 @@
// Data URL
if ($currentLayer->layer_dataurl[0]->href){
- $e = new mb_exception("class_wmcToXml: dataurl given: ".$currentLayer->layer_dataurl[0]->href);
$e_layer_data_url = $this->doc->createElement("DataURL");
-
$e_layer_data_url_or = $this->doc->createElement("OnlineResource");
$e_layer_data_url_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
$e_layer_data_url_or->setAttribute("xlink:type", "simple");
$e_layer_data_url_or->setAttribute("xlink:href", $currentLayer->layer_dataurl[0]->href);
-
$e_layer_data_url->appendChild($e_layer_data_url_or);
$e_layer->appendChild($e_layer_data_url);
}
@@ -328,7 +325,6 @@
// Metadata URL
if ($currentLayer->layer_metadataurl[0]->href){
$e_layer_metadata_url = $this->doc->createElement("MetadataURL");
-
// Metadata URL online resource
$e_layer_metadata_url_or = $this->doc->createElement("OnlineResource");
$e_layer_metadata_url_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php 2014-09-08 15:34:59 UTC (rev 9062)
+++ trunk/mapbender/http/classes/class_wms.php 2014-09-10 11:01:22 UTC (rev 9063)
@@ -1375,13 +1375,23 @@
$newLayer->layer_name = $currentLayer["name"];
$newLayer->layer_title = $currentLayer["title"];
$newLayer->gui_layer_title = $currentLayer["title"];
- $newLayer->layer_dataurl[0]->href = $currentLayer["dataurl"];
- $newLayer->gui_layer_dataurl_href = $currentLayer["dataurl"];
+ //if layer is built from wmc, there will only be a string given for each dataurl/metadataurl
+ if (is_string($currentLayer["layer_dataurl"])) {
+ $newLayer->layer_dataurl[0]->href = $currentLayer["layer_dataurl"];
+ } else {
+ $newLayer->layer_dataurl = $currentLayer["layer_dataurl"];
+ }
+ if (is_string($currentLayer["layer_metadataurl"])) {
+ $newLayer->layer_metadataurl[0]->href = $currentLayer["layer_metadataurl"];
+ } else {
+ $newLayer->layer_metadataurl = $currentLayer["layer_metadataurl"];
+ }
+ //$newLayer->gui_layer_dataurl_href = $currentLayer["dataurl"];
$newLayer->layer_pos = $currentLayer["extension"]["LAYER_POS"];
$newLayer->layer_queryable = $currentLayer["queryable"];
$newLayer->layer_minscale = $currentLayer["extension"]["MINSCALE"];
$newLayer->layer_maxscale = $currentLayer["extension"]["MAXSCALE"];
- $newLayer->layer_metadataurl[0]->href = $currentLayer["metadataurl"];
+// $newLayer->layer_metadataurl[0]->href = $currentLayer["layer_metadataurl"];
// $newLayer->layer_searchable = $currentLayer["searchable"];
$newLayer->gui_layer_wms_id = $currentLayer["extension"]["WMS_ID"];
$newLayer->gui_layer_status = $currentLayer["extension"]["GUI_STATUS"];
@@ -1536,8 +1546,8 @@
$this->objLayer[$i]->layer_minscale . "','".
$this->objLayer[$i]->layer_maxscale ."','".
$this->objLayer[$i]->layer_metadataurl[0]->href ."','".
-// will be added later, not needed now TODO check if more than one metadataUrl is usefull here
-// $this->objLayer[$i]->layer_searchable ."','".
+ // will be added later, not needed now TODO check if more than one metadataUrl is usefull here
+ // $this->objLayer[$i]->layer_searchable ."','".
$this->objLayer[$i]->gui_layer_wms_id ."','".
$this->objLayer[$i]->gui_layer_status ."','".
$this->objLayer[$i]->gui_layer_style ."','".
@@ -3314,7 +3324,7 @@
while($row = db_fetch_array($res)){
$layer_id = $row["fkey_layer_id"];
- $sql = "Select * from layer where layer_id = $1";
+ $sql = "SELECT *, f_get_download_options_for_layer(layer_id) as downloadoptions FROM layer WHERE layer_id = $1";
$v = array($layer_id);
$t = array('i');
$res_layer = db_prep_query($sql,$v,$t);
@@ -3325,10 +3335,8 @@
$this->objLayer[$layer_cnt]->layer_uid = $layer_id;
$this->objLayer[$layer_cnt]->layer_name = administration::convertIncomingString($row2["layer_name"]);
$this->objLayer[$layer_cnt]->layer_title = administration::convertIncomingString($row2["layer_title"]);
- //$this->objLayer[$layer_cnt]->layer_dataurl[0]->href =$row2["layer_dataurl"];
//load all dataUrl elements from datalink!
$sql = "SELECT datalink_id, datalink_url, datalink_format FROM datalink INNER JOIN (SELECT * from ows_relation_data WHERE fkey_layer_id = $1) as relation ON datalink.datalink_id = relation.fkey_datalink_id AND datalink.datalink_origin = 'capabilities'";
- $e = new mb_exception(" layer_id=".$layer_id);
$v = array($layer_id);
$t = array('i');
$res_dataUrl = db_prep_query($sql,$v,$t);
@@ -3339,9 +3347,16 @@
$this->objLayer[$layer_cnt]->layer_dataurl[$count_dataUrl]->format = $row3["datalink_format"];
$count_dataUrl++;
}
- //asign first dataurl to gui_layer_dataurl_href
-
- $this->objLayer[$layer_cnt]->gui_layer_dataurl_href = $this->objLayer[$layer_cnt]->layer_dataurl[0]->href;
+ //exchange layer_dataurl[0]->href with downloadoptions for inspire if defined in mapbender.conf
+ if (defined("SHOW_INSPIRE_DOWNLOAD_IN_TREE") && SHOW_INSPIRE_DOWNLOAD_IN_TREE == true && $row2["downloadoptions"] != "") {
+ //delete {} from downloadoptions and add url
+ if (defined("MAPBENDER_PATH") && MAPBENDER_PATH != "") {
+ $downloadOptionsUrl = MAPBENDER_PATH."/php/mod_getDownloadOptions.php?outputFormat=html&id=".str_replace('{','',str_replace('}','',$row2["downloadoptions"]));
+ } else {
+ $downloadOptionsUrl = "../php/mod_getDownloadOptions.php?outputFormat=html&id=".str_replace('{','',str_replace('}','',$row2["downloadoptions"]));
+ }
+ $this->objLayer[$layer_cnt]->layer_dataurl[0]->href = $downloadOptionsUrl;
+ }
//load all metadataUrl elements from mb_metadata
$sql = "SELECT metadata_id, link, linktype, md_format FROM mb_metadata INNER JOIN (SELECT * from ows_relation_metadata WHERE fkey_layer_id = $1) as relation ON mb_metadata.metadata_id = relation.fkey_metadata_id AND mb_metadata.origin = 'capabilities'";
$v = array($layer_id);
@@ -3523,7 +3538,7 @@
}
- $sql = "Select * from layer where fkey_wms_id = $1 ORDER BY layer_pos";
+ $sql = "SELECT *, f_get_download_options_for_layer(layer_id) as downloadoptions from layer where fkey_wms_id = $1 ORDER BY layer_pos";
$v = array($wms_id);
$t = array('i');
$res_layer = db_prep_query($sql,$v,$t);
@@ -3536,8 +3551,6 @@
$this->objLayer[$layer_cnt]->layer_title = administration::convertIncomingString($row2["layer_title"]);
$this->objLayer[$layer_cnt]->layer_abstract = administration::convertIncomingString($row2["layer_abstract"]);
$this->objLayer[$layer_cnt]->gui_layer_title = $this->objLayer[$layer_cnt]->layer_title;
- //$this->objLayer[$layer_cnt]->layer_dataurl[0]->href =$row2["layer_dataurl"];
-
//load all dataUrl elements from datalink!
$sql = "SELECT datalink_id, datalink_url, datalink_format FROM datalink INNER JOIN (SELECT * from ows_relation_data WHERE fkey_layer_id = $1) as relation ON datalink.datalink_id = relation.fkey_datalink_id AND datalink.datalink_origin = 'capabilities'";
$e = new mb_notice("class_wms: layer_id: ".$layer_id);
@@ -3545,17 +3558,23 @@
$t = array('i');
$res_dataUrl = db_prep_query($sql,$v,$t);
$count_dataUrl = 0;
-
while($row3 = db_fetch_array($res_dataUrl)){
$this->objLayer[$layer_cnt]->layer_dataurl[$count_dataUrl]->href = $row3["datalink_url"];
//$this->objLayer[$layer_cnt]->layer_dataurl[$count_dataUrl]->type = $row3["linktype"];
$this->objLayer[$layer_cnt]->layer_dataurl[$count_dataUrl]->format = $row3["datalink_format"];
-
-
$count_dataUrl++;
}
- //asign first dataurl to gui_layer_dataurl_href to use it in layertree
- $this->objLayer[$layer_cnt]->gui_layer_dataurl_href = $this->objLayer[$layer_cnt]->layer_dataurl[0]->href;
+ //exchange layer_dataurl[0]->href with downloadoptions for inspire if defined in mapbender.conf
+ if (defined("SHOW_INSPIRE_DOWNLOAD_IN_TREE") && SHOW_INSPIRE_DOWNLOAD_IN_TREE == true && $row2["downloadoptions"] != "") {
+ //delete {} from downloadoptions and add url
+ if (defined("MAPBENDER_PATH") && MAPBENDER_PATH != "") {
+ $downloadOptionsUrl = MAPBENDER_PATH."/php/mod_getDownloadOptions.php?outputFormat=html&id=".str_replace('{','',str_replace('}','',$row2["downloadoptions"]));
+ } else {
+ $downloadOptionsUrl = "../php/mod_getDownloadOptions.php?outputFormat=html&id=".str_replace('{','',str_replace('}','',$row2["downloadoptions"]));
+ }
+ $this->objLayer[$layer_cnt]->layer_dataurl[0]->href = $downloadOptionsUrl;
+ }
+
$e = new mb_notice("class_wms.php: # of found dataurls in db: ".$count_dataUrl);
//load all metadataUrl elements from mb_metadata
$sql = "SELECT metadata_id, link, linktype, md_format FROM mb_metadata INNER JOIN (SELECT * from ows_relation_metadata WHERE fkey_layer_id = $1) as relation ON mb_metadata.metadata_id = relation.fkey_metadata_id AND mb_metadata.origin = 'capabilities'";
@@ -3567,11 +3586,8 @@
$this->objLayer[$layer_cnt]->layer_metadataurl[$count_metadataUrl]->href = $row4["link"];
$this->objLayer[$layer_cnt]->layer_metadataurl[$count_metadataUrl]->type = $row4["linktype"];
$this->objLayer[$layer_cnt]->layer_metadataurl[$count_metadataUrl]->format = $row4["md_format"];
-
$count_metadataUrl++;
}
- //old one:
- //$this->objLayer[$layer_cnt]->layer_metadataurl[0]->href = $row2["layer_metadataurl"];
$this->objLayer[$layer_cnt]->layer_searchable =$row2["layer_searchable"];
$this->objLayer[$layer_cnt]->inspire_download =$row2["inspire_download"];
$this->objLayer[$layer_cnt]->layer_pos =$row2["layer_pos"];
@@ -3809,9 +3825,9 @@
var $layer_queryable;
var $layer_minscale;
var $layer_maxscale;
- var $layer_dataurl;
- var $layer_dataurl_href;
- var $layer_metadataurl;
+ var $layer_dataurl = array();
+ //var $layer_dataurl_href;
+ var $layer_metadataurl = array();
var $layer_searchable;
var $inspire_download;
var $layer_keyword = array();
@@ -3829,7 +3845,7 @@
var $gui_layer_queryable = 0;
var $gui_layer_querylayer = 0;
var $gui_layer_style = NULL;
- var $gui_layer_dataurl_href;
+ //var $gui_layer_dataurl_href;
function layer($id,$parent){
$this->layer_id = $id;
More information about the Mapbender_commits
mailing list