Logo Search packages:      
Sourcecode: nagvis version File versions  Download package

GlobalMapCfg::readMapConfig ( onlyGlobal = 0  )  [inherited]

Reads the map config file (copied from readFile->readNagVisCfg())

Returns:
Boolean Is Successful?
Author:
Lars Michelsen <lars@vertical-visions.de>

The default values refer to global settings in the validConfig array - so they have to be defined here and mustn't be defined in the array at creation. Cause of the default values should refer to the truely defined settings in global area they have to be read here.

Definition at line 517 of file GlobalMapCfg.php.

References GlobalMapCfg::checkMapConfigIsValid(), GlobalMapCfg::checkMapConfigReadable(), GlobalMapCfg::filterGlobal(), GlobalMapCfg::fixTemplateIndexes(), GlobalMapCfg::getBackground(), GlobalMapCfg::getObjectDefaults(), and GlobalMapCfg::mergeTemplates().

                                            {
            if (DEBUG&&DEBUGLEVEL&1) debug('Start method GlobalMapCfg::readMapConfig('.$onlyGlobal.')');
            if($this->name != '') {
                  if($this->checkMapConfigReadable(1)) {
                        $this->mapConfig = Array();
                        $types = Array('global'=>0,'host'=>0,'service'=>0,'hostgroup'=>0,'servicegroup'=>0,'map'=>0,'textbox'=>0,'shape'=>0,'template'=>0);
                        
                        // read file in array
                        if (DEBUG&&DEBUGLEVEL&2) debug('Start reading map configuration');
                        $file = file($this->MAINCFG->getValue('paths', 'mapcfg').$this->name.'.cfg');
                        if (DEBUG&&DEBUGLEVEL&2) debug('End reading map configuration');
                        $createArray = Array('allowed_user','allowed_for_config','use');
                        $l = 0;
                        
                        if (DEBUG&&DEBUGLEVEL&2) debug('Start parsing map configuration');
                        while(isset($file[$l]) && $file[$l] != '') {
                              // tested all of them, seems the runtime is nearly the same
                              // preg_match('/^(#|;)/',$file[$l])
                              // (strpos($file[$l],'#') !== 0) && (strpos($file[$l],'#') !== 0)
                              // !ereg('^(#|;)',$file[$l]) && !ereg('^;',$file[$l])
                              if(!ereg('^(#|;)',$file[$l])) {
                                    $defineCln = explode('{', $file[$l]);
                                    $define = explode(' ',$defineCln[0]);
                                    if(isset($define[1]) && array_key_exists(trim($define[1]),$this->validConfig)) {
                                          $type = $types[$define[1]];
                                          $l++;
                                          $this->mapConfig[$define[1]][$type] = Array('type'=>$define[1]);
                                          while (isset($file[$l]) && trim($file[$l]) != '}') {
                                                if(!ereg('^(#|;)',$file[$l])) {
                                                      $entry = explode('=',$file[$l], 2);
                                                      $entry[0] = trim($entry[0]);
                                                      if(isset($entry[1])) {
                                                            $entry[1] = trim($entry[1]);
                                                            if(in_array($entry[0],$createArray)) {
                                                                  $this->mapConfig[$define[1]][$type][$entry[0]] = explode(',',str_replace(' ','',$entry[1]));
                                                            } else {
                                                                  $this->mapConfig[$define[1]][$type][$entry[0]] = $entry[1];
                                                            }
                                                      }
                                                }
                                                $l++;
                                          }
                                          // increase type index
                                          $types[$define[1]]++;
                                    }
                              }
                              $l++;
                        }
                        if (DEBUG&&DEBUGLEVEL&2) debug('End parsing map configuration');
                        
                        /**
                         * The default values refer to global settings in the validConfig array - so they have to be 
                         * defined here and mustn't be defined in the array at creation.
                         * Cause of the default values should refer to the truely defined settings in global area they have to be read here.
                         */
                        $this->getObjectDefaults();
                        
                        if($onlyGlobal == 1) {
                              $this->filterGlobal();  
                        }
                        
                        if(isset($this->mapConfig['template'])) {
                              // Removes the numeric indexes and replaces them with the template name
                              $this->fixTemplateIndexes();
                              // Merge the objects with the linked templates
                              $this->mergeTemplates();
                        }
                        
                        if($this->checkMapConfigIsValid(1)) {
                              $this->BACKGROUND = $this->getBackground();
                              if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMapCfg::readMapConfig(): TRUE');
                              return TRUE;
                        } else {
                              if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMapCfg::readMapConfig(): FALSE');
                              return FALSE;
                        }
                  } else {
                        if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMapCfg::readMapConfig(): TRUE');
                        return FALSE;     
                  }
            } else {
                  if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMapCfg::readMapConfig(): TRUE');
                  return FALSE;
            }
      }


Generated by  Doxygen 1.6.0   Back to index