Skip to content

Commit

Permalink
Continue
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Dec 20, 2024
1 parent abd34de commit 44db452
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lizmap/modules/dataviz/classes/datavizPlot.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public function fetchData($method = 'wfs', $exp_filter = '')
$features = null;

// Check code
if (floor($wfsresponse->getCode() / 100) >= 4) {
if ($wfsresponse->getCode() >= 400) {
return false;
}
// Check mime/type
Expand Down
19 changes: 1 addition & 18 deletions lizmap/modules/lizmap/classes/qgisVectorLayer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ public function isFeatureEditable($feature)
$result = $wfsRequest->process();

// Check code
if (floor($result->getCode() / 100) >= 4) {
if ($result->getCode() >= 400) {
return true;
}

Expand All @@ -1143,23 +1143,6 @@ public function isFeatureEditable($feature)
}

return true;
/*
// Get data
$wfsData = $result->getBodyAsString();
// Check data: if there is no data returned by WFS, the user has not access to it
if (!$wfsData) {
return true;
}
// Get data from layer
$wfsData = json_decode($wfsData);
if (count($wfsData->features) !== 1) {
return false;
}
return true;
*/
}

/**
Expand Down
8 changes: 4 additions & 4 deletions lizmap/modules/lizmap/lib/Form/QgisForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -1777,14 +1777,14 @@ protected function PerformWfsRequest($wfsRequest, $formControl, $referencedField
// Perform request
$result = $wfsRequest->process();

$wfsData = $result->getBodyAsString();
$code = $result->getCode();
$mime = $result->getMime();

// Used data
if ($wfsData && !in_array(strtolower($mime), array('text/html', 'text/xml'))) {
$wfsData = json_decode($wfsData);
if ($code < 400 && !in_array(strtolower($mime), array('text/html', 'text/xml'))) {
// Get data from layer
$features = $wfsData->features;
$featureStream = Psr7\StreamWrapper::getResource($result->getBodyAsStream());
$features = \JsonMachine\Items::fromStream($featureStream, array('pointer' => '/features'));
$data = array();
foreach ($features as $feat) {
if (property_exists($feat, 'properties')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,12 @@ public function getData($form)
// Process request
$wfsResult = $wfsRequest->process();

// $data = $wfsResult->getBodyAsString();
$code = $wfsResult->getCode();
$mime = $wfsResult->getMime();

if (strpos($mime, 'text/json') === 0
|| strpos($mime, 'application/json') === 0
|| strpos($mime, 'application/vnd.geo+json') === 0) {
/*$json = json_decode($data);
// Get result from json
$features = $json->features;*/
if ($code < 400 && (strpos($mime, 'text/json') === 0
|| strpos($mime, 'application/json') === 0
|| strpos($mime, 'application/vnd.geo+json') === 0)) {

$featureStream = Psr7\StreamWrapper::getResource($wfsResult->getBodyAsStream());
$features = \JsonMachine\Items::fromStream($featureStream, array('pointer' => '/features'));
Expand Down

0 comments on commit 44db452

Please sign in to comment.