/** * CREATES HTML LEGEND FOR PRINT OUTPUT */ function writePrintLegendHTML() { $layerView = new LayerView($this->map, true, true, $this->scale); $grouplist = $layerView->getGroupList(); $icoW = $_SESSION["icoW"]; // Width in pixels $icoH = $_SESSION["icoH"]; // Height in pixels $html = "<table class=\"print_legendtable\"> \n"; foreach ($grouplist as $grp) { // Only 1 class for Layer -> 1 Symbol for Group $classList = $grp['classList']; $numcls = count($classList); if ($numcls == 1) { $iconUrl = $classList[0]['iconUrl']; $html .= "<tr>"; $html .= "<th><img src=\"{$iconUrl}\" width=\"{$icoW}\" height=\"{$icoH}\" alt=\"ico\" /></th>"; $html .= "<th style=\"width:100%\" colspan=\"3\">" . $grp['description'] . "</th>"; $html .= "</tr> \n"; // More than 2 classes for Group -> symbol for *every* class } elseif ($numcls > 1) { $html .= "\n <tr><th colspan=\"4\">" . $grp['description'] . "</th></tr> \n"; $clscnt = 0; foreach ($classList as $cls) { $clsName = $cls['name']; $iconUrl = $cls['iconUrl']; $html .= $clscnt % 2 ? "" : "<tr>"; $html .= "<td style=\"width:{$icoW}\"><img src=\"{$iconUrl}\" width=\"{$icoW}\" height=\"{$icoH}\" alt=\"ico\" /> </td>"; $html .= "<td>{$clsName}</td> "; if ($clscnt % 2) { // after printing RIGHT column $html .= " </tr> \n"; } else { // after printing LEFT column if ($clscnt == $numcls - 1) { // Begin new group when number of printed classes equals total class number $html .= "<td></td></tr> \n"; } else { // Continue in same group, add only new class item } } $clscnt++; } } } $html .= "</table> \n"; return $html; }
* p.mapper is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. See the COPYING file. * * p.mapper is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with p.mapper; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ******************************************************************************/ require_once "../group.php"; require_once "../pmsession.php"; require_once "../common.php"; require_once "../globals.php"; require_once "../layerview.php"; $categories = $_SESSION['useCategories'] ? $_SESSION['categories'] : false; $layerView = new LayerView($map, $categories, false); $groupList = json_encode($layerView->getGroupList()); pm_logDebug(3, $groupList, "Group list: "); //$categoryList = $layerView->getCategoryList(); //pm_logDebug(3, $categoryList, "category List: "); //$groupList = $layerView->getGroupNameList(); //pm_logDebug(3, $groupList, "Group list: "); header("Content-Type: text/plain; charset={$defCharset}"); // return JS object literals "{}" for XMLHTTP request echo "{\"groupList\":{$groupList}}";
/** * Create HTML output for groups * @return string */ public function writeGroups($groupList = false) { if ($groupList == false) { $layerView = new LayerView($this->map, false, false); $groupList = $layerView->getGroupList(); } $html = "<ul>"; foreach ($groupList as $grp) { $grpName = $grp['name']; //$grpDescr = addslashes($grp['description']); $grpDescr = $grp['description']; $classList = $grp['classList']; $numcls = count($classList); $html .= "<li id=\"ligrp_{$grpName}\" class=\"tocgrp\">"; $html .= "<input type=\"checkbox\" name=\"groupscbx\" value=\"{$grpName}\" id=\"ginput_{$grpName}\"/>"; $html .= "<span class=\"vis\" id=\"spxg_{$grpName}\"><span class=\"grp-title\">{$grpDescr}</span></span>"; // Add classes if ($numcls > 0 && $this->legendStyle == "attached") { $html .= $this->writeClasses($grpName, $classList); } $html .= "</li>"; } $html .= "</ul>"; //error_log($html); return $html; }