Skip to content
This repository has been archived by the owner on Mar 29, 2019. It is now read-only.

Commit

Permalink
Merge pull request #109 from SemanticMediaWiki/mvqi
Browse files Browse the repository at this point in the history
Moved and simplified query printer initialization code
  • Loading branch information
JeroenDeDauw committed Sep 13, 2016
2 parents 8f6bcf8 + d25086b commit 9346476
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 73 deletions.
37 changes: 34 additions & 3 deletions SemanticMaps.php
Expand Up @@ -81,14 +81,14 @@ public function initExtension() {
'license-name' => 'GPL-2.0+'
];

include_once __DIR__ . '/src/queryprinters/SM_QueryPrinters.php';

$this->registerResourceModules();

$this->registerGoogleMaps();
$this->registerLeaflet();
$this->registerOpenLayers();

$this->initializeQueryPrinters();

// Internationalization
$this->mwGlobals['wgMessagesDirs']['SemanticMaps'] = __DIR__ . '/i18n';
}
Expand Down Expand Up @@ -215,7 +215,7 @@ private function registerOpenLayers() {
];

$this->mwGlobals['wgHooks']['MappingServiceLoad'][] = function() {
MapsMappingServices::registerServiceFeature( 'openlayers', 'qp', 'SMMapPrinter' );
MapsMappingServices::registerServiceFeature( 'openlayers', 'qp', SMMapPrinter::class );

/* @var MapsMappingService $openlayers */
$openlayers = MapsMappingServices::getServiceInstance( 'openlayers' );
Expand All @@ -225,6 +225,37 @@ private function registerOpenLayers() {
};
}

private function initializeQueryPrinters() {
$GLOBALS['smwgResultFormats']['kml'] = SMKMLPrinter::class;

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, skip 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 ( $GLOBALS['egMapsDefaultServices']['qp'] == $serviceIdentifier ) {
$aliases[] = 'map';
}

// Add the QP to SMW.
$GLOBALS['smwgResultFormats'][$service->getName()] = SMMapPrinter::class;

$GLOBALS['smwgResultAliases'][$service->getName()] = $aliases;
}

return true;
}

/**
* @since 3.4
*
Expand Down
70 changes: 0 additions & 70 deletions src/queryprinters/SM_QueryPrinters.php

This file was deleted.

0 comments on commit 9346476

Please sign in to comment.