Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsQP.php |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | * @see SMMapPrinter::addSpecificMapHTML() |
47 | 47 | * |
48 | 48 | */ |
49 | | - protected function addSpecificMapHTML() { |
| 49 | + protected function addSpecificMapHTML( Parser $parser ) { |
50 | 50 | global $wgJsMimeType; |
51 | 51 | |
52 | 52 | $markerItems = array(); |
Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsFormInput.php |
— | — | @@ -67,7 +67,7 @@ |
68 | 68 | * @see MapsMapFeature::addSpecificMapHTML() |
69 | 69 | * |
70 | 70 | */ |
71 | | - protected function addSpecificMapHTML() { |
| 71 | + protected function addSpecificMapHTML( Parser $parser ) { |
72 | 72 | global $wgJsMimeType; |
73 | 73 | |
74 | 74 | $this->output .= " |
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersQP.php |
— | — | @@ -45,15 +45,12 @@ |
46 | 46 | * @see SMMapPrinter::addSpecificMapHTML() |
47 | 47 | * |
48 | 48 | */ |
49 | | - protected function addSpecificMapHTML() { |
50 | | - global $wgJsMimeType; |
51 | | - |
52 | | - $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers ); |
53 | | - |
| 49 | + protected function addSpecificMapHTML( Parser $parser ) { |
| 50 | + // TODO: refactor up like done in maps with display point |
54 | 51 | $markerItems = array(); |
55 | 52 | |
56 | 53 | foreach ( $this->m_locations as $location ) { |
57 | | - // Create a string containing the marker JS |
| 54 | + // Create a string containing the marker JS . |
58 | 55 | list( $lat, $lon, $title, $label, $icon ) = $location; |
59 | 56 | |
60 | 57 | $markerItems[] = "getOLMarkerData($lon, $lat, '$title', '$label', '$icon')"; |
— | — | @@ -61,15 +58,35 @@ |
62 | 59 | |
63 | 60 | $markersString = implode( ',', $markerItems ); |
64 | 61 | |
65 | | - $this->output .= "<div id='$this->mapName' style='width: {$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div> |
66 | | - <script type='$wgJsMimeType'> /*<![CDATA[*/ |
67 | | - addOnloadHook( |
68 | | - function() { |
69 | | - initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$this->controls], [$markersString], $this->height); |
70 | | - } |
71 | | - ); |
72 | | - /*]]>*/ </script>"; |
| 62 | + $this->output .= Html::element( |
| 63 | + 'div', |
| 64 | + array( |
| 65 | + 'id' => $this->mapName, |
| 66 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 67 | + ), |
| 68 | + wfMsg('maps-loading-map') |
| 69 | + ); |
| 70 | + |
| 71 | + $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers ); |
| 72 | + |
| 73 | + $parser->getOutput()->addHeadItem( |
| 74 | + Html::inlineScript( <<<EOT |
| 75 | +addOnloadHook( |
| 76 | + function() { |
| 77 | + initOpenLayer( |
| 78 | + '$this->mapName', |
| 79 | + $this->centre_lat, |
| 80 | + $this->centre_lon, |
| 81 | + $this->zoom, |
| 82 | + [$layerItems], |
| 83 | + [$this->controls], |
| 84 | + [$markersString] |
| 85 | + ); |
73 | 86 | } |
| 87 | +); |
| 88 | +EOT |
| 89 | + ) ); |
| 90 | + } |
74 | 91 | |
75 | 92 | /** |
76 | 93 | * Returns type info, descriptions and allowed values for this QP's parameters after adding the spesific ones to the list. |
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersFormInput.php |
— | — | @@ -66,22 +66,43 @@ |
67 | 67 | * @see MapsMapFeature::addSpecificMapHTML() |
68 | 68 | * |
69 | 69 | */ |
70 | | - protected function addSpecificMapHTML() { |
71 | | - global $wgJsMimeType; |
| 70 | + protected function addSpecificMapHTML( Parser $parser ) { |
| 71 | + $this->output .= Html::element( |
| 72 | + 'div', |
| 73 | + array( |
| 74 | + 'id' => $this->mapName, |
| 75 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 76 | + ), |
| 77 | + wfMsg('maps-loading-map') |
| 78 | + ); |
72 | 79 | |
73 | 80 | $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers ); |
74 | 81 | |
75 | | - $this->output .= " |
76 | | - <div id='" . $this->mapName . "' style='width: {$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div> |
| 82 | + $parser->getOutput()->addHeadItem( |
| 83 | + Html::inlineScript( <<<EOT |
| 84 | +addOnloadHook( |
| 85 | + function() { |
| 86 | + makeFormInputOpenLayer( |
| 87 | + '$this->mapName', |
| 88 | + '$this->coordsFieldName', |
| 89 | + $this->centre_lat, |
| 90 | + $this->centre_lon, |
| 91 | + $this->zoom, |
| 92 | + $this->marker_lat, |
| 93 | + $this->marker_lon, |
| 94 | + [$layerItems], |
| 95 | + [$this->controls], |
| 96 | + ); |
| 97 | + } |
| 98 | +); |
| 99 | +EOT |
| 100 | + ) ); |
77 | 101 | |
78 | | - <script type='$wgJsMimeType'>/*<![CDATA[*/ |
79 | | - addOnloadHook(function() {makeFormInputOpenLayer('" . $this->mapName . "', '" . $this->coordsFieldName . "', " . $this->centre_lat . ", " . $this->centre_lon . ", " . $this->zoom . ", " . $this->marker_lat . ", " . $this->marker_lon . ", [$layerItems], [$this->controls], $this->height);}); |
80 | | - /*]]>*/</script>"; |
81 | 102 | } |
82 | 103 | |
83 | 104 | /** |
84 | 105 | * @see SMFormInput::manageGeocoding() |
85 | | - * |
| 106 | + * TODO: find a geocoding service that can be used here |
86 | 107 | */ |
87 | 108 | protected function manageGeocoding() { |
88 | 109 | $this->enableGeocoding = false; |
Index: trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMQP.php |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | * @see SMMapPrinter::addSpecificMapHTML() |
47 | 47 | * |
48 | 48 | */ |
49 | | - protected function addSpecificMapHTML() { |
| 49 | + protected function addSpecificMapHTML( Parser $parser ) { |
50 | 50 | global $wgJsMimeType; |
51 | 51 | |
52 | 52 | $markerItems = array(); |
Index: trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMFormInput.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | * @see MapsMapFeature::addSpecificMapHTML() |
70 | 70 | * |
71 | 71 | */ |
72 | | - protected function addSpecificMapHTML() { |
| 72 | + protected function addSpecificMapHTML( Parser $parser ) { |
73 | 73 | global $wgJsMimeType; |
74 | 74 | |
75 | 75 | $this->output .= <<<EOT |
Index: trunk/extensions/SemanticMaps/SemanticMaps.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | |
37 | 37 | // Only initialize the extension when all dependencies are present. |
38 | 38 | if ( defined( 'Maps_VERSION' ) && defined( 'SMW_VERSION' ) ) { |
39 | | - define( 'SM_VERSION', '0.6 a4' ); |
| 39 | + define( 'SM_VERSION', '0.6 a5' ); |
40 | 40 | |
41 | 41 | $smgScriptPath = ( isset( $wgExtensionAssetsPath ) && $wgExtensionAssetsPath ? $wgExtensionAssetsPath : $wgScriptPath . '/extensions' ) . '/SemanticMaps'; |
42 | 42 | $smgDir = dirname( __FILE__ ) . '/'; |
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * Abstract class that provides the common functionallity for all map query printers |
| 5 | + * File holding abstract class SMMapPrinter. |
6 | 6 | * |
7 | 7 | * @file SM_MapPrinter.php |
8 | 8 | * @ingroup SemanticMaps |
— | — | @@ -15,16 +15,23 @@ |
16 | 16 | die( 'Not an entry point.' ); |
17 | 17 | } |
18 | 18 | |
| 19 | +/** |
| 20 | + * Abstract class that provides the common functionallity for all map query printers. |
| 21 | + * |
| 22 | + * @ingroup SemanticMaps |
| 23 | + * |
| 24 | + * @author Jeroen De Dauw |
| 25 | + * @author Robert Buzink |
| 26 | + * @author Yaron Koren |
| 27 | + * |
| 28 | + * TODO: |
| 29 | + * This class is borrowing an awefull lot code from MapsMapFeature, which |
| 30 | + * ideally should be inherited. Since SMWResultPrinter already gets inherited, |
| 31 | + * this is not possible. Finding a better solution to this code redundancy |
| 32 | + * would be nice, cause now changes to MapsMapFeature need to be copied here. |
| 33 | + */ |
19 | 34 | abstract class SMMapPrinter extends SMWResultPrinter { |
20 | 35 | |
21 | | - /* |
22 | | - * TODO: |
23 | | - * This class is borrowing an awefull lot code from MapsMapFeature, which |
24 | | - * ideally should be inherited. Since SMWResultPrinter already gets inherited, |
25 | | - * this is not possible. Finding a better solution to this code redundancy |
26 | | - * would be nice, cause now changes to MapsMapFeature need to be copied here. |
27 | | - */ |
28 | | - |
29 | 36 | /** |
30 | 37 | * Sets the map service specific element name |
31 | 38 | */ |
— | — | @@ -38,7 +45,7 @@ |
39 | 46 | /** |
40 | 47 | * Gets the query result |
41 | 48 | */ |
42 | | - protected abstract function addSpecificMapHTML(); |
| 49 | + protected abstract function addSpecificMapHTML( Parser $parser ); |
43 | 50 | |
44 | 51 | public $serviceName; |
45 | 52 | |
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsQP.php |
— | — | @@ -63,47 +63,53 @@ |
64 | 64 | * @see SMMapPrinter::getQueryResult() |
65 | 65 | * |
66 | 66 | */ |
67 | | - protected function addSpecificMapHTML() { |
68 | | - global $wgJsMimeType; |
69 | | - |
70 | | - $onloadFunctions = MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls ); |
| 67 | + protected function addSpecificMapHTML( Parser $parser ) { |
| 68 | + MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls ); |
71 | 69 | |
| 70 | + // TODO: refactor up like done in maps with display point |
72 | 71 | $markerItems = array(); |
73 | 72 | |
74 | 73 | foreach ( $this->m_locations as $location ) { |
75 | 74 | list( $lat, $lon, $title, $label, $icon ) = $location; |
76 | | - |
77 | 75 | $markerItems[] = "getGMarkerData($lat, $lon, '$title', '$label', '$icon')"; |
78 | 76 | } |
79 | 77 | |
80 | | - // Create a string containing the marker JS |
| 78 | + // Create a string containing the marker JS. |
81 | 79 | $markersString = implode( ',', $markerItems ); |
82 | 80 | |
83 | | - $this->output .= <<<EOT |
84 | | -<div id="$this->mapName"></div> |
85 | | -<script type="$wgJsMimeType"> /*<![CDATA[*/ |
| 81 | + $this->output .= Html::element( |
| 82 | + 'div', |
| 83 | + array( |
| 84 | + 'id' => $this->mapName, |
| 85 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 86 | + ), |
| 87 | + wfMsg('maps-loading-map') |
| 88 | + ); |
| 89 | + |
| 90 | + $parser->getOutput()->addHeadItem( |
| 91 | + Html::inlineScript( <<<EOT |
86 | 92 | addOnloadHook( |
87 | 93 | function() { |
88 | | - initializeGoogleMap('$this->mapName', |
89 | | - { |
90 | | - width: $this->width, |
91 | | - height: $this->height, |
92 | | - lat: $this->centre_lat, |
93 | | - lon: $this->centre_lon, |
94 | | - zoom: $this->zoom, |
95 | | - type: $this->type, |
96 | | - types: [$this->types], |
97 | | - controls: [$this->controls], |
98 | | - scrollWheelZoom: $this->autozoom |
99 | | - }, |
100 | | - [$markersString] |
101 | | - ); |
| 94 | + initializeGoogleMap('$this->mapName', |
| 95 | + { |
| 96 | + width: $this->width, |
| 97 | + height: $this->height, |
| 98 | + lat: $this->centre_lat, |
| 99 | + lon: $this->centre_lon, |
| 100 | + zoom: $this->zoom, |
| 101 | + type: $this->type, |
| 102 | + types: [$this->types], |
| 103 | + controls: [$this->controls], |
| 104 | + scrollWheelZoom: $this->autozoom |
| 105 | + }, |
| 106 | + [$markersString] |
| 107 | + ); |
102 | 108 | } |
103 | 109 | ); |
104 | | -/*]]>*/ </script> |
105 | | -EOT; |
106 | | - |
107 | | - $this->output .= $onloadFunctions; |
| 110 | +EOT |
| 111 | + ) ); |
| 112 | + |
| 113 | + |
108 | 114 | } |
109 | 115 | |
110 | 116 | /** |
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsFormInput.php |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | * @see MapsMapFeature::addSpecificFormInputHTML() |
71 | 71 | * |
72 | 72 | */ |
73 | | - protected function addSpecificMapHTML() { |
| 73 | + protected function addSpecificMapHTML( Parser $parser ) { |
74 | 74 | global $wgJsMimeType; |
75 | 75 | |
76 | 76 | // Remove the overlays control in case it's present. |