Index: trunk/extensions/Maps/Maps_MapFeature.php |
— | — | @@ -1,128 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * File holding class MapsMapFeature. |
6 | | - * |
7 | | - * @file Maps_MapFeature.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 | | -/** |
18 | | - * MapsMapFeature bundles base functionallity for all general mapping feature classes. |
19 | | - * |
20 | | - * @ingroup Maps |
21 | | - * |
22 | | - * @author Jeroen De Dauw |
23 | | - * |
24 | | - * TODO: refactor this and subclasses to follow mw conventions and simply have a better design pattern. |
25 | | - */ |
26 | | -abstract class MapsMapFeature { |
27 | | - |
28 | | - /** |
29 | | - * Set the map service specific element name and the javascript function handling the displaying of an address |
30 | | - */ |
31 | | - protected abstract function setMapSettings(); |
32 | | - |
33 | | - /** |
34 | | - * Map service specific map count and loading of dependencies |
35 | | - */ |
36 | | - protected abstract function doMapServiceLoad(); |
37 | | - |
38 | | - /** |
39 | | - * Adds the HTML specific to the mapping service to the output |
40 | | - */ |
41 | | - protected abstract function addSpecificMapHTML( Parser $parser ); |
42 | | - |
43 | | - public $serviceName; |
44 | | - |
45 | | - protected $elementNr; |
46 | | - protected $elementNamePrefix; |
47 | | - |
48 | | - protected $mapName; |
49 | | - |
50 | | - protected $centreLat, $centreLon; |
51 | | - |
52 | | - protected $output = ''; |
53 | | - |
54 | | - protected $spesificParameters = false; |
55 | | - protected $featureParameters = false; |
56 | | - |
57 | | - /** |
58 | | - * Sets the map properties as class fields. |
59 | | - * |
60 | | - * @param array $mapProperties |
61 | | - * @param string $className |
62 | | - */ |
63 | | - protected function setMapProperties( array $mapProperties, $className ) { |
64 | | - foreach ( $mapProperties as $paramName => $paramValue ) { |
65 | | - if ( !property_exists( $className, $paramName ) ) { |
66 | | - $this-> { $paramName } = $paramValue; |
67 | | - } |
68 | | - else { |
69 | | - // If this happens in any way, it could be a big vunerability, so throw an exception. |
70 | | - throw new Exception( 'Attempt to override a class field during map property assignment. Field name: ' . $paramName ); |
71 | | - } |
72 | | - } |
73 | | - } |
74 | | - |
75 | | - /** |
76 | | - * Sets the $mapName field, using the $elementNamePrefix and $elementNr. |
77 | | - */ |
78 | | - protected function setMapName() { |
79 | | - $this->mapName = $this->elementNamePrefix . '_' . $this->elementNr; |
80 | | - } |
81 | | - |
82 | | - /** |
83 | | - * @return array |
84 | | - */ |
85 | | - public function getSpecificParameterInfo() { |
86 | | - return array(); |
87 | | - } |
88 | | - |
89 | | - /** |
90 | | - * @return array |
91 | | - */ |
92 | | - public function getFeatureParameters() { |
93 | | - global $egMapsAvailableServices, $egMapsAvailableGeoServices, $egMapsDefaultGeoService, $egMapsMapWidth, $egMapsMapHeight; |
94 | | - |
95 | | - return array( |
96 | | - 'service' => array( |
97 | | - 'criteria' => array( |
98 | | - 'in_array' => $egMapsAvailableServices |
99 | | - ), |
100 | | - ), |
101 | | - 'geoservice' => array( |
102 | | - 'criteria' => array( |
103 | | - 'in_array' => $egMapsAvailableGeoServices |
104 | | - ), |
105 | | - 'default' => $egMapsDefaultGeoService |
106 | | - ), |
107 | | - 'zoom' => array( |
108 | | - 'type' => 'integer', |
109 | | - 'criteria' => array( |
110 | | - 'not_empty' => array() |
111 | | - ) |
112 | | - ), |
113 | | - 'width' => array( |
114 | | - 'criteria' => array( |
115 | | - 'is_map_dimension' => array( 'width' ), |
116 | | - ), |
117 | | - 'default' => $egMapsMapWidth, |
118 | | - 'output-type' => array( 'mapdimension', 'width', $egMapsMapWidth ) |
119 | | - ), |
120 | | - 'height' => array( |
121 | | - 'criteria' => array( |
122 | | - 'is_map_dimension' => array( 'height' ), |
123 | | - ), |
124 | | - 'default' => $egMapsMapHeight, |
125 | | - 'output-type' => array( 'mapdimension', 'height', $egMapsMapHeight ) |
126 | | - ), |
127 | | - ); |
128 | | - } |
129 | | -} |
\ No newline at end of file |
Index: trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispPoint.php |
— | — | @@ -24,21 +24,7 @@ |
25 | 25 | |
26 | 26 | public $serviceName = MapsGoogleMaps3::SERVICE_NAME; |
27 | 27 | |
28 | | - /** |
29 | | - * @see MapsBaseMap::setMapSettings() |
30 | | - * |
31 | | - */ |
32 | | - protected function setMapSettings() { |
33 | | - global $egMapsGMaps3Zoom, $egMapsGMaps3Prefix; |
34 | | - |
35 | | - $this->elementNamePrefix = $egMapsGMaps3Prefix; |
36 | | - $this->defaultZoom = $egMapsGMaps3Zoom; |
37 | | - |
38 | | - $this->markerStringFormat = 'getGMaps3MarkerData(lat, lon, \'title\', \'label\', "icon")'; |
39 | | - |
40 | | - $this->spesificParameters = array( |
41 | | - ); |
42 | | - } |
| 28 | + protected $markerStringFormat = 'getGMaps3MarkerData(lat, lon, \'title\', \'label\', "icon")'; |
43 | 29 | |
44 | 30 | /** |
45 | 31 | * @see MapsBaseMap::doMapServiceLoad() |
— | — | @@ -58,21 +44,26 @@ |
59 | 45 | * |
60 | 46 | */ |
61 | 47 | public function addSpecificMapHTML( Parser $parser ) { |
| 48 | + global $egMapsGMaps3Prefix, $egGMaps3OnThisPage; |
| 49 | + |
| 50 | + $mapName = $egMapsGMaps3Prefix . '_' . $egGMaps3OnThisPage; |
| 51 | + |
62 | 52 | $this->output .= Html::element( |
63 | 53 | 'div', |
64 | 54 | array( |
65 | | - 'id' => $this->mapName, |
| 55 | + 'id' => $mapName, |
66 | 56 | 'width' => $this->width, |
67 | 57 | 'height' => $this->height |
68 | 58 | ), |
69 | 59 | null |
70 | 60 | ); |
71 | 61 | |
72 | | - $wgOut->addInlineScript( <<<EOT |
| 62 | + $parser->getOutput()->addHeadItem( |
| 63 | + Html::inlineScript( <<<EOT |
73 | 64 | addOnloadHook( |
74 | 65 | function() { |
75 | 66 | initGMap3( |
76 | | - "$this->mapName", |
| 67 | + '$mapName', |
77 | 68 | { |
78 | 69 | zoom: $this->zoom, |
79 | 70 | lat: $this->centreLat, |
— | — | @@ -85,6 +76,7 @@ |
86 | 77 | } |
87 | 78 | ); |
88 | 79 | EOT |
| 80 | + ) |
89 | 81 | ); |
90 | 82 | } |
91 | 83 | |
Index: trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispMap.php |
— | — | @@ -23,20 +23,6 @@ |
24 | 24 | final class MapsGoogleMaps3DispMap extends MapsBaseMap { |
25 | 25 | |
26 | 26 | public $serviceName = MapsGoogleMaps3::SERVICE_NAME; |
27 | | - |
28 | | - /** |
29 | | - * @see MapsBaseMap::setMapSettings() |
30 | | - * |
31 | | - */ |
32 | | - protected function setMapSettings() { |
33 | | - global $egMapsGMaps3Zoom, $egMapsGMaps3Prefix; |
34 | | - |
35 | | - $this->elementNamePrefix = $egMapsGMaps3Prefix; |
36 | | - $this->defaultZoom = $egMapsGMaps3Zoom; |
37 | | - |
38 | | - $this->spesificParameters = array( |
39 | | - ); |
40 | | - } |
41 | 27 | |
42 | 28 | /** |
43 | 29 | * @see MapsBaseMap::doMapServiceLoad() |
— | — | @@ -56,21 +42,26 @@ |
57 | 43 | * |
58 | 44 | */ |
59 | 45 | public function addSpecificMapHTML( Parser $parser ) { |
| 46 | + global $egMapsGMaps3Prefix, $egGMaps3OnThisPage; |
| 47 | + |
| 48 | + $mapName = $egMapsGMaps3Prefix . '_' . $egGMaps3OnThisPage; |
| 49 | + |
60 | 50 | $this->output .= Html::element( |
61 | 51 | 'div', |
62 | 52 | array( |
63 | | - 'id' => $this->mapName, |
| 53 | + 'id' => $mapName, |
64 | 54 | 'width' => $this->width, |
65 | 55 | 'height' => $this->height |
66 | 56 | ), |
67 | 57 | null |
68 | 58 | ); |
69 | 59 | |
70 | | - $wgOut->addInlineScript( <<<EOT |
| 60 | + $parser->getOutput()->addHeadItem( |
| 61 | + Html::inlineScript( <<<EOT |
71 | 62 | addOnloadHook( |
72 | 63 | function() { |
73 | 64 | initGMap3( |
74 | | - "$this->mapName", |
| 65 | + '$mapName', |
75 | 66 | { |
76 | 67 | zoom: $this->zoom, |
77 | 68 | lat: $this->centreLat, |
— | — | @@ -83,6 +74,7 @@ |
84 | 75 | } |
85 | 76 | ); |
86 | 77 | EOT |
| 78 | + ) |
87 | 79 | ); |
88 | 80 | } |
89 | 81 | |
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispPoint.php |
— | — | @@ -22,20 +22,9 @@ |
23 | 23 | |
24 | 24 | public $serviceName = MapsOpenLayers::SERVICE_NAME; |
25 | 25 | |
| 26 | + protected $markerStringFormat = 'getOLMarkerData(lon, lat, \'title\', \'label\', "icon")'; |
| 27 | + |
26 | 28 | /** |
27 | | - * @see MapsBaseMap::setMapSettings() |
28 | | - * |
29 | | - */ |
30 | | - protected function setMapSettings() { |
31 | | - global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix; |
32 | | - |
33 | | - $this->elementNamePrefix = $egMapsOpenLayersPrefix; |
34 | | - $this->defaultZoom = $egMapsOpenLayersZoom; |
35 | | - |
36 | | - $this->markerStringFormat = 'getOLMarkerData(lon, lat, \'title\', \'label\', "icon")'; |
37 | | - } |
38 | | - |
39 | | - /** |
40 | 29 | * @see MapsBaseMap::doMapServiceLoad() |
41 | 30 | * |
42 | 31 | */ |
— | — | @@ -53,12 +42,16 @@ |
54 | 43 | * |
55 | 44 | */ |
56 | 45 | public function addSpecificMapHTML( Parser $parser ) { |
| 46 | + global $egMapsOpenLayersPrefix, $egOpenLayersOnThisPage; |
| 47 | + |
57 | 48 | $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers ); |
58 | 49 | |
| 50 | + $mapName = $egMapsOpenLayersPrefix . '_' . $egOpenLayersOnThisPage; |
| 51 | + |
59 | 52 | $this->output .= Html::element( |
60 | 53 | 'div', |
61 | 54 | array( |
62 | | - 'id' => $this->mapName, |
| 55 | + 'id' => $mapName, |
63 | 56 | 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
64 | 57 | ), |
65 | 58 | wfMsg('maps-loading-map') |
— | — | @@ -69,7 +62,7 @@ |
70 | 63 | addOnloadHook( |
71 | 64 | function() { |
72 | 65 | initOpenLayer( |
73 | | - '$this->mapName', |
| 66 | + '$mapName', |
74 | 67 | $this->centreLon, |
75 | 68 | $this->centreLat, |
76 | 69 | $this->zoom, |
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispMap.php |
— | — | @@ -18,16 +18,6 @@ |
19 | 19 | public $serviceName = MapsOpenLayers::SERVICE_NAME; |
20 | 20 | |
21 | 21 | /** |
22 | | - * @see MapsBaseMap::setMapSettings() |
23 | | - */ |
24 | | - protected function setMapSettings() { |
25 | | - global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix; |
26 | | - |
27 | | - $this->elementNamePrefix = $egMapsOpenLayersPrefix; |
28 | | - $this->defaultZoom = $egMapsOpenLayersZoom; |
29 | | - } |
30 | | - |
31 | | - /** |
32 | 22 | * @see MapsBaseMap::doMapServiceLoad() |
33 | 23 | */ |
34 | 24 | protected function doMapServiceLoad() { |
— | — | @@ -43,23 +33,27 @@ |
44 | 34 | * @see MapsBaseMap::addSpecificMapHTML() |
45 | 35 | */ |
46 | 36 | public function addSpecificMapHTML( Parser $parser ) { |
| 37 | + global $egMapsOpenLayersPrefix, $egOpenLayersOnThisPage; |
| 38 | + |
47 | 39 | $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers ); |
| 40 | + |
| 41 | + $mapName = $egMapsOpenLayersPrefix . '_' . $egOpenLayersOnThisPage; |
48 | 42 | |
49 | 43 | $this->output .= Html::element( |
50 | 44 | 'div', |
51 | 45 | array( |
52 | | - 'id' => $this->mapName, |
| 46 | + 'id' => $mapName, |
53 | 47 | 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
54 | 48 | ), |
55 | 49 | wfMsg('maps-loading-map') |
56 | 50 | ); |
57 | 51 | |
58 | | - $parser->getOutput()->addHeadItem( |
| 52 | + $parser->getOutput()->addHeadItem( |
59 | 53 | Html::inlineScript( <<<EOT |
60 | 54 | addOnloadHook( |
61 | 55 | function() { |
62 | 56 | initOpenLayer( |
63 | | - '$this->mapName', |
| 57 | + '$mapName', |
64 | 58 | $this->centreLon, |
65 | 59 | $this->centreLat, |
66 | 60 | $this->zoom, |
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php |
— | — | @@ -61,31 +61,31 @@ |
62 | 62 | private static function initializeParams() { |
63 | 63 | global $egMapsServices, $egMapsOLLayers, $egMapsOLControls, $egMapsOpenLayersZoom; |
64 | 64 | |
| 65 | + $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
| 66 | + 'controls' => array( |
| 67 | + 'type' => array( 'string', 'list' ), |
| 68 | + 'criteria' => array( |
| 69 | + 'in_array' => self::getControlNames() |
| 70 | + ), |
| 71 | + 'default' => $egMapsOLControls, |
| 72 | + 'output-type' => array( 'list', ',', '\'' ) |
| 73 | + ), |
| 74 | + 'layers' => array( |
| 75 | + 'type' => array( 'string', 'list' ), |
| 76 | + 'criteria' => array( |
| 77 | + 'in_array' => self::getLayerNames( true ) |
| 78 | + ), |
| 79 | + 'default' => $egMapsOLLayers, |
| 80 | + 'output-types' => array( |
| 81 | + 'unique_items', |
| 82 | + 'olgroups', |
| 83 | + array( 'filtered_array', self::getLayerNames() ), |
| 84 | + ) |
| 85 | + ), |
| 86 | + ); |
| 87 | + |
65 | 88 | $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['default'] = $egMapsOpenLayersZoom; |
66 | | - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 0, 19 ); |
67 | | - |
68 | | - $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
69 | | - 'controls' => array( |
70 | | - 'type' => array( 'string', 'list' ), |
71 | | - 'criteria' => array( |
72 | | - 'in_array' => self::getControlNames() |
73 | | - ), |
74 | | - 'default' => $egMapsOLControls, |
75 | | - 'output-type' => array( 'list', ',', '\'' ) |
76 | | - ), |
77 | | - 'layers' => array( |
78 | | - 'type' => array( 'string', 'list' ), |
79 | | - 'criteria' => array( |
80 | | - 'in_array' => self::getLayerNames( true ) |
81 | | - ), |
82 | | - 'default' => $egMapsOLLayers, |
83 | | - 'output-types' => array( |
84 | | - 'unique_items', |
85 | | - 'olgroups', |
86 | | - array( 'filtered_array', self::getLayerNames() ), |
87 | | - ) |
88 | | - ), |
89 | | - ); |
| 89 | + $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 0, 19 ); |
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
— | — | @@ -97,15 +97,15 @@ |
98 | 98 | */ |
99 | 99 | public static function getControlNames() { |
100 | 100 | return array( |
101 | | - 'argparser', 'attribution', 'button', 'dragfeature', 'dragpan', |
102 | | - 'drawfeature', 'editingtoolbar', 'getfeature', 'keyboarddefaults', 'layerswitcher', |
103 | | - 'measure', 'modifyfeature', 'mousedefaults', 'mouseposition', 'mousetoolbar', |
104 | | - 'navigation', 'navigationhistory', 'navtoolbar', 'overviewmap', 'pan', |
105 | | - 'panel', 'panpanel', 'panzoom', 'panzoombar', 'autopanzoom', 'permalink', |
106 | | - 'scale', 'scaleline', 'selectfeature', 'snapping', 'split', |
107 | | - 'wmsgetfeatureinfo', 'zoombox', 'zoomin', 'zoomout', 'zoompanel', |
108 | | - 'zoomtomaxextent' |
109 | | - ); |
| 101 | + 'argparser', 'attribution', 'button', 'dragfeature', 'dragpan', |
| 102 | + 'drawfeature', 'editingtoolbar', 'getfeature', 'keyboarddefaults', 'layerswitcher', |
| 103 | + 'measure', 'modifyfeature', 'mousedefaults', 'mouseposition', 'mousetoolbar', |
| 104 | + 'navigation', 'navigationhistory', 'navtoolbar', 'overviewmap', 'pan', |
| 105 | + 'panel', 'panpanel', 'panzoom', 'panzoombar', 'autopanzoom', 'permalink', |
| 106 | + 'scale', 'scaleline', 'selectfeature', 'snapping', 'split', |
| 107 | + 'wmsgetfeatureinfo', 'zoombox', 'zoomin', 'zoomout', 'zoompanel', |
| 108 | + 'zoomtomaxextent' |
| 109 | + ); |
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
Index: trunk/extensions/Maps/ParserFunctions/Maps_iDisplayFunction.php |
— | — | @@ -1,23 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * File holding interface iDisplayFunction. |
6 | | - * |
7 | | - * @file Maps_iDisplayFunction.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 | | -/** |
18 | | - * Interface that should be implemented by all display_ parser functions. |
19 | | - * |
20 | | - * @author Jeroen De Dauw |
21 | | - */ |
22 | | -interface iDisplayFunction { |
23 | | - public function displayMap( Parser &$parser, array $params ); |
24 | | -} |
\ No newline at end of file |
Index: trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_BasePointMap.php |
— | — | @@ -21,48 +21,80 @@ |
22 | 22 | * @ingroup Maps |
23 | 23 | * |
24 | 24 | * @author Jeroen De Dauw |
| 25 | + * |
| 26 | + * TODO: fix zoom - should default to 'null' when no value given and multiple points |
25 | 27 | */ |
26 | | -abstract class MapsBasePointMap extends MapsMapFeature implements iDisplayFunction { |
| 28 | +abstract class MapsBasePointMap implements iMapFeature { |
27 | 29 | |
| 30 | + public $serviceName; |
| 31 | + |
| 32 | + protected $centreLat, $centreLon; |
| 33 | + |
| 34 | + protected $output = ''; |
| 35 | + |
| 36 | + protected $spesificParameters = false; |
| 37 | + protected $featureParameters = false; |
| 38 | + |
28 | 39 | private $markerData = array(); |
29 | 40 | protected $markerString; |
30 | 41 | |
31 | 42 | /** |
| 43 | + * Sets the map properties as class fields. |
| 44 | + * |
| 45 | + * @param array $mapProperties |
| 46 | + */ |
| 47 | + protected function setMapProperties( array $mapProperties ) { |
| 48 | + foreach ( $mapProperties as $paramName => $paramValue ) { |
| 49 | + if ( !property_exists( __CLASS__, $paramName ) ) { |
| 50 | + $this-> { $paramName } = $paramValue; |
| 51 | + } |
| 52 | + else { |
| 53 | + // If this happens in any way, it could be a big vunerability, so throw an exception. |
| 54 | + throw new Exception( 'Attempt to override a class field during map property assignment. Field name: ' . $paramName ); |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + /** |
32 | 60 | * @return array |
| 61 | + */ |
| 62 | + public function getSpecificParameterInfo() { |
| 63 | + return array(); |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * @return array |
33 | 68 | */ |
34 | 69 | public function getFeatureParameters() { |
35 | 70 | global $egMapsDefaultServices, $egMapsDefaultTitle, $egMapsDefaultLabel; |
36 | 71 | |
37 | | - return array_merge( |
38 | | - parent::getFeatureParameters(), |
39 | | - array( |
40 | | - 'service' => array( |
41 | | - 'default' => $egMapsDefaultServices['display_point'] |
| 72 | + return array( |
| 73 | + 'service' => array( |
| 74 | + 'default' => $egMapsDefaultServices['display_point'] |
| 75 | + ), |
| 76 | + 'centre' => array( |
| 77 | + 'aliases' => array( 'center' ), |
| 78 | + ), |
| 79 | + 'title' => array( |
| 80 | + 'default' => $egMapsDefaultTitle |
| 81 | + ), |
| 82 | + 'label' => array( |
| 83 | + 'default' => $egMapsDefaultLabel |
| 84 | + ), |
| 85 | + 'icon' => array( |
| 86 | + 'criteria' => array( |
| 87 | + 'not_empty' => array() |
| 88 | + ) |
| 89 | + ), |
| 90 | + 'coordinates' => array( |
| 91 | + 'required' => true, |
| 92 | + 'type' => array( 'string', 'list', ';' ), |
| 93 | + 'aliases' => array( 'coords', 'location', 'locations' ), |
| 94 | + 'criteria' => array( |
| 95 | + 'are_locations' => array() |
42 | 96 | ), |
43 | | - 'centre' => array( |
44 | | - 'aliases' => array( 'center' ), |
45 | | - ), |
46 | | - 'title' => array( |
47 | | - 'default' => $egMapsDefaultTitle |
48 | | - ), |
49 | | - 'label' => array( |
50 | | - 'default' => $egMapsDefaultLabel |
51 | | - ), |
52 | | - 'icon' => array( |
53 | | - 'criteria' => array( |
54 | | - 'not_empty' => array() |
55 | | - ) |
56 | | - ), |
57 | | - 'coordinates' => array( |
58 | | - 'required' => true, |
59 | | - 'type' => array( 'string', 'list', ';' ), |
60 | | - 'aliases' => array( 'coords', 'location', 'locations' ), |
61 | | - 'criteria' => array( |
62 | | - 'are_locations' => array() |
63 | | - ), |
64 | | - 'output-type' => 'coordinateSets', |
65 | | - ), |
66 | | - ) |
| 97 | + 'output-type' => 'coordinateSets', |
| 98 | + ), |
67 | 99 | ); |
68 | 100 | } |
69 | 101 | |
— | — | @@ -75,23 +107,17 @@ |
76 | 108 | * |
77 | 109 | * @return html |
78 | 110 | */ |
79 | | - public final function displayMap( Parser &$parser, array $params ) { |
80 | | - $this->setMapSettings(); |
81 | | - |
| 111 | + public final function displayMap( Parser &$parser, array $params ) { |
82 | 112 | $this->featureParameters = MapsDisplayPoint::$parameters; |
83 | 113 | |
84 | 114 | $this->doMapServiceLoad(); |
85 | 115 | |
86 | | - parent::setMapProperties( $params, __CLASS__ ); |
| 116 | + $this->setMapProperties( $params ); |
87 | 117 | |
88 | | - $this->setMapName(); |
89 | | - |
90 | 118 | $this->setMarkerData( $parser ); |
91 | 119 | |
92 | 120 | $this->createMarkerString(); |
93 | 121 | |
94 | | - $this->setZoom(); |
95 | | - |
96 | 122 | $this->setCentre(); |
97 | 123 | |
98 | 124 | $this->addSpecificMapHTML( $parser ); |
— | — | @@ -100,23 +126,6 @@ |
101 | 127 | } |
102 | 128 | |
103 | 129 | /** |
104 | | - * Sets the zoom level to the provided value. When no zoom is provided, set |
105 | | - * it to the default when there is only one location, or the best fitting soom when |
106 | | - * there are multiple locations. |
107 | | - * |
108 | | - */ |
109 | | - private function setZoom() { |
110 | | - if ( strlen( $this->zoom ) < 1 ) { |
111 | | - if ( count( $this->markerData ) > 1 ) { |
112 | | - $this->zoom = 'null'; |
113 | | - } |
114 | | - else { |
115 | | - $this->zoom = $this->defaultZoom; |
116 | | - } |
117 | | - } |
118 | | - } |
119 | | - |
120 | | - /** |
121 | 130 | * Fills the $markerData array with the locations and their meta data. |
122 | 131 | * |
123 | 132 | * @param unknown_type $parser |
Index: trunk/extensions/Maps/ParserFunctions/DisplayMap/Maps_BaseMap.php |
— | — | @@ -22,29 +22,59 @@ |
23 | 23 | * |
24 | 24 | * @author Jeroen De Dauw |
25 | 25 | */ |
26 | | -abstract class MapsBaseMap extends MapsMapFeature implements iDisplayFunction { |
| 26 | +abstract class MapsBaseMap implements iMapFeature { |
27 | 27 | |
| 28 | + public $serviceName; |
| 29 | + |
| 30 | + protected $centreLat, $centreLon; |
| 31 | + |
| 32 | + protected $output = ''; |
| 33 | + |
| 34 | + protected $spesificParameters = false; |
| 35 | + protected $featureParameters = false; |
| 36 | + |
28 | 37 | /** |
| 38 | + * Sets the map properties as class fields. |
| 39 | + * |
| 40 | + * @param array $mapProperties |
| 41 | + */ |
| 42 | + protected function setMapProperties( array $mapProperties ) { |
| 43 | + foreach ( $mapProperties as $paramName => $paramValue ) { |
| 44 | + if ( !property_exists( __CLASS__, $paramName ) ) { |
| 45 | + $this-> { $paramName } = $paramValue; |
| 46 | + } |
| 47 | + else { |
| 48 | + // If this happens in any way, it could be a big vunerability, so throw an exception. |
| 49 | + throw new Exception( 'Attempt to override a class field during map property assignment. Field name: ' . $paramName ); |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + /** |
29 | 55 | * @return array |
| 56 | + */ |
| 57 | + public function getSpecificParameterInfo() { |
| 58 | + return array(); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * @return array |
30 | 63 | */ |
31 | 64 | public function getFeatureParameters() { |
32 | 65 | global $egMapsDefaultServices; |
33 | 66 | |
34 | | - return array_merge( |
35 | | - parent::getFeatureParameters(), |
36 | | - array( |
37 | | - 'service' => array( |
38 | | - 'default' => $egMapsDefaultServices['display_map'] |
| 67 | + return array( |
| 68 | + 'service' => array( |
| 69 | + 'default' => $egMapsDefaultServices['display_map'] |
| 70 | + ), |
| 71 | + 'coordinates' => array( |
| 72 | + 'required' => true, |
| 73 | + 'aliases' => array( 'coords', 'location', 'locations' ), |
| 74 | + 'criteria' => array( |
| 75 | + 'is_location' => array() |
39 | 76 | ), |
40 | | - 'coordinates' => array( |
41 | | - 'required' => true, |
42 | | - 'aliases' => array( 'coords', 'location', 'locations' ), |
43 | | - 'criteria' => array( |
44 | | - 'is_location' => array() |
45 | | - ), |
46 | | - 'output-type' => 'coordinateSet', |
47 | | - ), |
48 | | - ) |
| 77 | + 'output-type' => 'coordinateSet', |
| 78 | + ), |
49 | 79 | ); |
50 | 80 | } |
51 | 81 | |
— | — | @@ -58,18 +88,12 @@ |
59 | 89 | * @return html |
60 | 90 | */ |
61 | 91 | public final function displayMap( Parser &$parser, array $params ) { |
62 | | - $this->setMapSettings(); |
63 | | - |
64 | 92 | $this->featureParameters = MapsDisplayMap::$parameters; |
65 | 93 | |
66 | 94 | $this->doMapServiceLoad(); |
67 | 95 | |
68 | | - parent::setMapProperties( $params, __CLASS__ ); |
| 96 | + $this->setMapProperties( $params ); |
69 | 97 | |
70 | | - $this->setMapName(); |
71 | | - |
72 | | - $this->setZoom(); |
73 | | - |
74 | 98 | $this->setCentre(); |
75 | 99 | |
76 | 100 | $this->addSpecificMapHTML( $parser ); |
— | — | @@ -78,16 +102,6 @@ |
79 | 103 | } |
80 | 104 | |
81 | 105 | /** |
82 | | - * Sets the zoom level to the provided value. When no zoom is provided, set |
83 | | - * it to the default when there is only one location, or the best fitting soom when |
84 | | - * there are multiple locations. |
85 | | - * |
86 | | - */ |
87 | | - private function setZoom() { |
88 | | - if ( empty( $this->zoom ) ) $this->zoom = $this->defaultZoom; |
89 | | - } |
90 | | - |
91 | | - /** |
92 | 106 | * Sets the $centre_lat and $centre_lon fields. |
93 | 107 | */ |
94 | 108 | private function setCentre() { |
Index: trunk/extensions/Maps/ParserFunctions/Maps_iMapFeature.php |
— | — | @@ -0,0 +1,34 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File holding interface iMapFeature. |
| 6 | + * |
| 7 | + * @file Maps_iMapFeature.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 | +/** |
| 18 | + * Interface that should be implemented by all mapping feature classes. |
| 19 | + * |
| 20 | + * @author Jeroen De Dauw |
| 21 | + */ |
| 22 | +interface iMapFeature { |
| 23 | + function displayMap( Parser &$parser, array $params ); |
| 24 | + |
| 25 | + /** |
| 26 | + * Map service specific map count and loading of dependencies. |
| 27 | + */ |
| 28 | + function doMapServiceLoad(); |
| 29 | + |
| 30 | + /** |
| 31 | + * Adds the HTML specific to the mapping service to the output. |
| 32 | + */ |
| 33 | + function addSpecificMapHTML( Parser $parser ); |
| 34 | +} |
| 35 | + |
Property changes on: trunk/extensions/Maps/ParserFunctions/Maps_iMapFeature.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 36 | + native |
Index: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php |
— | — | @@ -24,8 +24,6 @@ |
25 | 25 | */ |
26 | 26 | final class MapsParserFunctions { |
27 | 27 | |
28 | | - public static $parameters = array(); |
29 | | - |
30 | 28 | /** |
31 | 29 | * Initialize the parser functions feature. This function handles the parser function hook, |
32 | 30 | * and will load the required classes. |
— | — | @@ -33,7 +31,7 @@ |
34 | 32 | public static function initialize() { |
35 | 33 | global $egMapsDir, $egMapsFeatures; |
36 | 34 | |
37 | | - include_once $egMapsDir . 'ParserFunctions/Maps_iDisplayFunction.php'; |
| 35 | + include_once $egMapsDir . 'ParserFunctions/Maps_iMapFeature.php'; |
38 | 36 | |
39 | 37 | // This runs a small hook that enables parser functions to run initialization code. |
40 | 38 | foreach ( $egMapsFeatures['pf'] as $hook ) { |
— | — | @@ -66,7 +64,7 @@ |
67 | 65 | foreach( $args as $arg ) { |
68 | 66 | $split = explode( '=', $arg ); |
69 | 67 | $name = strtolower( trim( array_shift( $split ) ) ); |
70 | | - if ( count( $split ) > 1 && self::inParamAliases( $name, 'service', self::$parameters ) ) { |
| 68 | + if ( count( $split ) > 1 && self::inParamAliases( $name, 'service', MapsMapper::getCommonParameters() ) ) { |
71 | 69 | if ( !$setService ) { |
72 | 70 | $service = implode( '=', $split ); |
73 | 71 | $parameters = 'service=' . $service; |
— | — | @@ -90,7 +88,7 @@ |
91 | 89 | * again overidden by the service parameters (the ones spesific to the service), |
92 | 90 | * and finally by the spesific parameters (the ones spesific to a service-feature combination). |
93 | 91 | */ |
94 | | - $parameterInfo = array_merge( self::$parameters, $mapClass->getFeatureParameters() ); |
| 92 | + $parameterInfo = array_merge( MapsMapper::getCommonParameters(), $mapClass->getFeatureParameters() ); |
95 | 93 | $parameterInfo = array_merge( $parameterInfo, $egMapsServices[$service]['parameters'] ); |
96 | 94 | $parameterInfo = array_merge( $parameterInfo, $mapClass->getSpecificParameterInfo() ); |
97 | 95 | |
Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -84,7 +84,6 @@ |
85 | 85 | |
86 | 86 | // Autoload the general classes |
87 | 87 | $wgAutoloadClasses['MapsCoordinateParser'] = $egMapsDir . 'Maps_CoordinateParser.php'; |
88 | | - $wgAutoloadClasses['MapsMapFeature'] = $egMapsDir . 'Maps_MapFeature.php'; |
89 | 88 | $wgAutoloadClasses['MapsMapper'] = $egMapsDir . 'Maps_Mapper.php'; |
90 | 89 | |
91 | 90 | wfLoadExtensionMessages( 'Maps' ); |
Index: trunk/extensions/Maps/Maps_Mapper.php |
— | — | @@ -201,6 +201,49 @@ |
202 | 202 | public static function geocoderIsAvailable() { |
203 | 203 | global $wgAutoloadClasses; |
204 | 204 | return array_key_exists( 'MapsGeocoder', $wgAutoloadClasses ); |
| 205 | + } |
| 206 | + |
| 207 | + /** |
| 208 | + * This function returns the definitions for the parameters used by every map feature. |
| 209 | + * |
| 210 | + * @return array |
| 211 | + */ |
| 212 | + public static function getCommonParameters() { |
| 213 | + global $egMapsAvailableServices, $egMapsAvailableGeoServices, $egMapsDefaultGeoService, $egMapsMapWidth, $egMapsMapHeight; |
| 214 | + |
| 215 | + return array( |
| 216 | + 'service' => array( |
| 217 | + 'criteria' => array( |
| 218 | + 'in_array' => $egMapsAvailableServices |
| 219 | + ), |
| 220 | + ), |
| 221 | + 'geoservice' => array( |
| 222 | + 'criteria' => array( |
| 223 | + 'in_array' => $egMapsAvailableGeoServices |
| 224 | + ), |
| 225 | + 'default' => $egMapsDefaultGeoService |
| 226 | + ), |
| 227 | + 'zoom' => array( |
| 228 | + 'type' => 'integer', |
| 229 | + 'criteria' => array( |
| 230 | + 'not_empty' => array() |
| 231 | + ) |
| 232 | + ), |
| 233 | + 'width' => array( |
| 234 | + 'criteria' => array( |
| 235 | + 'is_map_dimension' => array( 'width' ), |
| 236 | + ), |
| 237 | + 'default' => $egMapsMapWidth, |
| 238 | + 'output-type' => array( 'mapdimension', 'width', $egMapsMapWidth ) |
| 239 | + ), |
| 240 | + 'height' => array( |
| 241 | + 'criteria' => array( |
| 242 | + 'is_map_dimension' => array( 'height' ), |
| 243 | + ), |
| 244 | + 'default' => $egMapsMapHeight, |
| 245 | + 'output-type' => array( 'mapdimension', 'height', $egMapsMapHeight ) |
| 246 | + ), |
| 247 | + ); |
205 | 248 | } |
206 | 249 | |
207 | 250 | } |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | final class MapsGoogleMapsDispMap extends MapsBaseMap { |
25 | 25 | |
26 | 26 | public $serviceName = MapsGoogleMaps::SERVICE_NAME; |
27 | | - |
| 27 | + |
28 | 28 | public function getSpecificParameterInfo() { |
29 | 29 | global $egMapsGMapOverlays; |
30 | 30 | // TODO: it'd be cool to have this static so it can be cheched in order to only init it once. |
— | — | @@ -40,19 +40,9 @@ |
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | | - * @see MapsBaseMap::setMapSettings() |
45 | | - */ |
46 | | - protected function setMapSettings() { |
47 | | - global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix; |
48 | | - |
49 | | - $this->elementNamePrefix = $egMapsGoogleMapsPrefix; |
50 | | - $this->defaultZoom = $egMapsGoogleMapsZoom; |
51 | | - } |
52 | | - |
53 | | - /** |
54 | 44 | * @see MapsBaseMap::doMapServiceLoad() |
55 | 45 | */ |
56 | | - protected function doMapServiceLoad() { |
| 46 | + public function doMapServiceLoad() { |
57 | 47 | global $egGoogleMapsOnThisPage; |
58 | 48 | |
59 | 49 | MapsGoogleMaps::addGMapDependencies( $this->output ); |
— | — | @@ -65,22 +55,26 @@ |
66 | 56 | * @see MapsBaseMap::addSpecificMapHTML() |
67 | 57 | */ |
68 | 58 | public function addSpecificMapHTML( Parser $parser ) { |
69 | | - MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls ); |
| 59 | + global $egMapsGoogleMapsPrefix, $egGoogleMapsOnThisPage; |
70 | 60 | |
| 61 | + $mapName = $egMapsGoogleMapsPrefix . '_' . $egGoogleMapsOnThisPage; |
| 62 | + |
| 63 | + MapsGoogleMaps::addOverlayOutput( $this->output, $mapName, $this->overlays, $this->controls ); |
| 64 | + |
71 | 65 | $this->output .= Html::element( |
72 | 66 | 'div', |
73 | 67 | array( |
74 | | - 'id' => $this->mapName, |
| 68 | + 'id' => $mapName, |
75 | 69 | 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
76 | 70 | ), |
77 | | - wfMsg('maps-loading-map') |
| 71 | + wfMsg( 'maps-loading-map' ) |
78 | 72 | ); |
79 | 73 | |
80 | 74 | $parser->getOutput()->addHeadItem( |
81 | 75 | Html::inlineScript( <<<EOT |
82 | 76 | addOnloadHook( |
83 | 77 | function() { |
84 | | - initializeGoogleMap('$this->mapName', |
| 78 | + initializeGoogleMap('$mapName', |
85 | 79 | { |
86 | 80 | lat: $this->centreLat, |
87 | 81 | lon: $this->centreLon, |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php |
— | — | @@ -64,9 +64,6 @@ |
65 | 65 | |
66 | 66 | $allowedTypes = self::getTypeNames(); |
67 | 67 | |
68 | | - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['default'] = $egMapsGoogleMapsZoom; |
69 | | - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 0, 20 ); |
70 | | - |
71 | 68 | $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
72 | 69 | 'controls' => array( |
73 | 70 | 'type' => array( 'string', 'list' ), |
— | — | @@ -100,6 +97,9 @@ |
101 | 98 | 'output-type' => 'boolstr' |
102 | 99 | ), |
103 | 100 | ); |
| 101 | + |
| 102 | + $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['default'] = $egMapsGoogleMapsZoom; |
| 103 | + $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 0, 20 ); |
104 | 104 | } |
105 | 105 | |
106 | 106 | // http://code.google.com/apis/maps/documentation/reference.html#GMapType.G_NORMAL_MAP |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php |
— | — | @@ -24,6 +24,8 @@ |
25 | 25 | |
26 | 26 | public $serviceName = MapsGoogleMaps::SERVICE_NAME; |
27 | 27 | |
| 28 | + protected $markerStringFormat = 'getGMarkerData(lat, lon, \'title\', \'label\', "icon")'; |
| 29 | + |
28 | 30 | public function getSpecificParameterInfo() { |
29 | 31 | global $egMapsGMapOverlays; |
30 | 32 | // TODO: it'd be cool to have this static so it can be cheched in order to only init it once. |
— | — | @@ -38,25 +40,11 @@ |
39 | 41 | ); |
40 | 42 | return $this->spesificParameters; |
41 | 43 | } |
42 | | - |
| 44 | + |
43 | 45 | /** |
44 | | - * @see MapsBaseMap::setMapSettings() |
45 | | - * |
46 | | - */ |
47 | | - protected function setMapSettings() { |
48 | | - global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix; |
49 | | - |
50 | | - $this->elementNamePrefix = $egMapsGoogleMapsPrefix; |
51 | | - $this->defaultZoom = $egMapsGoogleMapsZoom; |
52 | | - |
53 | | - $this->markerStringFormat = 'getGMarkerData(lat, lon, \'title\', \'label\', "icon")'; |
54 | | - } |
55 | | - |
56 | | - /** |
57 | 46 | * @see MapsBaseMap::doMapServiceLoad() |
58 | | - * |
59 | 47 | */ |
60 | | - protected function doMapServiceLoad() { |
| 48 | + public function doMapServiceLoad() { |
61 | 49 | global $egGoogleMapsOnThisPage; |
62 | 50 | |
63 | 51 | MapsGoogleMaps::addGMapDependencies( $this->output ); |
— | — | @@ -67,18 +55,21 @@ |
68 | 56 | |
69 | 57 | /** |
70 | 58 | * @see MapsBaseMap::addSpecificMapHTML() |
71 | | - * |
72 | 59 | */ |
73 | 60 | public function addSpecificMapHTML( Parser $parser ) { |
74 | | - MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls ); |
| 61 | + global $egMapsGoogleMapsPrefix, $egGoogleMapsOnThisPage; |
75 | 62 | |
| 63 | + $mapName = $egMapsGoogleMapsPrefix . '_' . $egGoogleMapsOnThisPage; |
| 64 | + |
| 65 | + MapsGoogleMaps::addOverlayOutput( $this->output, $mapName, $this->overlays, $this->controls ); |
| 66 | + |
76 | 67 | $this->output .= Html::element( |
77 | 68 | 'div', |
78 | 69 | array( |
79 | | - 'id' => $this->mapName, |
| 70 | + 'id' => $mapName, |
80 | 71 | 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
81 | 72 | ), |
82 | | - wfMsg('maps-loading-map') |
| 73 | + wfMsg( 'maps-loading-map' ) |
83 | 74 | ); |
84 | 75 | |
85 | 76 | $parser->getOutput()->addHeadItem( |
— | — | @@ -86,7 +77,7 @@ |
87 | 78 | <<<EOT |
88 | 79 | addOnloadHook( |
89 | 80 | function() { |
90 | | - initializeGoogleMap('$this->mapName', |
| 81 | + initializeGoogleMap('$mapName', |
91 | 82 | { |
92 | 83 | lat: $this->centreLat, |
93 | 84 | lon: $this->centreLon, |
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispPoint.php |
— | — | @@ -22,18 +22,7 @@ |
23 | 23 | |
24 | 24 | public $serviceName = MapsYahooMaps::SERVICE_NAME; |
25 | 25 | |
26 | | - /** |
27 | | - * @see MapsBaseMap::setFormInputSettings() |
28 | | - * |
29 | | - */ |
30 | | - protected function setMapSettings() { |
31 | | - global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix; |
32 | | - |
33 | | - $this->elementNamePrefix = $egMapsYahooMapsPrefix; |
34 | | - $this->defaultZoom = $egMapsYahooMapsZoom; |
35 | | - |
36 | | - $this->markerStringFormat = 'getYMarkerData(lat, lon, \'title\', \'label\', "icon")'; |
37 | | - } |
| 26 | + protected $markerStringFormat = 'getYMarkerData(lat, lon, \'title\', \'label\', "icon")'; |
38 | 27 | |
39 | 28 | /** |
40 | 29 | * @see MapsBaseMap::doMapServiceLoad() |
— | — | @@ -53,10 +42,14 @@ |
54 | 43 | * |
55 | 44 | */ |
56 | 45 | public function addSpecificMapHTML( Parser $parser ) { |
| 46 | + global $egMapsYahooMapsPrefix, $egYahooMapsOnThisPage; |
| 47 | + |
| 48 | + $mapName = $egMapsYahooMapsPrefix . '_' . $egYahooMapsOnThisPage; |
| 49 | + |
57 | 50 | $this->output .= Html::element( |
58 | 51 | 'div', |
59 | 52 | array( |
60 | | - 'id' => $this->mapName, |
| 53 | + 'id' => $mapName, |
61 | 54 | 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
62 | 55 | ), |
63 | 56 | wfMsg('maps-loading-map') |
— | — | @@ -67,7 +60,7 @@ |
68 | 61 | addOnloadHook( |
69 | 62 | function() { |
70 | 63 | initializeYahooMap( |
71 | | - '$this->mapName', |
| 64 | + '$mapName', |
72 | 65 | $this->centreLat, |
73 | 66 | $this->centreLon, |
74 | 67 | $this->zoom, |
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispMap.php |
— | — | @@ -18,21 +18,9 @@ |
19 | 19 | public $serviceName = MapsYahooMaps::SERVICE_NAME; |
20 | 20 | |
21 | 21 | /** |
22 | | - * @see MapsBaseMap::setFormInputSettings() |
23 | | - * |
24 | | - */ |
25 | | - protected function setMapSettings() { |
26 | | - global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix; |
27 | | - |
28 | | - $this->elementNamePrefix = $egMapsYahooMapsPrefix; |
29 | | - $this->defaultZoom = $egMapsYahooMapsZoom; |
30 | | - } |
31 | | - |
32 | | - /** |
33 | 22 | * @see MapsBaseMap::doMapServiceLoad() |
34 | | - * |
35 | 23 | */ |
36 | | - protected function doMapServiceLoad() { |
| 24 | + public function doMapServiceLoad() { |
37 | 25 | global $egYahooMapsOnThisPage; |
38 | 26 | |
39 | 27 | MapsYahooMaps::addYMapDependencies( $this->output ); |
— | — | @@ -43,13 +31,16 @@ |
44 | 32 | |
45 | 33 | /** |
46 | 34 | * @see MapsBaseMap::addSpecificMapHTML() |
47 | | - * |
48 | 35 | */ |
49 | 36 | public function addSpecificMapHTML( Parser $parser ) { |
| 37 | + global $egMapsYahooMapsPrefix, $egYahooMapsOnThisPage; |
| 38 | + |
| 39 | + $mapName = $egMapsYahooMapsPrefix . '_' . $egYahooMapsOnThisPage; |
| 40 | + |
50 | 41 | $this->output .= Html::element( |
51 | 42 | 'div', |
52 | 43 | array( |
53 | | - 'id' => $this->mapName, |
| 44 | + 'id' => $mapName, |
54 | 45 | 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
55 | 46 | ), |
56 | 47 | wfMsg('maps-loading-map') |
— | — | @@ -60,7 +51,7 @@ |
61 | 52 | addOnloadHook( |
62 | 53 | function() { |
63 | 54 | initializeYahooMap( |
64 | | - '$this->mapName', |
| 55 | + '$mapName', |
65 | 56 | $this->centreLat, |
66 | 57 | $this->centreLon, |
67 | 58 | $this->zoom, |
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php |
— | — | @@ -62,50 +62,50 @@ |
63 | 63 | |
64 | 64 | $allowedTypes = MapsYahooMaps::getTypeNames(); |
65 | 65 | |
| 66 | + $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
| 67 | + 'controls' => array( |
| 68 | + 'type' => array( 'string', 'list' ), |
| 69 | + 'criteria' => array( |
| 70 | + 'in_array' => self::getControlNames() |
| 71 | + ), |
| 72 | + 'default' => $egMapsYMapControls, |
| 73 | + 'output-type' => array( 'list', ',', '\'' ) |
| 74 | + ), |
| 75 | + 'type' => array ( |
| 76 | + 'aliases' => array( 'map-type', 'map type' ), |
| 77 | + 'criteria' => array( |
| 78 | + 'in_array' => $allowedTypes |
| 79 | + ), |
| 80 | + 'default' => $egMapsYahooMapsType, // FIXME: default value should not be used when not present in types parameter. |
| 81 | + 'output-type' => 'ymaptype' |
| 82 | + ), |
| 83 | + 'types' => array ( |
| 84 | + 'type' => array( 'string', 'list' ), |
| 85 | + 'aliases' => array( 'map-types', 'map types' ), |
| 86 | + 'criteria' => array( |
| 87 | + 'in_array' => $allowedTypes |
| 88 | + ), |
| 89 | + 'default' => $egMapsYahooMapsTypes, |
| 90 | + 'output-types' => array( 'ymaptypes', 'list' ) |
| 91 | + ), |
| 92 | + 'autozoom' => array( |
| 93 | + 'type' => 'boolean', |
| 94 | + 'aliases' => array( 'auto zoom', 'mouse zoom', 'mousezoom' ), |
| 95 | + 'default' => $egMapsYahooAutozoom, |
| 96 | + 'output-type' => 'boolstr' |
| 97 | + ), |
| 98 | + ); |
| 99 | + |
66 | 100 | $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['default'] = $egMapsYahooMapsZoom; |
67 | | - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 1, 13 ); |
68 | | - |
69 | | - $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
70 | | - 'controls' => array( |
71 | | - 'type' => array( 'string', 'list' ), |
72 | | - 'criteria' => array( |
73 | | - 'in_array' => self::getControlNames() |
74 | | - ), |
75 | | - 'default' => $egMapsYMapControls, |
76 | | - 'output-type' => array( 'list', ',', '\'' ) |
77 | | - ), |
78 | | - 'type' => array ( |
79 | | - 'aliases' => array( 'map-type', 'map type' ), |
80 | | - 'criteria' => array( |
81 | | - 'in_array' => $allowedTypes |
82 | | - ), |
83 | | - 'default' => $egMapsYahooMapsType, // FIXME: default value should not be used when not present in types parameter. |
84 | | - 'output-type' => 'ymaptype' |
85 | | - ), |
86 | | - 'types' => array ( |
87 | | - 'type' => array( 'string', 'list' ), |
88 | | - 'aliases' => array( 'map-types', 'map types' ), |
89 | | - 'criteria' => array( |
90 | | - 'in_array' => $allowedTypes |
91 | | - ), |
92 | | - 'default' => $egMapsYahooMapsTypes, |
93 | | - 'output-types' => array( 'ymaptypes', 'list' ) |
94 | | - ), |
95 | | - 'autozoom' => array( |
96 | | - 'type' => 'boolean', |
97 | | - 'aliases' => array( 'auto zoom', 'mouse zoom', 'mousezoom' ), |
98 | | - 'default' => $egMapsYahooAutozoom, |
99 | | - 'output-type' => 'boolstr' |
100 | | - ), |
101 | | - ); |
| 101 | + $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 1, 13 ); |
102 | 102 | } |
103 | 103 | |
104 | 104 | // http://developer.yahoo.com/maps/ajax |
105 | 105 | private static $mapTypes = array( |
106 | | - 'normal' => 'YAHOO_MAP_REG', |
107 | | - 'satellite' => 'YAHOO_MAP_SAT', |
108 | | - 'hybrid' => 'YAHOO_MAP_HYB', |
109 | | - ); |
| 106 | + 'normal' => 'YAHOO_MAP_REG', |
| 107 | + 'satellite' => 'YAHOO_MAP_SAT', |
| 108 | + 'hybrid' => 'YAHOO_MAP_HYB', |
| 109 | + ); |
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Returns the names of all supported map types. |