} catch (MapFile\Exception $e) { $error = $e->getMessage(); } } else { if ($mapscript && isset($_POST['action']) && $_POST['action'] == 'save-class') { try { $map = new mapObj($mapfile); $l = $map->getLayer(intval($_GET['layer'])); if (isset($_POST['class'])) { $c = $l->getClass(intval($_POST['class'])); } else { $c = new classObj($l); } $c->name = $_POST['name']; $c->setExpression($_POST['expression']); $c->free(); unset($c); $l->free(); unset($l); $map->save($mapfile); $map->free(); unset($map); header('Location: layer-class.php?layer=' . $_GET['layer']); exit; } catch (MapScriptException $e) { $error = $e->getMessage(); } } else { if (isset($_POST['action']) && $_POST['action'] == 'save-class') { try { $map = new MapFile\Map($mapfile);
if (isset($_label['color']) && !empty($_label['color']) && array_sum($_label['color']) >= 0) { $label->color->setRGB($_label['color']['r'], $_label['color']['g'], $_label['color']['b']); } if (isset($_label['outlinecolor']) && !empty($_label['outlinecolor']) && array_sum($_label['outlinecolor']) >= 0) { $label->outlinecolor->setRGB($_label['outlinecolor']['r'], $_label['outlinecolor']['g'], $_label['outlinecolor']['b']); } if (isset($_label['minscaledenom']) && strlen($_label['minscaledenom']) > 0) { $label->minscaledenom = floatval($_label['minscaledenom']); } if (isset($_label['maxscaledenom']) && strlen($_label['maxscaledenom']) > 0) { $label->maxscaledenom = floatval($_label['maxscaledenom']); } $label->free(); unset($label); } $class->free(); unset($class); } } for ($i = 0; $i < $layer->numclasses; $i++) { if (!isset($_layer['class'][$i]) || empty($_layer['class'][$i])) { $layer->removeClass($i); } } $layer->free(); unset($layer); } } for ($i = 0; $i < $map->numlayers; $i++) { if (!isset($_POST['layers'][$i]) || empty($_POST['layers'][$i])) { $map->removeLayer($i);