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

NagVisMap::getHoverTemplate ( &$  obj  ) 

Gets the hover template

Parameters:
Array $obj Array with object informations
Returns:
String HTML HTML Code for the hover menu
Author:
Lars Michelsen <lars@vertical-visions.de>

Definition at line 449 of file NagVisMap.php.

                                       {
            if($this->checkHoverTemplateReadable($obj,1)) {
                  $ret = file_get_contents($this->MAINCFG->getValue('paths','hovertemplate').'tmpl.'.$obj['hover_template'].'.html');
                  
                  if($obj['type'] == 'service') {
                        $name = 'host_name';
                  } else {
                        $name = $obj['type'] . '_name';
                  }
                  
                  // For maps use the alias as display string
                  if($obj['type'] == 'map') {
                        $displayName = 'alias';
                  } else {
                        $displayName = $name;
                  }
                  
                  // Replace the macros
                  $ret = str_replace('[obj_type]',$obj['type'],$ret);
                  $ret = str_replace('[obj_name]',$obj[$displayName],$ret);
                  $ret = str_replace('[obj_state]',$obj['state'],$ret);
                  if($obj['type'] != 'map') {
                        $ret = str_replace('[obj_backendid]',$obj['backend_id'],$ret);
                        if($this->MAINCFG->getValue('backend_'.$obj['backend_id'],'backendtype') == 'ndomy') {
                              $ret = str_replace('[obj_backend_instancename]',$this->MAINCFG->getValue('backend_'.$obj['backend_id'],'dbinstancename'),$ret);
                        } else {
                              $ret = str_replace('[obj_backend_instancename]','',$ret);
                        }
                  } else {
                        // Remove the macros in map objects
                        $ret = str_replace('[obj_backendid]','',$ret);
                        $ret = str_replace('[obj_backend_instancename]','',$ret);
                  }
                  $ret = str_replace('[obj_output]',strtr($obj['stateOutput'], Array("\r" => '<br />', "\n" => '<br />')),$ret);
                  $ret = str_replace('[pnp_hostname]',str_replace(' ','%20',$obj[$name]),$ret);
                  $ret = str_replace('[lang_name]',$this->LANG->getLabel(str_replace('_','',$name)),$ret);
                  $ret = str_replace('[lang_state]',$this->LANG->getLabel('state'),$ret);
                  $ret = str_replace('[lang_output]',$this->LANG->getLabel('output'),$ret);
                  $ret = str_replace('[lang_obj_type]',$this->LANG->getLabel($obj['type']),$ret);
                  $ret = str_replace('[lang_overview]',$this->LANG->getLabel('overview'),$ret);
                  $ret = str_replace('[lang_instance]',$this->LANG->getLabel('instance'),$ret);
                  $ret = str_replace('[html_base]',$this->MAINCFG->getValue('paths','htmlbase'),$ret);
                  $ret = str_replace('[html_templates]',$this->MAINCFG->getValue('paths','htmlhovertemplates'),$ret);
                  $ret = str_replace('[html_template_images]',$this->MAINCFG->getValue('paths','htmlhovertemplateimages'),$ret);
                  if($obj['type'] == 'service') {
                        $ret = str_replace('[lang_service_description]',$this->LANG->getLabel('servicename'),$ret);
                        $ret = str_replace('[service_description]',$obj['service_description'],$ret);
                        $ret = str_replace('[pnp_service_description]',str_replace(' ','%20',$obj['service_description']),$ret);
                  } else {
                        $ret = preg_replace('/(<!-- BEGIN service -->(.+?)<!-- END service -->)+/sS','',$ret);
                  }
                  // Escape chars which could make problems
                  $ret = strtr(addslashes($ret),Array('"' => '\'', "\r" => '', "\n" => ''));
            }
            
            return $ret;
      }


Generated by  Doxygen 1.6.0   Back to index