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

GlobalMainCfg::checkMainConfigIsValid ( printErr  )  [inherited]

Checks if the main config file is valid

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

Definition at line 419 of file GlobalMainCfg.php.

References GlobalMainCfg::getValue().

Referenced by GlobalMainCfg::readConfig().

                                                 {
            if (DEBUG&&DEBUGLEVEL&1) debug('Start method GlobalMainCfg::checkMainConfigIsValid('.$printErr.')');
            
            // check given objects and attributes
            foreach($this->config AS $type => $vars) {
                  if(!ereg('^comment_',$type)) {
                        if(array_key_exists($type,$this->validConfig) || ereg('^(backend|rotation)_', $type)) {
                              // loop validConfig for checking: => missing "must" atributes
                              if(ereg('^backend_', $type)) {
                                    $arrValidConfig = array_merge($this->validConfig['backend'],$this->validConfig['backend']['options'][$this->getValue($type,'backendtype')]);
                              } elseif(ereg('^rotation_', $type)) {
                                    $arrValidConfig = $this->validConfig['rotation'];
                              } else {
                                    $arrValidConfig = $this->validConfig[$type];
                              }
                              foreach($arrValidConfig AS $key => $val) {
                                    if((isset($val['must']) && $val['must'] == '1')) {
                                          // value is "must"
                                          if($this->getValue($type,$key) == '') {
                                                // a "must" value is missing or empty
                                                $FRONTEND = new GlobalPage($this,Array('languageRoot'=>'global:global'));
                                                $FRONTEND->messageToUser('ERROR','mainMustValueNotSet','ATTRIBUTE~'.$key.',TYPE~'.$type);
                                          }
                                    }
                              }
                              
                              // loop given elements for checking: => all given atributes valid
                              foreach($vars AS $key => $val) {
                                    if(!ereg('^comment_',$key)) {
                                          if(ereg('^backend_', $type)) {
                                                $arrValidConfig = array_merge($this->validConfig['backend'],$this->validConfig['backend']['options'][$this->getValue($type,'backendtype')]);
                                          } elseif(ereg('^rotation_', $type)) {
                                                $arrValidConfig = $this->validConfig['rotation'];
                                          } else {
                                                $arrValidConfig = $this->validConfig[$type];
                                          }
                                          
                                          if(!array_key_exists($key,$arrValidConfig)) {
                                                // unknown attribute
                                                if($printErr) {
                                                      $FRONTEND = new GlobalPage($this,Array('languageRoot'=>'global:global'));
                                                      $FRONTEND->messageToUser('ERROR','unknownValue','ATTRIBUTE~'.$key.',TYPE~'.$type);
                                                }
                                                if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMapCfg::checkMapConfigIsValid(): FALSE');
                                                return FALSE;
                                          } else {
                                                if(isset($val) && is_array($val)) {
                                                      $val = implode(',',$val);
                                                }
                                                // valid attribute, now check for value format
                                                if(!preg_match($arrValidConfig[$key]['match'],$val)) {
                                                      # DEBUG: echo $val;
                                                      // wrong format
                                                      if($printErr) {
                                                            $FRONTEND = new GlobalPage($this,Array('languageRoot'=>'global:global'));
                                                            $FRONTEND->messageToUser('ERROR','wrongValueFormat','TYPE~'.$type.',ATTRIBUTE~'.$key);
                                                      }
                                                      if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMapCfg::checkMapConfigIsValid(): FALSE');
                                                      return FALSE;
                                                }
                                          }
                                    }
                              }     
                        } else {
                              // unknown type
                              if($printErr) {
                                    $FRONTEND = new GlobalPage($this,Array('languageRoot'=>'global:global'));
                                    $FRONTEND->messageToUser('ERROR','unknownSection','TYPE~'.$type);
                              }
                              if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMainCfg::checkMainConfigIsValid(): FALSE');
                              return FALSE;
                        }
                  }
            }
            if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMainCfg::checkMainConfigIsValid(): TRUE');
            return TRUE;
      }


Generated by  Doxygen 1.6.0   Back to index