Permalink
Browse files

some improvements to MapEditor special page

Change-Id: Iab44f644babde43cbe52e48d3e7d8ec4075d0cb3
  • Loading branch information...
1 parent a79baa8 commit 6d9d26fd4f2e4df05dc45f7380c10c1f020769b1 @JeroenDeDauw committed Jul 21, 2012
Showing with 58 additions and 14 deletions.
  1. +8 −2 Maps.php
  2. +14 −7 includes/services/GoogleMaps3/Maps_GoogleMaps3.php
  3. +36 −5 includes/specials/SpecialMapEditor.php
View
@@ -164,8 +164,6 @@
// Load the special pages
$wgAutoloadClasses['SpecialMapEditor'] = $egMapsDir . 'includes/specials/SpecialMapEditor.php';
-$wgSpecialPages['MapEditor'] = 'SpecialMapEditor';
-$wgSpecialPageGroups['MapEditor'] = 'maps';
unset( $phDir );
unset( $incDir );
@@ -331,6 +329,14 @@
function efMapsSetup() {
wfRunHooks( 'MappingServiceLoad' );
wfRunHooks( 'MappingFeatureLoad' );
+
+ if ( in_array( 'googlemaps3', $GLOBALS['egMapsAvailableServices'] ) ) {
+ global $wgSpecialPages, $wgSpecialPageGroups;
+
+ $wgSpecialPages['MapEditor'] = 'SpecialMapEditor';
+ $wgSpecialPageGroups['MapEditor'] = 'maps';
+ }
+
return true;
}
@@ -230,20 +230,27 @@ public static function getLayerNames() {
* @return array
*/
protected function getDependencies() {
- global $wgLang, $egGoogleJsApiKey;
+ return array(
+ self::getApiScript( $GLOBALS['wgLang']->getCode() ),
+ );
+ }
- $urlArgs = array(
- 'language' => self::getMappedLanguageCode( $wgLang->getCode() ),
- 'sensor' => 'false'
+ public static function getApiScript( $langCode, array $urlArgs = array() ) {
+ global $egGoogleJsApiKey;
+
+ $urlArgs = array_merge(
+ array(
+ 'language' => self::getMappedLanguageCode( $langCode ),
+ 'sensor' => 'false'
+ ),
+ $urlArgs
);
if ( $egGoogleJsApiKey !== '' ) {
$urlArgs['key'] = $egGoogleJsApiKey;
}
- return array(
- Html::linkedScript( 'http://maps.googleapis.com/maps/api/js?' . wfArrayToCgi( $urlArgs ) )
- );
+ return Html::linkedScript( 'http://maps.googleapis.com/maps/api/js?' . wfArrayToCgi( $urlArgs ) );
}
/**
@@ -1,16 +1,46 @@
<?php
+/**
+ * Special page with map editor interface using Google Maps.
+ *
+ * @since 2.0
+ *
+ * @file
+ * @ingroup Maps
+ *
+ * @licence GNU GPL v2+
+ * @author Kim Eik
+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
+ */
class SpecialMapEditor extends SpecialPage{
- function __construct() {
+
+ /**
+ * @see SpecialPage::__construct
+ *
+ * @since 2.0
+ */
+ public function __construct() {
parent::__construct( 'MapEditor' );
}
- function execute( $par ) {
+ /**
+ * @see SpecialPage::execute
+ *
+ * @since 2.0
+ *
+ * @param null|string $subPage
+ */
+ public function execute( $subPage ) {
$this->setHeaders();
$outputPage = $this->getOutput();
- $outputPage->addHtml(Html::linkedScript( "http://maps.google.com/maps/api/js?sensor=false&libraries=drawing" ));
- $outputPage->addModules('mapeditor');
+
+ $outputPage->addHtml( MapsGoogleMaps3::getApiScript(
+ $this->getLanguage()->getCode(),
+ array( 'libraries' => 'drawing' )
+ ) );
+
+ $outputPage->addModules( 'mapeditor' );
//as requested
$output = <<<EOT
@@ -181,4 +211,5 @@ function execute( $par ) {
$outputPage->addHTML($output);
}
-}
+
+}

0 comments on commit 6d9d26f

Please sign in to comment.