[Mapbender-commits] r7414 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Sun Dec 26 17:52:24 EST 2010
Author: marc
Date: 2010-12-26 14:52:24 -0800 (Sun, 26 Dec 2010)
New Revision: 7414
Modified:
trunk/mapbender/http/php/mod_wmc2ol.php
Log:
some path and whitespace corrections
Modified: trunk/mapbender/http/php/mod_wmc2ol.php
===================================================================
--- trunk/mapbender/http/php/mod_wmc2ol.php 2010-12-26 22:47:24 UTC (rev 7413)
+++ trunk/mapbender/http/php/mod_wmc2ol.php 2010-12-26 22:52:24 UTC (rev 7414)
@@ -39,11 +39,11 @@
if (isset($_REQUEST["wmc_id"]) & $_REQUEST["wmc_id"] != "") {
//validate to csv integer list
$testMatch = $_REQUEST["wmc_id"];
- $pattern = '/^[0-9_]*$/';
- if (!preg_match($pattern,$testMatch)){
+ $pattern = '/^[0-9_]*$/';
+ if (!preg_match($pattern,$testMatch)){
echo 'wmc_id: <b>'.$testMatch.'</b> is not valid.<br/>';
die();
- }
+ }
$wmc_id = $testMatch;
$testMatch = NULL;
}
@@ -53,17 +53,17 @@
//dummy parameter for drawing georss points:
-$pointRadius = "10";
+$pointRadius = "10";
$fillColor = "#666666"; //grey
if (isset($_REQUEST["pointRadius"]) & $_REQUEST["pointRadius"] != "") {
//validate to csv integer list
$testMatch = $_REQUEST["pointRadius"];
$pattern = '/^[0-9]{2}|^[1-9]{1}$/';
- if (!preg_match($pattern,$testMatch)){
+ if (!preg_match($pattern,$testMatch)){
echo 'pointRadius: <b>'.$testMatch.'</b> is not valid.<br/>';
- die();
- }
+ die();
+ }
$pointRadius = $testMatch;
$testMatch = NULL;
}
@@ -72,10 +72,10 @@
if (isset($_REQUEST["fillColor"]) & $_REQUEST["fillColor"] != "") {
//validate to csv integer list
$testMatch = $_REQUEST["fillColor"];
- $pattern = '/^#[0-9a-f]{3}|#[0-9a-f]{6}$/';
- if (!preg_match($pattern,$testMatch)){
+ $pattern = '/^#[0-9a-f]{3}|#[0-9a-f]{6}$/';
+ if (!preg_match($pattern,$testMatch)){
echo 'fillColor: <b>'.$testMatch.'</b> is not valid.<br/>';
- die();
+ die();
}
$fillColor = $testMatch;
$testMatch = NULL;
@@ -84,10 +84,10 @@
if (isset($_REQUEST["markerUrl"]) & $_REQUEST["markerUrl"] != "") {
//validate to csv integer list
$testMatch = $_REQUEST["markerUrl"];
- $pattern = '/^[\d,]*$/';
+ $pattern = '/^[\d,]*$/';
if (!preg_match($pattern,$testMatch)){
echo 'markerUrl: <b>'.$testMatch.'</b> is not valid.<br/>';
- die();
+ die();
}
$fillColor = $testMatch;
$testMatch = NULL;
@@ -184,7 +184,7 @@
//Read out WMC into XML object
$xml=simplexml_load_string($wmc[0], "SimpleXMLElement", LIBXML_NOBLANKS);
if ($_REQUEST['withoutBody'] == '1') {
-
+
} else {
//generate general html data
$html='';
@@ -197,21 +197,20 @@
$htmlWidth=$windowWidth+40;
$htmlHeight=$windowHeight+70;
//define CSS
- $html.="<style type='text/css'>\n";
- $html.=" #map {\n";
- $html.="width: ".$windowWidth."px;\n";
- $html.="height: ".$windowHeight."px;\n";
- $html.="border: 1px solid black;\n";
- $html.="overflow:visible;\n";
- $html.="}\n";
+ $html.="<style type='text/css'>\n";
+ $html.=" #map {\n";$html.="width: ".$windowWidth."px;\n";
+ $html.="height: ".$windowHeight."px;\n";
+ $html.="border: 1px solid black;\n";
+ $html.="overflow:visible;\n";
+ $html.="}\n";
$html.=" #srs {\n";
- $html.="font-size: 80%;\n";
- $html.="color: #444;\n";
- $html.="}\n";
+ $html.="font-size: 80%;\n";
+ $html.="color: #444;\n";
+ $html.="}\n";
$html.=" #showpos {\n";
- $html.="font-size: 80%;\n";
- $html.="color: #444;\n";
- $html.="}\n";
+ $html.="font-size: 80%;\n";
+ $html.="color: #444;\n";
+ $html.="}\n";
$html.="</style>\n";
//don't show any html, title and/or body tag when integrate it into external website
if ($_REQUEST['withoutBody'] == '1') {
@@ -223,13 +222,13 @@
$e = new mb_exception('georss request : '.$_REQUEST['GEORSS']);
if(isset($_REQUEST["withDigitize"]) or isset($_REQUEST["GEORSS"])){
if(($_REQUEST["withDigitize"]=='1') or ($_REQUEST["GEORSS"]!='')){
- $html.="<script src='http://".$_SERVER['HTTP_HOST']."/mapbender/extensions/OpenLayers-2.8/OpenLayers.js'></script>\n";
- #$html.="<script src='../../openlayers/OpenLayers.js'></script>\n";
+ #$html.="<script src='http://".$_SERVER['HTTP_HOST']."/mapbender/extensions/OpenLayers-2.8/OpenLayers.js'></script>\n";
+ $html.="<script src='../extensions/OpenLayers-2.8/OpenLayers.js'></script>\n";
}
} else {
//use the minimized version
//$html.="<script src='../../openlayers/build/geoportal_ol_geoportal.js'></script>\n";
- $html.="<script src='http://".$_SERVER['HTTP_HOST']."/mapbender/extensions/OpenLayers-2.8/OpenLayers.js'></script>\n"; //TODO minimize this or use other lib
+ $html.="<script src='../extensions/OpenLayers-2.8/OpenLayers.js'></script>\n"; //TODO minimize this or use other lib
}
//begin part for javascript code
$html.="<script type='text/javascript'>\n";
@@ -272,11 +271,11 @@
$numberZoomLevels=20;
//define central position in projected system
$html.="var lat = $centralx;\n";
- $html.="var lon = $centraly;\n";
+ $html.="var lon = $centraly;\n";
$centralPointx=($maxx+$minx)/2;
$centralPointy=($maxy+$miny)/2;
//startzoom faktor - check if usefull
- $html.="var zoom = 10;\n";
+ $html.="var zoom = 10;\n";
$html.="\n";
//start function for initialize client
$html.="function initGeoportal(){\n";
@@ -284,7 +283,7 @@
$html.=" map = new OpenLayers.Map('map');\n";
//define options for ol map object
$html.=" var options = {\n";
- $html.=" projection: \"".$xml->General->BoundingBox['SRS']."\",\n";
+ $html.=" projection: \"".$xml->General->BoundingBox['SRS']."\",\n";
if ($xml->General->BoundingBox['SRS']=='EPSG:4326'){
echo 'Please choose an other coordinatereferencesystem. Converting Scales to Geographic Coordinates is not yet implemented!';
return;
@@ -314,8 +313,8 @@
#echo "is in the codespace of the epsg registry\n";
} else {
#echo "is outside\n";
- echo "alert('The REQUEST parameter mb_myBBOXEpsg is not in the epsg realm - please define another EPSG Code.');";
- return;
+ echo "alert('The REQUEST parameter mb_myBBOXEpsg is not in the epsg realm - please define another EPSG Code.');";
+ return;
}
//Check if epsg is equal to BBOXEpsg
//Get epsg code out of WMC
@@ -388,11 +387,11 @@
$html.=" transparent: \"On\"\n";
$html.=" },\n";
$html.=" {\n";
- $html.=" maxExtent: new OpenLayers.Bounds(".$minx.",".$miny.",".$maxx.",".$maxy."),\n";
- // then check map.baseLayer.resolutions[0] for
- // a reasonable value.
+ $html.=" maxExtent: new OpenLayers.Bounds(".$minx.",".$miny.",".$maxx.",".$maxy."),\n";
+ // then check map.baseLayer.resolutions[0] for
+ // a reasonable value.
$html.=" projection: \"".$xml->General->BoundingBox['SRS']."\",\n";
- $html.=" units: \"m\",\n";
+ $html.=" units: \"m\",\n";
$html.=" numZoomLevels: ".$numberZoomLevels.",\n";
$minScale=dom_import_simplexml($extensions->gui_minscale)->nodeValue;
$maxScale=dom_import_simplexml($extensions->gui_maxscale)->nodeValue;
@@ -406,9 +405,9 @@
$html.=" minScale: ".$minScale.",\n";
$html.=" maxScale: ".$maxScale.",\n";
$html.=" singleTile: true\n";
- //Only necessary for working with scales.
- $html.=" } );\n";
- $html.=" map.addLayer(layer0);\n";
+ //Only necessary for working with scales.
+ $html.=" } );\n";
+ $html.=" map.addLayer(layer0);\n";
} else {
echo "Guest don't have permission on Base-Layer or ".$layer_id." therefor OpenLayers client will not be generated! Check if the layer does exists any longer or if someone has removed the permission to access this service.<br>";
}
@@ -440,9 +439,9 @@
$html.=" transparent: \"TRUE\"\n";
$html.=" },\n";
$html.=" {\n";
- $html.=" maxExtent: new OpenLayers.Bounds(".$minx.",".$miny.",".$maxx.",".$maxy."),\n";
+ $html.=" maxExtent: new OpenLayers.Bounds(".$minx.",".$miny.",".$maxx.",".$maxy."),\n";
$html.=" projection: \"".$xml->General->BoundingBox['SRS']."\",\n";
- $html.=" units: \"m\",\n";
+ $html.=" units: \"m\",\n";
$html.=" singleTile: true,\n";
$html.=" numZoomLevels: ".$numberZoomLevels.",\n";
//$extensions=$xml->LayerList->Layer[$i]->Extension->children('http://www.mapbender.org');
@@ -457,29 +456,29 @@
$html.=" minScale: ".$minScale.",\n";
$html.=" maxScale: ".$maxScale.",\n";
$html.=" 'isBaseLayer': false\n";
- $html.=" } );\n";
+ $html.=" } );\n";
$html.=" layer".$i.".alwaysInRange = true;\n"; //TODO: there is a problem with calculating the scale hints - therefor this is only a workaround - must be fixed!
- $html.=" map.addLayer(layer".$i.");\n";
+ $html.=" map.addLayer(layer".$i.");\n";
}
}
$html.="\n";
$html.=" markers.alwaysInRange = true;\n";
$html.=" map.addLayer(markers);\n";
if(isset($_REQUEST["LayerSwitcher"]) && $_REQUEST["LayerSwitcher"] == '1'){
- $html.=" map.addControl(new OpenLayers.Control.LayerSwitcher());\n";
+ $html.=" map.addControl(new OpenLayers.Control.LayerSwitcher());\n";
}
if(isset($_REQUEST["mb_drawCentre"])&isset($centralx)&isset($centraly)){
if ($_REQUEST["mb_drawCentre"]='1'){
$html.=" var size = new OpenLayers.Size(15,20);\n";
$html.=" calculateOffset = function(size) {return new OpenLayers.Pixel(-(size.w/2), -size.h); };\n";
- $html.=" var icon = new OpenLayers.Icon('http://".$_SERVER['HTTP_HOST']."/mapbender/img/marker/red.png',size, null, calculateOffset);\n";
+ $html.=" var icon = new OpenLayers.Icon('../img/marker/red.png',size, null, calculateOffset);\n";
$html.=" markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(".$centralx.",".$centraly."),icon));\n";
}
else {
echo "alert('The REQUEST parameter mb_drawCentre is outside of its realm!');";
- return;
+ return;
}
}
//Zoom to extent of given mb_myBBOX
@@ -502,10 +501,10 @@
if(isset($_REQUEST["GEORSS"])){
if($_REQUEST["GEORSS"]!=''){
$html.=" var pointVectorLayer = new OpenLayers.Layer.Vector(\"Vector Layer\", {\n";
- $html.=" styleMap: new OpenLayers.StyleMap({\n";
- $html.=" pointRadius: \"".$pointRadius."\", // based on feature.attributes.type\n";
- $html.=" fillColor: \"".$fillColor."\"\n";
- $html.=" })\n";
+ $html.=" styleMap: new OpenLayers.StyleMap({\n";
+ $html.=" pointRadius: \"".$pointRadius."\", // based on feature.attributes.type\n";
+ $html.=" fillColor: \"".$fillColor."\"\n";
+ $html.=" })\n";
$html.=" });\n";
//end of definition of the point vector layer
//push the features to the layer
@@ -515,9 +514,9 @@
//define the controls for the features in the point vector layer
//add the vector layer to map
$html.=" selectControl = new OpenLayers.Control.SelectFeature(pointVectorLayer,
- {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});\n";
- $html.=" map.addControl(selectControl);\n";
- $html.=" selectControl.activate(); \n";
+ {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});\n";
+ $html.=" map.addControl(selectControl);\n";
+ $html.=" selectControl.activate(); \n";
}
}
@@ -528,7 +527,7 @@
for ($i=0; $i<count($layer_array); $i++){
if ($layer_array_queryable[$i]=='1'){
$html.=" var url".$i." = layer".$i.".getFullRequestString({\n";
- $html.=" REQUEST: \"GetFeatureInfo\",\n";
+ $html.=" REQUEST: \"GetFeatureInfo\",\n";
$html.=" FEATURE_COUNT: \"100\",\n";
$html.=" EXCEPTIONS: \"application/vnd.ogc.se_xml\",\n";
$html.=" BBOX: layer".$i.".map.getExtent().toBBOX(),\n";
@@ -555,9 +554,9 @@
$html.=" }\n";
$html.=" var size = new OpenLayers.Size(15,20);\n";
$html.=" calculateOffset = function(size) {return new OpenLayers.Pixel(-(size.w/2), -size.h); };\n";
- $html.=" var icon = new OpenLayers.Icon('http://".$_SERVER['HTTP_HOST']."/mapbender/img/marker/red.png',size, null, calculateOffset);\n";
+ $html.=" var icon = new OpenLayers.Icon('../img/marker/red.png',size, null, calculateOffset);\n";
$html.=" markers.addMarker(new OpenLayers.Marker(lonlat,icon));\n";
- $html.=" var digX = String.substr(lonlat.lon,0,10);\n";
+ $html.=" var digX = String.substr(lonlat.lon,0,10);\n";
$html.=" var digY = String.substr(lonlat.lat,0,10);\n";
if (isset($_REQUEST['xID']) && isset($_REQUEST['yID']) && $_REQUEST['xID'] != '' && $_REQUEST['yID'] != '') {
$html.=" document.getElementById(\"".$_REQUEST['xID']."\").value = digX;\n";
@@ -576,25 +575,25 @@
if(isset($_REQUEST["GEORSS"])){
if($_REQUEST["GEORSS"]!=''){
$html.="function onPopupClose(evt) {\n";
- $html.=" selectControl.unselect(selectedFeature);\n";
- $html.="}\n";
+ $html.=" selectControl.unselect(selectedFeature);\n";
+ $html.="}\n";
- $html.="function onFeatureSelect(feature) {\n";
- $html.=" selectedFeature = feature;\n";
- $html.=" popup = new OpenLayers.Popup.FramedCloud(\"chicken\", \n";
- $html.=" feature.geometry.getBounds().getCenterLonLat(),
- null,
- \"<div class='georsstitle'>\" + feature.attributes['title'] +\"</div><br/>\"+\"<div class='georssdescription'>\" +feature.attributes['description']+\"</div><br/><div class='georsslink'><a href='\"+feature.attributes['link']+\"' target='_blank'>Weitere Informationen</a></div>\",
- null, true, onPopupClose);\n";
- $html.=" feature.popup = popup;\n";
- $html.=" map.addPopup(popup);\n";
- $html.="}\n";
+ $html.="function onFeatureSelect(feature) {\n";
+ $html.=" selectedFeature = feature;\n";
+ $html.=" popup = new OpenLayers.Popup.FramedCloud(\"chicken\", \n";
+ $html.=" feature.geometry.getBounds().getCenterLonLat(),
+ null,
+ \"<div class='georsstitle'>\" + feature.attributes['title'] +\"</div><br/>\"+\"<div class='georssdescription'>\" +feature.attributes['description']+\"</div><br/><div class='georsslink'><a href='\"+feature.attributes['link']+\"' target='_blank'>Weitere Informationen</a></div>\",
+ null, true, onPopupClose);\n";
+ $html.=" feature.popup = popup;\n";
+ $html.=" map.addPopup(popup);\n";
+ $html.="}\n";
- $html.="function onFeatureUnselect(feature) {\n";
- $html.=" map.removePopup(feature.popup);\n";
- $html.=" feature.popup.destroy();\n";
- $html.=" feature.popup = null;\n";
- $html.="}\n";
+ $html.="function onFeatureUnselect(feature) {\n";
+ $html.=" map.removePopup(feature.popup);\n";
+ $html.=" feature.popup.destroy();\n";
+ $html.=" feature.popup = null;\n";
+ $html.="}\n";
$html.="function createFeaturesFromGeoRSS() {\n";
//First check if some georss is send in the request variable GEORSS
@@ -618,18 +617,18 @@
$gmlElements = $georssElements->children('http://www.opengis.net/gml');
$coords = explode(" ", $gmlElements->Point->pos);
- $html.=" var point = new OpenLayers.Geometry.Point(";
+ $html.=" var point = new OpenLayers.Geometry.Point(";
$html.="".$coords[0].",".$coords[1].");\n";
$html.=" pointFeatures[".$i."] = new OpenLayers.Feature.Vector(point, {title: \"".$georssXml->entry[$i]->title."\", description : \"".str_replace("\"", "'",$georssXml->entry[$i]->content)."\", link : \"".$georssXml->entry[$i]->link->attributes()->href."\"});\n";
}
$html.=" return pointFeatures;\n";
- $html.="}\n";
+ $html.="}\n";
}
} else {
//
if (file_exists('/tmp/georss_test_v1a.xml')) {
- $georssXml = simplexml_load_file('/tmp/georss_test_v1a.xml');
+ $georssXml = simplexml_load_file('/tmp/georss_test_v1a.xml');
$featureCount = 0;
foreach ($georssXml->entry as $item){
$featureCount++;
@@ -642,26 +641,26 @@
$gmlElements = $georssElements->children('http://www.opengis.net/gml');
$coords = explode(" ", $gmlElements->Point->pos);
- $html.=" var point = new OpenLayers.Geometry.Point(";
+ $html.=" var point = new OpenLayers.Geometry.Point(";
$html.="".$coords[0].",".$coords[1].");\n";
$html.=" pointFeatures[".$i."] = new OpenLayers.Feature.Vector(point, {title: \"".$georssXml->entry[$i]->title."\", description : \"".str_replace("\"", "'",$georssXml->entry[$i]->content)."\", link : \"".$georssXml->entry[$i]->link->attributes()->href."\"});\n";
}
//***Generate Dummy Point for testing
$html.=" var point = new OpenLayers.Geometry.Point(2594468.92,5530693.03);\n";
- $html.=" pointFeatures[".$featureCount."] = new OpenLayers.Feature.Vector(point, {description : \"Testbeschreibung\", link : \"Testlink\"});\n";
+ $html.=" pointFeatures[".$featureCount."] = new OpenLayers.Feature.Vector(point, {description : \"Testbeschreibung\", link : \"Testlink\"});\n";
- $html.=" return pointFeatures;\n";
- $html.="}\n";
+ $html.=" return pointFeatures;\n";
+ $html.="}\n";
} else {
- $html.=" alert('No GeoRSS found - use only dummy point!');\n";
+ $html.=" alert('No GeoRSS found - use only dummy point!');\n";
$html.=" var point = new OpenLayers.Geometry.Point(2594468.92,5530693.03);\n";
- $html.=" var pointFeature = new OpenLayers.Feature.Vector(point, {description : \"Testbeschreibung\", link : \"Testlink\"});\n";
- $html.=" return pointFeature;\n";
- $html.="}\n";
+ $html.=" var pointFeature = new OpenLayers.Feature.Vector(point, {description : \"Testbeschreibung\", link : \"Testlink\"});\n";
+ $html.=" return pointFeature;\n";
+ $html.="}\n";
}
- }
+ }
//TODO: validate the content of the XML
//pull out the relevant content: name, id, description
//filter out javascript content!
@@ -670,27 +669,28 @@
}
}
//end of javascripting part
- $html.="</script>\n";
+ $html.="</script>\n";
if ($_REQUEST['withoutBody'] == '1') {
} else {
- $html.=" </head>\n";
- $html.="<body onload='initGeoportal()'>\n";
+ $html.=" </head>\n";
+ $html.="<body onload='initGeoportal()'>\n";
}
- $html.="<div id='tags'></div>\n";
- $html.="<div id='map' class='smallmap'></div>\n";//class dont exists
+ $html.="<div id='tags'></div>\n";
+ $html.="<div id='map' class='smallmap'></div>\n";//class dont exists
+
//show textareas with coordinates which are digitized
if(isset($_REQUEST["withDebug"])){
if($_REQUEST["withDebug"]=='1'){
- $html.="<input type=\"textarea\" name=\"xCoord\" value=\"0\" id=\"xCoord\"/>\n";
- $html.="<input type=\"textarea\" name=\"yCoord\" value=\"0\" id=\"yCoord\"/>\n";
+ $html.="<input type=\"textarea\" name=\"xCoord\" value=\"0\" id=\"xCoord\"/>\n";
+ $html.="<input type=\"textarea\" name=\"yCoord\" value=\"0\" id=\"yCoord\"/>\n";
}
}
//*******************************
//echo "<a href = 'http://www.geoportal.rlp.de' target='_blank'> <img src = '".$_SERVER['HTTP_HOST']."/mapbender/img/geoportal_rlp.png' title=\"GeoPortal Rheinland-Pfalz\" border=0></a>";
- $html.="<div id='docs'>\n";
- $html.="\n";
- $html.="</div>\n";
+ $html.="<div id='docs'>\n";
+ $html.="\n";
+ $html.="</div>\n";
//Show coords if wished
if($_REQUEST["mb_showCoords"]=='1'){
//$html.="<div id='srs' class='csrs'>Koordinaten in <a href = '../../../mediawiki/index.php/".$xml->General->BoundingBox['SRS']."' target='_blank'>".$xml->General->BoundingBox['SRS']."</a>:</div>\n"; //only for geoportal.rlp
@@ -701,7 +701,7 @@
if ($_REQUEST['withoutBody'] == '1') {
} else {
- $html.="</body>\n";
+ $html.="</body>\n";
$html.="</html>\n";
}
//Print out HTML code
More information about the Mapbender_commits
mailing list