[Nagvis-checkins] SF.net Git: nagvis: Reimplemented "to static map" functionality
Brought to you by:
larsi-
From: lars <la...@us...> - 2012-03-17 20:18:39
|
Author: Lars Michelsen <lm...@la...> Date: Sat Mar 17 21:06:06 2012 +0100 Committer: Lars Michelsen <lm...@la...> Commit-Date: Sat Mar 17 21:06:06 2012 +0100 Reimplemented "to static map" functionality --- TODO | 1 - share/server/core/classes/CoreModMap.php | 60 +++++++++++++++------------- share/server/core/classes/GlobalMapCfg.php | 5 ++- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/TODO b/TODO index ce08af0..d15885c 100644 --- a/TODO +++ b/TODO @@ -11,7 +11,6 @@ Zu tun: - Speichern testen (Nur nötigste Attribute schreiben) - Werden die korrekt übernommen? - margin abziehen? - - Export To Map umziehen - Geomap: - Max. resolution (limit of OSM/API?) - bbox Limit? diff --git a/share/server/core/classes/CoreModMap.php b/share/server/core/classes/CoreModMap.php index f71343c..be6b277 100644 --- a/share/server/core/classes/CoreModMap.php +++ b/share/server/core/classes/CoreModMap.php @@ -271,7 +271,7 @@ class CoreModMap extends CoreModule { // Is called on form submission $this->toStaticMap(); } else { - $VIEW = new NagVisViewtoStaticMap($this->CORE); + $VIEW = new NagVisViewToStaticMap($this->CORE); $sReturn = json_encode(Array('code' => $VIEW->parse())); } break; @@ -283,35 +283,39 @@ class CoreModMap extends CoreModule { /** * Converts maps using sources to static maps - * FIXME: Not implemented yet */ private function toStaticMap() { - throw new NagVisException(l('Needs to be migrated.')); -// $MAPCFG = new NagVisAutomapCfg($this->CORE, $this->name); -// $MAPCFG->readMapConfig(); -// -// $MAP = new NagVisAutoMap($this->CORE, $MAPCFG, false, IS_VIEW); -// -// if($this->sAction == 'parseAutomap') { -// $MAP->renderMap(); -// return json_encode(true); -// } else { -// $FHANDLER = new CoreRequestHandler($_POST); -// if($FHANDLER->match('target', MATCH_MAP_NAME)) { -// $target = $FHANDLER->get('target'); -// -// if($MAP->toClassicMap($target)) { -// throw new Success(l('The map has been created.'), -// null, -// 1, -// cfg('paths','htmlbase').'/frontend/nagvis-js/index.php?mod=Map&show='.$target); -// } else { -// throw new NagVisException(l('Unable to create map configuration file.')); -// } -// } else { -// throw new NagVisException(l('Invalid target option given.')); -// } -// } + $FHANDLER = new CoreRequestHandler($_POST); + if(!$FHANDLER->match('target', MATCH_MAP_NAME)) { + throw new NagVisException(l('Invalid target option given.')); + } + + $target = $FHANDLER->get('target'); + // "true" negates the check + $this->verifyMapExists($target, true); + + // Read the old config + $this->verifyMapExists($this->name); + $MAPCFG = new GlobalMapCfg($this->CORE, $this->name); + $MAPCFG->readMapConfig(); + + // Create a new map config + $NEW = new GlobalMapCfg($this->CORE, $target); + $NEW->createMapConfig(); + foreach($MAPCFG->getMapObjects() AS $object_id => $cfg) { + // Remove "sources" from the global section. Cause this makes the maps dynamic + if($cfg['type'] == 'global') { + unset($cfg['sources']); + } + $NEW->addElement($cfg['type'], $cfg, $perm = true, $object_id); + } + + throw new Success( + l('The map has been created.'), + null, + 1, + cfg('paths','htmlbase').'/frontend/nagvis-js/index.php?mod=Map&show='.$target + ); } diff --git a/share/server/core/classes/GlobalMapCfg.php b/share/server/core/classes/GlobalMapCfg.php index a77475d..7b9b0a5 100644 --- a/share/server/core/classes/GlobalMapCfg.php +++ b/share/server/core/classes/GlobalMapCfg.php @@ -1112,7 +1112,10 @@ class GlobalMapCfg { foreach($keys AS $key) if($key !== 'type' && isset($this->mapConfig[$id][$key]) && $this->mapConfig[$id][$key] !== '') - $a[] = $key.'='.$this->mapConfig[$id][$key]."\n"; + if(is_array($this->mapConfig[$id][$key])) + $a[] = $key.'='.implode(',', $this->mapConfig[$id][$key])."\n"; + else + $a[] = $key.'='.$this->mapConfig[$id][$key]."\n"; $a[] = "}\n"; $a[] = "\n"; |