/** * Initialization function for Maps query printer functionality. */ public static function initialize() { global $wgAutoloadClasses, $egMapsDefaultServices; $wgAutoloadClasses['SMQueryHandler'] = __DIR__ . '/SM_QueryHandler.php'; $wgAutoloadClasses['SMMapPrinter'] = __DIR__ . '/SM_MapPrinter.php'; $wgAutoloadClasses['SMKMLPrinter'] = __DIR__ . '/SM_KMLPrinter.php'; self::initFormat('kml', 'SMKMLPrinter'); foreach (MapsMappingServices::getServiceIdentifiers() as $serviceIdentifier) { $service = MapsMappingServices::getServiceInstance($serviceIdentifier); // Check if the service has a query printer. $QPClass = $service->getFeature('qp'); // If the service has no QP, skipt it and continue with the next one. if ($QPClass === false) { continue; } // Initiate the format. $aliases = $service->getAliases(); // Add the 'map' result format if there are mapping services that have QP's loaded. if ($egMapsDefaultServices['qp'] == $serviceIdentifier) { $aliases[] = 'map'; } self::initFormat($service->getName(), 'SMMapPrinter', $aliases); } return true; }
/** * Initialization function for Maps query printer functionality. */ public static function initialize() { global $wgAutoloadClasses; $wgAutoloadClasses['SMQueryHandler'] = dirname(__FILE__) . '/SM_QueryHandler.php'; $wgAutoloadClasses['SMMapper'] = dirname(__FILE__) . '/SM_Mapper.php'; $wgAutoloadClasses['SMMapPrinter'] = dirname(__FILE__) . '/SM_MapPrinter.php'; $wgAutoloadClasses['SMKMLPrinter'] = dirname(__FILE__) . '/SM_KMLPrinter.php'; self::initFormat('kml', 'SMKMLPrinter'); $hasQueryPrinters = false; foreach (MapsMappingServices::getServiceIdentifiers() as $serviceIdentifier) { $service = MapsMappingServices::getServiceInstance($serviceIdentifier); // Check if the service has a query printer. $QPClass = $service->getFeature('qp'); // If the service has no QP, skipt it and continue with the next one. if ($QPClass === false) { continue; } // At least one query printer will be enabled when this point is reached. $hasQueryPrinters = true; // Initiate the format. $aliases = $service->getAliases(); self::initFormat($service->getName(), 'SMMapper', $aliases); } // Add the 'map' result format if there are mapping services that have QP's loaded. if ($hasQueryPrinters) { self::initFormat('map', 'SMMapper'); } return true; }
public static function initialize() { global $wgAutoloadClasses; // This code should not get called when SF is not loaded, but let's have this // check to not run into problems when people mess up the settings. if (!defined('SF_VERSION')) { return true; } $wgAutoloadClasses['SMFormInput'] = __DIR__ . '/SM_FormInput.php'; $hasFormInputs = false; foreach (MapsMappingServices::getServiceIdentifiers() as $serviceIdentifier) { $service = MapsMappingServices::getServiceInstance($serviceIdentifier); // Check if the service has a form input. $FIClass = $service->getFeature('fi'); // If the service has no FI, skipt it and continue with the next one. if ($FIClass === false) { continue; } // At least one form input will be enabled when this point is reached. $hasFormInputs = true; // Add the result form input type for the service name. self::initFormHook($service->getName(), $service->getName()); // Loop through the service alliases, and add them as form input types. foreach ($service->getAliases() as $alias) { self::initFormHook($alias, $service->getName()); } } // Add the 'map' form input type if there are mapping services that have FI's loaded. if ($hasFormInputs) { self::initFormHook('map'); } self::initFormHook('googlemapsEditor'); return true; }
/** * @see ItemParameterManipulation::doManipulation * * @since 0.7 */ public function doManipulation(&$value, Parameter $parameter, array &$parameters) { // Make sure the service is valid. $value = MapsMappingServices::getValidServiceName($value, $this->feature); // Get the service object so the service specific parameters can be retrieved. $serviceObject = MapsMappingServices::getServiceInstance($value); // Add the service specific service parameters. $serviceObject->addParameterInfo($parameters); }
/** * Initialization function for the Leaflet service. * * @ingroup Leaflet * * @return boolean true */ function efMapsInitLeaflet() { global $wgAutoloadClasses; $wgAutoloadClasses['MapsLeaflet'] = __DIR__ . '/Maps_Leaflet.php'; MapsMappingServices::registerService('leaflet', 'MapsLeaflet'); $leafletMaps = MapsMappingServices::getServiceInstance('leaflet'); $leafletMaps->addFeature('display_map', 'MapsDisplayMapRenderer'); return true; }
/** * @see ParamDefinition::formatValue() * * @since 2.0 * * @param $value mixed * @param $param IParam * @param $definitions array of IParamDefinition * @param $params array of IParam * * @return mixed */ protected function formatValue($value, IParam $param, array &$definitions, array $params) { // Make sure the service is valid. $value = MapsMappingServices::getValidServiceName($value, $this->feature); // Get the service object so the service specific parameters can be retrieved. $serviceObject = MapsMappingServices::getServiceInstance($value); // Add the service specific service parameters. $serviceObject->addParameterInfo($definitions); return $value; }
/** * Initialization function for the Google Maps v3 service. * * @since 0.6.3 * @ingroup MapsGoogleMaps3 * * @return boolean true */ function efMapsInitGoogleMaps3() { global $wgAutoloadClasses; $wgAutoloadClasses['MapsGoogleMaps3'] = __DIR__ . '/Maps_GoogleMaps3.php'; MapsMappingServices::registerService('googlemaps3', 'MapsGoogleMaps3'); // TODO: kill below code $googleMaps = MapsMappingServices::getServiceInstance('googlemaps3'); $googleMaps->addFeature('display_map', 'MapsDisplayMapRenderer'); return true; }
/** * Initialization function for the Google Maps v2 service. * * @since 0.6.3 * @ingroup MapsGoogleMaps * * @return true */ function efMapsInitGoogleMaps() { global $wgAutoloadClasses; $wgAutoloadClasses['MapsGoogleMaps'] = dirname(__FILE__) . '/Maps_GoogleMaps.php'; $wgAutoloadClasses['CriterionGoogleOverlay'] = dirname(__FILE__) . '/CriterionGoogleOverlay.php'; $wgAutoloadClasses['MapsParamGMapType'] = dirname(__FILE__) . '/Maps_ParamGMapType.php'; MapsMappingServices::registerService('googlemaps2', 'MapsGoogleMaps'); $googleMaps = MapsMappingServices::getServiceInstance('googlemaps2'); $googleMaps->addFeature('display_point', 'MapsBasePointMap'); $googleMaps->addFeature('display_map', 'MapsBaseMap'); return true; }
/** * Initialization function for the Google Maps v3 service. * * @since 0.6.3 * @ingroup MapsGoogleMaps3 * * @return true */ function efMapsInitGoogleMaps3() { global $wgAutoloadClasses; $wgAutoloadClasses['MapsGoogleMaps3'] = __DIR__ . '/Maps_GoogleMaps3.php'; $wgAutoloadClasses['MapsParamGMap3Type'] = __DIR__ . '/Maps_ParamGMap3Type.php'; $wgAutoloadClasses['MapsParamGMap3Types'] = __DIR__ . '/Maps_ParamGMap3Types.php'; $wgAutoloadClasses['MapsParamGMap3Typestyle'] = __DIR__ . '/Maps_ParamGMap3Typestyle.php'; $wgAutoloadClasses['MapsParamGMap3Zoomstyle'] = __DIR__ . '/Maps_ParamGMap3Zoomstyle.php'; MapsMappingServices::registerService('googlemaps3', 'MapsGoogleMaps3'); $googleMaps = MapsMappingServices::getServiceInstance('googlemaps3'); $googleMaps->addFeature('display_map', 'MapsDisplayMapRenderer'); return true; }
/** * Initialization function for the Google Maps v3 service. * * @since 0.6.3 * @ingroup MapsGoogleMaps3 * * @return true */ function efMapsInitGoogleMaps3() { global $wgAutoloadClasses; $wgAutoloadClasses['MapsGoogleMaps3'] = dirname(__FILE__) . '/Maps_GoogleMaps3.php'; $wgAutoloadClasses['MapsParamGMap3Type'] = dirname(__FILE__) . '/Maps_ParamGMap3Type.php'; $wgAutoloadClasses['MapsParamGMap3Types'] = dirname(__FILE__) . '/Maps_ParamGMap3Types.php'; $wgAutoloadClasses['MapsParamGMap3Typestyle'] = dirname(__FILE__) . '/Maps_ParamGMap3Typestyle.php'; $wgAutoloadClasses['MapsParamGMap3Zoomstyle'] = dirname(__FILE__) . '/Maps_ParamGMap3Zoomstyle.php'; MapsMappingServices::registerService('googlemaps3', 'MapsGoogleMaps3'); $googleMaps = MapsMappingServices::getServiceInstance('googlemaps3'); $googleMaps->addFeature('display_map', 'MapsBaseMap'); $googleMaps->addFeature('display_point', 'MapsBasePointMap'); return true; }
/** * @see ParameterManipulation::manipulate * * @since 0.7 */ public function manipulate(Parameter &$parameter, array &$parameters) { global $egMapsOLLayerGroups, $egMapsOLAvailableLayers; $layerDefs = array(); $layerNames = array(); foreach ($parameter->getValue() as $layerOrGroup) { $lcLayerOrGroup = strtolower($layerOrGroup); // Layer groups. Loop over all items and add them when not present yet. if (array_key_exists($lcLayerOrGroup, $egMapsOLLayerGroups)) { foreach ($egMapsOLLayerGroups[$lcLayerOrGroup] as $layerName) { if (!in_array($layerName, $layerNames)) { if (is_array($egMapsOLAvailableLayers[$layerName])) { $layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$layerName][0]; } else { $layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$layerName]; } $layerNames[] = $layerName; } } } elseif (array_key_exists($lcLayerOrGroup, $egMapsOLAvailableLayers)) { if (!in_array($lcLayerOrGroup, $layerNames)) { if (is_array($egMapsOLAvailableLayers[$lcLayerOrGroup])) { $layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$lcLayerOrGroup][0]; } else { $layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$lcLayerOrGroup]; } $layerNames[] = $lcLayerOrGroup; } } else { $title = Title::newFromText($layerOrGroup, Maps_NS_LAYER); if ($title->getNamespace() == Maps_NS_LAYER && $title->exists()) { $layerPage = new MapsLayerPage($title); if ($layerPage->hasValidDefinition('openlayers')) { $layer = $layerPage->getLayer(); if (!in_array($layerOrGroup, $layerNames)) { $layerDefs[] = $layer->getJavaScriptDefinition(); $layerNames[] = $layerOrGroup; } } else { wfWarn("Invalid layer ({$layerOrGroup}) encountered after validation."); } } else { wfWarn("Invalid layer ({$layerOrGroup}) encountered after validation."); } } } $parameter->setValue($layerDefs); MapsMappingServices::getServiceInstance('openlayers')->addLayerDependencies($this->getDependencies($layerNames)); }
/** * Renders and returns the output. * @see ParserHook::render * * @since 0.7 * * @param array $parameters * * @return string */ public function render(array $parameters) { // Get the instance of the service class. $service = MapsMappingServices::getServiceInstance($parameters['mappingservice'], $this->getName()); // Get an instance of the class handling the current parser hook and service. $mapClass = $service->getFeatureInstance('display_point'); return $mapClass->renderMap($parameters, $this->parser); }
public static function onInputRequest($coordinates, $input_name, $is_mandatory, $is_disabled, array $field_args) { $formInput = new self(MapsMappingServices::getServiceInstance('googlemaps3')); return $formInput->getInputOutput($coordinates, $input_name, $is_mandatory, $is_disabled, $field_args); }
protected function getServiceParameters($service) { $service = MapsMappingServices::getServiceInstance($service); $params = array(); $params['zoom'] = array('type' => 'integer', 'message' => 'maps-par-zoom'); $service->addParameterInfo($params); return $params; }
protected function getServiceParameters($service) { $service = MapsMappingServices::getServiceInstance($service); $params = array(); $params['zoom'] = new Parameter('zoom', Parameter::TYPE_INTEGER); $params['zoom']->setMessage('maps-par-zoom'); $service->addParameterInfo($params); return $params; }
/** * @see ParameterManipulation::manipulate * * @since 0.7 */ public function manipulate(Parameter &$parameter, array &$parameters) { global $egMapsOLLayerGroups, $egMapsOLAvailableLayers; $layerDefs = array(); $usedLayers = array(); foreach ($parameter->getValue() as $layerOrGroup) { $lcLayerOrGroup = strtolower($layerOrGroup); // Layer groups. Loop over all items and add them if not present yet. if (array_key_exists($lcLayerOrGroup, $egMapsOLLayerGroups)) { foreach ($egMapsOLLayerGroups[$lcLayerOrGroup] as $layerName) { if (!in_array($layerName, $usedLayers)) { if (is_array($egMapsOLAvailableLayers[$layerName])) { $layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$layerName][0]; } else { $layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$layerName]; } $usedLayers[] = $layerName; } } } elseif (array_key_exists($lcLayerOrGroup, $egMapsOLAvailableLayers)) { if (!in_array($lcLayerOrGroup, $usedLayers)) { if (is_array($egMapsOLAvailableLayers[$lcLayerOrGroup])) { $layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$lcLayerOrGroup][0]; } else { $layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$lcLayerOrGroup]; } $usedLayers[] = $lcLayerOrGroup; } } else { $layerParts = explode($this->groupNameSep, $layerOrGroup, 2); $layerGroup = $layerParts[0]; $layerName = count($layerParts) > 1 ? $layerParts[1] : null; $title = Title::newFromText($layerGroup, Maps_NS_LAYER); if ($title !== null && $title->getNamespace() == Maps_NS_LAYER) { /** * TODO/FIXME: This shouldn't be here and using $wgParser, instead it should * be somewhere around MapsBaseMap::renderMap. But since we do a lot more than * 'parameter manipulation' in here, we already diminish the information needed * for this which will never arrive there. Perhaps the whole * MapsLayer::getJavaScriptDefinition() shouldn't be done here. */ global $wgParser; // add dependency to the layer page so if the layer definition gets updated, // the page where it is used will be updated as well: $rev = Revision::newFromTitle($title); $wgParser->getOutput()->addTemplate($title, $title->getArticleID(), $rev->getId()); // if the whole layer group is not yet loaded into the map and the group exists: if (!in_array($layerGroup, $usedLayers) && $title->exists()) { $layerPage = new MapsLayerPage($title); if ($layerName !== null) { // load specific layer with name: $layer = MapsLayers::loadLayer($title, $layerName); $layers = new MapsLayerGroup($layer); $usedLayer = $layerOrGroup; } else { // load all layers from group: $layers = MapsLayers::loadLayerGroup($title); $usedLayer = $layerGroup; } foreach ($layers->getLayers() as $layer) { if (($layer->getName() === null || !in_array($layerGroup . $this->groupNameSep . $layer->getName(), $usedLayers)) && $layer->isOk()) { $layerDefs[] = $layer->getJavaScriptDefinition(); } } $usedLayers[] = $usedLayer; // have to add this after loop of course! } } else { wfWarn("Invalid layer ({$layerOrGroup}) encountered after validation."); } } } $parameter->setValue($layerDefs); MapsMappingServices::getServiceInstance('openlayers')->addLayerDependencies($this->getDependencies($usedLayers)); }
/** * Renders and returns the output. * @see ParserHook::render * * @since 0.7 * * @param array $parameters * * @return string */ public function render(array $parameters) { // Get the instance of the service class. $service = MapsMappingServices::getServiceInstance($parameters['mappingservice'], $this->getName()); $mapClass = new MapsDisplayMapRenderer($service); $fullParams = $this->validator->getParameters(); if (array_key_exists('zoom', $fullParams) && $fullParams['zoom']->wasSetToDefault() && count($parameters['coordinates']) > 1) { $parameters['zoom'] = false; } global $egMapsEnableCategory; if ($egMapsEnableCategory) { $this->parser->addTrackingCategory('maps-tracking-category'); } return $mapClass->renderMap($parameters, $this->parser); }