map = $map; $this->categories = $categories; $this->legendonly = $legendonly; $this->legPath = "images/legend/"; //$this->mutualDisableList = $_SESSION['mutualDisableList']; $this->catStyle = $_SESSION["catStyle"]; $this->grpStyle = $_SESSION["grpStyle"]; $this->legStyle = $_SESSION["legStyle"]; $this->grouplist = $_SESSION["grouplist"]; $this->defGroups = $_SESSION["defGroups"]; $this->allGroups = $_SESSION["allGroups"]; $this->icoW = $_SESSION["icoW"]; // Width in pixels $this->icoH = $_SESSION["icoH"]; // Height in pixels $this->imgFormat = $_SESSION["imgFormat"]; $this->scaleLayers = $_SESSION["scaleLayers"]; $this->scale = $_SESSION['geo_scale']; // GET LAYERS FOR DRAWING AND IDENTIFY if (isset ($_SESSION["groups"]) && count($_SESSION["groups"]) > 0){ $this->groups = $_SESSION["groups"]; } else { $this->groups = $this->defGroups; } } function writeToc() { // Legend style POPUP: add 'show' button if ($this->legStyle == "popup" && !$this->legendonly) { $toc .= $this->printButton(_p("Show Legend"), "showPopupLegend()"); } // Legend stle SWAP: add 'show' button if ($this->legStyle == "swap") { if (!$this->legendonly) { $toc .= $this->printButton(_p("Show Legend"), "swapToLegendView()"); } else { $toc .= $this->printButton(_p("Show Layers"), "swapToLayerView()"); } } $tabclass = $this->legendonly ? "class=\"legtab\"" : ""; $catW = $this->legStyle == "attached" ? "100" : "98"; $toc .= ""; // using CATEGORIES if ($this->categories && !$this->legendonly) { $toc .= $this->_printCategory(); // NO categories } else { foreach ($this->grouplist as $grp){ if ($this->legendonly) { if (in_array($grp->getGroupName(), $this->groups) && $this->checkGroup($this->map, $grp, $this->scale)) { $toc .= $this->_printGroup($grp); } } else { $toc .= $this->_printGroup($grp); } } } $toc .= "
"; // Add dummy image for onLoad event to initialize tree or reset checkboxes of groups if ((($this->grpStyle == "tree" && $this->legStyle == "attached") || $this->catStyle == "tree" ) && !$this->legendonly) { $toc .= ""; } elseif (!$this->legendonly) { $toc .= ""; } return $toc; } function printButton($value, $jsFunction) { $bstr = "
"; $bstr .= "categories as $cat=>$catL) { $catDescr = addslashes(_p($cat)); $cstr .= ""; // Add open/close icon for TREE style if ($this->catStyle == "tree") { $cstr .= "\"*\""; } $cstr .= ""; // Add open/close HREF for TREE style if ($this->catStyle == "tree") { $cstr .= "$catDescr"; } else { $cstr .= "$catDescr"; } $cstr .= ""; $cstr .= ""; $cstr .= ""; $cstr .= ""; $cstr .= "
"; $cstr .= ""; foreach ($this->grouplist as $grp){ if (in_array($grp->groupName, $catL, TRUE)) { $cstr .= $this->_printGroup($grp); } } $cstr .= "
"; } return $cstr; } function _printGroup($grp) { $grpName = $grp->getGroupName(); $grpDescr = addslashes($grp->getDescription()); $glayerList = $grp->getLayers(); // Settings for groups with raster layer without classes $ltype = 0; $numClassesGrp = 0; foreach ($glayerList as $glayer) { $skipLegend = $glayer->getSkipLegend(); $numClassesGrp += count($glayer->getClasses()); $legLayer = $this->map->getLayer($glayer->getLayerIdx()); //if ($legLayer->getMetadata("LEGENDICON")) $numClassesGrp += 1; } $gstr .= ""; // Add open/close IMG icon for TREE style if ($this->grpStyle == "tree" && $this->legStyle == "attached" && !$this->legendonly) { $ocImg = $numClassesGrp > 0 ? "plus" : "empty"; //error_log("$grpName $ocImg"); $gstr .= "\"*\""; } // Add if (!$this->legendonly) { $gstr .= ""; $grpcolspan = ""; } else { $grpcolspan = " colspan=\"2\""; } // Add open/close HREF for TREE style $gstr .= ""; if ($this->grpStyle == "tree" && $this->legStyle == "attached" && !$this->legendonly && $numClassesGrp > 0) { $gstr .= "$grpDescr"; } else { $gstr .= "$grpDescr"; } $gstr .= ""; $gstr .= ""; // Create CLASS entries for all LAYERS if ($this->legStyle == "attached" || $this->legendonly) { if (!$this->legendonly && $numClassesGrp > 0) { // If not only legend and if group has classes: add DIV for tree $colspan = ($this->grpStyle == "tree" ? 2 : 1); $gstr .= ""; $gstr .= ""; $gstr .= ""; $gstr .= "
"; $gstr .= ""; } $count = 0; foreach ($glayerList as $glayer) { $legLayer = $this->map->getLayer($glayer->getLayerIdx()); $legLayerName = $legLayer->name; $legLayerType = $legLayer->type; $legIconPath = $legLayer->getMetadata("LEGENDICON"); $skipLegend = $glayer->getSkipLegend(); $numClassesLay = count($glayer->getClasses()); // All layers but RASTER layers WITHOUT class definitions if ((($legLayer->type < 3 && $skipLegend < 1) || $numClassesLay > 0) && $skipLegend != 2) { $classes = $glayer->getClasses(); $clno = 0; foreach ($classes as $cl) { $icoUrl = $this->legPath.$legLayerName.'_i'.$clno.'.'.$this->imgFormat; $gstr .= ""; $gstr .= ""; $gstr .= ""; $gstr .= " "; $clno++; } $totalClno += $clno; // used for condition adding group to 'mainNodes' JS array (see below) } $count++; } if (!$this->legendonly && $numClassesGrp > 0) $gstr .= "
icoW . "px\">\"legend\"icoW\" height=\"$this->icoH\" /> " . addslashes($cl) . "
"; } return $gstr; } // CHECK IF GROUP HAS VISIBLE LAYER AT CURRENT SCALE function checkGroup($map, $grp, $scale) { $printGroup = 0; $glayerList = $grp->getLayers(); foreach ($glayerList as $glayer) { $tocLayer = $map->getLayer($glayer->getLayerIdx()); if ((checkScale($map, $tocLayer, $scale) == 1) && $tocLayer->type != 5) { $printGroup = 1; } } return $printGroup; } } function writeJSArrays() { $mutualDisableList = $_SESSION['mutualDisableList']; if (count($mutualDisableList) > 0) { $js_array = "var mutualDisableList = ['" . implode("','", $mutualDisableList) . "'];"; } else { $js_array = "var mutualDisableList = false;"; } if (isset($_SESSION["groups"]) && count($_SESSION["groups"]) > 0) { $defGroups = $_SESSION["groups"]; }else{ $defGroups = $_SESSION["defGroups"]; } $js_array .= "\nvar defGroupList = ['ginput_" . implode("','ginput_", $defGroups) . "'];"; return $js_array; } ?>