public function returnUrl()
 {
     $mbjson = new Mapbender_JSON();
     if ($this->isSaved) {
         return $mbjson->encode(array("outputFileName" => TMPDIR . "/" . $this->outputFileName));
     } else {
         return $mbjson->encode(array("error" => "Possibly no map urls delivered."));
     }
 }
 public function toGeoJSON()
 {
     $str = "";
     $str .= "{\"type\":\"Feature\", \"id\":\"" . $this->fid . "\", \"crs\":";
     if (!$this->geometry || !$this->geometry->srs) {
         $str .= "null, ";
     } else {
         $str .= "{\"type\":\"name\", \"properties\":{\"name\":\"" . $this->geometry->srs . "\"}}, ";
     }
     $str .= "\"geometry\": ";
     if ($this->geometry) {
         $str .= $this->geometry->toGeoJSON();
     } else {
         $str .= "\"\"";
     }
     $prop = array();
     $str .= ", \"properties\": ";
     $cnt = 0;
     foreach ($this->properties as $key => $value) {
         $prop[$key] = preg_replace('/\\r\\n|\\r|\\n/', '\\n', $value);
         $cnt++;
     }
     $json = new Mapbender_JSON();
     $str .= $json->encode($prop);
     $str .= "}";
     return $str;
 }
function sendErrorMessage($data)
{
    $resObj = array();
    $response = "error";
    $resObj["errorMessage"] = $data;
    $resObj["response"] = $response;
    header("Content-Type:application/x-json");
    $json = new Mapbender_JSON();
    echo $json->encode($resObj);
    die;
}
                            $x = trim(floatval($row["rechtsw"]));
                            $y = trim(floatval($row["hochw"]));
                            $obj["landparcels"][$landparcelId] = array("x" => $x, "y" => $y);
                        }
                    }
                    $obj["limited"] = isOverLimit($counter, $numberOfResults, $numberOfResults);
                } else {
                    if ($command == "getDistricts") {
                        $obj["districts"] = array();
                        $sql = "SELECT DISTINCT gemschl, name FROM public.gemarkungen WHERE gkz = \$1 ORDER BY name";
                        $v = array($communeId);
                        $t = array("i");
                        $res = db_prep_query($sql, $v, $t);
                        while ($row = db_fetch_array($res)) {
                            $districtID = trim($row["gemschl"]);
                            $districtName = trim($row["name"]);
                            $obj["districts"][$districtID] = $districtName;
                        }
                        $obj["limited"] = false;
                    } else {
                        // unknown command
                        $e = new mb_exception("unknown command: " . $command);
                    }
                }
            }
        }
    }
}
$json = new Mapbender_JSON();
$output = $json->encode($obj);
echo $output;
while ($row_js = db_fetch_array($mb_res)) {
    //
    // Create element properties
    //
    $e_id = isset($row_js["e_id"]) ? str_replace(" ", "", $row_js["e_id"]) : "";
    $e_src = $row_js["e_src"];
    $e_require = $row_js["e_requires"];
    $e_title = $row_js["e_title"];
    $e_currentTitle = $row_js["e_current_title"];
    $e_target = explode(",", $row_js["e_target"]);
    $e_width = intval($row_js["e_width"]);
    $e_height = intval($row_js["e_height"]);
    $e_top = intval($row_js["e_top"]);
    $e_left = intval($row_js["e_left"]);
    $e_url = $row_js["e_url"];
    $elementAttributes = "{" . "id:'{$e_id}'," . "target:" . ($e_target[0] != "" ? $json->encode($e_target) : "[]") . "," . "url:'{$e_url}'," . "top:{$e_top}," . "left:{$e_left}," . "width:{$e_width}," . "height:{$e_height}," . "src:'{$e_src}'," . "title:'{$e_title}'," . "currentTitle:'{$e_currentTitle}'" . "}";
    echo "Mapbender.modules." . $e_id . " = " . $elementAttributes . ";\n";
    echo "var t = Mapbender.modules." . $e_id . ".target;";
    echo "var sel = [];for (var k in t) {t[k] = \$.trim(t[k]);if(\$('#' + t[k]).size() > 0) {sel.push(\$('#' + t[k]).get(0))}}\n";
    echo "Mapbender.modules." . $e_id . ".\$target = sel.length > 0 ? \$(sel) : \$([]);\n";
    echo "\$('#" . $e_id . "').data('api', Mapbender.modules." . $e_id . ");";
    //
    // Include JavaScript files
    //
    $jsFileString = $row_js["e_js_file"];
    if ($jsFileString) {
        if (in_array($e_id, $modulesNotRelyingOnGlobalsArray) || preg_match("/\\/plugins\\//", $jsFileString)) {
            //
            // Create the jQuery plugin in output buffer
            //
            ob_start();
 function getAllUserColumns($userId)
 {
     $userArray = array();
     $sql = "SELECT * FROM mb_user WHERE mb_user_id = \$1";
     $v = array($userId);
     $t = array('s');
     $res = db_prep_query($sql, $v, $t);
     while ($row = db_fetch_array($res)) {
         foreach ($row as $key => $value) {
             if (is_int($key) == false) {
                 array_push($userArray, array("id" => $key, "value" => $value));
             }
         }
     }
     $json = new Mapbender_JSON();
     $output = $json->encode($userArray);
     header("Content-type:text/plain; charset=utf-8");
     return $output;
 }
#$lineArray = explode(";", $lineList);
//check for valid lines for merging (2 lines)
$sql = "SELECT ";
$sql .= "ST_StartPoint(ST_GeomFromText('" . $line1 . "')) = ST_StartPoint(ST_GeomFromText('" . $line2 . "')) as a, ";
$sql .= "ST_StartPoint(ST_GeomFromText('" . $line1 . "')) = ST_EndPoint(ST_GeomFromText('" . $line2 . "')) as b, ";
$sql .= "ST_EndPoint(ST_GeomFromText('" . $line1 . "')) = ST_StartPoint(ST_GeomFromText('" . $line2 . "')) as c, ";
$sql .= "ST_EndPoint(ST_GeomFromText('" . $line1 . "')) = ST_EndPoint(ST_GeomFromText('" . $line2 . "')) as d";
$res = db_query($sql);
$row = db_fetch_array($res);
if ($row['a'] == 't' || $row['b'] == 't' || $row['c'] == 't' || $row['d'] == 't') {
    $sql = "SELECT ST_AsText(multi(st_linemerge(st_collect_garray(ARRAY[";
    $sql .= "ST_GeomFromText('" . $line1 . "'), ST_GeomFromText('" . $line2 . "')";
    /*	for ($i = 0; $i < count($lineArray); $i++) {
    		if ($i > 0) {
    			$sql .= ", ";
    		}
    		$sql .= "ST_GeomFromText('" . $lineArray[$i] . "')";
    	}
    */
    $sql .= "])))) as a";
    #echo $sql;
    $res = db_query($sql);
    $lineArray = array();
    $row = db_fetch_array($res);
    $data = array("line" => $row[0]);
} else {
    $data = array("line" => "");
}
$output = $json->encode($data);
header("Content-type:application/x-json; charset=utf-8");
echo $output;
            $queryJSON->searchFilter->orderFilter->item[2]->title = $orderByTitle['date'];
            $queryJSON->searchFilter->orderFilter->item[2]->url = str_replace("orderBy=title", "orderBy=date", $searchURL);
            break;
        case "date":
            $queryJSON->searchFilter->orderFilter->title = $orderByTitle['date'];
            $queryJSON->searchFilter->orderFilter->item[0]->title = $orderByTitle['rank'];
            $queryJSON->searchFilter->orderFilter->item[0]->url = str_replace("orderBy=date", "orderBy=rank", $searchURL);
            $queryJSON->searchFilter->orderFilter->item[1]->title = $orderByTitle['id'];
            $queryJSON->searchFilter->orderFilter->item[1]->url = str_replace("orderBy=date", "orderBy=id", $searchURL);
            $queryJSON->searchFilter->orderFilter->item[2]->title = $orderByTitle['title'];
            $queryJSON->searchFilter->orderFilter->item[2]->url = str_replace("orderBy=date", "orderBy=title", $searchURL);
            break;
    }
}
//write out json to file or web
$queryFilter = $classJSON->encode($queryJSON);
if ($resultTarget == 'debug') {
    echo "<br>DEBUG: filter: " . $queryFilter . "<br>";
    #echo "<br>DEBUG: searchTypeBbox: ".$searchTypeBbox."<br>";
}
if ($resultTarget == 'file') {
    $filename = $tempFolder . "/" . $searchId . "_filter.json";
    if (file_exists($filename)) {
        $e = new mb_notice("php/callMetdata.php: The file {$filename} exists - it will not be overwritten!");
    } else {
        if ($catFileHandle = fopen($filename, "w")) {
            fwrite($catFileHandle, $queryFilter);
            fclose($catFileHandle);
            $e = new mb_notice("php/callMetdata.php: new filter_file created!");
        } else {
            $e = new mb_notice("php/callMetdata.php: cannot create filter_file!");
 public function toGeoJSON()
 {
     $str = "";
     $str .= "{\"type\":\"Feature\", \"id\":\"" . $this->fid . "\", \"geometry\": ";
     if ($this->geometry) {
         $str .= $this->geometry->toGeoJSON();
     } else {
         $str .= "\"\"";
     }
     $prop = array();
     $str .= ", \"properties\": ";
     $cnt = 0;
     foreach ($this->properties as $key => $value) {
         $prop[$key] = $value;
         $cnt++;
     }
     $json = new Mapbender_JSON();
     $str .= $json->encode($prop);
     $str .= "}";
     return $str;
 }
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/********** Configuration*************************************************/
require_once dirname(__FILE__) . "/../php/mb_validatePermission.php";
require_once dirname(__FILE__) . "/../classes/class_json.php";
include dirname(__FILE__) . "/../include/dyn_js.php";
$tab_ids = array();
include dirname(__FILE__) . "/../include/dyn_php.php";
echo "var tab_titles = [];\n";
for ($i = 0; $i < count($tab_ids); $i++) {
    $sql = "SELECT gettext(\$1, e_title) AS e_title FROM gui_element WHERE fkey_gui_id = \$2 AND e_id = \$3";
    $v = array(Mapbender::session()->get("mb_lang"), $gui_id, $tab_ids[$i]);
    $t = array("s", "s", "s");
    $res = db_prep_query($sql, $v, $t);
    $row = db_fetch_array($res);
    echo "tab_titles[" . $i . "] = '" . $row["e_title"] . "';\n";
}
$json = new Mapbender_JSON();
$output = $json->encode($tab_ids);
echo "var tab_ids = " . $output . ";";
if (!isset($expandable) || !$expandable) {
    include dirname(__FILE__) . "/mod_tab.js";
} else {
    include dirname(__FILE__) . "/mod_tab_expandable.js";
}
    $xml .= 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ';
    $xml .= 'xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2/CSW-discovery.xsd"> ';
    $xml .= '> ';
    $xml .= '<csw:Query typeNames="csw:Record">';
    $xml .= '<csw:ElementSetName>summary</csw:ElementSetName>';
    $xml .= '</csw:Query>';
    $xml .= '</csw:GetRecords>';
    #$xml .= '</GetRecords>';
    //parse xml for validating it before sending
    $data = stripslashes($xml);
    $dataXMLObject = new SimpleXMLElement($xml);
    $xml = $dataXMLObject->asXML();
    return $xml;
}
function getrecords_post($url, $postData)
{
    $connection = new connector();
    $connection->set("httpType", "post");
    $connection->set("httpContentType", "text/xml");
    $connection->set("httpPostData", $postData);
    $e = new mb_notice("CAT REQUEST: " . $url . "\n\n" . $postData);
    $data = $connection->load($url);
    if (!$data) {
        $e = new mb_exception("CAT getrecords returned no result: " . $url . "\n" . $postData);
        return null;
    }
    return $data;
}
$json = new Mapbender_JSON();
$output = $json->encode($resultObj);
echo $output;
$res = db_query($intersection_sql);
// add first and last points to the array of intersectionpoints
while ($row = db_fetch_array($res)) {
    $startPoint = $row['startpoint'];
    $endPoint = $row['endpoint'];
    $points[] = $row['point'];
}
// if the two lines don't intersect, we just do nothing, and return the first line
if (count($points) == 0) {
    $lineArray[] = $line1Text;
} else {
    $points = array_merge(array($startPoint), $points, array($endPoint));
    // go through the point array in pairs, cut into segment, and add each segment onto resultArray
    for ($i = 0; $i < count($points) - 1; $i++) {
        $pointStartText = $points[$i];
        $pointEndText = $points[$i + 1];
        if ($i == count($points) - 2 && $startPoint == $endPoint) {
            $nthSegment_sql = sprintf("SELECT ST_AsText(ST_multi(geom)) AS substring FROM " . " ST_Dump((SELECT ST_AsText(ST_FORCE_COLLECTION(ST_Line_Substring(" . "'%s'::geometry," . "ST_Line_Locate_Point('%s'::geometry,'%s'::geometry)," . "1.0" . ")))));", $line1Text, $line1Text, $pointStartText);
        } else {
            $nthSegment_sql = sprintf("SELECT ST_AsText(ST_multi(geom)) AS substring FROM " . " ST_Dump((SELECT ST_AsText(ST_FORCE_COLLECTION(ST_Line_Substring(" . "'%s'::geometry," . "ST_Line_Locate_Point('%s'::geometry,'%s'::geometry)," . "ST_Line_Locate_Point('%s'::geometry,'%s'::geometry)" . ")))));", $line1Text, $line1Text, $pointStartText, $line1Text, $pointEndText);
        }
        $res = db_query($nthSegment_sql);
        if ($row = db_fetch_array($res)) {
            $lineArray[] = $row['substring'];
        }
    }
}
// OUTPUT
header("Content-type:application/x-json; charset=utf-8");
echo $json->encode(array("geometries" => $lineArray));
 /**
  * Returns an array of JavaScript statements
  *
  * @return String[]
  */
 public function toJavaScript()
 {
     $skipWmsArray = array();
     if (func_num_args() === 1) {
         if (!is_array(func_get_arg(0))) {
             throw new Exception("Invalid argument, must be array.");
         }
         $skipWmsArray = func_get_arg(0);
     }
     // will contain the JS code to create the maps
     // representing the state stored in this WMC
     $wmcJsArray = array();
     // set general extension data
     if (count($this->generalExtensionArray) > 0) {
         $json = new Mapbender_JSON();
         array_push($wmcJsArray, "restoredWmcExtensionData = " . $json->encode($this->generalExtensionArray) . ";");
     }
     // reset WMS data
     array_push($wmcJsArray, "wms = [];");
     array_push($wmcJsArray, "wms_layer_count = 0;");
     // add WMS for main map frame
     $wmsArray = $this->mainMap->getWmsArray();
     // find the WMS in the main map which is equal to the WMS
     // in the overview map
     $overviewWmsIndex = null;
     $ovWmsArray = array();
     if ($this->overviewMap !== null) {
         $ovWmsArray = $this->overviewMap->getWmsArray();
         $overviewWmsIndex = 0;
         for ($i = 0; $i < count($ovWmsArray); $i++) {
             for ($j = 0; $j < count($wmsArray); $j++) {
                 if ($ovWmsArray[$i]->equals($wmsArray[$j]) && !in_array($j, $skipWmsArray)) {
                     $overviewWmsIndex = $j;
                     $wmsIndexOverview = $i;
                     break;
                 }
             }
         }
     }
     // for all wms...
     for ($i = 0; $i < count($wmsArray); $i++) {
         if (in_array($i, $skipWmsArray)) {
             continue;
         }
         array_push($wmcJsArray, $wmsArray[$i]->createJsObjFromWMS_());
         $this->incrementLoadCount($wmsArray[$i]);
     }
     // delete existing map objects...
     //		array_push($wmcJsArray, "mb_mapObj = [];");
     // .. and add the overview map (if exists) and set map request
     if ($this->overviewMap !== null) {
         $wmcJsArray = array_merge($wmcJsArray, $this->overviewMap->toJavaScript("{wms:wms,wmsIndexOverview:" . $overviewWmsIndex . "}"));
     }
     // .. and add main map ..
     $wmcJsArray = array_merge($wmcJsArray, $this->mainMap->toJavaScript("{wms:wms,wmsIndexOverview:null}"));
     // set visibility of ov map WMS (may be different from main)
     if ($this->overviewMap !== null) {
         for ($i = 0; $i < count($ovWmsArray[$wmsIndexOverview]->objLayer); $i++) {
             $visStr = "try { Mapbender.modules['" . $this->overviewMap->getFrameName() . "'].wms[0].handleLayer(" . "'" . $ovWmsArray[$wmsIndexOverview]->objLayer[$i]->layer_name . "', " . "'visible', " . ($ovWmsArray[$wmsIndexOverview]->objLayer[$i]->gui_layer_visible ? 1 : 0) . ")} catch (e) {};";
             array_push($wmcJsArray, $visStr);
         }
         array_push($wmcJsArray, "try { Mapbender.modules['" . $this->overviewMap->getFrameName() . "'].restateLayers(" . $ovWmsArray[$wmsIndexOverview]->wms_id . ");} catch (e) {};");
     }
     // .. request the map
     array_push($wmcJsArray, "Mapbender.modules['" . $this->mainMap->getFrameName() . "'].setMapRequest();");
     if ($this->overviewMap !== null) {
         array_push($wmcJsArray, "try {Mapbender.modules['" . $this->overviewMap->getFrameName() . "'].setMapRequest()} catch (e) {};");
     }
     array_push($wmcJsArray, "eventAfterLoadWMS.trigger();");
     return $wmcJsArray;
 }
 function __toString()
 {
     $json = new Mapbender_JSON();
     return $json->encode($this->confArray);
 }
    }
    $i = 0;
    while ($row = db_fetch_array($res)) {
        $i++;
        $str .= "<label for=\"{$prefix}_wmcIsoTopicCategory_{$row[0]}\">" . "<input class=\"wmcIsoTopicCategory\" id=\"{$prefix}_wmcIsoTopicCategory_{$row[0]}\" " . "type=\"checkbox\" />{$row[1]}</label>";
    }
    return $str;
}
$originalI18nObj = array("labelNewOrOverwrite" => "New / overwrite", "labelNewWmc" => "(new WMC)", "labelName" => "Name", "labelAbstract" => "Abstract", "labelKeywords" => "Keywords", "labelCategories" => "Categories", "labelCancel" => "Abort", "labelSave" => "Save", "title" => $e_title, "labelSaveInSession" => "Save configuration");
$translatedI18nObj = array();
foreach ($originalI18nObj as $key => $value) {
    $translatedI18nObj[$key] = _mb($value);
}
$json = new Mapbender_JSON();
$saveWmcCategoryString = createIsoTopicCategoryString($e_id, $languageCode);
$originalI18nObjJson = $json->encode($originalI18nObj);
$translatedI18nObjJson = $json->encode($translatedI18nObj);
$labelNewOrOverwrite = $translatedI18nObj["labelNewOrOverwrite"];
$labelNewWmc = $translatedI18nObj["labelNewWmc"];
$labelName = $translatedI18nObj["labelName"];
$labelAbstract = $translatedI18nObj["labelAbstract"];
$labelKeywords = $translatedI18nObj["labelKeywords"];
$labelCategories = $translatedI18nObj["labelCategories"];
echo <<<HTML

var wmcSaveFormHtml = '<form><fieldset>' + 
\t'<label for="{$e_id}_wmctype">{$labelNewOrOverwrite}</label>' + 
\t'<select class="ui-corner-all" id="{$e_id}_wmctype">' + 
\t'<option value="">{$labelNewWmc}</option></select>' + 
\t'<label for="{$e_id}_wmcname">{$labelName}</label>' + 
\t'<input id="{$e_id}_wmcname" type="text" class="text ui-widget-content ui-corner-all" />' + 
 private function updateGeometry($currentNode, $geometry)
 {
     $json = new Mapbender_JSON();
     $currentNode_SimpleXML = simplexml_import_dom($currentNode);
     $currentTypeXml = mb_strtoupper($currentNode->nodeName);
     $currentTypeGeoJson = mb_strtoupper($geometry->type);
     if ($currentTypeGeoJson != $currentTypeXml) {
         $e = new mb_exception("class_kml: geometry type mismatch: geoJSON: " . $currentTypeGeoJson . "; XML: " . $currentTypeXml);
         return false;
     }
     if ($currentTypeXml == "POLYGON") {
         // GML 3
         $gmlNode = $currentNode_SimpleXML->{"exterior"}->{"LinearRing"}->{"posList"};
         $kmlNode = $currentNode_SimpleXML->{"outerBoundaryIs"}->{"LinearRing"}->{"coordinates"};
         if ($gmlNode && $gmlNode->asXML()) {
             $currentNode_SimpleXML->{"exterior"}->{"LinearRing"}->{"posList"} = preg_replace("/,/", " ", preg_replace("/\\[|\\]/", "", $json->encode($geometry->coordinates)));
         } else {
             if ($kmlNode && $kmlNode->asXML()) {
                 $currentNode_SimpleXML->{"outerBoundaryIs"}->{"LinearRing"}->{"coordinates"} = preg_replace("/\\],/", " ", preg_replace("/\\][^,]|\\[/", "", $json->encode($geometry->coordinates)));
             }
         }
     } elseif ($currentTypeXml == "POINT") {
         $gmlNode = $currentNode_SimpleXML->{"pos"};
         $kmlNode = $currentNode_SimpleXML->{"coordinates"};
         // GML 3
         if ($gmlNode && $gmlNode->asXML()) {
             $currentNode_SimpleXML->{"pos"} = preg_replace("/,/", " ", preg_replace("/\\[|\\]/", "", $json->encode($geometry->coordinates)));
         } else {
             if ($kmlNode && $kmlNode->asXML()) {
                 $currentNode_SimpleXML->{"coordinates"} = preg_replace("/\\[|\\]/", "", $json->encode($geometry->coordinates));
             }
         }
     } elseif ($currentTypeXml == "LINESTRING") {
         $gmlNode = $currentNode_SimpleXML->{"posList"};
         $kmlNode = $currentNode_SimpleXML->{"coordinates"};
         // GML 3
         if ($gmlNode && $gmlNode->asXML()) {
             $currentNode_SimpleXML->{"posList"} = preg_replace("/,/", " ", preg_replace("/\\[|\\]/", "", $json->encode($geometry->coordinates)));
         } else {
             if ($kmlNode && $kmlNode->asXML()) {
                 $currentNode_SimpleXML->{"coordinates"} = preg_replace("/\\[|\\]/", "", $json->encode($geometry->coordinates));
             }
         }
     }
     return true;
 }
$msg_obj["buttonLabelLineContinueOn"] = _mb("finish line");
$msg_obj["buttonLabelPolygonOff"] = _mb("add polygon");
$msg_obj["buttonLabelPolygonOn"] = _mb("close polygon");
$msg_obj["buttonLabelMoveBasepointOff"] = _mb("move basepoint");
$msg_obj["buttonLabelMoveBasepointOn"] = _mb("move basepoint");
$msg_obj["buttonLabelInsertBasepointOff"] = _mb("Insert basepoint");
$msg_obj["buttonLabelInsertBasepointOn"] = _mb("Insert basepoint");
$msg_obj["buttonLabelDeleteBasepointOff"] = _mb("Delete basepoint");
$msg_obj["buttonLabelDeleteBasepointOn"] = _mb("Delete basepoint");
$msg_obj["buttonLabelClearListOff"] = _mb("clear list of geometries");
$msg_obj["buttonLabelClearListOn"] = _mb("clear list of geometries");
$msg_obj["buttonLabelMergeOff"] = _mb("Merge two polygons into a single polygon (will be added to the geometry list)");
$msg_obj["buttonLabelMergeOn"] = _mb("Merge two polygons into a single polygon (will be added to the geometry list)");
$msg_obj["buttonLabelSplitOff"] = _mb("Split a polygon/line by a line (the new polygons/lines will be added to the geometry list)");
$msg_obj["buttonLabelSplitOn"] = _mb("Split a polygon/line by a line (the new polygons/lines will be added to the geometry list)");
$msg_obj["buttonLabelDifferenceOff"] = _mb("Combine two polygons (to create en- and exclave or to compute the difference)");
$msg_obj["buttonLabelDifferenceOn"] = _mb("Split geometries");
$msg_obj["buttonLabelMergeLineOff"] = _mb("Merge two lines into a single line");
$msg_obj["buttonLabelMergeLineOn"] = _mb("Merge two lines into a single line");
$msg_obj["buttonDig_wfs_title"] = _mb("save / update / delete");
$msg_obj["buttonDig_remove_title"] = _mb("remove from workspace");
$msg_obj["buttonDig_removeDb_title"] = _mb("remove from database");
$msg_obj["buttonDig_clone_title"] = _mb("clone this geometry");
$msg_obj["closePolygon_title"] = _mb("click the first basepoint to close the polygon");
$msg_obj["measureTagLabelCurrent"] = _mb("Current: ");
$msg_obj["measureTagLabelTotal"] = _mb("Total: ");
$msg_obj["digitizeDefaultGeometryName"] = _mb("new");
$json = new Mapbender_JSON();
$output = $json->encode($msg_obj);
header("Content-type:application/x-json; charset=utf-8");
echo $output;
    } else {
        echo "please specify wfs conf id.";
        die;
    }
    $obj = new WfsConf();
    $obj->load($wfsConfIdArray);
    $json = new Mapbender_JSON();
    $output = $json->encode($obj->confArray);
    echo $output;
} elseif ($command == "getWfsConfsForThisApplication") {
    // get all WFS conf IDs for this application
    $availableWfsConfIds = $user->getWfsConfByPermission(Mapbender::session()->get("mb_user_gui"));
    $obj = new WfsConf();
    $obj->load($availableWfsConfIds);
    $json = new Mapbender_JSON();
    $output = $json->encode($obj->confArray);
    echo $output;
} else {
    if ($command == "getSearchResults") {
        $wfs_conf_id = $_REQUEST["wfs_conf_id"];
        $backlink = $_REQUEST["backlink"];
        $frame = $_REQUEST["frame"];
        $filter = $_REQUEST["filter"];
        $url = $_REQUEST["url"];
        $typename = $_REQUEST["typename"];
        $destSrs = $_REQUEST["destSrs"];
        $wfsConf = WfsConfiguration::createFromDb($wfs_conf_id);
        if (is_null($wfsConf)) {
            sendErrorMessage("Invalid WFS conf: " . $wfs_conf_id);
        }
        // append authorisation condition to filter
#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_insertWmcIntoDb.php,v 1.19 2006/03/09 14:02:42 uli_rothstein Exp $
# Copyright (C) 2002 CCGIS
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once dirname(__FILE__) . "/../php/mb_validateSession.php";
require_once dirname(__FILE__) . "/../classes/class_json.php";
require_once dirname(__FILE__) . "/../classes/class_mb_exception.php";
$buttonObj = array();
$sql = "SELECT e_id, gettext(\$1, e_title) AS e_title FROM gui_element, " . "(SELECT v.var_value AS current_e_id FROM gui_element AS e, " . "gui_element_vars AS v WHERE e.e_id = v.fkey_e_id AND " . "e.fkey_gui_id = v.fkey_gui_id AND e.e_id = 'tabs' AND " . "v.var_name LIKE 'tab_ids%' AND e.fkey_gui_id = \$2) " . "AS gui_element_temp WHERE gui_element_temp.current_e_id = e_id " . "AND fkey_gui_id = \$3";
$v = array(Mapbender::session()->get("mb_lang"), Mapbender::session()->get("mb_user_gui"), Mapbender::session()->get("mb_user_gui"));
$t = array("s", "s", "s");
$res = db_prep_query($sql, $v, $t);
while ($row = db_fetch_array($res)) {
    array_push($buttonObj, array("id" => $row["e_id"], "title" => $row["e_title"]));
}
$json = new Mapbender_JSON();
$output = $json->encode($buttonObj);
header("Content-type:text/plain; charset=utf-8");
echo $output;
    echo $tagCloud->displayTagCloud();
    echo "</div>";
    echo "</body>";
    echo "</html>";
}
if ($outputFormat == 'json') {
    $tagCloudJSON = new stdClass();
    $tagCloudJSON->tagCloud = (object) array('maxFontSize' => $maxFontSize, 'maxObjects' => $maxObjects, 'tags' => array());
    shuffle($tags);
    for ($i = 0; $i < count($tags); $i++) {
        $tagCloudJSON->tagCloud->tags[$i]->title = $tags[$i]['tagname'];
        $tagCloudJSON->tagCloud->tags[$i]->url = $tags[$i]['url'];
        $tagCloudJSON->tagCloud->tags[$i]->weight = $tags[$i]['weight'];
    }
    #echo "json";
    $tagCloudJSON = $classJSON->encode($tagCloudJSON);
    echo $tagCloudJSON;
}
class tagCloud
{
    /*** the array of tags ***/
    private $tagsArray;
    public function __construct($tags)
    {
        /*** set a few properties ***/
        $this->tagsArray = $tags;
    }
    /**
     *
     * Display tag cloud
     *