Module: nagvis
Branch: master
Commit: 10d886bda3f802086de9e034416d615d407d1778
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis/commit/?id=10d886bda3f802086de9e034416d615d407d1778

Author: Roman Kyrylych <[email protected]>
Date:   Tue Aug 25 19:03:33 2009 +0300

gmap: Load XML files from etc/geomap directory

Signed-off-by: Roman Kyrylych <[email protected]>

---

 share/netmap/LinkService.php      |   18 +++++++++---------
 share/netmap/LocationService.php  |   18 +++++++++---------
 share/netmap/SettingsService.php  |    8 ++++----
 share/netmap/ViewpointService.php |   10 +++++-----
 share/netmap/amf-server.php       |    2 ++
 5 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/share/netmap/LinkService.php b/share/netmap/LinkService.php
index 976f4c6..ca9e843 100644
--- a/share/netmap/LinkService.php
+++ b/share/netmap/LinkService.php
@@ -62,7 +62,7 @@ class LinkService
        private function createFile()
        {
                $xml = '<?xml version="1.0" standalone="yes" ?><links/>';
-               if (file_put_contents('links.xml', $xml) === FALSE)
+               if (file_put_contents($config_path . 'links.xml', $xml) === 
FALSE)
                        throw new Exception('Could not create links.xml');
        }
 
@@ -72,10 +72,10 @@ class LinkService
         */
        public function getAll($problemonly = false)
        {
-               if (!file_exists('links.xml'))
+               if (!file_exists($config_path . 'links.xml'))
                        self::createFile();
 
-               if (($xml = @simplexml_load_file('links.xml')) === FALSE)
+               if (($xml = @simplexml_load_file($config_path . 'links.xml')) 
=== FALSE)
                        throw new Exception('Could not read links.xml');
 
                $links = array();
@@ -103,13 +103,13 @@ class LinkService
                $link->id = uniqid('', true);
                self::validate($link);
 
-               if (($xml = @simplexml_load_file('links.xml')) === FALSE)
+               if (($xml = @simplexml_load_file($config_path . 'links.xml')) 
=== FALSE)
                        throw new Exception('Could not read links.xml');
 
                self::updateState($link);
                $node = $link->toXML($xml);
 
-               if (file_put_contents('links.xml', $xml->asXML()) !== FALSE)
+               if (file_put_contents($config_path . 'links.xml', 
$xml->asXML()) !== FALSE)
                        return $link;
                else
                        throw new Exception('Could not write links.xml');
@@ -141,7 +141,7 @@ class LinkService
        {
                self::validate($link);
 
-               if (($xml = @simplexml_load_file('links.xml')) === FALSE)
+               if (($xml = @simplexml_load_file($config_path . 'links.xml')) 
=== FALSE)
                        throw new Exception('Could not read links.xml');
 
                self::updateState($link);
@@ -150,7 +150,7 @@ class LinkService
 
                $link->toXML($xml);
 
-               if (file_put_contents('links.xml', $xml->asXML()) !== FALSE)
+               if (file_put_contents($config_path . 'links.xml', 
$xml->asXML()) !== FALSE)
                        return $link;
                else
                        throw new Exception('Could not write links.xml');
@@ -162,12 +162,12 @@ class LinkService
         */
        public function remove($id)
        {
-               if (($xml = @simplexml_load_file('links.xml')) === FALSE)
+               if (($xml = @simplexml_load_file($config_path . 'links.xml')) 
=== FALSE)
                        throw new Exception('Could not read links.xml');
 
                self::removeNode($xml, $id);
 
-               if (file_put_contents('links.xml', $xml->asXML()) !== FALSE)
+               if (file_put_contents($config_path . 'links.xml', 
$xml->asXML()) !== FALSE)
                        return $id;
                else
                        throw new Exception('Could not write links.xml');
diff --git a/share/netmap/LocationService.php b/share/netmap/LocationService.php
index 3c78a6a..49009de 100644
--- a/share/netmap/LocationService.php
+++ b/share/netmap/LocationService.php
@@ -62,7 +62,7 @@ class LocationService
        private function createFile()
        {
                $xml = '<?xml version="1.0" standalone="yes" ?><locations/>';
-               if (file_put_contents('locations.xml', $xml) === FALSE)
+               if (file_put_contents($config_path . 'locations.xml', $xml) === 
FALSE)
                        throw new Exception('Could not create locations.xml');
        }
 
@@ -72,10 +72,10 @@ class LocationService
         */
        public function getAll($problemonly = false)
        {
-               if (!file_exists('locations.xml'))
+               if (!file_exists($config_path . 'locations.xml'))
                        self::createFile();
 
-               if (($xml = @simplexml_load_file('locations.xml')) === FALSE)
+               if (($xml = @simplexml_load_file($config_path . 
'locations.xml')) === FALSE)
                        throw new Exception('Could not read locations.xml');
 
                $locations = array();
@@ -103,13 +103,13 @@ class LocationService
                $location->id = uniqid('', true);
                self::validate($location);
 
-               if (($xml = @simplexml_load_file('locations.xml')) === FALSE)
+               if (($xml = @simplexml_load_file($config_path . 
'locations.xml')) === FALSE)
                        throw new Exception('Could not read locations.xml');
 
                self::updateState($location);
                $node = $location->toXML($xml);
 
-               if (file_put_contents('locations.xml', $xml->asXML()) !== FALSE)
+               if (file_put_contents($config_path . 'locations.xml', 
$xml->asXML()) !== FALSE)
                        return $location;
                else
                        throw new Exception('Could not write locations.xml');
@@ -141,7 +141,7 @@ class LocationService
        {
                self::validate($location);
 
-               if (($xml = @simplexml_load_file('locations.xml')) === FALSE)
+               if (($xml = @simplexml_load_file($config_path . 
'locations.xml')) === FALSE)
                        throw new Exception('Could not read locations.xml');
 
                self::updateState($location);
@@ -150,7 +150,7 @@ class LocationService
 
                $location->toXML($xml);
 
-               if (file_put_contents('locations.xml', $xml->asXML()) !== FALSE)
+               if (file_put_contents($config_path . 'locations.xml', 
$xml->asXML()) !== FALSE)
                        return $location;
                else
                        throw new Exception('Could not write locations.xml');
@@ -162,12 +162,12 @@ class LocationService
         */
        public function remove($id)
        {
-               if (($xml = @simplexml_load_file('locations.xml')) === FALSE)
+               if (($xml = @simplexml_load_file($config_path . 
'locations.xml')) === FALSE)
                        throw new Exception('Could not read locations.xml');
 
                self::removeNode($xml, $id);
 
-               if (file_put_contents('locations.xml', $xml->asXML()) !== FALSE)
+               if (file_put_contents($config_path . 'locations.xml', 
$xml->asXML()) !== FALSE)
                        return $id;
                else
                        throw new Exception('Could not write locations.xml');
diff --git a/share/netmap/SettingsService.php b/share/netmap/SettingsService.php
index ef566db..e5f8e42 100644
--- a/share/netmap/SettingsService.php
+++ b/share/netmap/SettingsService.php
@@ -26,7 +26,7 @@ class SettingsService
        private function createFile()
        {
                $xml = '<?xml version="1.0" standalone="yes" ?><settings/>';
-               if (file_put_contents('settings.xml', $xml) === FALSE)
+               if (file_put_contents($config_path . 'settings.xml', $xml) === 
FALSE)
                        throw new Exception('Could not create settings.xml');
        }
 
@@ -63,10 +63,10 @@ class SettingsService
                if (($mapurl = $CORE->MAINCFG->getValue('defaults', 'mapurl')) 
=== false)
                        throw new Exception('Error in NagVis configuration');
 
-               if (!file_exists('settings.xml'))
+               if (!file_exists($config_path . 'settings.xml'))
                        self::createFile();
 
-               if (($xml = @simplexml_load_file('settings.xml')) === FALSE)
+               if (($xml = @simplexml_load_file($config_path . 
'settings.xml')) === FALSE)
                        throw new Exception('Could not read settings.xml');
 
                return new Settings((string)$xml['googleMapsKey'],
@@ -88,7 +88,7 @@ class SettingsService
                @$xml->addAttribute('defaultLocationAction', 
$settings->defaultLocationAction);
                @$xml->addAttribute('openLinksInNewWindow', 
$settings->openLinksInNewWindow);
 
-               if (file_put_contents('settings.xml', $xml->asXML()) !== FALSE)
+               if (file_put_contents($config_path . 'settings.xml', 
$xml->asXML()) !== FALSE)
                        return $settings;
                else
                        throw new Exception('Could not write settings.xml');
diff --git a/share/netmap/ViewpointService.php 
b/share/netmap/ViewpointService.php
index d7e1985..b71a7e2 100644
--- a/share/netmap/ViewpointService.php
+++ b/share/netmap/ViewpointService.php
@@ -26,7 +26,7 @@ class ViewpointService
        private function createFile()
        {
                $xml = '<?xml version="1.0" standalone="yes" ?><viewpoints/>';
-               if (file_put_contents('viewpoints.xml', $xml) === FALSE)
+               if (file_put_contents($config_path . 'viewpoints.xml', $xml) 
=== FALSE)
                        throw new Exception('Could not create viewpoints.xml');
        }
 
@@ -36,10 +36,10 @@ class ViewpointService
        public function getAll()
        {
 
-               if (!file_exists('viewpoints.xml'))
+               if (!file_exists($config_path . 'viewpoints.xml'))
                        self::createFile();
 
-               if (($xml = @simplexml_load_file('viewpoints.xml')) === FALSE)
+               if (($xml = @simplexml_load_file($config_path . 
'viewpoints.xml')) === FALSE)
                        throw new Exception('Could not read viewpoints.xml');
 
                $viewpoints = array();
@@ -58,7 +58,7 @@ class ViewpointService
         */
        public function add($label, $center, $zoom)
        {
-               if (($xml = @simplexml_load_file('viewpoints.xml')) === FALSE)
+               if (($xml = @simplexml_load_file($config_path . 
'viewpoints.xml')) === FALSE)
                        throw new Exception('Could not read viewpoints.xml');
 
                $node = $xml->addChild('viewpoint');
@@ -68,7 +68,7 @@ class ViewpointService
 
                $viewpoint = new Viewpoint($label, $center, $zoom);
 
-               if (file_put_contents('viewpoints.xml', $xml->asXML()) !== 
FALSE)
+               if (file_put_contents($config_path . 'viewpoints.xml', 
$xml->asXML()) !== FALSE)
                        return $viewpoint;
                else
                        throw new Exception('Could not write viewpoints.xml');
diff --git a/share/netmap/amf-server.php b/share/netmap/amf-server.php
index 193f730..3f7e7cb 100644
--- a/share/netmap/amf-server.php
+++ b/share/netmap/amf-server.php
@@ -39,6 +39,8 @@ class Custom_Zend_Amf_Server extends Zend_Amf_Server
        protected $_production = false;
 }
 
+$config_path = realpath(dirname($_SERVER['SCRIPT_FILENAME']) . '/../..') . 
'/etc/geomap/';
+
 $server = new Custom_Zend_Amf_Server();
 $server->setClassMap("Settings", "Settings");
 $server->setClassMap("Viewpoint", "Viewpoint");


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to