From 86a5fb196793229849225ffa15823517a82ddcef Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Tue, 1 Oct 2024 16:35:01 +0200 Subject: [PATCH] Remove some code related to QGIS < 3.0 --- .../lizmap/lib/Project/QgisProject.php | 76 ++++--------------- 1 file changed, 14 insertions(+), 62 deletions(-) diff --git a/lizmap/modules/lizmap/lib/Project/QgisProject.php b/lizmap/modules/lizmap/lib/Project/QgisProject.php index c48fecb155..a4ee34469e 100644 --- a/lizmap/modules/lizmap/lib/Project/QgisProject.php +++ b/lizmap/modules/lizmap/lib/Project/QgisProject.php @@ -1122,69 +1122,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; } }