function request() { global $app; $httprequest = new Phalcon\Http\Request(); $datain = $httprequest->get(); $data = array(); foreach ($datain as $key => $value) { $data[strtolower($key)] = $value; } $filter = new \Phalcon\Filter(); $request = $filter->sanitize($data["request"], array("string", "lower")); $response = null; switch ($request) { case "getcapabilities": $response = getCapabilities(); break; case "describefeaturetype": $response = describeFeatureType($data); break; case "getfeatures": $response = getFeatures($data); break; case "delete": $response = delete($data); break; case "create": $response = create($data); break; case "update": $response = update($data); break; case "transaction": $response = transaction($data); break; /* For grouping*/ /* For grouping*/ case "getassoclayers": $response = getAssocLayers($data); break; case "getgrouping": $response = getGrouping($data); break; case "describegrouping": $response = describeGrouping($data); break; case "creategrouping": $response = createGrouping($data); break; case "updategrouping": $response = updateGrouping($data); break; case "deletegrouping": $response = deleteGrouping($data); break; case "getFeaturesFk": $response = getFeaturesFk($data); break; case "duplicategrouping": $response = duplicateGrouping($data); break; case "associatedocument": $response = associateDocument($data); break; case "deletedocument": $response = deleteDocument($data); break; case "downloaddocument": $response = downloadDocument($data); echo $response; break; case "getdocumentlist": $response = getDocumentList($data); break; case "getdocumentdescription": $response = getDocumentDescription($data); break; default: $response = false; break; } $app->response->setContentType('application/json; charset=UTF-8')->sendHeaders(); echo json_encode($response); }
/** * Get the layers associated to the grouping to select them in the user interface * @param object $grouping object of the grouping * @return object of result * @throws Exception */ public function getAssociatedLayers($grouping) { $tabValue = array(); $columnTypes = array(); if (!$this->isAuthenticated()) { return $this->getAuthenticationErrorMessage(); } //Colonne associée au type de regroupement $attrGroupType = $this->getGroupingTypeName(); //Nom de la table $table = $this->getTableAssociationName(); //Colonne du nom du service $attrLayer = $this->getGroupingAttribLayer(); array_push($tabValue, $grouping[$attrGroupType]); $strCol = $attrGroupType; array_push($columnTypes, 2); $sql = "SELECT {$attrLayer} FROM {$table} WHERE {$strCol} = ?"; //Condition pour obtenir seulement les couches actives à l'édition if ($this->getActiveServiceCondition()) { $sql .= " AND {$this->getActiveServiceCondition()}"; } $config = $this->getDi()->get("config"); if ($config->application->debug == true) { error_log($sql); } $connection = $this->getConnection(); $result = $connection->query($sql, $tabValue, $columnTypes); $result->setFetchMode(\Phalcon\Db::FETCH_ASSOC); if (!$result) { throw new Exception('Database error'); } $i = 0; while ($r = $result->fetch()) { $arrLayers[$i]["layer"] = $r[$attrLayer]; $arrLayers[$i]["fk"] = $grouping[$this->getIdentifier()]; $arrLayers[$i]["describe"] = describeFeatureType($arrLayers[$i]); $arrLayers[$i]["data"] = getFeaturesFk($arrLayers[$i]); $arrLayers[$i]["title"] = getTitleDescription($arrLayers[$i]); $arrLayers[$i]["associatedLayers"] = getAssociatedLayersInformation($arrLayers[$i]); $arrLayers[$i]["label"] = getLabelNameInformation($arrLayers[$i]); $i++; } return $arrLayers; }