}
  	return true;
  }
</script>
    
</head>
<body>
Gazetteer Configuration<br>
<form method='POST' onsubmit='return validate()'>

<?php 
echo "<input type='hidden' name='gui' value='" . $_REQUEST["gui"] . "'>";
echo "<input type='hidden' name='wms' value='" . $_REQUEST["wms"] . "'>";
echo "<input type='hidden' name='layer' value='" . $_REQUEST["layer"] . "'>";
$aWFS = new wfs_conf();
$aWFS->getallwfs();
/* save gazetteer properties */
if (isset($_REQUEST["save"])) {
    $sql = "UPDATE gui_layer SET gui_layer_wfs_featuretype = \$1 ";
    $sql .= "WHERE fkey_gui_id = \$2 AND fkey_layer_id = \$3";
    $v = array($_REQUEST["myWFS"], $_REQUEST["gui"], $_REQUEST["layer"]);
    $t = array("s", "s", "i");
    $res = db_prep_query($sql, $v, $t);
    echo "layer is connected with: " . $_REQUEST["myWFS"];
    die;
}
/* end save gazetteer properties */
/* select wfs */
if (isset($_REQUEST["wfs"]) && $_REQUEST["wfs"] == "") {
    unset($_REQUEST["wfs"]);
    unset($_REQUEST["featuretype"]);
     if ($wfsConfIds === null) {
         $wfsConfIds = array();
     }
     $result = array();
     foreach ($wfsConfIds as $id) {
         $currentWfsConf = WfsConfiguration::createFromDb($id);
         if ($currentWfsConf !== null) {
             $result[] = $currentWfsConf;
         }
     }
     $ajaxResponse->setResult($result);
     $ajaxResponse->send();
     break;
 case "getWfs":
     $aWFS = new wfs_conf();
     $aWFS->getallwfs(Mapbender::session()->get("mb_user_id"));
     $result = array();
     for ($i = 0; $i < count($aWFS->wfs_id); $i++) {
         // featuretypes
         $featuretypeArray = array();
         $aWFS->getfeatures($aWFS->wfs_id[$i]);
         for ($j = 0; $j < count($aWFS->features->featuretype_id); $j++) {
             // featuretype elements
             $ftElementArray = array();
             $aWFS->getelements($aWFS->features->featuretype_id[$j]);
             for ($k = 0; $k < count($aWFS->elements->element_id); $k++) {
                 $ftElementArray[] = array("id" => $aWFS->elements->element_id[$k], "name" => $aWFS->elements->element_name[$k], "type" => $aWFS->elements->element_type[$k]);
             }
             $featuretypeArray[] = array("id" => $aWFS->features->featuretype_id[$j], "name" => $aWFS->features->featuretype_name[$j], "srs" => $aWFS->features->featuretype_srs[$j], "elementArray" => $ftElementArray);
         }
         $result[] = array("id" => $aWFS->wfs_id[$i], "name" => $aWFS->wfs_name[$i], "title" => $aWFS->wfs_title[$i], "abstr" => $aWFS->wfs_abstract[$i], "getCapabilities" => $aWFS->wfs_getcapabilities[$i], "describeFeaturetype" => $aWFS->wfs_describefeaturetype[$i], "getFeature" => $aWFS->wfs_getfeature[$i], "featuretypeArray" => $featuretypeArray);