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 @@ |
11 | 11 | */ |
12 | 12 | |
13 | 13 | $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 | + ), |
15 | 18 | 'classes' => array( |
16 | 19 | array('class' => 'MapsOpenLayersUtils', 'file' => 'OpenLayers/Maps_OpenLayersUtils.php', 'local' => true) |
17 | 20 | ), |
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 @@ |
21 | 21 | * Adds the magic words for the parser functions |
22 | 22 | */ |
23 | 23 | 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' ); |
28 | 26 | |
| 27 | + $magicWords['display_map'] = array( 0, 'display_map'); |
| 28 | + |
29 | 29 | $magicWords['geocode'] = array( 0, 'geocode' ); |
30 | 30 | $magicWords['geocodelat'] = array ( 0, 'geocodelat' ); |
31 | 31 | $magicWords['geocodelng'] = array ( 0, 'geocodelng' ); |
— | — | @@ -36,18 +36,22 @@ |
37 | 37 | * Adds the parser function hooks |
38 | 38 | */ |
39 | 39 | 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 |
41 | 44 | $wgParser->setFunctionHook( 'display_point', array('MapsParserFunctions', 'displayPointRender') ); |
42 | | - $wgParser->setFunctionHook( 'display_points', array('MapsParserFunctions', 'displayPointsRender') ); |
| 45 | + //$wgParser->setFunctionHook( 'display_points', array('MapsParserFunctions', 'displayPointRender') ); |
43 | 46 | |
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 |
45 | 48 | $wgParser->setFunctionHook( 'display_address', array('MapsParserFunctions', 'displayAddressRender') ); |
46 | | - $wgParser->setFunctionHook( 'display_addresses', array('MapsParserFunctions', 'displayAddressesRender') ); |
| 49 | + //$wgParser->setFunctionHook( 'display_addresses', array('MapsParserFunctions', 'displayAddressRender') ); |
47 | 50 | |
48 | | - // A hook to enable the geocoder parser functions |
| 51 | + // Hooks to enable the geocoding parser functions |
49 | 52 | $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 | + |
52 | 56 | return true; |
53 | 57 | } |
54 | 58 | |
— | — | @@ -61,16 +65,37 @@ |
62 | 66 | final class MapsParserFunctions { |
63 | 67 | |
64 | 68 | /** |
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. |
66 | 71 | * |
67 | 72 | */ |
68 | 73 | public static function initialize() { |
69 | | - global $egMapsIP, $wgAutoloadClasses, $wgHooks, $wgParser; |
| 74 | + global $egMapsIP, $IP, $wgAutoloadClasses, $egMapsAvailableFeatures, $egMapsServices; |
70 | 75 | |
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 | + } |
72 | 97 | } |
73 | 98 | |
74 | | - public static function getMapHtml(&$parser, array $params, array $coordFails = array()) { |
| 99 | + public static function getMapHtml(&$parser, array $params, $parserFunction, array $coordFails = array()) { |
75 | 100 | global $wgLang; |
76 | 101 | |
77 | 102 | $map = array(); |
— | — | @@ -97,7 +122,7 @@ |
98 | 123 | if (! MapsMapper::paramIsPresent('service', $map)) $map['service'] = ''; |
99 | 124 | $map['service'] = MapsMapper::getValidService($map['service'], 'pf'); |
100 | 125 | |
101 | | - $mapClass = self::getParserClassInstance($map['service']); |
| 126 | + $mapClass = self::getParserClassInstance($map['service'], $parserFunction); |
102 | 127 | |
103 | 128 | // Call the function according to the map service to get the HTML output |
104 | 129 | $output = $mapClass->displayMap($parser, $map); |
— | — | @@ -117,9 +142,11 @@ |
118 | 143 | return array( $output, 'noparse' => true, 'isHTML' => true ); |
119 | 144 | } |
120 | 145 | |
121 | | - private static function getParserClassInstance($service) { |
| 146 | + private static function getParserClassInstance($service, $parserFunction) { |
122 | 147 | 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'](); |
124 | 151 | } |
125 | 152 | |
126 | 153 | /** |
— | — | @@ -133,20 +160,9 @@ |
134 | 161 | $params = func_get_args(); |
135 | 162 | array_shift( $params ); // We already know the $parser ... |
136 | 163 | |
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 |
149 | 165 | |
150 | | - return self::getMapHtml($parser, $params); |
| 166 | + return self::getMapHtml($parser, $params, 'display_point'); |
151 | 167 | } |
152 | 168 | |
153 | 169 | /** |
— | — | @@ -156,29 +172,33 @@ |
157 | 173 | * @param unknown_type $parser |
158 | 174 | * @return array |
159 | 175 | */ |
160 | | - public static function displayAddressRender(&$parser) { |
| 176 | + public static function displayAddressRender(&$parser) { |
| 177 | + // TODO: remove |
161 | 178 | $params = func_get_args(); |
162 | 179 | array_shift( $params ); // We already know the $parser ... |
163 | 180 | |
164 | 181 | $fails = self::changeAddressToCoords($params); |
165 | 182 | |
166 | | - return self::getMapHtml($parser, $params, $fails); |
| 183 | + return self::getMapHtml($parser, $params, 'display_point', $fails); |
167 | 184 | } |
168 | 185 | |
169 | 186 | /** |
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. |
172 | 189 | * |
173 | 190 | * @param unknown_type $parser |
| 191 | + * @return array |
174 | 192 | */ |
175 | | - public static function displayAddressesRender(&$parser) { |
| 193 | + public static function displayMapRender(&$parser) { |
176 | 194 | $params = func_get_args(); |
177 | 195 | array_shift( $params ); // We already know the $parser ... |
178 | 196 | |
179 | | - $fails = self::changeAddressToCoords($params); |
| 197 | + // TODO: auto geocode when required |
| 198 | + //$fails = self::changeAddressToCoords($params); |
| 199 | + //die('disp map'); |
180 | 200 | |
181 | | - return self::getMapHtml($parser, $params, $fails); |
182 | | - } |
| 201 | + return self::getMapHtml($parser, $params, 'display_map'); |
| 202 | + } |
183 | 203 | |
184 | 204 | /** |
185 | 205 | * Changes the values of the address or addresses parameter into coordinates |
Index: trunk/extensions/Maps/ParserFunctions/Maps_BaseMap.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * Abstract class MapsBaseMap provides the scafolding for classes handling parser function |
| 5 | + * Abstract class MapsBaseMap provides the scafolding for classes handling display_map |
6 | 6 | * calls for a spesific mapping service. It inherits from MapsMapFeature and therefore |
7 | 7 | * forces inheriting classes to implement sereveral methods. |
8 | 8 | * |
— | — | @@ -17,8 +17,6 @@ |
18 | 18 | |
19 | 19 | abstract class MapsBaseMap extends MapsMapFeature { |
20 | 20 | |
21 | | - protected $markerData = array(); |
22 | | - |
23 | 21 | /** |
24 | 22 | * Handles the request from the parser hook by doing the work that's common for all |
25 | 23 | * mapping services, calling the specific methods and finally returning the resulting output. |
— | — | @@ -28,8 +26,8 @@ |
29 | 27 | * |
30 | 28 | * @return html |
31 | 29 | */ |
32 | | - public final function displayMap(&$parser, array $params) { |
33 | | - global $wgLang; |
| 30 | + public final function displayMap(&$parser, array $params) { |
| 31 | +die('disp map'); |
34 | 32 | |
35 | 33 | $this->setMapSettings(); |
36 | 34 | |
— | — | @@ -37,18 +35,12 @@ |
38 | 36 | |
39 | 37 | $this->doMapServiceLoad(); |
40 | 38 | |
41 | | - $this->setMapName(); |
| 39 | + $this->setMapName(); |
42 | 40 | |
43 | | - $this->setCoordinates($parser); |
44 | | - |
45 | 41 | $this->setZoom(); |
46 | 42 | |
47 | 43 | $this->setCentre(); |
48 | 44 | |
49 | | - $this->doParsing($parser); |
50 | | - |
51 | | - $this->doEscaping(); |
52 | | - |
53 | 45 | $this->addSpecificMapHTML(); |
54 | 46 | |
55 | 47 | return $this->output; |
— | — | @@ -69,98 +61,11 @@ |
70 | 62 | * |
71 | 63 | */ |
72 | 64 | 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; |
81 | 66 | } |
82 | 67 | |
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 | | - */ |
120 | 68 | 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; |
156 | 70 | } |
157 | 71 | |
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 | | - |
167 | 72 | } |
Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | die( 'Not an entry point.' ); |
25 | 25 | } |
26 | 26 | |
27 | | -define('Maps_VERSION', '0.3.5 a3'); |
| 27 | +define('Maps_VERSION', '0.3.5 a4'); |
28 | 28 | |
29 | 29 | $egMapsScriptPath = $wgScriptPath . '/extensions/Maps'; |
30 | 30 | $egMapsIP = $IP . '/extensions/Maps'; |
— | — | @@ -48,11 +48,6 @@ |
49 | 49 | |
50 | 50 | if (empty($egMapsServices)) $egMapsServices = array(); |
51 | 51 | |
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 | | - |
57 | 52 | // TODO: split Maps_ParserFunctions.php functionallity so this line is not required |
58 | 53 | include_once $egMapsIP . '/ParserFunctions/Maps_ParserFunctions.php'; |
59 | 54 | |
— | — | @@ -101,9 +96,11 @@ |
102 | 97 | // Check for wich services there are handlers for the current fature, and load them |
103 | 98 | foreach ($egMapsServices as $serviceData) { |
104 | 99 | 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 | + } |
108 | 105 | |
109 | 106 | if (array_key_exists('classes', $serviceData)) { |
110 | 107 | 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 @@ |
11 | 11 | */ |
12 | 12 | |
13 | 13 | $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 | + ), |
15 | 18 | 'classes' => array( |
16 | 19 | array('class' => 'MapsGoogleMapsUtils', 'file' => 'GoogleMaps/Maps_GoogleMapsUtils.php', 'local' => true) |
17 | 20 | ), |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsUtils.php |
— | — | @@ -167,7 +167,7 @@ |
168 | 168 | * @param boolean $enableEarth |
169 | 169 | * @return string |
170 | 170 | */ |
171 | | - public function createTypesString(array &$types, $enableEarth) { |
| 171 | + public function createTypesString(array &$types, $enableEarth = false) { |
172 | 172 | global $egMapsGoogleMapsTypes, $egMapsGoogleMapTypesValid; |
173 | 173 | |
174 | 174 | $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 @@ |
11 | 11 | */ |
12 | 12 | |
13 | 13 | $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 | + ), |
15 | 18 | 'classes' => array( |
16 | 19 | array('class' => 'MapsYahooMapsUtils', 'file' => 'YahooMaps/Maps_YahooMapsUtils.php', 'local' => true) |
17 | 20 | ), |
Index: trunk/extensions/Maps/Maps_Settings.php |
— | — | @@ -18,20 +18,10 @@ |
19 | 19 | die( 'Not an entry point.' ); |
20 | 20 | } |
21 | 21 | |
22 | | -# API keys configuration |
23 | 22 | |
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 = ''; |
27 | 23 | |
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 = ''; |
31 | 24 | |
32 | 25 | |
33 | | - |
34 | | - |
35 | | - |
36 | 26 | # Map features configuration |
37 | 27 | # (named) Array of String. This array contains the available features for Maps. |
38 | 28 | # The array element name contains an abbriviation, used for code references, |
— | — | @@ -42,7 +32,11 @@ |
43 | 33 | 'name' => 'Parser Function', |
44 | 34 | 'class' => 'MapsParserFunctions', |
45 | 35 | '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 | + ), |
47 | 41 | ); |
48 | 42 | |
49 | 43 | |
— | — | @@ -50,8 +44,13 @@ |
51 | 45 | |
52 | 46 | |
53 | 47 | # 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. |
55 | 49 | |
| 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 | + |
56 | 55 | # Array of String. Array containing all the mapping services that will be made available to the user. |
57 | 56 | # Currently Maps provides the following services: googlemaps, yahoomaps, openlayers |
58 | 57 | $egMapsAvailableServices = array('googlemaps', 'yahoomaps', 'openlayers'); |
— | — | @@ -102,6 +101,10 @@ |
103 | 102 | |
104 | 103 | # Google maps |
105 | 104 | |
| 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 | + |
106 | 109 | # String. The Google Maps map name prefix. It can not be identical to the one of another mapping service. |
107 | 110 | $egMapsGoogleMapsPrefix = 'map_google'; |
108 | 111 | |
— | — | @@ -126,6 +129,10 @@ |
127 | 130 | |
128 | 131 | # Yahoo maps |
129 | 132 | |
| 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 | + |
130 | 137 | # String. The Yahoo! maps map name prefix. It can not be identical to the one of another mapping service. |
131 | 138 | $egMapsYahooMapsPrefix = 'map_yahoo'; |
132 | 139 | |