Skip to content

Commit

Permalink
Merge pull request #4882 from 3liz/backport-4824-to-release_3_9
Browse files Browse the repository at this point in the history
[Backport release_3_9] Remove some code related to QGIS < 3.0
  • Loading branch information
Gustry authored Oct 17, 2024
2 parents 545811a + 8af4c1c commit 0ae0464
Showing 1 changed file with 14 additions and 62 deletions.
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

0 comments on commit 0ae0464

Please sign in to comment.