r57704 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57703‎ | r57704 | r57705 >
Date:13:46, 14 October 2009
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Modified paths:
  • /trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php (modified) (history)
  • /trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php (added) (history)
  • /trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php (added) (history)
  • /trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsParserFunctions.php (deleted) (history)
  • /trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsUtils.php (modified) (history)
  • /trunk/extensions/Maps/Maps.php (modified) (history)
  • /trunk/extensions/Maps/Maps_Settings.php (modified) (history)
  • /trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php (modified) (history)
  • /trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispMap.php (added) (history)
  • /trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispPoint.php (added) (history)
  • /trunk/extensions/Maps/OpenLayers/Maps_OpenLayersParserFunctions.php (deleted) (history)
  • /trunk/extensions/Maps/ParserFunctions/Maps_BaseMap.php (modified) (history)
  • /trunk/extensions/Maps/ParserFunctions/Maps_BasePointMap.php (added) (history)
  • /trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php (modified) (history)
  • /trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php (modified) (history)
  • /trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispMap.php (added) (history)
  • /trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispPoint.php (added) (history)
  • /trunk/extensions/Maps/YahooMaps/Maps_YahooMapsParserFunctions.php (deleted) (history)

Diff [purge]

Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersParserFunctions.php
@@ -1,88 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Class for handling the Maps parser functions with OpenLayers
6 - *
7 - * @file Maps_OpenLayersParserFunctions.php
8 - * @ingroup Maps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -class MapsOpenLayersParserFunctions extends MapsBaseMap {
18 -
19 - public $serviceName = MapsOpenLayersUtils::SERVICE_NAME;
20 -
21 - /**
22 - * @see MapsBaseMap::setMapSettings()
23 - *
24 - */
25 - protected function setMapSettings() {
26 - global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix;
27 -
28 - $this->defaultParams = MapsOpenLayersUtils::getDefaultParams();
29 -
30 - $this->elementNamePrefix = $egMapsOpenLayersPrefix;
31 - $this->defaultZoom = $egMapsOpenLayersZoom;
32 - }
33 -
34 - /**
35 - * @see MapsBaseMap::doMapServiceLoad()
36 - *
37 - */
38 - protected function doMapServiceLoad() {
39 - global $egOpenLayersOnThisPage;
40 -
41 - MapsOpenLayersUtils::addOLDependencies($this->output);
42 - $egOpenLayersOnThisPage++;
43 -
44 - $this->elementNr = $egOpenLayersOnThisPage;
45 - }
46 -
47 - /**
48 - * @see MapsBaseMap::addSpecificMapHTML()
49 - *
50 - */
51 - public function addSpecificMapHTML() {
52 - global $wgJsMimeType;
53 -
54 - $controlItems = MapsOpenLayersUtils::createControlsString($this->controls);
55 -
56 - MapsMapper::enforceArrayValues($this->layers);
57 - $layerItems = MapsOpenLayersUtils::createLayersStringAndLoadDependencies($this->output, $this->layers);
58 -
59 - MapsUtils::makePxValue($this->width);
60 - MapsUtils::makePxValue($this->height);
61 -
62 - $markerItems = array();
63 -
64 - // TODO: Refactor up
65 - foreach ($this->markerData as $markerData) {
66 - $lat = $markerData['lat'];
67 - $lon = $markerData['lon'];
68 -
69 - $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
70 - $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
71 -
72 - $title = str_replace("'", "\'", $title);
73 - $label = str_replace("'", "\'", $label);
74 -
75 - $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
76 - $markerItems[] = "getOLMarkerData($lon, $lat, '$title', '$label', '$icon')";
77 - }
78 -
79 - $markersString = implode(',', $markerItems);
80 -
81 - $this->output .= "<div id='$this->mapName' style='width: $this->width; height: $this->height; background-color: #cccccc;'></div>
82 - <script type='$wgJsMimeType'> /*<![CDATA[*/
83 - addLoadEvent(
84 - initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$controlItems],[$markersString])
85 - );
86 - /*]]>*/ </script>";
87 - }
88 -
89 -}
\ No newline at end of file
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispPoint.php
@@ -0,0 +1,88 @@
 2+<?php
 3+
 4+/**
 5+ * Class for handling the display_point(s) parser functions with OpenLayers
 6+ *
 7+ * @file Maps_OpenLayersDispPoint.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+class MapsOpenLayersDispPoint extends MapsBasePointMap {
 18+
 19+ public $serviceName = MapsOpenLayersUtils::SERVICE_NAME;
 20+
 21+ /**
 22+ * @see MapsBaseMap::setMapSettings()
 23+ *
 24+ */
 25+ protected function setMapSettings() {
 26+ global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix;
 27+
 28+ $this->defaultParams = MapsOpenLayersUtils::getDefaultParams();
 29+
 30+ $this->elementNamePrefix = $egMapsOpenLayersPrefix;
 31+ $this->defaultZoom = $egMapsOpenLayersZoom;
 32+ }
 33+
 34+ /**
 35+ * @see MapsBaseMap::doMapServiceLoad()
 36+ *
 37+ */
 38+ protected function doMapServiceLoad() {
 39+ global $egOpenLayersOnThisPage;
 40+
 41+ MapsOpenLayersUtils::addOLDependencies($this->output);
 42+ $egOpenLayersOnThisPage++;
 43+
 44+ $this->elementNr = $egOpenLayersOnThisPage;
 45+ }
 46+
 47+ /**
 48+ * @see MapsBaseMap::addSpecificMapHTML()
 49+ *
 50+ */
 51+ public function addSpecificMapHTML() {
 52+ global $wgJsMimeType;
 53+
 54+ $controlItems = MapsOpenLayersUtils::createControlsString($this->controls);
 55+
 56+ MapsMapper::enforceArrayValues($this->layers);
 57+ $layerItems = MapsOpenLayersUtils::createLayersStringAndLoadDependencies($this->output, $this->layers);
 58+
 59+ MapsUtils::makePxValue($this->width);
 60+ MapsUtils::makePxValue($this->height);
 61+
 62+ $markerItems = array();
 63+
 64+ // TODO: Refactor up
 65+ foreach ($this->markerData as $markerData) {
 66+ $lat = $markerData['lat'];
 67+ $lon = $markerData['lon'];
 68+
 69+ $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
 70+ $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
 71+
 72+ $title = str_replace("'", "\'", $title);
 73+ $label = str_replace("'", "\'", $label);
 74+
 75+ $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
 76+ $markerItems[] = "getOLMarkerData($lon, $lat, '$title', '$label', '$icon')";
 77+ }
 78+
 79+ $markersString = implode(',', $markerItems);
 80+
 81+ $this->output .= "<div id='$this->mapName' style='width: $this->width; height: $this->height; background-color: #cccccc;'></div>
 82+ <script type='$wgJsMimeType'> /*<![CDATA[*/
 83+ addLoadEvent(
 84+ initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$controlItems],[$markersString])
 85+ );
 86+ /*]]>*/ </script>";
 87+ }
 88+
 89+}
\ No newline at end of file
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispMap.php
@@ -0,0 +1,69 @@
 2+<?php
 3+
 4+/**
 5+ * Class for handling the display_map parser function with OpenLayers
 6+ *
 7+ * @file Maps_OpenLayersDispMap.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+class MapsOpenLayersDispMap extends MapsBasePointMap {
 18+
 19+ public $serviceName = MapsOpenLayersUtils::SERVICE_NAME;
 20+
 21+ /**
 22+ * @see MapsBaseMap::setMapSettings()
 23+ *
 24+ */
 25+ protected function setMapSettings() {
 26+ global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix;
 27+
 28+ $this->defaultParams = MapsOpenLayersUtils::getDefaultParams();
 29+
 30+ $this->elementNamePrefix = $egMapsOpenLayersPrefix;
 31+ $this->defaultZoom = $egMapsOpenLayersZoom;
 32+ }
 33+
 34+ /**
 35+ * @see MapsBaseMap::doMapServiceLoad()
 36+ *
 37+ */
 38+ protected function doMapServiceLoad() {
 39+ global $egOpenLayersOnThisPage;
 40+
 41+ MapsOpenLayersUtils::addOLDependencies($this->output);
 42+ $egOpenLayersOnThisPage++;
 43+
 44+ $this->elementNr = $egOpenLayersOnThisPage;
 45+ }
 46+
 47+ /**
 48+ * @see MapsBaseMap::addSpecificMapHTML()
 49+ *
 50+ */
 51+ public function addSpecificMapHTML() {
 52+ global $wgJsMimeType;
 53+
 54+ $controlItems = MapsOpenLayersUtils::createControlsString($this->controls);
 55+
 56+ MapsMapper::enforceArrayValues($this->layers);
 57+ $layerItems = MapsOpenLayersUtils::createLayersStringAndLoadDependencies($this->output, $this->layers);
 58+
 59+ MapsUtils::makePxValue($this->width);
 60+ MapsUtils::makePxValue($this->height);
 61+
 62+ $this->output .= "<div id='$this->mapName' style='width: $this->width; height: $this->height; background-color: #cccccc;'></div>
 63+ <script type='$wgJsMimeType'> /*<![CDATA[*/
 64+ addLoadEvent(
 65+ initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$controlItems],[])
 66+ );
 67+ /*]]>*/ </script>";
 68+ }
 69+
 70+}
\ No newline at end of file
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php
@@ -10,7 +10,10 @@
1111 */
1212
1313 $egMapsServices['openlayers'] = array(
14 - 'pf' => array('class' => 'MapsOpenLayersParserFunctions', 'file' => 'OpenLayers/Maps_OpenLayersParserFunctions.php', 'local' => true),
 14+ 'pf' => array(
 15+ 'display_point' => array('class' => 'MapsOpenLayersDispPoint', 'file' => 'OpenLayers/Maps_OpenLayersDispPoint.php', 'local' => true),
 16+ 'display_map' => array('class' => 'MapsOpenLayersDispMap', 'file' => 'OpenLayers/Maps_OpenLayersDispMap.php', 'local' => true),
 17+ ),
1518 'classes' => array(
1619 array('class' => 'MapsOpenLayersUtils', 'file' => 'OpenLayers/Maps_OpenLayersUtils.php', 'local' => true)
1720 ),
Index: trunk/extensions/Maps/ParserFunctions/Maps_BasePointMap.php
@@ -0,0 +1,164 @@
 2+<?php
 3+
 4+/**
 5+ * Abstract class MapsBasePointMap provides the scafolding for classes handling display_point(s)
 6+ * and display_address(es) calls for a spesific mapping service. It inherits from MapsMapFeature and therefore
 7+ * forces inheriting classes to implement sereveral methods.
 8+ *
 9+ * @file Maps_BasePointMap.php
 10+ * @ingroup Maps
 11+ *
 12+ * @author Jeroen De Dauw
 13+ */
 14+
 15+if( !defined( 'MEDIAWIKI' ) ) {
 16+ die( 'Not an entry point.' );
 17+}
 18+
 19+abstract class MapsBasePointMap extends MapsMapFeature {
 20+
 21+ protected $markerData = array();
 22+
 23+ /**
 24+ * Handles the request from the parser hook by doing the work that's common for all
 25+ * mapping services, calling the specific methods and finally returning the resulting output.
 26+ *
 27+ * @param unknown_type $parser
 28+ * @param array $params
 29+ *
 30+ * @return html
 31+ */
 32+ public final function displayMap(&$parser, array $params) {
 33+ $this->setMapSettings();
 34+
 35+ $coords = $this->manageMapProperties($params);
 36+
 37+ $this->doMapServiceLoad();
 38+
 39+ $this->setMapName();
 40+
 41+ $this->setCoordinates($parser);
 42+
 43+ $this->setZoom();
 44+
 45+ $this->setCentre();
 46+
 47+ $this->doParsing($parser);
 48+
 49+ $this->doEscaping();
 50+
 51+ $this->addSpecificMapHTML();
 52+
 53+ return $this->output;
 54+ }
 55+
 56+ /**
 57+ * (non-PHPdoc)
 58+ * @see smw/extensions/Maps/MapsMapFeature#manageMapProperties($mapProperties, $className)
 59+ */
 60+ protected function manageMapProperties($params) {
 61+ parent::manageMapProperties($params, __CLASS__);
 62+ }
 63+
 64+ /**
 65+ * Sets the zoom level to the provided value. When no zoom is provided, set
 66+ * it to the default when there is only one location, or the best fitting soom when
 67+ * there are multiple locations.
 68+ *
 69+ */
 70+ private function setZoom() {
 71+ if (strlen($this->zoom) < 1) {
 72+ if (count($this->markerData) > 1) {
 73+ $this->zoom = 'null';
 74+ }
 75+ else {
 76+ $this->zoom = $this->defaultZoom;
 77+ }
 78+ }
 79+ }
 80+
 81+ /**
 82+ * Fills the $markerData array with the locations and their meta data.
 83+ *
 84+ * @param unknown_type $parser
 85+ */
 86+ private function setCoordinates($parser) {
 87+ $this->coordinates = explode(';', $this->coordinates);
 88+
 89+ foreach($this->coordinates as $coordinates) {
 90+ $args = explode('~', $coordinates);
 91+
 92+ $args[0] = str_replace('″', '"', $args[0]);
 93+ $args[0] = str_replace('′', "'", $args[0]);
 94+
 95+ $markerData = MapsUtils::getLatLon($args[0]);
 96+
 97+ if (count($args) > 1) {
 98+ $markerData['title'] = $parser->recursiveTagParse( $args[1] );
 99+
 100+ if (count($args) > 2) {
 101+ $markerData['label'] = $parser->recursiveTagParse( $args[2] );
 102+
 103+ if (count($args) > 3) {
 104+ $markerData['icon'] = $args[3];
 105+ }
 106+ }
 107+ }
 108+
 109+ $this->markerData[] = $markerData;
 110+ }
 111+ }
 112+
 113+ /**
 114+ * Sets the $centre_lat and $centre_lon fields.
 115+ * Note: this needs to be done AFTRE the maker coordinates are set.
 116+ *
 117+ */
 118+ private function setCentre() {
 119+ if (empty($this->centre)) {
 120+ if (count($this->markerData) == 1) {
 121+ // If centre is not set and there is exactelly one marker, use it's coordinates.
 122+ $this->centre_lat = $this->markerData[0]['lat'];
 123+ $this->centre_lon = $this->markerData[0]['lon'];
 124+ }
 125+ elseif (count($this->markerData) > 1) {
 126+ // If centre is not set and there are multiple markers, set the values to null,
 127+ // to be auto determined by the JS of the mapping API.
 128+ $this->centre_lat = 'null';
 129+ $this->centre_lon = 'null';
 130+ }
 131+ else {
 132+ // If centre is not set and there are no markers, use the default latitude and longitutde.
 133+ global $egMapsMapLat, $egMapsMapLon;
 134+ $this->centre_lat = $egMapsMapLat;
 135+ $this->centre_lon = $egMapsMapLon;
 136+ }
 137+ }
 138+ else {
 139+ // If a centre value is set, use it.
 140+ $centre = MapsUtils::getLatLon($this->centre);
 141+ $this->centre_lat = $centre['lat'];
 142+ $this->centre_lon = $centre['lon'];
 143+ }
 144+ }
 145+
 146+ /**
 147+ * Parse the wiki text in the title and label values.
 148+ *
 149+ * @param unknown_type $parser
 150+ */
 151+ private function doParsing(&$parser) {
 152+ $this->title = $parser->recursiveTagParse( $this->title );
 153+ $this->label = $parser->recursiveTagParse( $this->label );
 154+ }
 155+
 156+ /**
 157+ * Escape the title and label text
 158+ *
 159+ */
 160+ private function doEscaping() {
 161+ $this->title = str_replace("'", "\'", $this->title);
 162+ $this->label = str_replace("'", "\'", $this->label);
 163+ }
 164+
 165+}
Index: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php
@@ -20,11 +20,11 @@
2121 * Adds the magic words for the parser functions
2222 */
2323 function efMapsFunctionMagic( &$magicWords, $langCode ) {
24 - $magicWords['display_point'] = array( 0, 'display_point' );
25 - $magicWords['display_points'] = array( 0, 'display_points' );
26 - $magicWords['display_address'] = array( 0, 'display_address' );
27 - $magicWords['display_addresses'] = array( 0, 'display_addresses' );
 24+ $magicWords['display_point'] = array( 0, 'display_point', 'display_points' );
 25+ $magicWords['display_address'] = array( 0, 'display_address', 'display_addresses' );
2826
 27+ $magicWords['display_map'] = array( 0, 'display_map');
 28+
2929 $magicWords['geocode'] = array( 0, 'geocode' );
3030 $magicWords['geocodelat'] = array ( 0, 'geocodelat' );
3131 $magicWords['geocodelng'] = array ( 0, 'geocodelng' );
@@ -36,18 +36,22 @@
3737 * Adds the parser function hooks
3838 */
3939 function efMapsRegisterParserFunctions(&$wgParser) {
40 - // A hooks to enable the '#display_point' and '#display_points' parser functions
 40+ // A hook to enable the '#display_map' parser function
 41+ $wgParser->setFunctionHook( 'display_map', array('MapsParserFunctions', 'displayMapRender') );
 42+
 43+ // Hooks to enable the '#display_point' and '#display_points' parser functions
4144 $wgParser->setFunctionHook( 'display_point', array('MapsParserFunctions', 'displayPointRender') );
42 - $wgParser->setFunctionHook( 'display_points', array('MapsParserFunctions', 'displayPointsRender') );
 45+ //$wgParser->setFunctionHook( 'display_points', array('MapsParserFunctions', 'displayPointRender') );
4346
44 - // A hooks to enable the '#display_adress' and '#display_adresses' parser functions
 47+ // Hooks to enable the '#display_adress' and '#display_adresses' parser functions
4548 $wgParser->setFunctionHook( 'display_address', array('MapsParserFunctions', 'displayAddressRender') );
46 - $wgParser->setFunctionHook( 'display_addresses', array('MapsParserFunctions', 'displayAddressesRender') );
 49+ //$wgParser->setFunctionHook( 'display_addresses', array('MapsParserFunctions', 'displayAddressRender') );
4750
48 - // A hook to enable the geocoder parser functions
 51+ // Hooks to enable the geocoding parser functions
4952 $wgParser->setFunctionHook( 'geocode', array('MapsGeocoder', 'renderGeocoder') );
50 - $wgParser->setFunctionHook( 'geocodelat' , array('MapsGeocoder', 'renderGeocoderLat') );
51 - $wgParser->setFunctionHook( 'geocodelng' , array('MapsGeocoder', 'renderGeocoderLng') );
 53+ $wgParser->setFunctionHook( 'geocodelat', array('MapsGeocoder', 'renderGeocoderLat') );
 54+ $wgParser->setFunctionHook( 'geocodelng', array('MapsGeocoder', 'renderGeocoderLng') );
 55+
5256 return true;
5357 }
5458
@@ -61,16 +65,37 @@
6266 final class MapsParserFunctions {
6367
6468 /**
65 - * Initialize the parser functions feature
 69+ * Initialize the parser functions feature. This function handles the parser function hook,
 70+ * and will load the required classes.
6671 *
6772 */
6873 public static function initialize() {
69 - global $egMapsIP, $wgAutoloadClasses, $wgHooks, $wgParser;
 74+ global $egMapsIP, $IP, $wgAutoloadClasses, $egMapsAvailableFeatures, $egMapsServices;
7075
71 - $wgAutoloadClasses['MapsBaseMap'] = $egMapsIP . '/ParserFunctions/Maps_BaseMap.php';
 76+ //$wgAutoloadClasses['MapsBaseMap'] = $egMapsIP . '/ParserFunctions/Maps_BaseMap.php';
 77+ //$wgAutoloadClasses['MapsBasePointMap'] = $egMapsIP . '/ParserFunctions/Maps_BasePointMap.php';
 78+
 79+ foreach($egMapsAvailableFeatures['pf']['functions'] as $parser_name => $parser_data) {
 80+ $file = $parser_data['local'] ? $egMapsIP . '/' . $parser_data['file'] : $IP . '/extensions/' . $parser_data['file'];
 81+ $wgAutoloadClasses[$parser_data['class']] = $file;
 82+ }
 83+
 84+ foreach($egMapsServices as $serviceName => $serviceData) {
 85+ // Check if the service has parser function support
 86+ $hasPFs = array_key_exists('pf', $serviceData);
 87+
 88+ // If the service has no parser function support, skipt it and continue with the next one.
 89+ if (!$hasPFs) continue;
 90+
 91+ // Go through the parser functions supported by the mapping service, and load their classes.
 92+ foreach($serviceData['pf'] as $parser_name => $parser_data) {
 93+ $file = $parser_data['local'] ? $egMapsIP . '/' . $parser_data['file'] : $IP . '/extensions/' . $parser_data['file'];
 94+ $wgAutoloadClasses[$parser_data['class']] = $file;
 95+ }
 96+ }
7297 }
7398
74 - public static function getMapHtml(&$parser, array $params, array $coordFails = array()) {
 99+ public static function getMapHtml(&$parser, array $params, $parserFunction, array $coordFails = array()) {
75100 global $wgLang;
76101
77102 $map = array();
@@ -97,7 +122,7 @@
98123 if (! MapsMapper::paramIsPresent('service', $map)) $map['service'] = '';
99124 $map['service'] = MapsMapper::getValidService($map['service'], 'pf');
100125
101 - $mapClass = self::getParserClassInstance($map['service']);
 126+ $mapClass = self::getParserClassInstance($map['service'], $parserFunction);
102127
103128 // Call the function according to the map service to get the HTML output
104129 $output = $mapClass->displayMap($parser, $map);
@@ -117,9 +142,11 @@
118143 return array( $output, 'noparse' => true, 'isHTML' => true );
119144 }
120145
121 - private static function getParserClassInstance($service) {
 146+ private static function getParserClassInstance($service, $parserFunction) {
122147 global $egMapsServices;
123 - return new $egMapsServices[$service]['pf']['class']();
 148+ // TODO: add check to see if the service actually supports this parser function, and return false for error handling if not.
 149+ //die($egMapsServices[$service]['pf'][$parserFunction]['class']);
 150+ return new $egMapsServices[$service]['pf'][$parserFunction]['class']();
124151 }
125152
126153 /**
@@ -133,20 +160,9 @@
134161 $params = func_get_args();
135162 array_shift( $params ); // We already know the $parser ...
136163
137 - return self::getMapHtml($parser, $params);
138 - }
139 -
140 - /**
141 - * Sets the default map properties, gets the map HTML depending
142 - * on the provided service, and then returns it.
143 - *
144 - * @param unknown_type $parser
145 - */
146 - public static function displayPointsRender(&$parser) {
147 - $params = func_get_args();
148 - array_shift( $params ); // We already know the $parser ...
 164+ // TODO: auto geocode when required
149165
150 - return self::getMapHtml($parser, $params);
 166+ return self::getMapHtml($parser, $params, 'display_point');
151167 }
152168
153169 /**
@@ -156,29 +172,33 @@
157173 * @param unknown_type $parser
158174 * @return array
159175 */
160 - public static function displayAddressRender(&$parser) {
 176+ public static function displayAddressRender(&$parser) {
 177+ // TODO: remove
161178 $params = func_get_args();
162179 array_shift( $params ); // We already know the $parser ...
163180
164181 $fails = self::changeAddressToCoords($params);
165182
166 - return self::getMapHtml($parser, $params, $fails);
 183+ return self::getMapHtml($parser, $params, 'display_point', $fails);
167184 }
168185
169186 /**
170 - * Turns the address parameter into coordinates, then calls
171 - * getMapHtml() and returns it's result.
 187+ * If an address value is provided, turn it into coordinates,
 188+ * then calls getMapHtml() and returns it's result.
172189 *
173190 * @param unknown_type $parser
 191+ * @return array
174192 */
175 - public static function displayAddressesRender(&$parser) {
 193+ public static function displayMapRender(&$parser) {
176194 $params = func_get_args();
177195 array_shift( $params ); // We already know the $parser ...
178196
179 - $fails = self::changeAddressToCoords($params);
 197+ // TODO: auto geocode when required
 198+ //$fails = self::changeAddressToCoords($params);
 199+ //die('disp map');
180200
181 - return self::getMapHtml($parser, $params, $fails);
182 - }
 201+ return self::getMapHtml($parser, $params, 'display_map');
 202+ }
183203
184204 /**
185205 * Changes the values of the address or addresses parameter into coordinates
Index: trunk/extensions/Maps/ParserFunctions/Maps_BaseMap.php
@@ -1,7 +1,7 @@
22 <?php
33
44 /**
5 - * Abstract class MapsBaseMap provides the scafolding for classes handling parser function
 5+ * Abstract class MapsBaseMap provides the scafolding for classes handling display_map
66 * calls for a spesific mapping service. It inherits from MapsMapFeature and therefore
77 * forces inheriting classes to implement sereveral methods.
88 *
@@ -17,8 +17,6 @@
1818
1919 abstract class MapsBaseMap extends MapsMapFeature {
2020
21 - protected $markerData = array();
22 -
2321 /**
2422 * Handles the request from the parser hook by doing the work that's common for all
2523 * mapping services, calling the specific methods and finally returning the resulting output.
@@ -28,8 +26,8 @@
2927 *
3028 * @return html
3129 */
32 - public final function displayMap(&$parser, array $params) {
33 - global $wgLang;
 30+ public final function displayMap(&$parser, array $params) {
 31+die('disp map');
3432
3533 $this->setMapSettings();
3634
@@ -37,18 +35,12 @@
3836
3937 $this->doMapServiceLoad();
4038
41 - $this->setMapName();
 39+ $this->setMapName();
4240
43 - $this->setCoordinates($parser);
44 -
4541 $this->setZoom();
4642
4743 $this->setCentre();
4844
49 - $this->doParsing($parser);
50 -
51 - $this->doEscaping();
52 -
5345 $this->addSpecificMapHTML();
5446
5547 return $this->output;
@@ -69,98 +61,11 @@
7062 *
7163 */
7264 private function setZoom() {
73 - if (strlen($this->zoom) < 1) {
74 - if (count($this->markerData) > 1) {
75 - $this->zoom = 'null';
76 - }
77 - else {
78 - $this->zoom = $this->defaultZoom;
79 - }
80 - }
 65+ if (strlen($this->zoom) < 1) $this->zoom = $this->defaultZoom;
8166 }
8267
83 - /**
84 - * Fills the $markerData array with the locations and their meta data.
85 - *
86 - * @param unknown_type $parser
87 - */
88 - private function setCoordinates($parser) {
89 - $this->coordinates = explode(';', $this->coordinates);
90 -
91 - foreach($this->coordinates as $coordinates) {
92 - $args = explode('~', $coordinates);
93 -
94 - $args[0] = str_replace('″', '"', $args[0]);
95 - $args[0] = str_replace('′', "'", $args[0]);
96 -
97 - $markerData = MapsUtils::getLatLon($args[0]);
98 -
99 - if (count($args) > 1) {
100 - $markerData['title'] = $parser->recursiveTagParse( $args[1] );
101 -
102 - if (count($args) > 2) {
103 - $markerData['label'] = $parser->recursiveTagParse( $args[2] );
104 -
105 - if (count($args) > 3) {
106 - $markerData['icon'] = $args[3];
107 - }
108 - }
109 - }
110 -
111 - $this->markerData[] = $markerData;
112 - }
113 - }
114 -
115 - /**
116 - * Sets the $centre_lat and $centre_lon fields.
117 - * Note: this needs to be done AFTRE the maker coordinates are set.
118 - *
119 - */
12068 private function setCentre() {
121 - if (empty($this->centre)) {
122 - if (count($this->markerData) == 1) {
123 - // If centre is not set and there is exactelly one marker, use it's coordinates.
124 - $this->centre_lat = $this->markerData[0]['lat'];
125 - $this->centre_lon = $this->markerData[0]['lon'];
126 - }
127 - elseif (count($this->markerData) > 1) {
128 - // If centre is not set and there are multiple markers, set the values to null,
129 - // to be auto determined by the JS of the mapping API.
130 - $this->centre_lat = 'null';
131 - $this->centre_lon = 'null';
132 - }
133 - else {
134 - // If centre is not set and there are no markers, use the default latitude and longitutde.
135 - global $egMapsMapLat, $egMapsMapLon;
136 - $this->centre_lat = $egMapsMapLat;
137 - $this->centre_lon = $egMapsMapLon;
138 - }
139 - }
140 - else {
141 - // If a centre value is set, use it.
142 - $centre = MapsUtils::getLatLon($this->centre);
143 - $this->centre_lat = $centre['lat'];
144 - $this->centre_lon = $centre['lon'];
145 - }
146 - }
147 -
148 - /**
149 - * Parse the wiki text in the title and label values.
150 - *
151 - * @param unknown_type $parser
152 - */
153 - private function doParsing(&$parser) {
154 - $this->title = $parser->recursiveTagParse( $this->title );
155 - $this->label = $parser->recursiveTagParse( $this->label );
 69+ if (strlen($this->centre) < 1) $this->centre = $this->defaultZoom;
15670 }
15771
158 - /**
159 - * Escape the title and label text
160 - *
161 - */
162 - private function doEscaping() {
163 - $this->title = str_replace("'", "\'", $this->title);
164 - $this->label = str_replace("'", "\'", $this->label);
165 - }
166 -
16772 }
Index: trunk/extensions/Maps/Maps.php
@@ -23,7 +23,7 @@
2424 die( 'Not an entry point.' );
2525 }
2626
27 -define('Maps_VERSION', '0.3.5 a3');
 27+define('Maps_VERSION', '0.3.5 a4');
2828
2929 $egMapsScriptPath = $wgScriptPath . '/extensions/Maps';
3030 $egMapsIP = $IP . '/extensions/Maps';
@@ -48,11 +48,6 @@
4949
5050 if (empty($egMapsServices)) $egMapsServices = array();
5151
52 -// TODO: move inclusions, or add init file to settings to allow auto load?
53 -include_once $egMapsIP . '/GoogleMaps/Maps_GoogleMaps.php';
54 -include_once $egMapsIP . '/OpenLayers/Maps_OpenLayers.php';
55 -include_once $egMapsIP . '/YahooMaps/Maps_YahooMaps.php';
56 -
5752 // TODO: split Maps_ParserFunctions.php functionallity so this line is not required
5853 include_once $egMapsIP . '/ParserFunctions/Maps_ParserFunctions.php';
5954
@@ -101,9 +96,11 @@
10297 // Check for wich services there are handlers for the current fature, and load them
10398 foreach ($egMapsServices as $serviceData) {
10499 if (array_key_exists($key, $serviceData)) {
105 - $file = $serviceData[$key]['local'] ? $egMapsIP . '/' . $serviceData[$key]['file'] : $IP . '/extensions/' . $serviceData[$key]['file'];
106 - $wgAutoloadClasses[$serviceData[$key]['class']] = $file;
107 - }
 100+ if (array_key_exists('class', $serviceData[$key]) && array_key_exists('file', $serviceData[$key]) && array_key_exists('local', $serviceData[$key])) {
 101+ $file = $serviceData[$key]['local'] ? $egMapsIP . '/' . $serviceData[$key]['file'] : $IP . '/extensions/' . $serviceData[$key]['file'];
 102+ $wgAutoloadClasses[$serviceData[$key]['class']] = $file;
 103+ }
 104+ }
108105
109106 if (array_key_exists('classes', $serviceData)) {
110107 foreach($serviceData['classes'] as $class) {
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsParserFunctions.php
@@ -1,98 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Class for handling the Maps parser functions with Google Maps
6 - *
7 - * @file Maps_GoogleMapsParserFunctions.php
8 - * @ingroup Maps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -final class MapsGoogleMapsParserFunctions extends MapsBaseMap {
18 -
19 - public $serviceName = MapsGoogleMapsUtils::SERVICE_NAME;
20 -
21 - /**
22 - * @see MapsBaseMap::setMapSettings()
23 - *
24 - */
25 - protected function setMapSettings() {
26 - global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix;
27 -
28 - $this->defaultParams = MapsGoogleMapsUtils::getDefaultParams();
29 -
30 - $this->elementNamePrefix = $egMapsGoogleMapsPrefix;
31 - $this->defaultZoom = $egMapsGoogleMapsZoom;
32 - }
33 -
34 - /**
35 - * @see MapsBaseMap::doMapServiceLoad()
36 - *
37 - */
38 - protected function doMapServiceLoad() {
39 - global $egGoogleMapsOnThisPage;
40 -
41 - MapsGoogleMapsUtils::addGMapDependencies($this->output);
42 - $egGoogleMapsOnThisPage++;
43 -
44 - $this->elementNr = $egGoogleMapsOnThisPage;
45 - }
46 -
47 - /**
48 - * @see MapsBaseMap::addSpecificMapHTML()
49 - *
50 - */
51 - public function addSpecificMapHTML() {
52 - global $wgJsMimeType;
53 -
54 - $enableEarth = MapsGoogleMapsUtils::getEarthValue($this->earth);
55 -
56 - $this->type = MapsGoogleMapsUtils::getGMapType($this->type, true);
57 -
58 - $this->controls = MapsGoogleMapsUtils::createControlsString($this->controls);
59 -
60 - $this->autozoom = MapsGoogleMapsUtils::getAutozoomJSValue($this->autozoom);
61 -
62 - $markerItems = array();
63 -
64 - // TODO: Refactor up
65 - foreach ($this->markerData as $markerData) {
66 - $lat = $markerData['lat'];
67 - $lon = $markerData['lon'];
68 -
69 - $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
70 - $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
71 -
72 - $title = str_replace("'", "\'", $title);
73 - $label = str_replace("'", "\'", $label);
74 -
75 - $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
76 - $markerItems[] = "getGMarkerData($lat, $lon, '$title', '$label', '$icon')";
77 - }
78 -
79 - $markersString = implode(',', $markerItems);
80 -
81 - $this->types = explode(",", $this->types);
82 -
83 - $typesString = MapsGoogleMapsUtils::createTypesString($this->types, $enableEarth);
84 -
85 - $this->output .=<<<END
86 -
87 -<div id="$this->mapName" class="$this->class" style="$this->style" ></div>
88 -<script type="$wgJsMimeType"> /*<![CDATA[*/
89 -addLoadEvent(
90 - initializeGoogleMap('$this->mapName', $this->width, $this->height, $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [$markersString])
91 -);
92 -/*]]>*/ </script>
93 -
94 -END;
95 -
96 - }
97 -
98 -}
99 -
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php
@@ -0,0 +1,77 @@
 2+<?php
 3+
 4+/**
 5+ * Class for handling the display_map parser function with Google Maps
 6+ *
 7+ * @file Maps_GoogleMapsDispMap.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+final class MapsGoogleMapsDispMap extends MapsBasePointMap {
 18+
 19+ public $serviceName = MapsGoogleMapsUtils::SERVICE_NAME;
 20+
 21+ /**
 22+ * @see MapsBaseMap::setMapSettings()
 23+ *
 24+ */
 25+ protected function setMapSettings() {
 26+ global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix;
 27+
 28+ $this->defaultParams = MapsGoogleMapsUtils::getDefaultParams();
 29+
 30+ $this->elementNamePrefix = $egMapsGoogleMapsPrefix;
 31+ $this->defaultZoom = $egMapsGoogleMapsZoom;
 32+ }
 33+
 34+ /**
 35+ * @see MapsBaseMap::doMapServiceLoad()
 36+ *
 37+ */
 38+ protected function doMapServiceLoad() {
 39+ global $egGoogleMapsOnThisPage;
 40+
 41+ MapsGoogleMapsUtils::addGMapDependencies($this->output);
 42+ $egGoogleMapsOnThisPage++;
 43+
 44+ $this->elementNr = $egGoogleMapsOnThisPage;
 45+ }
 46+
 47+ /**
 48+ * @see MapsBaseMap::addSpecificMapHTML()
 49+ *
 50+ */
 51+ public function addSpecificMapHTML() {
 52+ global $wgJsMimeType;
 53+
 54+ $this->type = MapsGoogleMapsUtils::getGMapType($this->type, true);
 55+
 56+ $this->controls = MapsGoogleMapsUtils::createControlsString($this->controls);
 57+
 58+ $this->autozoom = MapsGoogleMapsUtils::getAutozoomJSValue($this->autozoom);
 59+
 60+ $this->types = explode(",", $this->types);
 61+
 62+ $typesString = MapsGoogleMapsUtils::createTypesString($this->types);
 63+
 64+ $this->output .=<<<END
 65+
 66+<div id="$this->mapName" class="$this->class" style="$this->style" ></div>
 67+<script type="$wgJsMimeType"> /*<![CDATA[*/
 68+addLoadEvent(
 69+ initializeGoogleMap('$this->mapName', $this->width, $this->height, $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [])
 70+);
 71+/*]]>*/ </script>
 72+
 73+END;
 74+
 75+ }
 76+
 77+}
 78+
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php
@@ -10,7 +10,10 @@
1111 */
1212
1313 $egMapsServices['googlemaps'] = array(
14 - 'pf' => array('class' => 'MapsGoogleMapsParserFunctions', 'file' => 'GoogleMaps/Maps_GoogleMapsParserFunctions.php', 'local' => true),
 14+ 'pf' => array(
 15+ 'display_point' => array('class' => 'MapsGoogleMapsDispPoint', 'file' => 'GoogleMaps/Maps_GoogleMapsDispPoint.php', 'local' => true),
 16+ 'display_map' => array('class' => 'MapsGoogleMapsDispMap', 'file' => 'GoogleMaps/Maps_GoogleMapsDispMap.php', 'local' => true),
 17+ ),
1518 'classes' => array(
1619 array('class' => 'MapsGoogleMapsUtils', 'file' => 'GoogleMaps/Maps_GoogleMapsUtils.php', 'local' => true)
1720 ),
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsUtils.php
@@ -167,7 +167,7 @@
168168 * @param boolean $enableEarth
169169 * @return string
170170 */
171 - public function createTypesString(array &$types, $enableEarth) {
 171+ public function createTypesString(array &$types, $enableEarth = false) {
172172 global $egMapsGoogleMapsTypes, $egMapsGoogleMapTypesValid;
173173
174174 $types = MapsMapper::getValidTypes($types, $egMapsGoogleMapsTypes, $egMapsGoogleMapTypesValid, array(__CLASS__, 'getGMapType'));
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php
@@ -0,0 +1,98 @@
 2+<?php
 3+
 4+/**
 5+ * Class for handling the display_point(s) parser functions with Google Maps
 6+ *
 7+ * @file Maps_GoogleMapsDispPoint.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+final class MapsGoogleMapsDispPoint extends MapsBasePointMap {
 18+
 19+ public $serviceName = MapsGoogleMapsUtils::SERVICE_NAME;
 20+
 21+ /**
 22+ * @see MapsBaseMap::setMapSettings()
 23+ *
 24+ */
 25+ protected function setMapSettings() {
 26+ global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix;
 27+
 28+ $this->defaultParams = MapsGoogleMapsUtils::getDefaultParams();
 29+
 30+ $this->elementNamePrefix = $egMapsGoogleMapsPrefix;
 31+ $this->defaultZoom = $egMapsGoogleMapsZoom;
 32+ }
 33+
 34+ /**
 35+ * @see MapsBaseMap::doMapServiceLoad()
 36+ *
 37+ */
 38+ protected function doMapServiceLoad() {
 39+ global $egGoogleMapsOnThisPage;
 40+
 41+ MapsGoogleMapsUtils::addGMapDependencies($this->output);
 42+ $egGoogleMapsOnThisPage++;
 43+
 44+ $this->elementNr = $egGoogleMapsOnThisPage;
 45+ }
 46+
 47+ /**
 48+ * @see MapsBaseMap::addSpecificMapHTML()
 49+ *
 50+ */
 51+ public function addSpecificMapHTML() {
 52+ global $wgJsMimeType;
 53+
 54+ $enableEarth = MapsGoogleMapsUtils::getEarthValue($this->earth);
 55+
 56+ $this->type = MapsGoogleMapsUtils::getGMapType($this->type, true);
 57+
 58+ $this->controls = MapsGoogleMapsUtils::createControlsString($this->controls);
 59+
 60+ $this->autozoom = MapsGoogleMapsUtils::getAutozoomJSValue($this->autozoom);
 61+
 62+ $markerItems = array();
 63+
 64+ // TODO: Refactor up
 65+ foreach ($this->markerData as $markerData) {
 66+ $lat = $markerData['lat'];
 67+ $lon = $markerData['lon'];
 68+
 69+ $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
 70+ $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
 71+
 72+ $title = str_replace("'", "\'", $title);
 73+ $label = str_replace("'", "\'", $label);
 74+
 75+ $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
 76+ $markerItems[] = "getGMarkerData($lat, $lon, '$title', '$label', '$icon')";
 77+ }
 78+
 79+ $markersString = implode(',', $markerItems);
 80+
 81+ $this->types = explode(",", $this->types);
 82+
 83+ $typesString = MapsGoogleMapsUtils::createTypesString($this->types, $enableEarth);
 84+
 85+ $this->output .=<<<END
 86+
 87+<div id="$this->mapName" class="$this->class" style="$this->style" ></div>
 88+<script type="$wgJsMimeType"> /*<![CDATA[*/
 89+addLoadEvent(
 90+ initializeGoogleMap('$this->mapName', $this->width, $this->height, $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [$markersString])
 91+);
 92+/*]]>*/ </script>
 93+
 94+END;
 95+
 96+ }
 97+
 98+}
 99+
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsParserFunctions.php
@@ -1,96 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Class for handling the Maps parser functions with Yahoo! Maps
6 - *
7 - * @file Maps_YahooMapsParserFunctions.php
8 - * @ingroup Maps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -class MapsYahooMapsParserFunctions extends MapsBaseMap {
18 -
19 - public $serviceName = MapsYahooMapsUtils::SERVICE_NAME;
20 -
21 - /**
22 - * @see MapsBaseMap::setFormInputSettings()
23 - *
24 - */
25 - protected function setMapSettings() {
26 - global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix;
27 -
28 - $this->defaultParams = MapsYahooMapsUtils::getDefaultParams();
29 -
30 - $this->elementNamePrefix = $egMapsYahooMapsPrefix;
31 - $this->defaultZoom = $egMapsYahooMapsZoom;
32 - }
33 -
34 - /**
35 - * @see MapsBaseMap::doMapServiceLoad()
36 - *
37 - */
38 - protected function doMapServiceLoad() {
39 - global $egYahooMapsOnThisPage;
40 -
41 - MapsYahooMapsUtils::addYMapDependencies($this->output);
42 - $egYahooMapsOnThisPage++;
43 -
44 - $this->elementNr = $egYahooMapsOnThisPage;
45 - }
46 -
47 - /**
48 - * @see MapsBaseMap::addSpecificMapHTML()
49 - *
50 - */
51 - public function addSpecificMapHTML() {
52 - global $wgJsMimeType;
53 -
54 - $this->type = MapsYahooMapsUtils::getYMapType($this->type, true);
55 -
56 - $this->controls = MapsYahooMapsUtils::createControlsString($this->controls);
57 -
58 - MapsUtils::makePxValue($this->width);
59 - MapsUtils::makePxValue($this->height);
60 -
61 - $this->autozoom = MapsYahooMapsUtils::getAutozoomJSValue($this->autozoom);
62 -
63 - $markerItems = array();
64 -
65 - // TODO: Refactor up
66 - foreach ($this->markerData as $markerData) {
67 - $lat = $markerData['lat'];
68 - $lon = $markerData['lon'];
69 -
70 - $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
71 - $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
72 -
73 - $title = str_replace("'", "\'", $title);
74 - $label = str_replace("'", "\'", $label);
75 -
76 - $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
77 - $markerItems[] = "getYMarkerData($lat, $lon, '$title', '$label', '$icon')";
78 - }
79 -
80 - $markersString = implode(',', $markerItems);
81 -
82 - $this->types = explode(",", $this->types);
83 -
84 - $typesString = MapsYahooMapsUtils::createTypesString($this->types);
85 -
86 - $this->output .= <<<END
87 - <div id="$this->mapName" style="width: $this->width; height: $this->height;"></div>
88 -
89 - <script type="$wgJsMimeType">/*<![CDATA[*/
90 - addLoadEvent(
91 - initializeYahooMap('$this->mapName', $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [$markersString])
92 - );
93 - /*]]>*/</script>
94 -END;
95 - }
96 -
97 -}
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispPoint.php
@@ -0,0 +1,96 @@
 2+<?php
 3+
 4+/**
 5+ * Class for handling the display_point(s) parser functions with Yahoo! Maps
 6+ *
 7+ * @file Maps_YahooMapsDispPoint.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+class MapsYahooMapsDispPoint extends MapsBasePointMap {
 18+
 19+ public $serviceName = MapsYahooMapsUtils::SERVICE_NAME;
 20+
 21+ /**
 22+ * @see MapsBaseMap::setFormInputSettings()
 23+ *
 24+ */
 25+ protected function setMapSettings() {
 26+ global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix;
 27+
 28+ $this->defaultParams = MapsYahooMapsUtils::getDefaultParams();
 29+
 30+ $this->elementNamePrefix = $egMapsYahooMapsPrefix;
 31+ $this->defaultZoom = $egMapsYahooMapsZoom;
 32+ }
 33+
 34+ /**
 35+ * @see MapsBaseMap::doMapServiceLoad()
 36+ *
 37+ */
 38+ protected function doMapServiceLoad() {
 39+ global $egYahooMapsOnThisPage;
 40+
 41+ MapsYahooMapsUtils::addYMapDependencies($this->output);
 42+ $egYahooMapsOnThisPage++;
 43+
 44+ $this->elementNr = $egYahooMapsOnThisPage;
 45+ }
 46+
 47+ /**
 48+ * @see MapsBaseMap::addSpecificMapHTML()
 49+ *
 50+ */
 51+ public function addSpecificMapHTML() {
 52+ global $wgJsMimeType;
 53+
 54+ $this->type = MapsYahooMapsUtils::getYMapType($this->type, true);
 55+
 56+ $this->controls = MapsYahooMapsUtils::createControlsString($this->controls);
 57+
 58+ MapsUtils::makePxValue($this->width);
 59+ MapsUtils::makePxValue($this->height);
 60+
 61+ $this->autozoom = MapsYahooMapsUtils::getAutozoomJSValue($this->autozoom);
 62+
 63+ $markerItems = array();
 64+
 65+ // TODO: Refactor up
 66+ foreach ($this->markerData as $markerData) {
 67+ $lat = $markerData['lat'];
 68+ $lon = $markerData['lon'];
 69+
 70+ $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
 71+ $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
 72+
 73+ $title = str_replace("'", "\'", $title);
 74+ $label = str_replace("'", "\'", $label);
 75+
 76+ $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
 77+ $markerItems[] = "getYMarkerData($lat, $lon, '$title', '$label', '$icon')";
 78+ }
 79+
 80+ $markersString = implode(',', $markerItems);
 81+
 82+ $this->types = explode(",", $this->types);
 83+
 84+ $typesString = MapsYahooMapsUtils::createTypesString($this->types);
 85+
 86+ $this->output .= <<<END
 87+ <div id="$this->mapName" style="width: $this->width; height: $this->height;"></div>
 88+
 89+ <script type="$wgJsMimeType">/*<![CDATA[*/
 90+ addLoadEvent(
 91+ initializeYahooMap('$this->mapName', $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [$markersString])
 92+ );
 93+ /*]]>*/</script>
 94+END;
 95+ }
 96+
 97+}
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispMap.php
@@ -0,0 +1,77 @@
 2+<?php
 3+
 4+/**
 5+ * Class for handling the display_map parser function with Yahoo! Maps
 6+ *
 7+ * @file Maps_YahooMapsDispMap.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+class MapsYahooMapsDispMap extends MapsBasePointMap {
 18+
 19+ public $serviceName = MapsYahooMapsUtils::SERVICE_NAME;
 20+
 21+ /**
 22+ * @see MapsBaseMap::setFormInputSettings()
 23+ *
 24+ */
 25+ protected function setMapSettings() {
 26+ global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix;
 27+
 28+ $this->defaultParams = MapsYahooMapsUtils::getDefaultParams();
 29+
 30+ $this->elementNamePrefix = $egMapsYahooMapsPrefix;
 31+ $this->defaultZoom = $egMapsYahooMapsZoom;
 32+ }
 33+
 34+ /**
 35+ * @see MapsBaseMap::doMapServiceLoad()
 36+ *
 37+ */
 38+ protected function doMapServiceLoad() {
 39+ global $egYahooMapsOnThisPage;
 40+
 41+ MapsYahooMapsUtils::addYMapDependencies($this->output);
 42+ $egYahooMapsOnThisPage++;
 43+
 44+ $this->elementNr = $egYahooMapsOnThisPage;
 45+ }
 46+
 47+ /**
 48+ * @see MapsBaseMap::addSpecificMapHTML()
 49+ *
 50+ */
 51+ public function addSpecificMapHTML() {
 52+ global $wgJsMimeType;
 53+
 54+ $this->type = MapsYahooMapsUtils::getYMapType($this->type, true);
 55+
 56+ $this->controls = MapsYahooMapsUtils::createControlsString($this->controls);
 57+
 58+ MapsUtils::makePxValue($this->width);
 59+ MapsUtils::makePxValue($this->height);
 60+
 61+ $this->autozoom = MapsYahooMapsUtils::getAutozoomJSValue($this->autozoom);
 62+
 63+ $this->types = explode(",", $this->types);
 64+
 65+ $typesString = MapsYahooMapsUtils::createTypesString($this->types);
 66+
 67+ $this->output .= <<<END
 68+ <div id="$this->mapName" style="width: $this->width; height: $this->height;"></div>
 69+
 70+ <script type="$wgJsMimeType">/*<![CDATA[*/
 71+ addLoadEvent(
 72+ initializeYahooMap('$this->mapName', $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [])
 73+ );
 74+ /*]]>*/</script>
 75+END;
 76+ }
 77+
 78+}
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php
@@ -10,7 +10,10 @@
1111 */
1212
1313 $egMapsServices['yahoomaps'] = array(
14 - 'pf' => array('class' => 'MapsYahooMapsParserFunctions', 'file' => 'YahooMaps/Maps_YahooMapsParserFunctions.php', 'local' => true),
 14+ 'pf' => array(
 15+ 'display_point' => array('class' => 'MapsYahooMapsDispPoint', 'file' => 'YahooMaps/Maps_YahooMapsDispPoint.php', 'local' => true),
 16+ 'display_map' => array('class' => 'MapsYahooMapsDispMap', 'file' => 'YahooMaps/Maps_YahooMapsDispMap.php', 'local' => true),
 17+ ),
1518 'classes' => array(
1619 array('class' => 'MapsYahooMapsUtils', 'file' => 'YahooMaps/Maps_YahooMapsUtils.php', 'local' => true)
1720 ),
Index: trunk/extensions/Maps/Maps_Settings.php
@@ -18,20 +18,10 @@
1919 die( 'Not an entry point.' );
2020 }
2121
22 -# API keys configuration
2322
24 -# Your Google Maps API key. Required for displaying Google Maps, and using the Google Geocoder services.
25 -# Haven't got an API key yet? Get it here: http://code.google.com/apis/maps/signup.html
26 -if (empty($egGoogleMapsKey)) $egGoogleMapsKey = '';
2723
28 -# Your Yahoo! Maps API key. Required for displaying Yahoo! Maps.
29 -# Haven't got an API key yet? Get it here: https://developer.yahoo.com/wsregapp/
30 -if (empty($egYahooMapsKey)) $egYahooMapsKey = '';
3124
3225
33 -
34 -
35 -
3626 # Map features configuration
3727 # (named) Array of String. This array contains the available features for Maps.
3828 # The array element name contains an abbriviation, used for code references,
@@ -42,7 +32,11 @@
4333 'name' => 'Parser Function',
4434 'class' => 'MapsParserFunctions',
4535 'file' => 'ParserFunctions/Maps_ParserFunctions.php',
46 - 'local' => true
 36+ 'local' => true,
 37+ 'functions' => array(
 38+ 'display_point' => array('class' => 'MapsBasePointMap', 'file' => 'ParserFunctions/Maps_BasePointMap.php', 'local' => true),
 39+ 'display_map' => array('class' => 'MapsBaseMap', 'file' => 'ParserFunctions/Maps_BaseMap.php', 'local' => true),
 40+ ),
4741 );
4842
4943
@@ -50,8 +44,13 @@
5145
5246
5347 # Map services configuration
54 -# Note: You can not use aliases in the setting. Use the main service names.
 48+# Note: You can not use aliases in the settings. Use the main service names.
5549
 50+# Include the mapping services that should be loaded into Maps.
 51+include_once $egMapsIP . '/GoogleMaps/Maps_GoogleMaps.php';
 52+include_once $egMapsIP . '/OpenLayers/Maps_OpenLayers.php';
 53+include_once $egMapsIP . '/YahooMaps/Maps_YahooMaps.php';
 54+
5655 # Array of String. Array containing all the mapping services that will be made available to the user.
5756 # Currently Maps provides the following services: googlemaps, yahoomaps, openlayers
5857 $egMapsAvailableServices = array('googlemaps', 'yahoomaps', 'openlayers');
@@ -102,6 +101,10 @@
103102
104103 # Google maps
105104
 105+# Your Google Maps API key. Required for displaying Google Maps, and using the Google Geocoder services.
 106+# Haven't got an API key yet? Get it here: http://code.google.com/apis/maps/signup.html
 107+if (empty($egGoogleMapsKey)) $egGoogleMapsKey = '';
 108+
106109 # String. The Google Maps map name prefix. It can not be identical to the one of another mapping service.
107110 $egMapsGoogleMapsPrefix = 'map_google';
108111
@@ -126,6 +129,10 @@
127130
128131 # Yahoo maps
129132
 133+# Your Yahoo! Maps API key. Required for displaying Yahoo! Maps.
 134+# Haven't got an API key yet? Get it here: https://developer.yahoo.com/wsregapp/
 135+if (empty($egYahooMapsKey)) $egYahooMapsKey = '';
 136+
130137 # String. The Yahoo! maps map name prefix. It can not be identical to the one of another mapping service.
131138 $egMapsYahooMapsPrefix = 'map_yahoo';
132139

Status & tagging log