r83272 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83271‎ | r83272 | r83273 >
Date:03:49, 5 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
multiple map fix
Modified paths:
  • /branches/Maps0.8/includes/Maps_Mapper.php (modified) (history)
  • /branches/Maps0.8/includes/features/Maps_BaseMap.php (modified) (history)
  • /branches/Maps0.8/includes/features/Maps_BasePointMap.php (modified) (history)

Diff [purge]

Index: branches/Maps0.8/includes/Maps_Mapper.php
@@ -157,4 +157,30 @@
158158 return $image;
159159 }
160160
 161+ /**
 162+ * Returns JS to init the vars to hold the map data when they are not there already.
 163+ *
 164+ * @since 0.8
 165+ *
 166+ * @param string $serviceName
 167+ */
 168+ public static function getBaseMapJSON( $serviceName ) {
 169+ static $baseInit = false;
 170+ static $serviceInit = array();
 171+
 172+ $json = '';
 173+
 174+ if ( !$baseInit ) {
 175+ $baseInit = true;
 176+ $json .= 'var maps={};';
 177+ }
 178+
 179+ if ( !in_array( $serviceName, $serviceInit ) ) {
 180+ $serviceInit[] = $serviceName;
 181+ $json .= "maps.$serviceName={};";
 182+ }
 183+
 184+ return $json;
 185+ }
 186+
161187 }
\ No newline at end of file
Index: branches/Maps0.8/includes/features/Maps_BasePointMap.php
@@ -106,8 +106,10 @@
107107 return '';
108108 }
109109
110 - // TODO
111 - return Html::inlineScript( "maps=[]; maps['{$this->service->getName()}']=[]; maps['{$this->service->getName()}']['{$mapName}']=" . json_encode( $object ) . ';' );
 110+ return Html::inlineScript(
 111+ MapsMapper::getBaseMapJSON( $this->service->getName() )
 112+ . "maps.{$this->service->getName()}.{$mapName}=" . json_encode( $object ) . ';'
 113+ );
112114 }
113115
114116 /**
Index: branches/Maps0.8/includes/features/Maps_BaseMap.php
@@ -108,8 +108,10 @@
109109 return '';
110110 }
111111
112 - // TODO
113 - return Html::inlineScript( "maps=[]; maps['{$this->service->getName()}']=[]; maps['{$this->service->getName()}']['{$mapName}']=" . json_encode( $object ) . ';' );
 112+ return Html::inlineScript(
 113+ MapsMapper::getBaseMapJSON( $this->service->getName() )
 114+ . "maps.{$this->service->getName()}.{$mapName}=" . json_encode( $object ) . ';'
 115+ );
114116 }
115117
116118 /**

Status & tagging log