/** * Gets the default values for the different object types * * @param Boolean Only fetch global type settings * @author Lars Michelsen <*****@*****.**> */ private function gatherTypeDefaults($onlyGlobal) { $types = array('global'); if (!$onlyGlobal) { $types = array_merge($types, getMapObjectTypes()); } // Extract defaults from valid config array foreach ($types as $type) { if (!isset($this->typeDefaults[$type])) { $this->typeDefaults[$type] = array(); } foreach (array_keys(self::$validConfig[$type]) as $key) { if (isset(self::$validConfig[$type][$key]['default'])) { $this->typeDefaults[$type][$key] = self::$validConfig[$type][$key]['default']; } } } // Treating the alias $this->typeDefaults['global']['alias'] = $this->name; if ($onlyGlobal) { return true; } // And now feed the typeDefaults array with the new // default options based on the global section of the current map $aVars = array('recognize_services', 'only_hard_states', 'backend_id', 'iconset', 'icon_size', 'exclude_members', 'exclude_member_states', 'line_type', 'line_width', 'line_weather_colors', 'context_menu', 'context_template', 'hover_menu', 'hover_template', 'hover_delay', 'hover_url', 'label_show', 'label_text', 'label_x', 'label_y', 'label_width', 'label_background', 'label_border', 'label_style', 'label_maxlen', 'url_target', 'hover_childs_show', 'hover_childs_sort', 'hover_childs_order', 'hover_childs_limit'); foreach ($aVars as $sVar) { $sTmp = $this->getValue(0, $sVar); $this->typeDefaults['host'][$sVar] = $sTmp; $this->typeDefaults['hostgroup'][$sVar] = $sTmp; $this->typeDefaults['dyngroup'][$sVar] = $sTmp; $this->typeDefaults['aggr'][$sVar] = $sTmp; // Handle exceptions for servicegroups if ($sVar != 'recognize_services') { $this->typeDefaults['servicegroup'][$sVar] = $sTmp; } // Handle exceptions for services if ($sVar != 'recognize_services' && $sVar != 'label_text') { $this->typeDefaults['service'][$sVar] = $sTmp; } // Handle exceptions for maps if ($sVar != 'recognize_services' && $sVar != 'backend_id') { $this->typeDefaults['map'][$sVar] = $sTmp; } // Handle exceptions for shapes if ($sVar == 'url_target' || $sVar == 'hover_delay') { $this->typeDefaults['shape'][$sVar] = $sTmp; } // Handle exceptions for lines if ($sVar == 'url_target' || $sVar == 'hover_delay') { $this->typeDefaults['line'][$sVar] = $sTmp; } } }
} define('MATCH_WORLDMAP_ZOOM', '/^1?[0-9]$/'); // Register this source as being selectable by the user global $selectable; $selectable = true; // options to be modifiable by the user(url) global $viewParams; $viewParams = array('worldmap' => array('backend_id', 'worldmap_center', 'worldmap_zoom')); // Config variables to be registered for this source global $configVars; $configVars = array('worldmap_center' => array('must' => true, 'default' => '50.86837814203458,10.21728515625', 'match' => MATCH_LATLONG), 'worldmap_zoom' => array('must' => true, 'default' => 6, 'match' => MATCH_WORLDMAP_ZOOM), 'min_zoom' => array('must' => false, 'default' => 2, 'match' => MATCH_WORLDMAP_ZOOM), 'max_zoom' => array('must' => false, 'default' => 18, 'match' => MATCH_WORLDMAP_ZOOM)); // Assign config variables to specific object types global $configVarMap; $configVarMap = array('global' => array('worldmap' => array('worldmap_center' => null, 'worldmap_zoom' => null))); // Assign these options to all map objects (except global) foreach (getMapObjectTypes() as $type) { $configVarMap[$type] = array('worldmap' => array('min_zoom' => null, 'max_zoom' => null)); } // Global config vars not to show for worldmaps $hiddenConfigVars = array('zoom', 'zoombar'); // Alter some global vars with automap specific things $updateConfigVars = array('iconset' => array('default' => 'std_geo'), 'icon_size' => array('default' => array(24))); // The worldmap database object $DB = null; function worldmap_init_schema() { global $DB, $CORE; // Create initial db scheme if needed if (!$DB->tableExist('objects')) { $DB->exec('CREATE TABLE objects ' . '(object_id VARCHAR(20),' . ' lat REAL,' . ' lng REAL,' . ' lat2 REAL,' . ' lng2 REAL,' . ' object TEXT,' . ' PRIMARY KEY(object_id))'); $DB->exec('CREATE INDEX latlng ON objects (lat,long)');