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

GlobalMapCfg::checkMapConfigIsValid ( printErr  )  [inherited]

Checks if the config file is valid

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

Definition at line 734 of file GlobalMapCfg.php.

References GlobalMapCfg::getName().

Referenced by GlobalMapCfg::readMapConfig().

                                                {
            if (DEBUG&&DEBUGLEVEL&1) debug('Start method GlobalMapCfg::checkMapConfigIsValid('.$printErr.')');
            // check given objects and attributes
            foreach($this->mapConfig AS $type => $elements) {
                  if($type != 'template') {
                        if(array_key_exists($type,$this->validConfig)) {
                              foreach($elements AS $id => $element) {
                                    // loop validConfig for checking: => missing "must" atributes
                                    foreach($this->validConfig[$type] AS $key => $val) {
                                          if((isset($val['must']) && $val['must'] == '1')) {
                                                // value is "must"
                                                if(!isset($element[$key]) || $element[$key] == '') {
                                                      // a "must" value is missing or empty
                                                      $FRONTEND = new GlobalPage($this->MAINCFG,Array('languageRoot'=>'global:global'));
                                                      $FRONTEND->messageToUser('ERROR','mustValueNotSet','MAPNAME~'.$this->name.',ATTRIBUTE~'.$key.',TYPE~'.$type.',ID~'.$id);
                                                }
                                          }
                                    }
                                    
                                    // loop given elements for checking: => all given atributes valid
                                    foreach($element AS $key => $val) {
                                          // check for valid atributes
                                          if(!array_key_exists($key,$this->validConfig[$type])) {
                                                // unknown atribute
                                                if($printErr == 1) {
                                                      $FRONTEND = new GlobalPage($this->MAINCFG,Array('languageRoot'=>'global:global'));
                                                      $FRONTEND->messageToUser('ERROR','unknownAttribute','MAPNAME~'.$this->name.',ATTRIBUTE~'.$key.',TYPE~'.$type);
                                                }
                                                if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMapCfg::checkMapConfigIsValid(): FALSE');
                                                return FALSE;
                                          } else {
                                                // FIXME: Only match non array values at the moment
                                                if(!is_array($val) && isset($this->validConfig[$type][$key]['match'])) {
                                                      // valid attribute, now check for value format
                                                      if(!preg_match($this->validConfig[$type][$key]['match'],$val)) {
                                                            
                                                            // wrong format
                                                            if($printErr) {
                                                                  $FRONTEND = new GlobalPage($this->MAINCFG,Array('languageRoot'=>'global:global'));
                                                                  $FRONTEND->messageToUser('ERROR','wrongValueFormatMap','MAP~'.$this->getName().',TYPE~'.$type.',ATTRIBUTE~'.$key);
                                                            }
                                                            if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMapCfg::checkMapConfigIsValid(): FALSE');
                                                            return FALSE;
                                                      }
                                                }
                                          }
                                    }
                              }     
                        } else {
                              // unknown type
                              if($printErr == 1) {
                                    $FRONTEND = new GlobalPage($this->MAINCFG,Array('languageRoot'=>'global:global'));
                                    $FRONTEND->messageToUser('ERROR','unknownObject','TYPE~'.$type);
                              }
                              if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMapCfg::checkMapConfigIsValid(): FALSE');
                              return FALSE;
                        }
                  }
            }
            if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMapCfg::checkMapConfigIsValid(): TRUE');
            return TRUE;
      }


Generated by  Doxygen 1.6.0   Back to index