<?php
/*
This script contains code that is needed for a proper initiation of the program. Should be include in the html interface
*/
if ($ajaxServer) {
echo "<script>var ajaxFlag=1;</script>";
}
include_once("libs/phpgeometry_class.php");
include_once("functions.php");
$maplink = new maplink();
if (($noClick) && ($clickX=="" || $clickX!="none")) { //used for printer friendly client
$HTTP_FORM_VARS["map_x"]=$clickX;
$HTTP_FORM_VARS["map_y"]=$clickY;
$HTTP_FORM_VARS["RubberWidth"]=$RubberWidthCache;
$HTTP_FORM_VARS["RubberHeight"]=$RubberHeightCache;
$clickX="";
$clickY="";
}
$postgisObject = & new postgis();
$controlObject = & new control();
$postgisObject -> setControlObject($controlObject);
echo $maplink->ele;
// read the wms connect strings from http vars
$i = 0;
$temp = "server_$i";
global $$temp;
while ($$temp != "")
{
$temp = "server_$i";
global $$temp;
$serviceObject[$i] = & new service($i,$$temp,$controlObject);
$i ++;
}
$controlObject -> serverCount = $i-2;
$i = 0;
$temp = "wfs_$i";
while ($$temp != "")
{
$temp = "wfs_$i";
global $$temp;
$wfsObject[$i] = & new wfsclient($i,$$temp,$controlObject);
$i ++;
}
$controlObject -> wfsCount = $i-2;
for ($i = 0; $i <= $controlObject->wfsCount; $i ++)
{
$wfsTree.=$wfsObject[$i] -> layercontrol();
}
if ($layerXml!="") // only if a xml file is specified
{
$mapscriptObject = & new mapscript($layerXml,$mapfileUrl,$controlObject);
$serviceObject[99] = & new service(99, $mapscriptObject -> layerXml,$controlObject);
$mapscriptObject -> setLayers();
$controlObject -> setMapscriptObject($mapscriptObject);
}
if ($deleteobject==true)
{
$postgisObject->delete($pg_digi_layer,"gid",$deleteobjectkey);
}
if ($pointArray != "" && $shapeId=="")
{
$postgisObject -> insertfeature($controlObject -> convertpointarray($pointArray));
}
elseif ($pointArray != "" && $shapeId!="")
{
$postgisObject -> updateFeature($controlObject -> convertpointarray($pointArray),$editKey,$shapeId);
}
// Write out the javascript var for layer tree
echo "<script>var olData ={childNodes:[ ";
for ($i = 0; $i <= $controlObject->serverCount; $i ++)
{
if ($i>0) echo ",";
echo $serviceObject[$i] -> layercontrolExpandableMenu();
$jsTableCheck.=$serviceObject[$i] -> jsTableCheck();
}
if ($controlObject->serverCount>=0 && $mapscriptObject -> layerXml!="") echo ",";
if ($mapscriptObject -> layerXml!="")
{
echo $serviceObject[99] -> layercontrolExpandableMenu();
$jsTableCheck.=$serviceObject[99] -> jsTableCheck();
}
echo "]};</script>";
echo "<script>var ajaxServer='";
echo $ajaxServer;
echo "'</script>";
?>