Index: trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispPoint.php |
— | — | @@ -58,28 +58,36 @@ |
59 | 59 | * |
60 | 60 | */ |
61 | 61 | public function addSpecificMapHTML() { |
62 | | - global $wgJsMimeType; |
| 62 | + global $wgOut; |
63 | 63 | |
64 | | - // TODO |
65 | | - $this->output .= <<<EOT |
66 | | -<div id="$this->mapName" style="width:{$this->width}px; height:{$this->height}px"></div> |
67 | | -<script type="$wgJsMimeType"> /*<![CDATA[*/ |
| 64 | + $this->output .= Html::element( |
| 65 | + 'div', |
| 66 | + array( |
| 67 | + 'id' => $this->mapName, |
| 68 | + 'width' => $this->width, |
| 69 | + 'height' => $this->height |
| 70 | + ), |
| 71 | + null |
| 72 | + ); |
| 73 | + |
| 74 | + $wgOut->addInlineScript( <<<EOT |
68 | 75 | addOnloadHook( |
69 | 76 | function() { |
70 | | - initGMap3("$this->mapName", { |
71 | | - zoom: $this->zoom, |
72 | | - lat: $this->centre_lat, |
73 | | - lon: $this->centre_lon, |
74 | | - types: [], |
75 | | - mapTypeId: $this->type |
76 | | - }, |
77 | | - [$this->markerString] |
78 | | - ); |
| 77 | + initGMap3( |
| 78 | + "$this->mapName", |
| 79 | + { |
| 80 | + zoom: $this->zoom, |
| 81 | + lat: $this->centre_lat, |
| 82 | + lon: $this->centre_lon, |
| 83 | + types: [], |
| 84 | + mapTypeId: $this->type |
| 85 | + }, |
| 86 | + [$this->markerString] |
| 87 | + ); |
79 | 88 | } |
80 | 89 | ); |
81 | | -/*]]>*/ </script> |
82 | | -EOT; |
83 | | - |
| 90 | +EOT |
| 91 | + ); |
84 | 92 | } |
85 | 93 | |
86 | 94 | } |
Index: trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispMap.php |
— | — | @@ -56,27 +56,36 @@ |
57 | 57 | * |
58 | 58 | */ |
59 | 59 | public function addSpecificMapHTML() { |
60 | | - global $wgJsMimeType; |
| 60 | + global $wgOut; |
61 | 61 | |
62 | | - $this->output .= <<<EOT |
63 | | -<div id="$this->mapName" style="width:{$this->width}px; height:{$this->height}px"></div> |
64 | | -<script type="$wgJsMimeType"> /*<![CDATA[*/ |
| 62 | + $this->output .= Html::element( |
| 63 | + 'div', |
| 64 | + array( |
| 65 | + 'id' => $this->mapName, |
| 66 | + 'width' => $this->width, |
| 67 | + 'height' => $this->height |
| 68 | + ), |
| 69 | + null |
| 70 | + ); |
| 71 | + |
| 72 | + $wgOut->addInlineScript( <<<EOT |
65 | 73 | addOnloadHook( |
66 | 74 | function() { |
67 | | - initGMap3("$this->mapName", { |
68 | | - zoom: $this->zoom, |
69 | | - lat: $this->centre_lat, |
70 | | - lon: $this->centre_lon, |
71 | | - types: [], |
72 | | - mapTypeId: $this->type |
73 | | - }, |
74 | | - [] |
75 | | - ); |
| 75 | + initGMap3( |
| 76 | + "$this->mapName", |
| 77 | + { |
| 78 | + zoom: $this->zoom, |
| 79 | + lat: $this->centre_lat, |
| 80 | + lon: $this->centre_lon, |
| 81 | + types: [], |
| 82 | + mapTypeId: $this->type |
| 83 | + }, |
| 84 | + [] |
| 85 | + ); |
76 | 86 | } |
77 | 87 | ); |
78 | | -/*]]>*/ </script> |
79 | | -EOT; |
80 | | - |
| 88 | +EOT |
| 89 | + ); |
81 | 90 | } |
82 | 91 | |
83 | 92 | } |
Index: trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3.php |
— | — | @@ -125,12 +125,12 @@ |
126 | 126 | */ |
127 | 127 | public static function addGMap3Dependencies( &$output ) { |
128 | 128 | global $wgJsMimeType, $wgLang; |
129 | | - global $egMapsScriptPath, $egGMaps3OnThisPage, $egMapsStyleVersion; |
| 129 | + global $egMapsScriptPath, $egGMaps3OnThisPage, $egMapsStyleVersion, $egMapsJsExt; |
130 | 130 | |
131 | 131 | if ( empty( $egGMaps3OnThisPage ) ) { |
132 | 132 | $egGMaps3OnThisPage = 0; |
133 | 133 | |
134 | | - $output .= "<script type='$wgJsMimeType' src='http://maps.google.com/maps/api/js?sensor=false&language={$wgLang->getCode()}'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps3/GoogleMap3Functions.js?$egMapsStyleVersion'></script>"; |
| 134 | + $output .= "<script type='$wgJsMimeType' src='http://maps.google.com/maps/api/js?sensor=false&language={$wgLang->getCode()}'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps3/GoogleMap3Functions{$egMapsJsExt}?$egMapsStyleVersion'></script>"; |
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispPoint.php |
— | — | @@ -13,7 +13,6 @@ |
14 | 14 | die( 'Not an entry point.' ); |
15 | 15 | } |
16 | 16 | |
17 | | - |
18 | 17 | /** |
19 | 18 | * Class for handling the display_point(s) parser functions with OpenLayers. |
20 | 19 | * |
— | — | @@ -54,18 +53,37 @@ |
55 | 54 | * |
56 | 55 | */ |
57 | 56 | public function addSpecificMapHTML() { |
58 | | - global $wgJsMimeType; |
59 | | - |
| 57 | + global $wgOut; |
| 58 | + |
60 | 59 | $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers ); |
61 | 60 | |
62 | | - $this->output .= "<div id='$this->mapName' style='width: {$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div> |
63 | | - <script type='$wgJsMimeType'> /*<![CDATA[*/ |
64 | | - addOnloadHook( |
65 | | - function() { |
66 | | - initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$this->controls],[$this->markerString], $this->height); |
67 | | - } |
68 | | - ); |
69 | | - /*]]>*/ </script>"; |
| 61 | + $this->output .= Html::element( |
| 62 | + 'div', |
| 63 | + array( |
| 64 | + 'id' => $this->mapName, |
| 65 | + 'width' => $this->width, |
| 66 | + 'height' => $this->height |
| 67 | + ), |
| 68 | + null |
| 69 | + ); |
| 70 | + |
| 71 | + $wgOut->addInlineScript( <<<EOT |
| 72 | +addOnloadHook( |
| 73 | + function() { |
| 74 | + initOpenLayer( |
| 75 | + '$this->mapName', |
| 76 | + $this->centre_lon, |
| 77 | + $this->centre_lat, |
| 78 | + $this->zoom, |
| 79 | + [$layerItems], |
| 80 | + [$this->controls], |
| 81 | + [$this->markerString], |
| 82 | + $this->height |
| 83 | + ); |
70 | 84 | } |
| 85 | +); |
| 86 | +EOT |
| 87 | + ); |
| 88 | + } |
71 | 89 | |
72 | 90 | } |
\ No newline at end of file |
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispMap.php |
— | — | @@ -46,18 +46,37 @@ |
47 | 47 | * |
48 | 48 | */ |
49 | 49 | public function addSpecificMapHTML() { |
50 | | - global $wgJsMimeType; |
| 50 | + global $wgOut; |
51 | 51 | |
52 | 52 | $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers ); |
53 | 53 | |
54 | | - $this->output .= "<div id='$this->mapName' style='width: {$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div> |
55 | | - <script type='$wgJsMimeType'> /*<![CDATA[*/ |
56 | | - addOnloadHook( |
57 | | - function() { |
58 | | - initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$this->controls],[], $this->height); |
59 | | - } |
60 | | - ); |
61 | | - /*]]>*/ </script>"; |
| 54 | + $this->output .= Html::element( |
| 55 | + 'div', |
| 56 | + array( |
| 57 | + 'id' => $this->mapName, |
| 58 | + 'width' => $this->width, |
| 59 | + 'height' => $this->height |
| 60 | + ), |
| 61 | + null |
| 62 | + ); |
| 63 | + |
| 64 | + $wgOut->addInlineScript( <<<EOT |
| 65 | +addOnloadHook( |
| 66 | + function() { |
| 67 | + initOpenLayer( |
| 68 | + '$this->mapName', |
| 69 | + $this->centre_lon, |
| 70 | + $this->centre_lat, |
| 71 | + $this->zoom, |
| 72 | + [$layerItems], |
| 73 | + [$this->controls], |
| 74 | + [], |
| 75 | + $this->height |
| 76 | + ); |
62 | 77 | } |
| 78 | +); |
| 79 | +EOT |
| 80 | + ); |
| 81 | + } |
63 | 82 | |
64 | 83 | } |
\ No newline at end of file |
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php |
— | — | @@ -118,14 +118,14 @@ |
119 | 119 | */ |
120 | 120 | public static function addOLDependencies( &$output ) { |
121 | 121 | global $wgJsMimeType; |
122 | | - global $egOpenLayersOnThisPage, $egMapsScriptPath, $egMapsStyleVersion; |
| 122 | + global $egOpenLayersOnThisPage, $egMapsScriptPath, $egMapsStyleVersion, $egMapsJsExt; |
123 | 123 | |
124 | 124 | if ( empty( $egOpenLayersOnThisPage ) ) { |
125 | 125 | $egOpenLayersOnThisPage = 0; |
126 | 126 | |
127 | 127 | $output .= "<link rel='stylesheet' href='$egMapsScriptPath/OpenLayers/OpenLayers/theme/default/style.css' type='text/css' /> |
128 | 128 | <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenLayers/OpenLayers/OpenLayers.js'></script> |
129 | | - <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenLayers/OpenLayerFunctions.js?$egMapsStyleVersion'></script> |
| 129 | + <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenLayers/OpenLayerFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script> |
130 | 130 | <script type='$wgJsMimeType'>initOLSettings(200, 100);</script>\n"; |
131 | 131 | } |
132 | 132 | } |
Index: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php |
— | — | @@ -146,8 +146,10 @@ |
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | | - // Return the result |
151 | | - return $parser->insertStripItem( $output, $parser->mStripState ); |
| 150 | + // Return the result. |
| 151 | + //return array( $parser->insertStripItem( $output, $parser->mStripState), 'noparse' => true, 'isHTML' => true ); |
| 152 | + //return $parser->insertStripItem( $output, $parser->mStripState); |
| 153 | + return array( $output, 'noparse' => true, 'isHTML' => true ); |
152 | 154 | } |
153 | 155 | |
154 | 156 | /** |
Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | echo '<b>Warning:</b> You need to have <a href="http://www.mediawiki.org/wiki/Extension:Validator">Validator</a> installed in order to use <a href="http://www.mediawiki.org/wiki/Extension:Maps">Maps</a>.'; |
35 | 35 | } |
36 | 36 | else { |
37 | | - define( 'Maps_VERSION', '0.6 a1' ); |
| 37 | + define( 'Maps_VERSION', '0.6 a2' ); |
38 | 38 | |
39 | 39 | // The different coordinate notations. |
40 | 40 | define( 'Maps_COORDS_FLOAT', 0 ); |
— | — | @@ -73,7 +73,8 @@ |
74 | 74 | */ |
75 | 75 | function efMapsSetup() { |
76 | 76 | global $wgExtensionCredits, $wgLang, $wgAutoloadClasses, $IP; |
77 | | - global $egMapsDefaultService, $egMapsAvailableServices, $egMapsServices, $egMapsDefaultGeoService, $egMapsAvailableGeoServices, $egMapsDir, $egMapsAvailableFeatures; |
| 77 | + global $egMapsDefaultService, $egMapsAvailableServices, $egMapsServices, $egMapsDefaultGeoService; |
| 78 | + global $egMapsAvailableGeoServices, $egMapsDir, $egMapsAvailableFeatures, $egMapsJsExt; |
78 | 79 | |
79 | 80 | // Remove all hooked in services that should not be available. |
80 | 81 | foreach ( $egMapsServices as $service => $data ) { |
— | — | @@ -125,6 +126,8 @@ |
126 | 127 | } |
127 | 128 | } |
128 | 129 | |
| 130 | + $egMapsJsExt = $egMapsUseMinJs ? '.min.js' : '.js'; |
| 131 | + |
129 | 132 | return true; |
130 | 133 | } |
131 | 134 | |
Index: trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispMap.php |
— | — | @@ -67,10 +67,14 @@ |
68 | 68 | * |
69 | 69 | */ |
70 | 70 | public function addSpecificMapHTML() { |
71 | | - global $wgJsMimeType; |
| 71 | + global $wgOut; |
72 | 72 | |
73 | | - $this->output .= <<<EOT |
74 | | - <script type='$wgJsMimeType'>slippymaps['$this->mapName'] = new slippymap_map('$this->mapName', { |
| 73 | + $wgOut->addInlineScript( <<<EOT |
| 74 | +addOnloadHook( |
| 75 | + function() { |
| 76 | + slippymaps['$this->mapName'] = new slippymap_map( |
| 77 | + '$this->mapName', |
| 78 | + { |
75 | 79 | mode: '$this->mode', |
76 | 80 | layer: 'osm-like', |
77 | 81 | locale: '$this->lang', |
— | — | @@ -81,9 +85,12 @@ |
82 | 86 | height: $this->height, |
83 | 87 | markers: [], |
84 | 88 | controls: [$this->controls] |
85 | | - });</script> |
86 | | - |
87 | | -EOT; |
| 89 | + } |
| 90 | + ); |
| 91 | + } |
| 92 | +); |
| 93 | +EOT |
| 94 | + ); |
88 | 95 | |
89 | 96 | $this->output .= $this->static ? $this->getStaticMap() : $this->getDynamicMap(); |
90 | 97 | } |
— | — | @@ -94,16 +101,28 @@ |
95 | 102 | * @return string |
96 | 103 | */ |
97 | 104 | private function getDynamicMap() { |
98 | | - global $wgJsMimeType; |
| 105 | + global $wgOut; |
99 | 106 | |
100 | | - return <<<EOT |
101 | | - <!-- map div --> |
102 | | - <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'> |
103 | | - <script type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script> |
104 | | - <!-- /map div --> |
105 | | - </div> |
106 | | -EOT; |
| 107 | + $wgOut->addInlineScript( <<<EOT |
| 108 | +addOnloadHook( |
| 109 | + function() { |
| 110 | + slippymaps['$this->mapName'].init(); |
107 | 111 | } |
| 112 | +); |
| 113 | +EOT |
| 114 | + ); |
| 115 | + |
| 116 | + return Html::element( |
| 117 | + 'div', |
| 118 | + array( |
| 119 | + 'id' => $this->mapName, |
| 120 | + 'width' => $this->width, |
| 121 | + 'height' => $this->height, |
| 122 | + 'class' => 'map' |
| 123 | + ), |
| 124 | + null |
| 125 | + ); |
| 126 | + } |
108 | 127 | |
109 | 128 | /** |
110 | 129 | * Returns html for a static map. |
— | — | @@ -120,28 +139,34 @@ |
121 | 140 | $rendering_url = $static->getUrl(); |
122 | 141 | |
123 | 142 | $alt = wfMsg( 'maps_centred_on', $this->centre_lat, $this->centre_lon ); |
| 143 | + $title = $this->activatable ? wfMsg( 'maps_click_to_activate' ) : $alt; |
124 | 144 | |
| 145 | + $image = array( |
| 146 | + 'class' => 'mapPreview', |
| 147 | + 'src' => $rendering_url, |
| 148 | + 'width' => $this->width, |
| 149 | + 'height' => $this->height, |
| 150 | + 'alt' => $alt, |
| 151 | + 'title' => $title, |
| 152 | + ); |
| 153 | + |
125 | 154 | if ( $this->activatable ) { |
126 | | - $title = wfMsg( 'maps_click_to_activate' ); |
127 | | - $activationCode = "onclick=\"slippymaps['$this->mapName'].init();\""; |
| 155 | + $image['onclick'] = "slippymaps['$this->mapName'].init();"; |
128 | 156 | } |
129 | | - else { |
130 | | - $activationCode = ''; |
131 | | - $title = $alt; |
132 | | - } |
133 | 157 | |
134 | | - return <<<EOT |
135 | | - <div id="$this->mapName" class="map" style="width:{$this->width}px; height:{$this->height}px;"> |
136 | | - <img id="$this->mapName-preview" |
137 | | - class="mapPreview" |
138 | | - src="{$rendering_url}" |
139 | | - width="$this->width" |
140 | | - height="$this->height" |
141 | | - alt="$alt" |
142 | | - title="$title" |
143 | | - $activationCode /> |
144 | | - </div> |
145 | | -EOT; |
| 158 | + return Html::element( |
| 159 | + 'div', |
| 160 | + array( |
| 161 | + 'id' => $this->mapName, |
| 162 | + 'width' => $this->width, |
| 163 | + 'height' => $this->height, |
| 164 | + 'class' => 'map' |
| 165 | + ), |
| 166 | + Html::element( |
| 167 | + 'img', |
| 168 | + $image |
| 169 | + ) |
| 170 | + ); |
146 | 171 | } |
147 | 172 | |
148 | 173 | } |
Index: trunk/extensions/Maps/OpenStreetMap/Maps_OSM.php |
— | — | @@ -149,14 +149,14 @@ |
150 | 150 | */ |
151 | 151 | public static function addOSMDependencies( &$output ) { |
152 | 152 | global $wgJsMimeType; |
153 | | - global $egOSMMapsOnThisPage, $egMapsScriptPath, $egMapsStyleVersion; |
| 153 | + global $egOSMMapsOnThisPage, $egMapsScriptPath, $egMapsStyleVersion, $egMapsJsExt; |
154 | 154 | |
155 | 155 | if ( empty( $egOSMMapsOnThisPage ) ) { |
156 | 156 | $egOSMMapsOnThisPage = 0; |
157 | 157 | |
158 | 158 | $output .= "<link rel='stylesheet' href='$egMapsScriptPath/OpenLayers/OpenLayers/theme/default/style.css' type='text/css' /> |
159 | 159 | <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenLayers/OpenLayers/OpenLayers.js'></script> |
160 | | - <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenStreetMap/OSMFunctions.min.js?$egMapsStyleVersion'></script> |
| 160 | + <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenStreetMap/OSMFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script> |
161 | 161 | <script type='$wgJsMimeType'>slippymaps = Array();</script>\n"; |
162 | 162 | } |
163 | 163 | } |
Index: trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispPoint.php |
— | — | @@ -53,13 +53,17 @@ |
54 | 54 | * |
55 | 55 | */ |
56 | 56 | public function addSpecificMapHTML() { |
57 | | - global $wgJsMimeType; |
| 57 | + global $wgOut; |
58 | 58 | |
59 | | - $this->output .= <<<EOT |
60 | | - <script type='$wgJsMimeType'>slippymaps['$this->mapName'] = new slippymap_map('$this->mapName', { |
61 | | - mode: 'osm-wm', |
| 59 | + $wgOut->addInlineScript( <<<EOT |
| 60 | +addOnloadHook( |
| 61 | + function() { |
| 62 | + slippymaps['$this->mapName'] = new slippymap_map( |
| 63 | + '$this->mapName', |
| 64 | + { |
| 65 | + mode: '$this->mode', |
62 | 66 | layer: 'osm-like', |
63 | | - locale: '$this->lang', |
| 67 | + locale: '$this->lang', |
64 | 68 | lat: $this->centre_lat, |
65 | 69 | lon: $this->centre_lon, |
66 | 70 | zoom: $this->zoom, |
— | — | @@ -67,14 +71,23 @@ |
68 | 72 | height: $this->height, |
69 | 73 | markers: [$this->markerString], |
70 | 74 | controls: [$this->controls] |
71 | | - });</script> |
| 75 | + } |
| 76 | + ); |
| 77 | + slippymaps['$this->mapName'].init(); |
| 78 | + } |
| 79 | +); |
| 80 | +EOT |
| 81 | + ); |
72 | 82 | |
73 | | - <!-- map div --> |
74 | | - <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'> |
75 | | - <script type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script> |
76 | | - <!-- /map div --> |
77 | | - </div> |
78 | | -EOT; |
| 83 | + $this->output .= Html::element( |
| 84 | + 'div', |
| 85 | + array( |
| 86 | + 'id' => $this->mapName, |
| 87 | + 'width' => $this->width, |
| 88 | + 'height' => $this->height, |
| 89 | + 'class' => 'map' |
| 90 | + ), |
| 91 | + null |
| 92 | + ); |
79 | 93 | } |
80 | | - |
81 | 94 | } |
\ No newline at end of file |
Index: trunk/extensions/Maps/Maps_Mapper.php |
— | — | @@ -26,31 +26,31 @@ |
27 | 27 | public static function initializeMainParams() { |
28 | 28 | global $egMapsSizeRestrictions, $egMapsMapWidth, $egMapsMapHeight; |
29 | 29 | |
30 | | - self::$mainParams = array |
31 | | - ( |
| 30 | + Validator::addOutputFormat( 'mapdimension', array( __CLASS__, 'setMapDimension' ) ); |
| 31 | + Validator::addValidationFunction( 'is_map_dimension', array( __CLASS__, 'isMapDimension' ) ); |
| 32 | + |
| 33 | + self::$mainParams = array ( |
32 | 34 | 'zoom' => array( |
33 | 35 | 'type' => 'integer', |
34 | 36 | 'criteria' => array( |
35 | 37 | 'not_empty' => array() |
36 | | - ) |
37 | | - ), |
| 38 | + ) |
| 39 | + ), |
38 | 40 | 'width' => array( |
39 | | - 'type' => 'integer', |
40 | 41 | 'criteria' => array( |
41 | | - 'not_empty' => array(), |
42 | | - 'in_range' => $egMapsSizeRestrictions['width'] |
43 | | - ), |
44 | | - 'default' => $egMapsMapWidth |
| 42 | + 'is_map_dimension' => array( 'width' ), |
45 | 43 | ), |
| 44 | + 'default' => $egMapsMapWidth, |
| 45 | + 'output-type' => array( 'mapdimension', 'width', true, $egMapsMapWidth ) |
| 46 | + ), |
46 | 47 | 'height' => array( |
47 | | - 'type' => 'integer', |
48 | 48 | 'criteria' => array( |
49 | | - 'not_empty' => array(), |
50 | | - 'in_range' => $egMapsSizeRestrictions['height'] |
51 | | - ), |
52 | | - 'default' => $egMapsMapHeight |
| 49 | + 'is_map_dimension' => array( 'height' ), |
53 | 50 | ), |
54 | | - ); |
| 51 | + 'default' => $egMapsMapHeight, |
| 52 | + 'output-type' => array( 'mapdimension', 'height', true, $egMapsMapHeight ) |
| 53 | + ), |
| 54 | + ); |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
— | — | @@ -147,4 +147,47 @@ |
148 | 148 | |
149 | 149 | return $service; |
150 | 150 | } |
| 151 | + |
| 152 | + public static function isMapDimension( &$value, $dimension, $correct = false, $default = 0 ) { |
| 153 | + global $egMapsSizeRestrictions; |
| 154 | + |
| 155 | + if ( !preg_match( '/^\d+(\.\d+)?(px|ex|em|%)?$/', $value ) ) { |
| 156 | + if ( $correct ) { |
| 157 | + $value = $default; |
| 158 | + } else { |
| 159 | + return false; |
| 160 | + } |
| 161 | + } |
| 162 | + |
| 163 | + if ( !preg_match( '/^.*%$/', $value ) ) { |
| 164 | + $number = preg_replace( '/[^0-9]/', '', $value ); |
| 165 | + if ( $number < $egMapsSizeRestrictions[$dimension][0] ) { |
| 166 | + if ( $correct ) { |
| 167 | + $value = $egMapsSizeRestrictions[$dimension][0]; |
| 168 | + } else { |
| 169 | + return false; |
| 170 | + } |
| 171 | + } else if ( $number > $egMapsSizeRestrictions[$dimension][1] ) { |
| 172 | + if ( $correct ) { |
| 173 | + $value = $egMapsSizeRestrictions[$dimension][1]; |
| 174 | + } else { |
| 175 | + return false; |
| 176 | + } |
| 177 | + } |
| 178 | + } |
| 179 | + |
| 180 | + if ( $correct ) { |
| 181 | + if ( !preg_match( '/(px|ex|em|%)$/', $value ) ) { |
| 182 | + $value .= 'px'; |
| 183 | + } |
| 184 | + } |
| 185 | + |
| 186 | + return true; |
| 187 | + } |
| 188 | + |
| 189 | + public static function setMapDimension( &$value, $dimension, $correct, $default ) { |
| 190 | + global $egMapsMapWidth; |
| 191 | + self::isMapDimension( $value, $dimension, $correct, $default ); |
| 192 | + } |
| 193 | + |
151 | 194 | } |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php |
— | — | @@ -63,33 +63,38 @@ |
64 | 64 | * |
65 | 65 | */ |
66 | 66 | public function addSpecificMapHTML() { |
67 | | - global $wgJsMimeType; |
| 67 | + global $wgOut; |
68 | 68 | |
69 | | - $onloadFunctions = MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls ); |
| 69 | + MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls ); |
70 | 70 | |
71 | | - $this->output .= <<<EOT |
72 | | -<div id="$this->mapName"></div> |
73 | | -<script type="$wgJsMimeType"> /*<![CDATA[*/ |
| 71 | + $this->output .= Html::element( |
| 72 | + 'div', |
| 73 | + array( |
| 74 | + 'id' => $this->mapName, |
| 75 | + 'width' => $this->width, |
| 76 | + 'height' => $this->height |
| 77 | + ), |
| 78 | + null |
| 79 | + ); |
| 80 | + |
| 81 | + $wgOut->addInlineScript( <<<EOT |
74 | 82 | addOnloadHook( |
75 | 83 | function() { |
76 | | - initializeGoogleMap('$this->mapName', |
77 | | - { |
78 | | - width: $this->width, |
79 | | - height: $this->height, |
80 | | - lat: $this->centre_lat, |
81 | | - lon: $this->centre_lon, |
82 | | - zoom: $this->zoom, |
83 | | - type: $this->type, |
84 | | - types: [$this->types], |
85 | | - controls: [$this->controls], |
86 | | - scrollWheelZoom: $this->autozoom |
87 | | - }, []); |
| 84 | + initializeGoogleMap('$this->mapName', |
| 85 | + { |
| 86 | + lat: $this->centre_lat, |
| 87 | + lon: $this->centre_lon, |
| 88 | + zoom: $this->zoom, |
| 89 | + type: $this->type, |
| 90 | + types: [$this->types], |
| 91 | + controls: [$this->controls], |
| 92 | + scrollWheelZoom: $this->autozoom |
| 93 | + }, |
| 94 | + []); |
88 | 95 | } |
89 | 96 | ); |
90 | | -/*]]>*/ </script> |
91 | | -EOT; |
92 | | - |
93 | | - $this->output .= $onloadFunctions; |
| 97 | +EOT |
| 98 | + ); |
94 | 99 | |
95 | 100 | } |
96 | 101 | |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php |
— | — | @@ -190,14 +190,14 @@ |
191 | 191 | */ |
192 | 192 | public static function addGMapDependencies( &$output ) { |
193 | 193 | global $wgJsMimeType, $wgLang; |
194 | | - global $egGoogleMapsKey, $egMapsScriptPath, $egGoogleMapsOnThisPage, $egMapsStyleVersion; |
| 194 | + global $egGoogleMapsKey, $egMapsScriptPath, $egGoogleMapsOnThisPage, $egMapsStyleVersion, $egMapsJsExt; |
195 | 195 | |
196 | 196 | if ( empty( $egGoogleMapsOnThisPage ) ) { |
197 | 197 | $egGoogleMapsOnThisPage = 0; |
198 | 198 | |
199 | 199 | MapsGoogleMaps::validateGoogleMapsKey(); |
200 | 200 | |
201 | | - $output .= "<script src='http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl={$wgLang->getCode()}' type='$wgJsMimeType'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps/GoogleMapFunctions.min.js?$egMapsStyleVersion'></script><script type='$wgJsMimeType'>window.unload = GUnload;</script>"; |
| 201 | + $output .= "<script src='http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl={$wgLang->getCode()}' type='$wgJsMimeType'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps/GoogleMapFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script><script type='$wgJsMimeType'>window.unload = GUnload;</script>"; |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
— | — | @@ -255,7 +255,7 @@ |
256 | 256 | // Add the inputs for the overlays. |
257 | 257 | $addedOverlays = array(); |
258 | 258 | $overlayHtml = ''; |
259 | | - $onloadFunctions = ''; |
| 259 | + $onloadFunctions = array(); |
260 | 260 | foreach ( $overlays as $overlay => $isOn ) { |
261 | 261 | $overlay = strtolower( $overlay ); |
262 | 262 | |
— | — | @@ -266,7 +266,7 @@ |
267 | 267 | $urlNr = self::$overlayData[$overlay]; |
268 | 268 | $overlayHtml .= "<input id='$mapName-overlay-box-$overlay' name='$mapName-overlay-box' type='checkbox' onclick='switchGLayer(GMaps[\"$mapName\"], this.checked, GOverlays[$urlNr])' /> $label <br />"; |
269 | 269 | if ( $isOn ) { |
270 | | - $onloadFunctions .= "<script type='$wgJsMimeType'>addOnloadHook( function() { initiateGOverlay('$mapName-overlay-box-$overlay', '$mapName', $urlNr) } );</script>"; |
| 270 | + $onloadFunctions .= "addOnloadHook( function() { initiateGOverlay('$mapName-overlay-box-$overlay', '$mapName', $urlNr) } );"; |
271 | 271 | } |
272 | 272 | } |
273 | 273 | } |
— | — | @@ -279,7 +279,7 @@ |
280 | 280 | </div></form></div> |
281 | 281 | EOT; |
282 | 282 | |
283 | | - return $onloadFunctions; |
| 283 | + $output .= "<script type='$wgJsMimeType'>" . implode( "\n", $onloadFunctions ) . '</script>'; |
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php |
— | — | @@ -65,36 +65,41 @@ |
66 | 66 | * |
67 | 67 | */ |
68 | 68 | public function addSpecificMapHTML() { |
69 | | - global $wgJsMimeType; |
| 69 | + global $wgOut; |
70 | 70 | |
71 | | - $onloadFunctions = MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls ); |
| 71 | + MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls ); |
72 | 72 | |
73 | | - $this->output .= <<<EOT |
74 | | -<div id="$this->mapName"></div> |
75 | | -<script type="$wgJsMimeType"> /*<![CDATA[*/ |
| 73 | + $this->output .= Html::element( |
| 74 | + 'div', |
| 75 | + array( |
| 76 | + 'id' => $this->mapName, |
| 77 | + 'width' => $this->width, |
| 78 | + 'height' => $this->height |
| 79 | + ), |
| 80 | + null |
| 81 | + ); |
| 82 | + |
| 83 | + $wgOut->addInlineScript( |
| 84 | + <<<EOT |
76 | 85 | addOnloadHook( |
77 | 86 | function() { |
78 | | - initializeGoogleMap('$this->mapName', |
79 | | - { |
80 | | - width: $this->width, |
81 | | - height: $this->height, |
82 | | - lat: $this->centre_lat, |
83 | | - lon: $this->centre_lon, |
84 | | - zoom: $this->zoom, |
85 | | - type: $this->type, |
86 | | - types: [$this->types], |
87 | | - controls: [$this->controls], |
88 | | - scrollWheelZoom: $this->autozoom |
89 | | - }, |
90 | | - [$this->markerString] |
91 | | - ); |
| 87 | + initializeGoogleMap('$this->mapName', |
| 88 | + { |
| 89 | + lat: $this->centre_lat, |
| 90 | + lon: $this->centre_lon, |
| 91 | + zoom: $this->zoom, |
| 92 | + type: $this->type, |
| 93 | + types: [$this->types], |
| 94 | + controls: [$this->controls], |
| 95 | + scrollWheelZoom: $this->autozoom |
| 96 | + }, |
| 97 | + [$this->markerString] |
| 98 | + ); |
92 | 99 | } |
93 | 100 | ); |
94 | | -/*]]>*/ </script> |
95 | | -EOT; |
| 101 | +EOT |
| 102 | + ); |
96 | 103 | |
97 | | - $this->output .= $onloadFunctions; |
98 | | - |
99 | 104 | } |
100 | 105 | |
101 | 106 | } |
Index: trunk/extensions/Maps/GoogleMaps/GoogleMapFunctions.js |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | function initializeGoogleMap(mapName, mapOptions, markers) { |
56 | 56 | if (GBrowserIsCompatible()) { |
57 | 57 | mapOptions.centre = (mapOptions.lat != null && mapOptions.lon != null) ? new GLatLng(mapOptions.lat, mapOptions.lon) : null; |
58 | | - mapOptions.size = new GSize(mapOptions.width, mapOptions.height); |
| 58 | + //mapOptions.size = new GSize(mapOptions.width, mapOptions.height); |
59 | 59 | return createGoogleMap(mapName, mapOptions, markers); |
60 | 60 | } |
61 | 61 | else { |
— | — | @@ -76,7 +76,7 @@ |
77 | 77 | |
78 | 78 | if (! typesContainType) mapOptions.types.push(mapOptions.type); |
79 | 79 | |
80 | | - var map = new GMap2(mapElement, {size: mapOptions.size, mapTypes: mapOptions.types}); |
| 80 | + var map = new GMap2(mapElement, {mapTypes: mapOptions.types}); |
81 | 81 | map.name = mapName; |
82 | 82 | |
83 | 83 | map.setMapType(mapOptions.type); |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | // List of GControls: http://code.google.com/apis/maps/documentation/reference.html#GControl |
86 | 86 | for (i in mapOptions.controls){ |
87 | 87 | if (mapOptions.controls[i].toLowerCase() == 'auto') { |
88 | | - if (mapOptions.height > 75) mapOptions.controls[i] = mapOptions.height > 320 ? 'large' : 'small'; |
| 88 | + // if (mapOptions.height > 75) mapOptions.controls[i] = mapOptions.height > 320 ? 'large' : 'small'; |
89 | 89 | } |
90 | 90 | |
91 | 91 | switch (mapOptions.controls[i]) { |
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispPoint.php |
— | — | @@ -53,19 +53,37 @@ |
54 | 54 | * |
55 | 55 | */ |
56 | 56 | public function addSpecificMapHTML() { |
57 | | - global $wgJsMimeType; |
| 57 | + global $wgOut; |
58 | 58 | |
59 | | - $this->output .= <<<EOT |
60 | | - <div id="$this->mapName" style="width: {$this->width}px; height: {$this->height}px;"></div> |
| 59 | + $this->output .= Html::element( |
| 60 | + 'div', |
| 61 | + array( |
| 62 | + 'id' => $this->mapName, |
| 63 | + 'width' => $this->width, |
| 64 | + 'height' => $this->height |
| 65 | + ), |
| 66 | + null |
| 67 | + ); |
61 | 68 | |
62 | | - <script type="$wgJsMimeType">/*<![CDATA[*/ |
63 | | - addOnloadHook( |
64 | | - function() { |
65 | | - initializeYahooMap('$this->mapName', $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$this->types], [$this->controls], $this->autozoom, [$this->markerString], $this->height); |
66 | | - } |
| 69 | + $wgOut->addInlineScript( <<<EOT |
| 70 | +addOnloadHook( |
| 71 | + function() { |
| 72 | + initializeYahooMap( |
| 73 | + '$this->mapName', |
| 74 | + $this->centre_lat, |
| 75 | + $this->centre_lon, |
| 76 | + $this->zoom, |
| 77 | + $this->type, |
| 78 | + [$this->types], |
| 79 | + [$this->controls], |
| 80 | + $this->autozoom, |
| 81 | + [$this->markerString], |
| 82 | + $this->height |
67 | 83 | ); |
68 | | - /*]]>*/</script> |
69 | | -EOT; |
70 | 84 | } |
| 85 | +); |
| 86 | +EOT |
| 87 | + ); |
| 88 | + } |
71 | 89 | |
72 | 90 | } |
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispMap.php |
— | — | @@ -46,19 +46,37 @@ |
47 | 47 | * |
48 | 48 | */ |
49 | 49 | public function addSpecificMapHTML() { |
50 | | - global $wgJsMimeType; |
| 50 | + global $wgOut; |
51 | 51 | |
52 | | - $this->output .= <<<EOT |
53 | | - <div id="$this->mapName" style="width: {$this->width}px; height: {$this->height}px;"></div> |
| 52 | + $this->output .= Html::element( |
| 53 | + 'div', |
| 54 | + array( |
| 55 | + 'id' => $this->mapName, |
| 56 | + 'width' => $this->width, |
| 57 | + 'height' => $this->height |
| 58 | + ), |
| 59 | + null |
| 60 | + ); |
54 | 61 | |
55 | | - <script type="$wgJsMimeType">/*<![CDATA[*/ |
56 | | - addOnloadHook( |
57 | | - function() { |
58 | | - initializeYahooMap('$this->mapName', $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$this->types], [$this->controls], $this->autozoom, [], $this->height); |
59 | | - } |
| 62 | + $wgOut->addInlineScript( <<<EOT |
| 63 | +addOnloadHook( |
| 64 | + function() { |
| 65 | + initializeYahooMap( |
| 66 | + '$this->mapName', |
| 67 | + $this->centre_lat, |
| 68 | + $this->centre_lon, |
| 69 | + $this->zoom, |
| 70 | + $this->type, |
| 71 | + [$this->types], |
| 72 | + [$this->controls], |
| 73 | + $this->autozoom, |
| 74 | + [], |
| 75 | + $this->height |
60 | 76 | ); |
61 | | - /*]]>*/</script> |
62 | | -EOT; |
63 | 77 | } |
| 78 | +); |
| 79 | +EOT |
| 80 | + ); |
| 81 | + } |
64 | 82 | |
65 | 83 | } |
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php |
— | — | @@ -149,12 +149,12 @@ |
150 | 150 | */ |
151 | 151 | public static function addYMapDependencies( &$output ) { |
152 | 152 | global $wgJsMimeType; |
153 | | - global $egYahooMapsKey, $egMapsScriptPath, $egYahooMapsOnThisPage, $egMapsStyleVersion; |
| 153 | + global $egYahooMapsKey, $egMapsScriptPath, $egYahooMapsOnThisPage, $egMapsStyleVersion, $egMapsJsExt; |
154 | 154 | |
155 | 155 | if ( empty( $egYahooMapsOnThisPage ) ) { |
156 | 156 | $egYahooMapsOnThisPage = 0; |
157 | 157 | $output .= "<script type='$wgJsMimeType' src='http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=$egYahooMapsKey'></script> |
158 | | - <script type='$wgJsMimeType' src='$egMapsScriptPath/YahooMaps/YahooMapFunctions.min.js?$egMapsStyleVersion'></script>"; |
| 158 | + <script type='$wgJsMimeType' src='$egMapsScriptPath/YahooMaps/YahooMapFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script>"; |
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
Index: trunk/extensions/Maps/Maps_Settings.php |
— | — | @@ -125,6 +125,15 @@ |
126 | 126 | |
127 | 127 | |
128 | 128 | |
| 129 | +# General configuration |
| 130 | + |
| 131 | +# Boolean. Indicates if minified js files should be used where available. |
| 132 | +$egMapsUseMinJs = false; |
| 133 | + |
| 134 | + |
| 135 | + |
| 136 | + |
| 137 | + |
129 | 138 | # Coordinate configuration |
130 | 139 | |
131 | 140 | # Enum. The default output format of coordinates. |
Index: trunk/extensions/Maps/Maps_Utils.php |
— | — | @@ -127,32 +127,7 @@ |
128 | 128 | return $decimal . "° E"; |
129 | 129 | } |
130 | 130 | } |
131 | | - |
132 | | - /** |
133 | | - * If the provided height or width do not fall within the allowed interval, |
134 | | - * they are changed to the nearest allowed value. |
135 | | - * |
136 | | - * @param integer $width |
137 | | - * @param integer $height |
138 | | - */ |
139 | | - public static function makeMapSizeValid( &$width, &$height ) { |
140 | | - global $egMapsSizeRestrictions; |
141 | 131 | |
142 | | - if ( $width < $egMapsSizeRestrictions['width'][0] ) { |
143 | | - $width = $egMapsSizeRestrictions['width'][0]; |
144 | | - } |
145 | | - else if ( $width > $egMapsSizeRestrictions['width'][1] ) { |
146 | | - $width = $egMapsSizeRestrictions['width'][1]; |
147 | | - } |
148 | | - |
149 | | - if ( $height < $egMapsSizeRestrictions['height'][0] ) { |
150 | | - $height = $egMapsSizeRestrictions['height'][0]; |
151 | | - } |
152 | | - else if ( $height > $egMapsSizeRestrictions['height'][1] ) { |
153 | | - $height = $egMapsSizeRestrictions['height'][1]; |
154 | | - } |
155 | | - } |
156 | | - |
157 | 132 | /** |
158 | 133 | * Convert from WGS84 to spherical mercator. |
159 | 134 | */ |