Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release_3_9] Remove some code related to QGIS < 3.0 #4882

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 14 additions & 62 deletions lizmap/modules/lizmap/lib/Project/QgisProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -1128,69 +1128,21 @@ public function readAttributeLayers($attributeLayers)
public function readLayersOrder($xml, $layers)
{
$layersOrder = array();
if ($this->qgisProjectVersion >= 30000) { // For QGIS >=3.0, custom-order is in layer-tree-group
$customOrder = $this->getXml()->xpath('layer-tree-group/custom-order');
if (count($customOrder) == 0) {
return $layersOrder;
}
$customOrderZero = $customOrder[0];
if (intval($customOrderZero->attributes()->enabled) == 1) {
$items = $customOrderZero->xpath('//item');
$lo = 0;
foreach ($items as $layerI) {
// Get layer name from config instead of XML for possible embedded layers
$name = $this->getLayerNameByIdFromConfig($layerI, $layers);
if ($name) {
$layersOrder[$name] = $lo;
}
++$lo;
}
} else {
return $layersOrder;
}
} elseif ($this->qgisProjectVersion >= 20400) { // For QGIS >=2.4, new item layer-tree-canvas
$customOrder = $this->getXml()->xpath('//layer-tree-canvas/custom-order');
if (count($customOrder) == 0) {
return $layersOrder;
}
$customOrderZero = $customOrder[0];
if (intval($customOrderZero->attributes()->enabled) == 1) {
$items = $customOrderZero->xpath('//item');
$lo = 0;
foreach ($items as $layerI) {
// Get layer name from config instead of XML for possible embedded layers
$name = $this->getLayerNameByIdFromConfig($layerI, $layers);
if ($name) {
$layersOrder[$name] = $lo;
}
++$lo;
}
} else {
$items = $this->getXml()->xpath('layer-tree-group//layer-tree-layer');
$lo = 0;
foreach ($items as $layerTree) {
// Get layer name from config instead of XML for possible embedded layers
$name = $this->getLayerNameByIdFromConfig($layerTree->attributes()->id, $layers);
if ($name) {
$layersOrder[$name] = $lo;
}
++$lo;
}
}
} else {
$legend = $this->getXml()->xpath('//legend');
if (count($legend) == 0) {
return $layersOrder;
}
$legendZero = $legend[0];
$updateDrawingOrder = (string) $legendZero->attributes()->updateDrawingOrder;
if ($updateDrawingOrder == 'false') {
$layers = $this->getXml()->xpath('//legendlayer');
foreach ($layers as $layer) {
if ($layer->attributes()->drawingOrder && intval($layer->attributes()->drawingOrder) >= 0) {
$layersOrder[(string) $layer->attributes()->name] = (int) $layer->attributes()->drawingOrder;
}
$customOrder = $this->getXml()->xpath('layer-tree-group/custom-order');
if (count($customOrder) == 0) {
return $layersOrder;
}
$customOrderZero = $customOrder[0];
if (intval($customOrderZero->attributes()->enabled) == 1) {
$items = $customOrderZero->xpath('//item');
$lo = 0;
foreach ($items as $layerI) {
// Get layer name from config instead of XML for possible embedded layers
$name = $this->getLayerNameByIdFromConfig($layerI, $layers);
if ($name) {
$layersOrder[$name] = $lo;
}
++$lo;
}
}

Expand Down
Loading