Author:   Lars Michelsen <[email protected]>
Date:     Mon Jan 23 19:21:32 2012 +0100
Committer:   Lars Michelsen <[email protected]>
Commit-Date: Mon Jan 23 19:21:32 2012 +0100

Made template objects work again. Added doc note which does not
recommend usage of templates and the webbased editor at the same time.

---

 ChangeLog                                         |    5 ++++
 docs/en_US/map_config_format_description.html     |    5 ++++
 share/server/core/classes/GlobalMapCfg.php        |   26 +++++++++++++-------
 share/server/core/classes/WuiViewMapAddModify.php |    9 +++++++
 share/server/core/mapcfg/default.php              |    7 +++--
 5 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5f2a679..96d97a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+1.6.4
+Core
+  * Made template objects work again. Added doc note which does not recommend
+    usage of templates and the webbased editor at the same time.
+
 1.6.3
 Core
   * Bugfix: Made upper/lower case rotation_id/backend_id definitions possible
diff --git a/docs/en_US/map_config_format_description.html 
b/docs/en_US/map_config_format_description.html
index 775d91f..a6c2606 100644
--- a/docs/en_US/map_config_format_description.html
+++ b/docs/en_US/map_config_format_description.html
@@ -1193,6 +1193,11 @@
         <code>must-have-attributes</code> in one object for many others. You 
can
         set all attributes to the value you need and inherit them with the
         <code>use</code> attribute to each object.</p>
+        <p><i>Please note:</i> When editing objects using object templates 
using
+        the web based editing functions the values configured in the template 
will
+        be copied to the edited objects. From this time the values set in the 
object
+        are not used anymore. It is not recommended to use the web editing 
frontend
+        and template objects at the same time.</p>
         <p>Example with all values which have to be set:</p>
 <pre>define template {
  name=generic-template
diff --git a/share/server/core/classes/GlobalMapCfg.php 
b/share/server/core/classes/GlobalMapCfg.php
index fa9ed92..a327bea 100644
--- a/share/server/core/classes/GlobalMapCfg.php
+++ b/share/server/core/classes/GlobalMapCfg.php
@@ -394,8 +394,7 @@ class GlobalMapCfg {
             $this->gatherTypeDefaults($onlyGlobal);
 
             if($onlyGlobal == 0) {
-                // FIXME
-                if(isset($this->mapConfig['template']) && $resolveTemplates == 
true) {
+                if($resolveTemplates == true) {
                     // Merge the objects with the linked templates
                     $this->mergeTemplates();
                 }
@@ -471,21 +470,23 @@ class GlobalMapCfg {
      * @author         Lars Michelsen <[email protected]>
      */
     private function mergeTemplates() {
-        // Loop all objects of that type
+        // Loop all objects
         foreach($this->mapConfig AS $id => $element) {
             // Except global and templates (makes no sense)
-            if($type == 'global')
+            if($id == '0')
                 continue;
 
             // Check for "use" value
             if(isset($element['use']) && is_array($element['use'])) {
                 // loop all given templates
                 foreach($element['use'] AS $templateName) {
-                    $id = $this->getTemplateIdByName($templateName);
+                    $tmpl_id = $this->getTemplateIdByName($templateName);
+                    if($tmpl_id === false)
+                        continue;
 
-                    if(isset($this->mapConfig[$id]) && 
is_array($this->mapConfig[$id])) {
+                    if(isset($this->mapConfig[$tmpl_id]) && 
is_array($this->mapConfig[$tmpl_id])) {
                         // merge object array with template object array 
(except type and name attribute)
-                        $tmpArray = $this->mapConfig[$id];
+                        $tmpArray = $this->mapConfig[$tmpl_id];
                         unset($tmpArray['type']);
                         unset($tmpArray['name']);
                         unset($tmpArray['object_id']);
@@ -496,8 +497,9 @@ class GlobalMapCfg {
         }
 
         // Everything is merged: The templates are not relevant anymore
-        // FIXME
-        //unset($this->mapConfig['template']);
+        foreach($this->getDefinitions('template') AS $id => $template) {
+            unset($this->mapConfig[$id]);
+        }
     }
 
     /**
@@ -797,6 +799,12 @@ class GlobalMapCfg {
      * @author         Lars Michelsen <[email protected]>
      */
     public function setValue($id, $key, $value) {
+        $prop = $this->getValidObjectType($this->mapConfig[$id]['type']);
+        if(isset($prop['array']) && $prop['array']) {
+            $value = explode(',', $value);
+        }
+        echo $value;
+
         $this->mapConfig[$id][$key] = $value;
         return TRUE;
     }
diff --git a/share/server/core/classes/WuiViewMapAddModify.php 
b/share/server/core/classes/WuiViewMapAddModify.php
index f2497a5..abcfda5 100644
--- a/share/server/core/classes/WuiViewMapAddModify.php
+++ b/share/server/core/classes/WuiViewMapAddModify.php
@@ -154,6 +154,8 @@ class WuiViewMapAddModify {
                || (isset($prop['deprecated']) && $prop['deprecated'] === true))
                 continue;
 
+            $isArrayValue = isset($prop['array']) && $prop['array'];
+
             list($inherited, $value) = $this->getAttr($typeDefaults, $update, 
$propname, $prop['must']);
             unset($this->hiddenAttrs[$propname]);
 
@@ -219,6 +221,13 @@ class WuiViewMapAddModify {
             else
                 $valueTxt = '';
 
+            if(isset($prop['array']) && $prop['array']) {
+                if(is_array($valueTxt))
+                    $valueTxt = implode(',', $valueTxt);
+                if(is_array($value))
+                    $value    = implode(',', $value);
+            }
+
             switch($fieldType) {
                 case 'boolean':
                     $options = Array(
diff --git a/share/server/core/mapcfg/default.php 
b/share/server/core/mapcfg/default.php
index bcdbbc9..944efd0 100644
--- a/share/server/core/mapcfg/default.php
+++ b/share/server/core/mapcfg/default.php
@@ -607,9 +607,10 @@ $mapConfigVars = Array(
         'match' => MATCH_STRING_URL_EMPTY,
     ),
     'use' => Array(
-        'must' => 0,
-        'default' => '',
-        'match' => MATCH_STRING_NO_SPACE,
+        'must'    => 0,
+        'default' => array(),
+        'array'   => True,
+        'match'   => MATCH_STRING_NO_SPACE,
     ),
 
     // HOST SPECIFIC OPTIONS


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to