@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * See the License for the specific language governing permissions and |
19 | 19 | * limitations under the License. |
20 | 20 | */ |
21 | -include_once (realpath ( dirname ( __FILE__ ) ) . '/../geophp/geoPHP/geoPHP.inc'); |
|
21 | +include_once (realpath(dirname(__FILE__)).'/../geophp/geoPHP/geoPHP.inc'); |
|
22 | 22 | /** |
23 | 23 | * |
24 | 24 | * @author Mark C. Prins <[email protected]> |
@@ -32,40 +32,40 @@ discard block |
||
32 | 32 | // the final output |
33 | 33 | var $doc = ''; |
34 | 34 | |
35 | - protected $tileInfo = array ( |
|
35 | + protected $tileInfo = array( |
|
36 | 36 | // OSM sources |
37 | - 'openstreetmap' => array ( |
|
37 | + 'openstreetmap' => array( |
|
38 | 38 | 'txt' => '(c) OpenStreetMap CC-BY-SA', |
39 | 39 | 'logo' => 'osm_logo.png', |
40 | 40 | 'url' => 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png' |
41 | 41 | ), |
42 | 42 | // OCM sources |
43 | - 'cycle' => array ( |
|
43 | + 'cycle' => array( |
|
44 | 44 | 'txt' => 'OpenCycleMap tiles', |
45 | 45 | 'logo' => 'cycle_logo.png', |
46 | 46 | 'url' => 'https://tile.thunderforest.com/cycle/{Z}/{X}/{Y}.png?apikey=' |
47 | 47 | ), |
48 | - 'transport' => array ( |
|
48 | + 'transport' => array( |
|
49 | 49 | 'txt' => 'OpenCycleMap tiles', |
50 | 50 | 'logo' => 'cycle_logo.png', |
51 | 51 | 'url' => 'https://tile.thunderforest.com/transport/{Z}/{X}/{Y}.png?apikey=' |
52 | 52 | ), |
53 | - 'landscape' => array ( |
|
53 | + 'landscape' => array( |
|
54 | 54 | 'txt' => 'OpenCycleMap tiles', |
55 | 55 | 'logo' => 'cycle_logo.png', |
56 | 56 | 'url' => 'https://tile.thunderforest.com/landscape/{Z}/{X}/{Y}.png?apikey=' |
57 | 57 | ), |
58 | - 'outdoors' => array ( |
|
58 | + 'outdoors' => array( |
|
59 | 59 | 'txt' => 'OpenCycleMap tiles', |
60 | 60 | 'logo' => 'cycle_logo.png', |
61 | 61 | 'url' => 'https://tile.thunderforest.com/outdoors/{Z}/{X}/{Y}.png?apikey=' |
62 | 62 | ), |
63 | - 'toner-lite' => array ( |
|
63 | + 'toner-lite' => array( |
|
64 | 64 | 'txt' => 'Stamen tiles', |
65 | 65 | 'logo' => 'stamen.png', |
66 | 66 | 'url' => 'http://tile.stamen.com/toner-lite/{Z}/{X}/{Y}.png' |
67 | 67 | ), |
68 | - 'terrain' => array ( |
|
68 | + 'terrain' => array( |
|
69 | 69 | 'txt' => 'Stamen tiles', |
70 | 70 | 'logo' => 'stamen.png', |
71 | 71 | 'url' => 'http://tile.stamen.com/terrain/{Z}/{X}/{Y}.png' |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | protected $tileDefaultSrc = 'openstreetmap'; |
92 | 92 | |
93 | 93 | // set up markers |
94 | - protected $markerPrototypes = array ( |
|
94 | + protected $markerPrototypes = array( |
|
95 | 95 | // found at http://www.mapito.net/map-marker-icons.html |
96 | 96 | // these are 17x19 px with a pointer at the bottom left |
97 | - 'lightblue' => array ( |
|
97 | + 'lightblue' => array( |
|
98 | 98 | 'regex' => '/^lightblue([0-9]+)$/', |
99 | 99 | 'extension' => '.png', |
100 | 100 | 'shadow' => false, |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | 'offsetShadow' => false |
103 | 103 | ), |
104 | 104 | // openlayers std markers are 21x25px with shadow |
105 | - 'ol-marker' => array ( |
|
105 | + 'ol-marker' => array( |
|
106 | 106 | 'regex' => '/^marker(|-blue|-gold|-green|-red)+$/', |
107 | 107 | 'extension' => '.png', |
108 | 108 | 'shadow' => 'marker_shadow.png', |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | 'offsetShadow' => '-1,-13' |
111 | 111 | ), |
112 | 112 | // these are 16x16 px |
113 | - 'ww_icon' => array ( |
|
113 | + 'ww_icon' => array( |
|
114 | 114 | 'regex' => '/ww_\S+$/', |
115 | 115 | 'extension' => '.png', |
116 | 116 | 'shadow' => false, |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | 'offsetShadow' => false |
119 | 119 | ), |
120 | 120 | // assume these are 16x16 px |
121 | - 'rest' => array ( |
|
121 | + 'rest' => array( |
|
122 | 122 | 'regex' => '/^(?!lightblue([0-9]+)$)(?!(ww_\S+$))(?!marker(|-blue|-gold|-green|-red)+$)(.*)/', |
123 | 123 | 'extension' => '.png', |
124 | 124 | 'shadow' => 'marker_shadow.png', |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $this->height = $height; |
173 | 173 | // validate + set maptype |
174 | 174 | $this->maptype = $this->tileDefaultSrc; |
175 | - if (array_key_exists ( $maptype, $this->tileInfo )) { |
|
175 | + if (array_key_exists($maptype, $this->tileInfo)) { |
|
176 | 176 | $this->maptype = $maptype; |
177 | 177 | } |
178 | 178 | $this->markers = $markers; |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | $this->gpxFileName = $gpx; |
181 | 181 | $this->geojsonFileName = $geojson; |
182 | 182 | $this->mediaBaseDir = $mediaDir; |
183 | - $this->tileCacheBaseDir = $tileCacheBaseDir . '/olmaptiles'; |
|
183 | + $this->tileCacheBaseDir = $tileCacheBaseDir.'/olmaptiles'; |
|
184 | 184 | $this->useTileCache = $this->tileCacheBaseDir !== ''; |
185 | - $this->mapCacheBaseDir = $mediaDir . '/olmapmaps'; |
|
185 | + $this->mapCacheBaseDir = $mediaDir.'/olmapmaps'; |
|
186 | 186 | $this->autoZoomExtent = $autoZoomExtent; |
187 | 187 | $this->apikey = $apikey; |
188 | 188 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @return number |
195 | 195 | */ |
196 | 196 | public function lonToTile($long, $zoom) { |
197 | - return (($long + 180) / 360) * pow ( 2, $zoom ); |
|
197 | + return (($long + 180) / 360) * pow(2, $zoom); |
|
198 | 198 | } |
199 | 199 | /** |
200 | 200 | * |
@@ -203,59 +203,59 @@ discard block |
||
203 | 203 | * @return number |
204 | 204 | */ |
205 | 205 | public function latToTile($lat, $zoom) { |
206 | - return (1 - log ( tan ( $lat * pi () / 180 ) + 1 / cos ( $lat * M_PI / 180 ) ) / M_PI) / 2 * pow ( 2, $zoom ); |
|
206 | + return (1 - log(tan($lat * pi() / 180) + 1 / cos($lat * M_PI / 180)) / M_PI) / 2 * pow(2, $zoom); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
210 | 210 | */ |
211 | 211 | public function initCoords() { |
212 | - $this->centerX = $this->lonToTile ( $this->lon, $this->zoom ); |
|
213 | - $this->centerY = $this->latToTile ( $this->lat, $this->zoom ); |
|
214 | - $this->offsetX = floor ( (floor ( $this->centerX ) - $this->centerX) * $this->tileSize ); |
|
215 | - $this->offsetY = floor ( (floor ( $this->centerY ) - $this->centerY) * $this->tileSize ); |
|
212 | + $this->centerX = $this->lonToTile($this->lon, $this->zoom); |
|
213 | + $this->centerY = $this->latToTile($this->lat, $this->zoom); |
|
214 | + $this->offsetX = floor((floor($this->centerX) - $this->centerX) * $this->tileSize); |
|
215 | + $this->offsetY = floor((floor($this->centerY) - $this->centerY) * $this->tileSize); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
219 | 219 | * make basemap image. |
220 | 220 | */ |
221 | 221 | public function createBaseMap() { |
222 | - $this->image = imagecreatetruecolor ( $this->width, $this->height ); |
|
223 | - $startX = floor ( $this->centerX - ($this->width / $this->tileSize) / 2 ); |
|
224 | - $startY = floor ( $this->centerY - ($this->height / $this->tileSize) / 2 ); |
|
225 | - $endX = ceil ( $this->centerX + ($this->width / $this->tileSize) / 2 ); |
|
226 | - $endY = ceil ( $this->centerY + ($this->height / $this->tileSize) / 2 ); |
|
227 | - $this->offsetX = - floor ( ($this->centerX - floor ( $this->centerX )) * $this->tileSize ); |
|
228 | - $this->offsetY = - floor ( ($this->centerY - floor ( $this->centerY )) * $this->tileSize ); |
|
229 | - $this->offsetX += floor ( $this->width / 2 ); |
|
230 | - $this->offsetY += floor ( $this->height / 2 ); |
|
231 | - $this->offsetX += floor ( $startX - floor ( $this->centerX ) ) * $this->tileSize; |
|
232 | - $this->offsetY += floor ( $startY - floor ( $this->centerY ) ) * $this->tileSize; |
|
233 | - |
|
234 | - for($x = $startX; $x <= $endX; $x ++) { |
|
235 | - for($y = $startY; $y <= $endY; $y ++) { |
|
236 | - $url = str_replace ( array ( |
|
222 | + $this->image = imagecreatetruecolor($this->width, $this->height); |
|
223 | + $startX = floor($this->centerX - ($this->width / $this->tileSize) / 2); |
|
224 | + $startY = floor($this->centerY - ($this->height / $this->tileSize) / 2); |
|
225 | + $endX = ceil($this->centerX + ($this->width / $this->tileSize) / 2); |
|
226 | + $endY = ceil($this->centerY + ($this->height / $this->tileSize) / 2); |
|
227 | + $this->offsetX = - floor(($this->centerX - floor($this->centerX)) * $this->tileSize); |
|
228 | + $this->offsetY = - floor(($this->centerY - floor($this->centerY)) * $this->tileSize); |
|
229 | + $this->offsetX += floor($this->width / 2); |
|
230 | + $this->offsetY += floor($this->height / 2); |
|
231 | + $this->offsetX += floor($startX - floor($this->centerX)) * $this->tileSize; |
|
232 | + $this->offsetY += floor($startY - floor($this->centerY)) * $this->tileSize; |
|
233 | + |
|
234 | + for ($x = $startX; $x <= $endX; $x++) { |
|
235 | + for ($y = $startY; $y <= $endY; $y++) { |
|
236 | + $url = str_replace(array( |
|
237 | 237 | '{Z}', |
238 | 238 | '{X}', |
239 | 239 | '{Y}' |
240 | - ), array ( |
|
240 | + ), array( |
|
241 | 241 | $this->zoom, |
242 | 242 | $x, |
243 | 243 | $y |
244 | - ), $this->tileInfo [$this->maptype] ['url'] ); |
|
244 | + ), $this->tileInfo [$this->maptype] ['url']); |
|
245 | 245 | $url .= $this->apikey; |
246 | 246 | |
247 | - $tileData = $this->fetchTile ( $url ); |
|
247 | + $tileData = $this->fetchTile($url); |
|
248 | 248 | if ($tileData) { |
249 | - $tileImage = imagecreatefromstring ( $tileData ); |
|
249 | + $tileImage = imagecreatefromstring($tileData); |
|
250 | 250 | } else { |
251 | - $tileImage = imagecreate ( $this->tileSize, $this->tileSize ); |
|
252 | - $color = imagecolorallocate ( $tileImage, 255, 255, 255 ); |
|
253 | - @imagestring ( $tileImage, 1, 127, 127, 'err', $color ); |
|
251 | + $tileImage = imagecreate($this->tileSize, $this->tileSize); |
|
252 | + $color = imagecolorallocate($tileImage, 255, 255, 255); |
|
253 | + @imagestring($tileImage, 1, 127, 127, 'err', $color); |
|
254 | 254 | } |
255 | 255 | $destX = ($x - $startX) * $this->tileSize + $this->offsetX; |
256 | 256 | $destY = ($y - $startY) * $this->tileSize + $this->offsetY; |
257 | - dbglog($this->tileSize,"imagecopy tile into image: $destX, $destY"); |
|
258 | - imagecopy ( $this->image, $tileImage, $destX, $destY, 0, 0, $this->tileSize, $this->tileSize ); |
|
257 | + dbglog($this->tileSize, "imagecopy tile into image: $destX, $destY"); |
|
258 | + imagecopy($this->image, $tileImage, $destX, $destY, 0, 0, $this->tileSize, $this->tileSize); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | } |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function placeMarkers() { |
267 | 267 | $count = 0; |
268 | - $color = imagecolorallocate ( $this->image, 0, 0, 0 ); |
|
269 | - $bgcolor = imagecolorallocate ( $this->image, 200, 200, 200 ); |
|
270 | - $markerBaseDir = dirname ( __FILE__ ) . '/icons'; |
|
268 | + $color = imagecolorallocate($this->image, 0, 0, 0); |
|
269 | + $bgcolor = imagecolorallocate($this->image, 200, 200, 200); |
|
270 | + $markerBaseDir = dirname(__FILE__).'/icons'; |
|
271 | 271 | // loop thru marker array |
272 | - foreach ( $this->markers as $marker ) { |
|
272 | + foreach ($this->markers as $marker) { |
|
273 | 273 | // set some local variables |
274 | 274 | $markerLat = $marker ['lat']; |
275 | 275 | $markerLon = $marker ['lon']; |
@@ -280,41 +280,41 @@ discard block |
||
280 | 280 | $matches = false; |
281 | 281 | // check for marker type, get settings from markerPrototypes |
282 | 282 | if ($markerType) { |
283 | - foreach ( $this->markerPrototypes as $markerPrototype ) { |
|
284 | - if (preg_match ( $markerPrototype ['regex'], $markerType, $matches )) { |
|
285 | - $markerFilename = $matches [0] . $markerPrototype ['extension']; |
|
283 | + foreach ($this->markerPrototypes as $markerPrototype) { |
|
284 | + if (preg_match($markerPrototype ['regex'], $markerType, $matches)) { |
|
285 | + $markerFilename = $matches [0].$markerPrototype ['extension']; |
|
286 | 286 | if ($markerPrototype ['offsetImage']) { |
287 | - list ( $markerImageOffsetX, $markerImageOffsetY ) = explode ( ",", $markerPrototype ['offsetImage'] ); |
|
287 | + list ($markerImageOffsetX, $markerImageOffsetY) = explode(",", $markerPrototype ['offsetImage']); |
|
288 | 288 | } |
289 | 289 | $markerShadow = $markerPrototype ['shadow']; |
290 | 290 | if ($markerShadow) { |
291 | - list ( $markerShadowOffsetX, $markerShadowOffsetY ) = explode ( ",", $markerPrototype ['offsetShadow'] ); |
|
291 | + list ($markerShadowOffsetX, $markerShadowOffsetY) = explode(",", $markerPrototype ['offsetShadow']); |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | } |
295 | 295 | } |
296 | 296 | // create img resource |
297 | - if (file_exists ( $markerBaseDir . '/' . $markerFilename )) { |
|
298 | - $markerImg = imagecreatefrompng ( $markerBaseDir . '/' . $markerFilename ); |
|
297 | + if (file_exists($markerBaseDir.'/'.$markerFilename)) { |
|
298 | + $markerImg = imagecreatefrompng($markerBaseDir.'/'.$markerFilename); |
|
299 | 299 | } else { |
300 | - $markerImg = imagecreatefrompng ( $markerBaseDir . '/marker.png' ); |
|
300 | + $markerImg = imagecreatefrompng($markerBaseDir.'/marker.png'); |
|
301 | 301 | } |
302 | 302 | // check for shadow + create shadow recource |
303 | - if ($markerShadow && file_exists ( $markerBaseDir . '/' . $markerShadow )) { |
|
304 | - $markerShadowImg = imagecreatefrompng ( $markerBaseDir . '/' . $markerShadow ); |
|
303 | + if ($markerShadow && file_exists($markerBaseDir.'/'.$markerShadow)) { |
|
304 | + $markerShadowImg = imagecreatefrompng($markerBaseDir.'/'.$markerShadow); |
|
305 | 305 | } |
306 | 306 | // calc position |
307 | - $destX = floor ( ($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile ( $markerLon, $this->zoom )) ); |
|
308 | - $destY = floor ( ($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile ( $markerLat, $this->zoom )) ); |
|
307 | + $destX = floor(($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($markerLon, $this->zoom))); |
|
308 | + $destY = floor(($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile($markerLat, $this->zoom))); |
|
309 | 309 | // copy shadow on basemap |
310 | 310 | if ($markerShadow && $markerShadowImg) { |
311 | - imagecopy ( $this->image, $markerShadowImg, $destX + intval ( $markerShadowOffsetX ), $destY + intval ( $markerShadowOffsetY ), 0, 0, imagesx ( $markerShadowImg ), imagesy ( $markerShadowImg ) ); |
|
311 | + imagecopy($this->image, $markerShadowImg, $destX + intval($markerShadowOffsetX), $destY + intval($markerShadowOffsetY), 0, 0, imagesx($markerShadowImg), imagesy($markerShadowImg)); |
|
312 | 312 | } |
313 | 313 | // copy marker on basemap above shadow |
314 | - imagecopy ( $this->image, $markerImg, $destX + intval ( $markerImageOffsetX ), $destY + intval ( $markerImageOffsetY ), 0, 0, imagesx ( $markerImg ), imagesy ( $markerImg ) ); |
|
314 | + imagecopy($this->image, $markerImg, $destX + intval($markerImageOffsetX), $destY + intval($markerImageOffsetY), 0, 0, imagesx($markerImg), imagesy($markerImg)); |
|
315 | 315 | // add label |
316 | - imagestring ( $this->image, 3, $destX - imagesx ( $markerImg ) + 1, $destY + intval ( $markerImageOffsetY ) + 1, ++ $count, $bgcolor ); |
|
317 | - imagestring ( $this->image, 3, $destX - imagesx ( $markerImg ), $destY + intval ( $markerImageOffsetY ), $count, $color ); |
|
316 | + imagestring($this->image, 3, $destX - imagesx($markerImg) + 1, $destY + intval($markerImageOffsetY) + 1, ++ $count, $bgcolor); |
|
317 | + imagestring($this->image, 3, $destX - imagesx($markerImg), $destY + intval($markerImageOffsetY), $count, $color); |
|
318 | 318 | } |
319 | 319 | ; |
320 | 320 | } |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | * @return string |
326 | 326 | */ |
327 | 327 | public function tileUrlToFilename($url) { |
328 | - return $this->tileCacheBaseDir . "/" . str_replace ( array ( |
|
328 | + return $this->tileCacheBaseDir."/".str_replace(array( |
|
329 | 329 | 'http://' |
330 | - ), '', $url ); |
|
330 | + ), '', $url); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -335,36 +335,36 @@ discard block |
||
335 | 335 | * @param string $url |
336 | 336 | */ |
337 | 337 | public function checkTileCache($url) { |
338 | - $filename = $this->tileUrlToFilename ( $url ); |
|
339 | - if (file_exists ( $filename )) { |
|
340 | - return file_get_contents ( $filename ); |
|
338 | + $filename = $this->tileUrlToFilename($url); |
|
339 | + if (file_exists($filename)) { |
|
340 | + return file_get_contents($filename); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | public function checkMapCache() { |
344 | - $this->mapCacheID = md5 ( $this->serializeParams () ); |
|
345 | - $filename = $this->mapCacheIDToFilename (); |
|
346 | - if (file_exists ( $filename )) |
|
344 | + $this->mapCacheID = md5($this->serializeParams()); |
|
345 | + $filename = $this->mapCacheIDToFilename(); |
|
346 | + if (file_exists($filename)) |
|
347 | 347 | return true; |
348 | 348 | } |
349 | 349 | public function serializeParams() { |
350 | - return join ( "&", array ( |
|
350 | + return join("&", array( |
|
351 | 351 | $this->zoom, |
352 | 352 | $this->lat, |
353 | 353 | $this->lon, |
354 | 354 | $this->width, |
355 | 355 | $this->height, |
356 | - serialize ( $this->markers ), |
|
356 | + serialize($this->markers), |
|
357 | 357 | $this->maptype, |
358 | 358 | $this->kmlFileName, |
359 | 359 | $this->gpxFileName, |
360 | 360 | $this->geojsonFileName |
361 | - ) ); |
|
361 | + )); |
|
362 | 362 | } |
363 | 363 | public function mapCacheIDToFilename() { |
364 | - if (! $this->mapCacheFile) { |
|
365 | - $this->mapCacheFile = $this->mapCacheBaseDir . "/" . $this->maptype . "/" . $this->zoom . "/cache_" . substr ( $this->mapCacheID, 0, 2 ) . "/" . substr ( $this->mapCacheID, 2, 2 ) . "/" . substr ( $this->mapCacheID, 4 ); |
|
364 | + if (!$this->mapCacheFile) { |
|
365 | + $this->mapCacheFile = $this->mapCacheBaseDir."/".$this->maptype."/".$this->zoom."/cache_".substr($this->mapCacheID, 0, 2)."/".substr($this->mapCacheID, 2, 2)."/".substr($this->mapCacheID, 4); |
|
366 | 366 | } |
367 | - return $this->mapCacheFile . "." . $this->mapCacheExtension; |
|
367 | + return $this->mapCacheFile.".".$this->mapCacheExtension; |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | * File access mode. For more information on modes, read the details on the chmod manpage. |
377 | 377 | */ |
378 | 378 | public function mkdir_recursive($pathname, $mode) { |
379 | - is_dir ( dirname ( $pathname ) ) || $this->mkdir_recursive ( dirname ( $pathname ), $mode ); |
|
380 | - return is_dir ( $pathname ) || @mkdir ( $pathname, $mode ); |
|
379 | + is_dir(dirname($pathname)) || $this->mkdir_recursive(dirname($pathname), $mode); |
|
380 | + return is_dir($pathname) || @mkdir($pathname, $mode); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -387,9 +387,9 @@ discard block |
||
387 | 387 | * @param mixed $data |
388 | 388 | */ |
389 | 389 | public function writeTileToCache($url, $data) { |
390 | - $filename = $this->tileUrlToFilename ( $url ); |
|
391 | - $this->mkdir_recursive ( dirname ( $filename ), 0777 ); |
|
392 | - file_put_contents ( $filename, $data ); |
|
390 | + $filename = $this->tileUrlToFilename($url); |
|
391 | + $this->mkdir_recursive(dirname($filename), 0777); |
|
392 | + file_put_contents($filename, $data); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -398,35 +398,35 @@ discard block |
||
398 | 398 | * @param string $url |
399 | 399 | */ |
400 | 400 | public function fetchTile($url) { |
401 | - if ($this->useTileCache && ($cached = $this->checkTileCache ( $url ))) |
|
401 | + if ($this->useTileCache && ($cached = $this->checkTileCache($url))) |
|
402 | 402 | return $cached; |
403 | 403 | |
404 | - $_UA = 'Mozilla/4.0 (compatible; DokuWikiSpatial HTTP Client; ' . PHP_OS . ')'; |
|
405 | - if (function_exists ( "curl_init" )) { |
|
404 | + $_UA = 'Mozilla/4.0 (compatible; DokuWikiSpatial HTTP Client; '.PHP_OS.')'; |
|
405 | + if (function_exists("curl_init")) { |
|
406 | 406 | // use cUrl |
407 | - $ch = curl_init (); |
|
408 | - curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); |
|
409 | - curl_setopt ( $ch, CURLOPT_USERAGENT, $_UA ); |
|
410 | - curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, 10 ); |
|
411 | - curl_setopt ( $ch, CURLOPT_URL, $url ); |
|
412 | - $tile = curl_exec ( $ch ); |
|
413 | - curl_close ( $ch ); |
|
407 | + $ch = curl_init(); |
|
408 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
409 | + curl_setopt($ch, CURLOPT_USERAGENT, $_UA); |
|
410 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); |
|
411 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
412 | + $tile = curl_exec($ch); |
|
413 | + curl_close($ch); |
|
414 | 414 | } else { |
415 | 415 | // use file_get_contents |
416 | 416 | global $conf; |
417 | - $opts = array ( |
|
418 | - 'http' => array ( |
|
417 | + $opts = array( |
|
418 | + 'http' => array( |
|
419 | 419 | 'method' => "GET", |
420 | - 'header' => "Accept-language: en\r\n" . "User-Agent: $_UA\r\n" . "accept: image/png\r\n", |
|
421 | - 'proxy' => "tcp://" . $conf ['proxy'] ['host'] . ":" . $conf ['proxy'] ['port'], |
|
420 | + 'header' => "Accept-language: en\r\n"."User-Agent: $_UA\r\n"."accept: image/png\r\n", |
|
421 | + 'proxy' => "tcp://".$conf ['proxy'] ['host'].":".$conf ['proxy'] ['port'], |
|
422 | 422 | 'request_fulluri' => true |
423 | 423 | ) |
424 | 424 | ); |
425 | - $context = stream_context_create ( $opts ); |
|
426 | - $tile = file_get_contents ( $url, false, $context ); |
|
425 | + $context = stream_context_create($opts); |
|
426 | + $tile = file_get_contents($url, false, $context); |
|
427 | 427 | } |
428 | 428 | if ($tile && $this->useTileCache) { |
429 | - $this->writeTileToCache ( $url, $tile ); |
|
429 | + $this->writeTileToCache($url, $tile); |
|
430 | 430 | } |
431 | 431 | return $tile; |
432 | 432 | } |
@@ -435,18 +435,18 @@ discard block |
||
435 | 435 | * Draw gpx trace on the map. |
436 | 436 | */ |
437 | 437 | public function drawGPX() { |
438 | - $col = imagecolorallocatealpha ( $this->image, 0, 0, 255, .4 * 127 ); |
|
439 | - $gpxgeom = geoPHP::load ( file_get_contents ( $this->gpxFileName ), 'gpx' ); |
|
440 | - $this->drawGeometry ( $gpxgeom, $col ); |
|
438 | + $col = imagecolorallocatealpha($this->image, 0, 0, 255, .4 * 127); |
|
439 | + $gpxgeom = geoPHP::load(file_get_contents($this->gpxFileName), 'gpx'); |
|
440 | + $this->drawGeometry($gpxgeom, $col); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | /** |
444 | 444 | * Draw geojson on the map. |
445 | 445 | */ |
446 | 446 | public function drawGeojson() { |
447 | - $col = imagecolorallocatealpha ( $this->image, 255, 0, 255, .4 * 127 ); |
|
448 | - $gpxgeom = geoPHP::load ( file_get_contents ( $this->geojsonFileName ), 'json' ); |
|
449 | - $this->drawGeometry ( $gpxgeom, $col ); |
|
447 | + $col = imagecolorallocatealpha($this->image, 255, 0, 255, .4 * 127); |
|
448 | + $gpxgeom = geoPHP::load(file_get_contents($this->geojsonFileName), 'json'); |
|
449 | + $this->drawGeometry($gpxgeom, $col); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -454,9 +454,9 @@ discard block |
||
454 | 454 | */ |
455 | 455 | public function drawKML() { |
456 | 456 | // TODO get colour from kml node (not currently supported in geoPHP) |
457 | - $col = imagecolorallocatealpha ( $this->image, 255, 0, 0, .4 * 127 ); |
|
458 | - $kmlgeom = geoPHP::load ( file_get_contents ( $this->kmlFileName ), 'kml' ); |
|
459 | - $this->drawGeometry ( $kmlgeom, $col ); |
|
457 | + $col = imagecolorallocatealpha($this->image, 255, 0, 0, .4 * 127); |
|
458 | + $kmlgeom = geoPHP::load(file_get_contents($this->kmlFileName), 'kml'); |
|
459 | + $this->drawGeometry($kmlgeom, $col); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | /** |
@@ -469,12 +469,12 @@ discard block |
||
469 | 469 | private function drawGeometry($geom, $colour) { |
470 | 470 | if (empty($geom)) return; |
471 | 471 | |
472 | - switch ($geom->geometryType ()) { |
|
472 | + switch ($geom->geometryType()) { |
|
473 | 473 | case 'GeometryCollection' : |
474 | 474 | // recursively draw part of the collection |
475 | - for($i = 1; $i < $geom->numGeometries () + 1; $i ++) { |
|
476 | - $_geom = $geom->geometryN ( $i ); |
|
477 | - $this->drawGeometry ( $_geom, $colour ); |
|
475 | + for ($i = 1; $i < $geom->numGeometries() + 1; $i++) { |
|
476 | + $_geom = $geom->geometryN($i); |
|
477 | + $this->drawGeometry($_geom, $colour); |
|
478 | 478 | } |
479 | 479 | break; |
480 | 480 | case 'MultiPolygon' : |
@@ -487,13 +487,13 @@ discard block |
||
487 | 487 | // TODO implement / do nothing |
488 | 488 | break; |
489 | 489 | case 'Polygon' : |
490 | - $this->drawPolygon ( $geom, $colour ); |
|
490 | + $this->drawPolygon($geom, $colour); |
|
491 | 491 | break; |
492 | 492 | case 'LineString' : |
493 | - $this->drawLineString ( $geom, $colour ); |
|
493 | + $this->drawLineString($geom, $colour); |
|
494 | 494 | break; |
495 | 495 | case 'Point' : |
496 | - $this->drawPoint ( $geom, $colour ); |
|
496 | + $this->drawPoint($geom, $colour); |
|
497 | 497 | break; |
498 | 498 | default : |
499 | 499 | // draw nothing |
@@ -509,20 +509,20 @@ discard block |
||
509 | 509 | * drawing colour |
510 | 510 | */ |
511 | 511 | private function drawLineString($line, $colour) { |
512 | - imagesetthickness ( $this->image, 2 ); |
|
513 | - for($p = 1; $p < $line->numGeometries (); $p ++) { |
|
512 | + imagesetthickness($this->image, 2); |
|
513 | + for ($p = 1; $p < $line->numGeometries(); $p++) { |
|
514 | 514 | // get first pair of points |
515 | - $p1 = $line->geometryN ( $p ); |
|
516 | - $p2 = $line->geometryN ( $p + 1 ); |
|
515 | + $p1 = $line->geometryN($p); |
|
516 | + $p2 = $line->geometryN($p + 1); |
|
517 | 517 | // translate to paper space |
518 | - $x1 = floor ( ($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile ( $p1->x (), $this->zoom )) ); |
|
519 | - $y1 = floor ( ($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile ( $p1->y (), $this->zoom )) ); |
|
520 | - $x2 = floor ( ($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile ( $p2->x (), $this->zoom )) ); |
|
521 | - $y2 = floor ( ($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile ( $p2->y (), $this->zoom )) ); |
|
518 | + $x1 = floor(($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($p1->x(), $this->zoom))); |
|
519 | + $y1 = floor(($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile($p1->y(), $this->zoom))); |
|
520 | + $x2 = floor(($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($p2->x(), $this->zoom))); |
|
521 | + $y2 = floor(($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile($p2->y(), $this->zoom))); |
|
522 | 522 | // draw to image |
523 | - imageline ( $this->image, $x1, $y1, $x2, $y2, $colour ); |
|
523 | + imageline($this->image, $x1, $y1, $x2, $y2, $colour); |
|
524 | 524 | } |
525 | - imagesetthickness ( $this->image, 1 ); |
|
525 | + imagesetthickness($this->image, 1); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -533,18 +533,18 @@ discard block |
||
533 | 533 | * drawing colour |
534 | 534 | */ |
535 | 535 | private function drawPoint($point, $colour) { |
536 | - imagesetthickness ( $this->image, 2 ); |
|
536 | + imagesetthickness($this->image, 2); |
|
537 | 537 | // translate to paper space |
538 | - $cx = floor ( ($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile ( $point->x (), $this->zoom )) ); |
|
539 | - $cy = floor ( ($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile ( $point->y (), $this->zoom )) ); |
|
538 | + $cx = floor(($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($point->x(), $this->zoom))); |
|
539 | + $cy = floor(($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile($point->y(), $this->zoom))); |
|
540 | 540 | $r = 5; |
541 | 541 | // draw to image |
542 | 542 | // imageellipse($this->image, $cx, $cy,$r, $r, $colour); |
543 | - imagefilledellipse ( $this->image, $cx, $cy, $r, $r, $colour ); |
|
543 | + imagefilledellipse($this->image, $cx, $cy, $r, $r, $colour); |
|
544 | 544 | // don't use imageellipse because the imagesetthickness function has |
545 | 545 | // no effect. So the better workaround is to use imagearc. |
546 | - imagearc ( $this->image, $cx, $cy, $r, $r, 0, 359, $colour ); |
|
547 | - imagesetthickness ( $this->image, 1 ); |
|
546 | + imagearc($this->image, $cx, $cy, $r, $r, 0, 359, $colour); |
|
547 | + imagesetthickness($this->image, 1); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
@@ -560,42 +560,42 @@ discard block |
||
560 | 560 | |
561 | 561 | // print_r('Polygon:<br />'); |
562 | 562 | // print_r($polygon); |
563 | - $extPoints = array (); |
|
563 | + $extPoints = array(); |
|
564 | 564 | // extring is a linestring actually.. |
565 | - $extRing = $polygon->exteriorRing (); |
|
565 | + $extRing = $polygon->exteriorRing(); |
|
566 | 566 | |
567 | - for($i = 1; $i < $extRing->numGeometries (); $i ++) { |
|
568 | - $p1 = $extRing->geometryN ( $i ); |
|
569 | - $x = floor ( ($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile ( $p1->x (), $this->zoom )) ); |
|
570 | - $y = floor ( ($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile ( $p1->y (), $this->zoom )) ); |
|
567 | + for ($i = 1; $i < $extRing->numGeometries(); $i++) { |
|
568 | + $p1 = $extRing->geometryN($i); |
|
569 | + $x = floor(($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($p1->x(), $this->zoom))); |
|
570 | + $y = floor(($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile($p1->y(), $this->zoom))); |
|
571 | 571 | $extPoints [] = $x; |
572 | 572 | $extPoints [] = $y; |
573 | 573 | } |
574 | 574 | // print_r('points:('.($i-1).')<br />'); |
575 | 575 | // print_r($extPoints); |
576 | 576 | // imagepolygon ($this->image, $extPoints, $i-1, $colour ); |
577 | - imagefilledpolygon ( $this->image, $extPoints, $i - 1, $colour ); |
|
577 | + imagefilledpolygon($this->image, $extPoints, $i - 1, $colour); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | /** |
581 | 581 | * add copyright and origin notice and icons to the map. |
582 | 582 | */ |
583 | 583 | public function drawCopyright() { |
584 | - $logoBaseDir = dirname ( __FILE__ ) . '/' . 'logo/'; |
|
585 | - $logoImg = imagecreatefrompng ( $logoBaseDir . $this->tileInfo ['openstreetmap'] ['logo'] ); |
|
586 | - $textcolor = imagecolorallocate ( $this->image, 0, 0, 0 ); |
|
587 | - $bgcolor = imagecolorallocate ( $this->image, 200, 200, 200 ); |
|
584 | + $logoBaseDir = dirname(__FILE__).'/'.'logo/'; |
|
585 | + $logoImg = imagecreatefrompng($logoBaseDir.$this->tileInfo ['openstreetmap'] ['logo']); |
|
586 | + $textcolor = imagecolorallocate($this->image, 0, 0, 0); |
|
587 | + $bgcolor = imagecolorallocate($this->image, 200, 200, 200); |
|
588 | 588 | |
589 | - imagecopy ( $this->image, $logoImg, 0, imagesy ( $this->image ) - imagesy ( $logoImg ), 0, 0, imagesx ( $logoImg ), imagesy ( $logoImg ) ); |
|
590 | - imagestring ( $this->image, 1, imagesx ( $logoImg ) + 2, imagesy ( $this->image ) - imagesy ( $logoImg ) + 1, $this->tileInfo ['openstreetmap'] ['txt'], $bgcolor ); |
|
591 | - imagestring ( $this->image, 1, imagesx ( $logoImg ) + 1, imagesy ( $this->image ) - imagesy ( $logoImg ), $this->tileInfo ['openstreetmap'] ['txt'], $textcolor ); |
|
589 | + imagecopy($this->image, $logoImg, 0, imagesy($this->image) - imagesy($logoImg), 0, 0, imagesx($logoImg), imagesy($logoImg)); |
|
590 | + imagestring($this->image, 1, imagesx($logoImg) + 2, imagesy($this->image) - imagesy($logoImg) + 1, $this->tileInfo ['openstreetmap'] ['txt'], $bgcolor); |
|
591 | + imagestring($this->image, 1, imagesx($logoImg) + 1, imagesy($this->image) - imagesy($logoImg), $this->tileInfo ['openstreetmap'] ['txt'], $textcolor); |
|
592 | 592 | |
593 | 593 | // additional tile source info, ie. who created/hosted the tiles |
594 | 594 | if ($this->maptype != 'openstreetmap') { |
595 | - $iconImg = imagecreatefrompng ( $logoBaseDir . $this->tileInfo [$this->maptype] ['logo'] ); |
|
596 | - imagecopy ( $this->image, $iconImg, imagesx ( $logoImg ) + 1, imagesy ( $this->image ) - imagesy ( $iconImg ), 0, 0, imagesx ( $iconImg ), imagesy ( $iconImg ) ); |
|
597 | - imagestring ( $this->image, 1, imagesx ( $logoImg ) + imagesx ( $iconImg ) + 4, imagesy ( $this->image ) - ceil ( imagesy ( $logoImg ) / 2 ) + 1, $this->tileInfo [$this->maptype] ['txt'], $bgcolor ); |
|
598 | - imagestring ( $this->image, 1, imagesx ( $logoImg ) + imagesx ( $iconImg ) + 3, imagesy ( $this->image ) - ceil ( imagesy ( $logoImg ) / 2 ), $this->tileInfo [$this->maptype] ['txt'], $textcolor ); |
|
595 | + $iconImg = imagecreatefrompng($logoBaseDir.$this->tileInfo [$this->maptype] ['logo']); |
|
596 | + imagecopy($this->image, $iconImg, imagesx($logoImg) + 1, imagesy($this->image) - imagesy($iconImg), 0, 0, imagesx($iconImg), imagesy($iconImg)); |
|
597 | + imagestring($this->image, 1, imagesx($logoImg) + imagesx($iconImg) + 4, imagesy($this->image) - ceil(imagesy($logoImg) / 2) + 1, $this->tileInfo [$this->maptype] ['txt'], $bgcolor); |
|
598 | + imagestring($this->image, 1, imagesx($logoImg) + imagesx($iconImg) + 3, imagesy($this->image) - ceil(imagesy($logoImg) / 2), $this->tileInfo [$this->maptype] ['txt'], $textcolor); |
|
599 | 599 | } |
600 | 600 | } |
601 | 601 | |
@@ -603,18 +603,18 @@ discard block |
||
603 | 603 | * make the map. |
604 | 604 | */ |
605 | 605 | public function makeMap() { |
606 | - $this->initCoords (); |
|
607 | - $this->createBaseMap (); |
|
608 | - if (! empty ( $this->markers )) |
|
609 | - $this->placeMarkers (); |
|
610 | - if (file_exists ( $this->kmlFileName )) |
|
611 | - $this->drawKML (); |
|
612 | - if (file_exists ( $this->gpxFileName )) |
|
613 | - $this->drawGPX (); |
|
614 | - if (file_exists ( $this->geojsonFileName )) |
|
615 | - $this->drawGeojson (); |
|
616 | - |
|
617 | - $this->drawCopyright (); |
|
606 | + $this->initCoords(); |
|
607 | + $this->createBaseMap(); |
|
608 | + if (!empty ($this->markers)) |
|
609 | + $this->placeMarkers(); |
|
610 | + if (file_exists($this->kmlFileName)) |
|
611 | + $this->drawKML(); |
|
612 | + if (file_exists($this->gpxFileName)) |
|
613 | + $this->drawGPX(); |
|
614 | + if (file_exists($this->geojsonFileName)) |
|
615 | + $this->drawGeojson(); |
|
616 | + |
|
617 | + $this->drawCopyright(); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | /** |
@@ -627,59 +627,59 @@ discard block |
||
627 | 627 | * buffer constant to enlarge (>1.0) the zoom level |
628 | 628 | */ |
629 | 629 | private function autoZoom($paddingFactor = 1.0) { |
630 | - $geoms = array (); |
|
631 | - $geoms [] = new Point ( $this->lon, $this->lat ); |
|
632 | - if (! empty ( $this->markers )) { |
|
633 | - foreach ( $this->markers as $marker ) { |
|
634 | - $geoms [] = new Point ( $marker ['lon'], $marker ['lat'] ); |
|
630 | + $geoms = array(); |
|
631 | + $geoms [] = new Point($this->lon, $this->lat); |
|
632 | + if (!empty ($this->markers)) { |
|
633 | + foreach ($this->markers as $marker) { |
|
634 | + $geoms [] = new Point($marker ['lon'], $marker ['lat']); |
|
635 | 635 | } |
636 | 636 | } |
637 | 637 | $g = FALSE; |
638 | - if (file_exists ( $this->kmlFileName )) { |
|
639 | - $g = geoPHP::load ( file_get_contents ( $this->kmlFileName ), 'kml' ); |
|
640 | - if($g !== FALSE) { |
|
638 | + if (file_exists($this->kmlFileName)) { |
|
639 | + $g = geoPHP::load(file_get_contents($this->kmlFileName), 'kml'); |
|
640 | + if ($g !== FALSE) { |
|
641 | 641 | $geoms [] = $g; |
642 | 642 | } |
643 | 643 | } |
644 | - if (file_exists ( $this->gpxFileName )) { |
|
645 | - $g = geoPHP::load ( file_get_contents ( $this->gpxFileName ), 'gpx' ); |
|
646 | - if($g !== FALSE) { |
|
644 | + if (file_exists($this->gpxFileName)) { |
|
645 | + $g = geoPHP::load(file_get_contents($this->gpxFileName), 'gpx'); |
|
646 | + if ($g !== FALSE) { |
|
647 | 647 | $geoms [] = $g; |
648 | 648 | } |
649 | 649 | } |
650 | - if (file_exists ( $this->geojsonFileName )) { |
|
651 | - $g = geoPHP::load ( file_get_contents ( $this->geojsonFileName ), 'geojson' ); |
|
652 | - if($g !== FALSE) { |
|
650 | + if (file_exists($this->geojsonFileName)) { |
|
651 | + $g = geoPHP::load(file_get_contents($this->geojsonFileName), 'geojson'); |
|
652 | + if ($g !== FALSE) { |
|
653 | 653 | $geoms [] = $g; |
654 | 654 | } |
655 | 655 | } |
656 | 656 | |
657 | - if (count ( $geoms ) <= 1) { |
|
658 | - dbglog($geoms,"StaticMap::autoZoom: Skip setting autozoom options"); |
|
657 | + if (count($geoms) <= 1) { |
|
658 | + dbglog($geoms, "StaticMap::autoZoom: Skip setting autozoom options"); |
|
659 | 659 | return; |
660 | 660 | } |
661 | 661 | |
662 | - $geom = new GeometryCollection ( $geoms ); |
|
663 | - $centroid = $geom->centroid (); |
|
664 | - $bbox = $geom->getBBox (); |
|
662 | + $geom = new GeometryCollection($geoms); |
|
663 | + $centroid = $geom->centroid(); |
|
664 | + $bbox = $geom->getBBox(); |
|
665 | 665 | |
666 | 666 | // determine vertical resolution, this depends on the distance from the equator |
667 | 667 | // $vy00 = log(tan(M_PI*(0.25 + $centroid->getY()/360))); |
668 | - $vy0 = log ( tan ( M_PI * (0.25 + $bbox ['miny'] / 360) ) ); |
|
669 | - $vy1 = log ( tan ( M_PI * (0.25 + $bbox ['maxy'] / 360) ) ); |
|
668 | + $vy0 = log(tan(M_PI * (0.25 + $bbox ['miny'] / 360))); |
|
669 | + $vy1 = log(tan(M_PI * (0.25 + $bbox ['maxy'] / 360))); |
|
670 | 670 | dbglog("StaticMap::autoZoom: vertical resolution: $vy0, $vy1"); |
671 | 671 | $zoomFactorPowered = ($this->height / 2) / (40.7436654315252 * ($vy1 - $vy0)); |
672 | 672 | $resolutionVertical = 360 / ($zoomFactorPowered * $this->tileSize); |
673 | 673 | // determine horizontal resolution |
674 | 674 | $resolutionHorizontal = ($bbox ['maxx'] - $bbox ['minx']) / $this->width; |
675 | - $resolution = max ( $resolutionHorizontal, $resolutionVertical ) * $paddingFactor; |
|
676 | - $zoom = log ( 360 / ($resolution * $this->tileSize), 2 ); |
|
675 | + $resolution = max($resolutionHorizontal, $resolutionVertical) * $paddingFactor; |
|
676 | + $zoom = log(360 / ($resolution * $this->tileSize), 2); |
|
677 | 677 | |
678 | 678 | if (is_finite($zoom) && $zoom < 15 && $zoom > 2) { |
679 | - $this->zoom = floor ( $zoom ); |
|
679 | + $this->zoom = floor($zoom); |
|
680 | 680 | } |
681 | - $this->lon = $centroid->getX (); |
|
682 | - $this->lat = $centroid->getY (); |
|
681 | + $this->lon = $centroid->getX(); |
|
682 | + $this->lat = $centroid->getY(); |
|
683 | 683 | dbglog("StaticMap::autoZoom: Set autozoom options to: z: $this->zoom, lon: $this->lon, lat: $this->lat"); |
684 | 684 | } |
685 | 685 | |
@@ -691,21 +691,21 @@ discard block |
||
691 | 691 | public function getMap() { |
692 | 692 | try { |
693 | 693 | if ($this->autoZoomExtent) { |
694 | - $this->autoZoom (); |
|
694 | + $this->autoZoom(); |
|
695 | 695 | } |
696 | 696 | } catch (Exception $e) { |
697 | 697 | dbglog($e); |
698 | 698 | } |
699 | 699 | |
700 | 700 | // use map cache, so check cache for map |
701 | - if (! $this->checkMapCache ()) { |
|
701 | + if (!$this->checkMapCache()) { |
|
702 | 702 | // map is not in cache, needs to be build |
703 | - $this->makeMap (); |
|
704 | - $this->mkdir_recursive ( dirname ( $this->mapCacheIDToFilename () ), 0777 ); |
|
705 | - imagepng ( $this->image, $this->mapCacheIDToFilename (), 9 ); |
|
703 | + $this->makeMap(); |
|
704 | + $this->mkdir_recursive(dirname($this->mapCacheIDToFilename()), 0777); |
|
705 | + imagepng($this->image, $this->mapCacheIDToFilename(), 9); |
|
706 | 706 | } |
707 | - $this->doc = $this->mapCacheIDToFilename (); |
|
707 | + $this->doc = $this->mapCacheIDToFilename(); |
|
708 | 708 | // make url relative to media dir |
709 | - return str_replace ( $this->mediaBaseDir, '', $this->doc ); |
|
709 | + return str_replace($this->mediaBaseDir, '', $this->doc); |
|
710 | 710 | } |
711 | 711 | } |
@@ -343,8 +343,9 @@ discard block |
||
343 | 343 | public function checkMapCache() { |
344 | 344 | $this->mapCacheID = md5 ( $this->serializeParams () ); |
345 | 345 | $filename = $this->mapCacheIDToFilename (); |
346 | - if (file_exists ( $filename )) |
|
347 | - return true; |
|
346 | + if (file_exists ( $filename )) { |
|
347 | + return true; |
|
348 | + } |
|
348 | 349 | } |
349 | 350 | public function serializeParams() { |
350 | 351 | return join ( "&", array ( |
@@ -398,8 +399,9 @@ discard block |
||
398 | 399 | * @param string $url |
399 | 400 | */ |
400 | 401 | public function fetchTile($url) { |
401 | - if ($this->useTileCache && ($cached = $this->checkTileCache ( $url ))) |
|
402 | - return $cached; |
|
402 | + if ($this->useTileCache && ($cached = $this->checkTileCache ( $url ))) { |
|
403 | + return $cached; |
|
404 | + } |
|
403 | 405 | |
404 | 406 | $_UA = 'Mozilla/4.0 (compatible; DokuWikiSpatial HTTP Client; ' . PHP_OS . ')'; |
405 | 407 | if (function_exists ( "curl_init" )) { |
@@ -467,7 +469,9 @@ discard block |
||
467 | 469 | * drawing colour |
468 | 470 | */ |
469 | 471 | private function drawGeometry($geom, $colour) { |
470 | - if (empty($geom)) return; |
|
472 | + if (empty($geom)) { |
|
473 | + return; |
|
474 | + } |
|
471 | 475 | |
472 | 476 | switch ($geom->geometryType ()) { |
473 | 477 | case 'GeometryCollection' : |
@@ -605,14 +609,18 @@ discard block |
||
605 | 609 | public function makeMap() { |
606 | 610 | $this->initCoords (); |
607 | 611 | $this->createBaseMap (); |
608 | - if (! empty ( $this->markers )) |
|
609 | - $this->placeMarkers (); |
|
610 | - if (file_exists ( $this->kmlFileName )) |
|
611 | - $this->drawKML (); |
|
612 | - if (file_exists ( $this->gpxFileName )) |
|
613 | - $this->drawGPX (); |
|
614 | - if (file_exists ( $this->geojsonFileName )) |
|
615 | - $this->drawGeojson (); |
|
612 | + if (! empty ( $this->markers )) { |
|
613 | + $this->placeMarkers (); |
|
614 | + } |
|
615 | + if (file_exists ( $this->kmlFileName )) { |
|
616 | + $this->drawKML (); |
|
617 | + } |
|
618 | + if (file_exists ( $this->gpxFileName )) { |
|
619 | + $this->drawGPX (); |
|
620 | + } |
|
621 | + if (file_exists ( $this->geojsonFileName )) { |
|
622 | + $this->drawGeojson (); |
|
623 | + } |
|
616 | 624 | |
617 | 625 | $this->drawCopyright (); |
618 | 626 | } |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
15 | 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | 16 | */ |
17 | -if (! defined ( 'DOKU_INC' )) |
|
18 | - define ( 'DOKU_INC', realpath ( dirname ( __FILE__ ) . '/../../' ) . '/' ); |
|
19 | -if (! defined ( 'DOKU_PLUGIN' )) |
|
20 | - define ( 'DOKU_PLUGIN', DOKU_INC . 'lib/plugins/' ); |
|
21 | -require_once (DOKU_PLUGIN . 'syntax.php'); |
|
17 | +if (!defined('DOKU_INC')) |
|
18 | + define('DOKU_INC', realpath(dirname(__FILE__).'/../../').'/'); |
|
19 | +if (!defined('DOKU_PLUGIN')) |
|
20 | + define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); |
|
21 | +require_once (DOKU_PLUGIN.'syntax.php'); |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * DokuWiki Plugin openlayersmap (Syntax Component). |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * defaults of the known attributes of the olmap tag. |
33 | 33 | */ |
34 | - private $dflt = array ( |
|
34 | + private $dflt = array( |
|
35 | 35 | 'id' => 'olmap', |
36 | 36 | 'width' => '550px', |
37 | 37 | 'height' => '450px', |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @see Doku_Parser_Mode::connectTo() |
80 | 80 | */ |
81 | 81 | function connectTo($mode) { |
82 | - $this->Lexer->addSpecialPattern ( '<olmap ?[^>\n]*>.*?</olmap>', $mode, 'plugin_openlayersmap_olmap' ); |
|
82 | + $this->Lexer->addSpecialPattern('<olmap ?[^>\n]*>.*?</olmap>', $mode, 'plugin_openlayersmap_olmap'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | */ |
89 | 89 | function handle($match, $state, $pos, Doku_Handler $handler) { |
90 | 90 | // break matched cdata into its components |
91 | - list ( $str_params, $str_points ) = explode ( '>', substr ( $match, 7, - 9 ), 2 ); |
|
91 | + list ($str_params, $str_points) = explode('>', substr($match, 7, - 9), 2); |
|
92 | 92 | // get the lat/lon for adding them to the metadata (used by geotag) |
93 | - preg_match ( '(lat[:|=]\"-?\d*\.?\d*\")', $match, $mainLat ); |
|
94 | - preg_match ( '(lon[:|=]\"-?\d*\.?\d*\")', $match, $mainLon ); |
|
95 | - $mainLat = substr ( $mainLat [0], 5, - 1 ); |
|
96 | - $mainLon = substr ( $mainLon [0], 5, - 1 ); |
|
93 | + preg_match('(lat[:|=]\"-?\d*\.?\d*\")', $match, $mainLat); |
|
94 | + preg_match('(lon[:|=]\"-?\d*\.?\d*\")', $match, $mainLon); |
|
95 | + $mainLat = substr($mainLat [0], 5, - 1); |
|
96 | + $mainLon = substr($mainLon [0], 5, - 1); |
|
97 | 97 | if (!is_numeric($mainLat)) { |
98 | 98 | $mainLat = $this->dflt ['lat']; |
99 | 99 | } |
@@ -101,30 +101,30 @@ discard block |
||
101 | 101 | $mainLon = $this->dflt ['lon']; |
102 | 102 | } |
103 | 103 | |
104 | - $gmap = $this->_extract_params ( $str_params ); |
|
105 | - $overlay = $this->_extract_points ( $str_points ); |
|
104 | + $gmap = $this->_extract_params($str_params); |
|
105 | + $overlay = $this->_extract_points($str_points); |
|
106 | 106 | $_firstimageID = ''; |
107 | 107 | |
108 | 108 | $_nocache = false; |
109 | 109 | // choose maptype based on the specified tag |
110 | 110 | $imgUrl = "{{"; |
111 | - if (stripos ( $gmap ['baselyr'], 'google' ) !== false) { |
|
111 | + if (stripos($gmap ['baselyr'], 'google') !== false) { |
|
112 | 112 | |
113 | - $imgUrl .= $this->_getGoogle ( $gmap, $overlay ); |
|
113 | + $imgUrl .= $this->_getGoogle($gmap, $overlay); |
|
114 | 114 | $imgUrl .= "&.png"; |
115 | - } elseif (stripos ( $gmap ['baselyr'], 'bing' ) !== false) { |
|
115 | + } elseif (stripos($gmap ['baselyr'], 'bing') !== false) { |
|
116 | 116 | // Bing |
117 | - if (! $this->getConf ( 'bingAPIKey' )) { |
|
117 | + if (!$this->getConf('bingAPIKey')) { |
|
118 | 118 | // in case there is no Bing api key we'll use OSM |
119 | - $_firstimageID = $this->_getStaticOSM ( $gmap, $overlay ); |
|
119 | + $_firstimageID = $this->_getStaticOSM($gmap, $overlay); |
|
120 | 120 | $imgUrl .= $_firstimageID; |
121 | - if ($this->getConf ( 'optionStaticMapGenerator' ) == 'remote') { |
|
121 | + if ($this->getConf('optionStaticMapGenerator') == 'remote') { |
|
122 | 122 | $imgUrl .= "&.png"; |
123 | 123 | } |
124 | 124 | } else { |
125 | 125 | // seems that Bing doesn't like the DW client, turn off caching |
126 | 126 | $_nocache = true; |
127 | - $imgUrl .= $this->_getBing ( $gmap, $overlay ) . "&.png"; |
|
127 | + $imgUrl .= $this->_getBing($gmap, $overlay)."&.png"; |
|
128 | 128 | } |
129 | 129 | } /* elseif (stripos ( $gmap ['baselyr'], 'mapquest' ) !== false) { |
130 | 130 | // MapQuest |
@@ -141,15 +141,15 @@ discard block |
||
141 | 141 | } |
142 | 142 | } */ else { |
143 | 143 | // default OSM |
144 | - $_firstimageID = $this->_getStaticOSM ( $gmap, $overlay ); |
|
144 | + $_firstimageID = $this->_getStaticOSM($gmap, $overlay); |
|
145 | 145 | $imgUrl .= $_firstimageID; |
146 | - if ($this->getConf ( 'optionStaticMapGenerator' ) == 'remote') { |
|
146 | + if ($this->getConf('optionStaticMapGenerator') == 'remote') { |
|
147 | 147 | $imgUrl .= "&.png"; |
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | 151 | // append dw p_render specific params and render |
152 | - $imgUrl .= "?" . str_replace ( "px", "", $gmap ['width'] ) . "x" . str_replace ( "px", "", $gmap ['height'] ); |
|
152 | + $imgUrl .= "?".str_replace("px", "", $gmap ['width'])."x".str_replace("px", "", $gmap ['height']); |
|
153 | 153 | $imgUrl .= "&nolink"; |
154 | 154 | |
155 | 155 | // add nocache option for selected services |
@@ -157,34 +157,34 @@ discard block |
||
157 | 157 | $imgUrl .= "&nocache"; |
158 | 158 | } |
159 | 159 | |
160 | - $imgUrl .= " |".$gmap ['summary'] . " }}"; |
|
160 | + $imgUrl .= " |".$gmap ['summary']." }}"; |
|
161 | 161 | |
162 | 162 | // dbglog($imgUrl,"complete image tags is:"); |
163 | 163 | |
164 | 164 | $mapid = $gmap ['id']; |
165 | 165 | // create a javascript parameter string for the map |
166 | 166 | $param = ''; |
167 | - foreach ( $gmap as $key => $val ) { |
|
168 | - $param .= is_numeric ( $val ) ? "$key: $val, " : "$key: '" . hsc ( $val ) . "', "; |
|
167 | + foreach ($gmap as $key => $val) { |
|
168 | + $param .= is_numeric($val) ? "$key: $val, " : "$key: '".hsc($val)."', "; |
|
169 | 169 | } |
170 | - if (! empty ( $param )) { |
|
171 | - $param = substr ( $param, 0, - 2 ); |
|
170 | + if (!empty ($param)) { |
|
171 | + $param = substr($param, 0, - 2); |
|
172 | 172 | } |
173 | - unset ( $gmap ['id'] ); |
|
173 | + unset ($gmap ['id']); |
|
174 | 174 | |
175 | 175 | // create a javascript serialisation of the point data |
176 | 176 | $poi = ''; |
177 | 177 | $poitable = ''; |
178 | 178 | $rowId = 0; |
179 | - if (! empty ( $overlay )) { |
|
180 | - foreach ( $overlay as $data ) { |
|
181 | - list ( $lat, $lon, $text, $angle, $opacity, $img ) = $data; |
|
182 | - $rowId ++; |
|
179 | + if (!empty ($overlay)) { |
|
180 | + foreach ($overlay as $data) { |
|
181 | + list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
|
182 | + $rowId++; |
|
183 | 183 | $poi .= ", {lat: $lat, lon: $lon, txt: '$text', angle: $angle, opacity: $opacity, img: '$img', rowId: $rowId}"; |
184 | 184 | |
185 | - if ($this->getConf ( 'displayformat' ) === 'DMS') { |
|
186 | - $lat = $this->convertLat ( $lat ); |
|
187 | - $lon = $this->convertLon ( $lon ); |
|
185 | + if ($this->getConf('displayformat') === 'DMS') { |
|
186 | + $lat = $this->convertLat($lat); |
|
187 | + $lon = $this->convertLon($lon); |
|
188 | 188 | } else { |
189 | 189 | $lat .= 'º'; |
190 | 190 | $lon .= 'º'; |
@@ -192,46 +192,46 @@ discard block |
||
192 | 192 | |
193 | 193 | $poitable .= ' |
194 | 194 | <tr> |
195 | - <td class="rowId">' . $rowId . '</td> |
|
196 | - <td class="icon"><img src="' . DOKU_BASE . 'lib/plugins/openlayersmap/icons/' . $img . '" alt="'. substr($img, 0, -4) . $this->getlang('alt_legend_poi').' " /></td> |
|
197 | - <td class="lat" title="' . $this->getLang ( 'olmapPOIlatTitle' ) . '">' . $lat . '</td> |
|
198 | - <td class="lon" title="' . $this->getLang ( 'olmapPOIlonTitle' ) . '">' . $lon . '</td> |
|
199 | - <td class="txt">' . $text . '</td> |
|
195 | + <td class="rowId">' . $rowId.'</td> |
|
196 | + <td class="icon"><img src="' . DOKU_BASE.'lib/plugins/openlayersmap/icons/'.$img.'" alt="'.substr($img, 0, -4).$this->getlang('alt_legend_poi').' " /></td> |
|
197 | + <td class="lat" title="' . $this->getLang('olmapPOIlatTitle').'">'.$lat.'</td> |
|
198 | + <td class="lon" title="' . $this->getLang('olmapPOIlonTitle').'">'.$lon.'</td> |
|
199 | + <td class="txt">' . $text.'</td> |
|
200 | 200 | </tr>'; |
201 | 201 | } |
202 | - $poi = substr ( $poi, 2 ); |
|
202 | + $poi = substr($poi, 2); |
|
203 | 203 | } |
204 | - if (! empty ( $gmap ['kmlfile'] )) { |
|
204 | + if (!empty ($gmap ['kmlfile'])) { |
|
205 | 205 | $poitable .= ' |
206 | 206 | <tr> |
207 | - <td class="rowId"><img src="' . DOKU_BASE . 'lib/plugins/openlayersmap/toolbar/kml_file.png" alt="KML file" /></td> |
|
208 | - <td class="icon"><img src="' . DOKU_BASE . 'lib/plugins/openlayersmap/toolbar/kml_line.png" alt="' . $this->getlang('alt_legend_kml') .'" /></td> |
|
209 | - <td class="txt" colspan="3">KML track: ' . $this->getFileName ( $gmap ['kmlfile'] ) . '</td> |
|
207 | + <td class="rowId"><img src="' . DOKU_BASE.'lib/plugins/openlayersmap/toolbar/kml_file.png" alt="KML file" /></td> |
|
208 | + <td class="icon"><img src="' . DOKU_BASE.'lib/plugins/openlayersmap/toolbar/kml_line.png" alt="'.$this->getlang('alt_legend_kml').'" /></td> |
|
209 | + <td class="txt" colspan="3">KML track: ' . $this->getFileName($gmap ['kmlfile']).'</td> |
|
210 | 210 | </tr>'; |
211 | 211 | } |
212 | - if (! empty ( $gmap ['gpxfile'] )) { |
|
212 | + if (!empty ($gmap ['gpxfile'])) { |
|
213 | 213 | $poitable .= ' |
214 | 214 | <tr> |
215 | - <td class="rowId"><img src="' . DOKU_BASE . 'lib/plugins/openlayersmap/toolbar/gpx_file.png" alt="GPX file" /></td> |
|
216 | - <td class="icon"><img src="' . DOKU_BASE . 'lib/plugins/openlayersmap/toolbar/gpx_line.png" alt="' . $this->getlang('alt_legend_gpx') .'" /></td> |
|
217 | - <td class="txt" colspan="3">GPX track: ' . $this->getFileName ( $gmap ['gpxfile'] ) . '</td> |
|
215 | + <td class="rowId"><img src="' . DOKU_BASE.'lib/plugins/openlayersmap/toolbar/gpx_file.png" alt="GPX file" /></td> |
|
216 | + <td class="icon"><img src="' . DOKU_BASE.'lib/plugins/openlayersmap/toolbar/gpx_line.png" alt="'.$this->getlang('alt_legend_gpx').'" /></td> |
|
217 | + <td class="txt" colspan="3">GPX track: ' . $this->getFileName($gmap ['gpxfile']).'</td> |
|
218 | 218 | </tr>'; |
219 | 219 | } |
220 | - if (! empty ( $gmap ['geojsonfile'] )) { |
|
220 | + if (!empty ($gmap ['geojsonfile'])) { |
|
221 | 221 | $poitable .= ' |
222 | 222 | <tr> |
223 | - <td class="rowId"><img src="' . DOKU_BASE . 'lib/plugins/openlayersmap/toolbar/geojson_file.png" alt="GeoJSON file" /></td> |
|
224 | - <td class="icon"><img src="' . DOKU_BASE . 'lib/plugins/openlayersmap/toolbar/geojson_line.png" alt="' . $this->getlang('alt_legend_geojson') .'" /></td> |
|
225 | - <td class="txt" colspan="3">GeoJSON track: ' . $this->getFileName ( $gmap ['geojsonfile'] ) . '</td> |
|
223 | + <td class="rowId"><img src="' . DOKU_BASE.'lib/plugins/openlayersmap/toolbar/geojson_file.png" alt="GeoJSON file" /></td> |
|
224 | + <td class="icon"><img src="' . DOKU_BASE.'lib/plugins/openlayersmap/toolbar/geojson_line.png" alt="'.$this->getlang('alt_legend_geojson').'" /></td> |
|
225 | + <td class="txt" colspan="3">GeoJSON track: ' . $this->getFileName($gmap ['geojsonfile']).'</td> |
|
226 | 226 | </tr>'; |
227 | 227 | } |
228 | 228 | |
229 | - $autozoom = empty ( $gmap ['autozoom'] ) ? $this->getConf ( 'autoZoomMap' ) : $gmap ['autozoom']; |
|
230 | - $js .= "{mapOpts: {" . $param . ", displayformat: '" . $this->getConf ( 'displayformat' ) . "', autozoom: " . $autozoom . "}, poi: [$poi]};"; |
|
229 | + $autozoom = empty ($gmap ['autozoom']) ? $this->getConf('autoZoomMap') : $gmap ['autozoom']; |
|
230 | + $js .= "{mapOpts: {".$param.", displayformat: '".$this->getConf('displayformat')."', autozoom: ".$autozoom."}, poi: [$poi]};"; |
|
231 | 231 | // unescape the json |
232 | - $poitable = stripslashes ( $poitable ); |
|
232 | + $poitable = stripslashes($poitable); |
|
233 | 233 | |
234 | - return array ( |
|
234 | + return array( |
|
235 | 235 | $mapid, |
236 | 236 | $js, |
237 | 237 | $mainLat, |
@@ -254,90 +254,90 @@ discard block |
||
254 | 254 | static $mapnumber = 0; |
255 | 255 | |
256 | 256 | // dbglog($data, 'olmap::render() data.'); |
257 | - list ( $mapid, $param, $mainLat, $mainLon, $poitable, $poitabledesc, $staticImgUrl, $_firstimage ) = $data; |
|
257 | + list ($mapid, $param, $mainLat, $mainLon, $poitable, $poitabledesc, $staticImgUrl, $_firstimage) = $data; |
|
258 | 258 | |
259 | 259 | if ($mode == 'xhtml') { |
260 | 260 | $olscript = ''; |
261 | 261 | $olEnable = false; |
262 | 262 | $gscript = ''; |
263 | - $gEnable = $this->getConf ( 'enableGoogle' ); |
|
264 | - $stamenEnable = $this->getConf ( 'enableStamen' ); |
|
265 | - $osmEnable = $this->getConf ( 'enableOSM' ); |
|
266 | - $enableBing = $this->getConf ( 'enableBing' ); |
|
263 | + $gEnable = $this->getConf('enableGoogle'); |
|
264 | + $stamenEnable = $this->getConf('enableStamen'); |
|
265 | + $osmEnable = $this->getConf('enableOSM'); |
|
266 | + $enableBing = $this->getConf('enableBing'); |
|
267 | 267 | |
268 | 268 | $scriptEnable = ''; |
269 | - if (! $initialised) { |
|
269 | + if (!$initialised) { |
|
270 | 270 | $initialised = true; |
271 | 271 | // render necessary script tags |
272 | 272 | if ($gEnable) { |
273 | - $gscript = '<script charset="utf-8" defer="defer" src="//maps.google.com/maps/api/js?v=3.29&key='.$this->getConf ( 'googleAPIkey' ).'"></script>'; |
|
273 | + $gscript = '<script charset="utf-8" defer="defer" src="//maps.google.com/maps/api/js?v=3.29&key='.$this->getConf('googleAPIkey').'"></script>'; |
|
274 | 274 | } |
275 | - $olscript = '<script charset="utf-8" defer="defer" src="' . DOKU_BASE . 'lib/plugins/openlayersmap/lib/OpenLayers.js"></script>'; |
|
275 | + $olscript = '<script charset="utf-8" defer="defer" src="'.DOKU_BASE.'lib/plugins/openlayersmap/lib/OpenLayers.js"></script>'; |
|
276 | 276 | |
277 | 277 | $scriptEnable = '<script defer="defer" charset="utf-8" src="data:text/javascript;base64,'; |
278 | 278 | $scriptSrc = $olscript ? 'olEnable = true;' : 'olEnable = false;'; |
279 | - $scriptSrc .= 'gEnable = ' . ($gEnable ? 'true' : 'false') . ';'; |
|
280 | - $scriptSrc .= 'osmEnable = ' . ($osmEnable ? 'true' : 'false') . ';'; |
|
281 | - $scriptSrc .= 'stamenEnable = ' . ($stamenEnable ? 'true' : 'false') . ';'; |
|
282 | - $scriptSrc .= 'bEnable = ' . ($enableBing ? 'true' : 'false') . ';'; |
|
283 | - $scriptSrc .= 'bApiKey="' . $this->getConf ( 'bingAPIKey' ) . '";'; |
|
284 | - $scriptSrc .= 'tfApiKey="' . $this->getConf ( 'tfApiKey' ) . '";'; |
|
285 | - $scriptSrc .= 'gApiKey="' . $this->getConf ( 'googleAPIkey' ) . '";'; |
|
279 | + $scriptSrc .= 'gEnable = '.($gEnable ? 'true' : 'false').';'; |
|
280 | + $scriptSrc .= 'osmEnable = '.($osmEnable ? 'true' : 'false').';'; |
|
281 | + $scriptSrc .= 'stamenEnable = '.($stamenEnable ? 'true' : 'false').';'; |
|
282 | + $scriptSrc .= 'bEnable = '.($enableBing ? 'true' : 'false').';'; |
|
283 | + $scriptSrc .= 'bApiKey="'.$this->getConf('bingAPIKey').'";'; |
|
284 | + $scriptSrc .= 'tfApiKey="'.$this->getConf('tfApiKey').'";'; |
|
285 | + $scriptSrc .= 'gApiKey="'.$this->getConf('googleAPIkey').'";'; |
|
286 | 286 | $scriptEnable .= base64_encode($scriptSrc); |
287 | 287 | $scriptEnable .= '"></script>'; |
288 | 288 | } |
289 | 289 | $renderer->doc .= "$gscript\n$olscript\n$scriptEnable"; |
290 | - $renderer->doc .= '<div class="olMapHelp">' . $this->locale_xhtml ( "help" ) . '</div>'; |
|
291 | - if ($this->getConf ( 'enableA11y' )) { |
|
292 | - $renderer->doc .= '<div id="' . $mapid . '-static" class="olStaticMap">' . p_render ( $mode, p_get_instructions ( $staticImgUrl ), $info ) . '</div>'; |
|
290 | + $renderer->doc .= '<div class="olMapHelp">'.$this->locale_xhtml("help").'</div>'; |
|
291 | + if ($this->getConf('enableA11y')) { |
|
292 | + $renderer->doc .= '<div id="'.$mapid.'-static" class="olStaticMap">'.p_render($mode, p_get_instructions($staticImgUrl), $info).'</div>'; |
|
293 | 293 | } |
294 | - $renderer->doc .= '<div id="' . $mapid . '-clearer" class="clearer"><p> </p></div>'; |
|
295 | - if ($this->getConf ( 'enableA11y' )) { |
|
294 | + $renderer->doc .= '<div id="'.$mapid.'-clearer" class="clearer"><p> </p></div>'; |
|
295 | + if ($this->getConf('enableA11y')) { |
|
296 | 296 | // render a table of the POI for the print and a11y presentation, it is hidden using javascript |
297 | - $renderer->doc .= '<div class="olPOItableSpan" id="' . $mapid . '-table-span"> |
|
298 | - <table class="olPOItable" id="' . $mapid . '-table"> |
|
299 | - <caption class="olPOITblCaption">' . $this->getLang ( 'olmapPOItitle' ) . '</caption> |
|
297 | + $renderer->doc .= '<div class="olPOItableSpan" id="'.$mapid.'-table-span"> |
|
298 | + <table class="olPOItable" id="' . $mapid.'-table"> |
|
299 | + <caption class="olPOITblCaption">' . $this->getLang('olmapPOItitle').'</caption> |
|
300 | 300 | <thead class="olPOITblHeader"> |
301 | 301 | <tr> |
302 | 302 | <th class="rowId" scope="col">id</th> |
303 | - <th class="icon" scope="col">' . $this->getLang ( 'olmapPOIicon' ) . '</th> |
|
304 | - <th class="lat" scope="col" title="' . $this->getLang ( 'olmapPOIlatTitle' ) . '">' . $this->getLang ( 'olmapPOIlat' ) . '</th> |
|
305 | - <th class="lon" scope="col" title="' . $this->getLang ( 'olmapPOIlonTitle' ) . '">' . $this->getLang ( 'olmapPOIlon' ) . '</th> |
|
306 | - <th class="txt" scope="col">' . $this->getLang ( 'olmapPOItxt' ) . '</th> |
|
303 | + <th class="icon" scope="col">' . $this->getLang('olmapPOIicon').'</th> |
|
304 | + <th class="lat" scope="col" title="' . $this->getLang('olmapPOIlatTitle').'">'.$this->getLang('olmapPOIlat').'</th> |
|
305 | + <th class="lon" scope="col" title="' . $this->getLang('olmapPOIlonTitle').'">'.$this->getLang('olmapPOIlon').'</th> |
|
306 | + <th class="txt" scope="col">' . $this->getLang('olmapPOItxt').'</th> |
|
307 | 307 | </tr> |
308 | 308 | </thead>'; |
309 | 309 | if ($poitabledesc != '') { |
310 | - $renderer->doc .= '<tfoot class="olPOITblFooter"><tr><td colspan="5">' . $poitabledesc . '</td></tr></tfoot>'; |
|
310 | + $renderer->doc .= '<tfoot class="olPOITblFooter"><tr><td colspan="5">'.$poitabledesc.'</td></tr></tfoot>'; |
|
311 | 311 | } |
312 | - $renderer->doc .= '<tbody class="olPOITblBody">' . $poitable . '</tbody> |
|
312 | + $renderer->doc .= '<tbody class="olPOITblBody">'.$poitable.'</tbody> |
|
313 | 313 | </table></div>'; |
314 | 314 | } |
315 | 315 | // render inline mapscript parts |
316 | 316 | $renderer->doc .= '<script charset="utf-8" defer="defer" src="data:text/javascript;base64,'; |
317 | 317 | $renderer->doc .= base64_encode("olMapData[$mapnumber] = $param"); |
318 | 318 | $renderer->doc .= '"></script>'; |
319 | - $mapnumber ++; |
|
319 | + $mapnumber++; |
|
320 | 320 | return true; |
321 | 321 | } elseif ($mode == 'metadata') { |
322 | - if (! (($this->dflt ['lat'] == $mainLat) && ($this->dflt ['lon'] == $mainLon))) { |
|
322 | + if (!(($this->dflt ['lat'] == $mainLat) && ($this->dflt ['lon'] == $mainLon))) { |
|
323 | 323 | // render geo metadata, unless they are the default |
324 | 324 | $renderer->meta ['geo'] ['lat'] = $mainLat; |
325 | 325 | $renderer->meta ['geo'] ['lon'] = $mainLon; |
326 | - if ($geophp = &plugin_load ( 'helper', 'geophp' )) { |
|
326 | + if ($geophp = &plugin_load('helper', 'geophp')) { |
|
327 | 327 | // if we have the geoPHP helper, add the geohash |
328 | 328 | // fails with older php versions.. $renderer->meta['geo']['geohash'] = (new Point($mainLon,$mainLat))->out('geohash'); |
329 | - $p = new Point ( $mainLon, $mainLat ); |
|
330 | - $renderer->meta ['geo'] ['geohash'] = $p->out ( 'geohash' ); |
|
329 | + $p = new Point($mainLon, $mainLat); |
|
330 | + $renderer->meta ['geo'] ['geohash'] = $p->out('geohash'); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
334 | - if (($this->getConf ( 'enableA11y' )) && (! empty ( $_firstimage ))) { |
|
334 | + if (($this->getConf('enableA11y')) && (!empty ($_firstimage))) { |
|
335 | 335 | // add map local image into relation/firstimage if not already filled and when it is a local image |
336 | 336 | |
337 | 337 | global $ID; |
338 | - $rel = p_get_metadata ( $ID, 'relation', METADATA_RENDER_USING_CACHE ); |
|
338 | + $rel = p_get_metadata($ID, 'relation', METADATA_RENDER_USING_CACHE); |
|
339 | 339 | $img = $rel ['firstimage']; |
340 | - if (empty ( $img ) /* || $img == $_firstimage*/){ |
|
340 | + if (empty ($img) /* || $img == $_firstimage*/) { |
|
341 | 341 | //dbglog ( $_firstimage, 'olmap::render#rendering image relation metadata for _firstimage as $img was empty or the same.' ); |
342 | 342 | // This seems to never work; the firstimage entry in the .meta file is empty |
343 | 343 | // $renderer->meta['relation']['firstimage'] = $_firstimage; |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | // p_set_metadata($ID, $relation, false, false); |
348 | 348 | |
349 | 349 | // ... this works |
350 | - $renderer->internalmedia ( $_firstimage, $poitabledesc ); |
|
350 | + $renderer->internalmedia($_firstimage, $poitabledesc); |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | return true; |
@@ -363,21 +363,21 @@ discard block |
||
363 | 363 | * @return array associative array of parameters key=>value |
364 | 364 | */ |
365 | 365 | private function _extract_params($str_params) { |
366 | - $param = array (); |
|
367 | - preg_match_all ( '/(\w*)="(.*?)"/us', $str_params, $param, PREG_SET_ORDER ); |
|
366 | + $param = array(); |
|
367 | + preg_match_all('/(\w*)="(.*?)"/us', $str_params, $param, PREG_SET_ORDER); |
|
368 | 368 | // parse match for instructions, break into key value pairs |
369 | 369 | $gmap = $this->dflt; |
370 | - foreach ( $gmap as $key => &$value ) { |
|
371 | - $defval = $this->getConf ( 'default_' . $key ); |
|
370 | + foreach ($gmap as $key => &$value) { |
|
371 | + $defval = $this->getConf('default_'.$key); |
|
372 | 372 | if ($defval !== '') { |
373 | 373 | $value = $defval; |
374 | 374 | } |
375 | 375 | } |
376 | - unset ( $value ); |
|
377 | - foreach ( $param as $kvpair ) { |
|
378 | - list ( $match, $key, $val ) = $kvpair; |
|
379 | - $key = strtolower ( $key ); |
|
380 | - if (isset ( $gmap [$key] )) { |
|
376 | + unset ($value); |
|
377 | + foreach ($param as $kvpair) { |
|
378 | + list ($match, $key, $val) = $kvpair; |
|
379 | + $key = strtolower($key); |
|
380 | + if (isset ($gmap [$key])) { |
|
381 | 381 | if ($key == 'summary') { |
382 | 382 | // preserve case for summary field |
383 | 383 | $gmap [$key] = $val; |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | // preserve case for id field |
386 | 386 | $gmap [$key] = $val; |
387 | 387 | } else { |
388 | - $gmap [$key] = strtolower ( $val ); |
|
388 | + $gmap [$key] = strtolower($val); |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | } |
@@ -400,28 +400,28 @@ discard block |
||
400 | 400 | * @return array multi-dimensional array of lat,lon,text triplets |
401 | 401 | */ |
402 | 402 | private function _extract_points($str_points) { |
403 | - $point = array (); |
|
403 | + $point = array(); |
|
404 | 404 | // preg_match_all('/^([+-]?[0-9].*?),\s*([+-]?[0-9].*?),(.*?),(.*?),(.*?),(.*)$/um', $str_points, $point, PREG_SET_ORDER); |
405 | 405 | /* |
406 | 406 | * group 1: ([+-]?[0-9]+(?:\.[0-9]*)?) group 2: ([+-]?[0-9]+(?:\.[0-9]*)?) group 3: (.*?) group 4: (.*?) group 5: (.*?) group 6: (.*) |
407 | 407 | */ |
408 | - preg_match_all ( '/^([+-]?[0-9]+(?:\.[0-9]*)?),\s*([+-]?[0-9]+(?:\.[0-9]*)?),(.*?),(.*?),(.*?),(.*)$/um', $str_points, $point, PREG_SET_ORDER ); |
|
408 | + preg_match_all('/^([+-]?[0-9]+(?:\.[0-9]*)?),\s*([+-]?[0-9]+(?:\.[0-9]*)?),(.*?),(.*?),(.*?),(.*)$/um', $str_points, $point, PREG_SET_ORDER); |
|
409 | 409 | // create poi array |
410 | - $overlay = array (); |
|
411 | - foreach ( $point as $pt ) { |
|
412 | - list ( $match, $lat, $lon, $angle, $opacity, $img, $text ) = $pt; |
|
413 | - $lat = is_numeric ( $lat ) ? $lat : 0; |
|
414 | - $lon = is_numeric ( $lon ) ? $lon : 0; |
|
415 | - $angle = is_numeric ( $angle ) ? $angle : 0; |
|
416 | - $opacity = is_numeric ( $opacity ) ? $opacity : 0.8; |
|
410 | + $overlay = array(); |
|
411 | + foreach ($point as $pt) { |
|
412 | + list ($match, $lat, $lon, $angle, $opacity, $img, $text) = $pt; |
|
413 | + $lat = is_numeric($lat) ? $lat : 0; |
|
414 | + $lon = is_numeric($lon) ? $lon : 0; |
|
415 | + $angle = is_numeric($angle) ? $angle : 0; |
|
416 | + $opacity = is_numeric($opacity) ? $opacity : 0.8; |
|
417 | 417 | // TODO validate using exist & set up default img? |
418 | - $img = trim ( $img ); |
|
419 | - $text = p_get_instructions ( $text ); |
|
418 | + $img = trim($img); |
|
419 | + $text = p_get_instructions($text); |
|
420 | 420 | // dbg ( $text ); |
421 | - $text = p_render ( "xhtml", $text, $info ); |
|
421 | + $text = p_render("xhtml", $text, $info); |
|
422 | 422 | // dbg ( $text ); |
423 | - $text = addslashes ( str_replace ( "\n", "", $text ) ); |
|
424 | - $overlay [] = array ( |
|
423 | + $text = addslashes(str_replace("\n", "", $text)); |
|
424 | + $overlay [] = array( |
|
425 | 425 | $lat, |
426 | 426 | $lon, |
427 | 427 | $text, |
@@ -501,8 +501,8 @@ discard block |
||
501 | 501 | * @param array $overlay |
502 | 502 | */ |
503 | 503 | private function _getGoogle($gmap, $overlay) { |
504 | - $sUrl = $this->getConf ( 'iconUrlOverload' ); |
|
505 | - if (! $sUrl) { |
|
504 | + $sUrl = $this->getConf('iconUrlOverload'); |
|
505 | + if (!$sUrl) { |
|
506 | 506 | $sUrl = DOKU_URL; |
507 | 507 | } |
508 | 508 | switch ($gmap ['baselyr']) { |
@@ -525,27 +525,27 @@ discard block |
||
525 | 525 | // see: https://developers.google.com/maps/documentation/staticmaps/index#Viewports |
526 | 526 | // http://maps.google.com/maps/api/staticmap?center=51.565690,5.456756&zoom=16&size=600x400&markers=icon:http://wild-water.nl/dokuwiki/lib/plugins/openlayersmap/icons/marker.png|label:1|51.565690,5.456756&markers=icon:http://wild-water.nl/dokuwiki/lib/plugins/openlayersmap/icons/marker-blue.png|51.566197,5.458966|label:2&markers=icon:http://wild-water.nl/dokuwiki/lib/plugins/openlayersmap/icons/parking.png|51.567177,5.457909|label:3&markers=icon:http://wild-water.nl/dokuwiki/lib/plugins/openlayersmap/icons/parking.png|51.566283,5.457330|label:4&markers=icon:http://wild-water.nl/dokuwiki/lib/plugins/openlayersmap/icons/parking.png|51.565630,5.457695|label:5&sensor=false&format=png&maptype=roadmap |
527 | 527 | $imgUrl = "http://maps.googleapis.com/maps/api/staticmap?"; |
528 | - $imgUrl .= "&size=" . str_replace ( "px", "", $gmap ['width'] ) . "x" . str_replace ( "px", "", $gmap ['height'] ); |
|
528 | + $imgUrl .= "&size=".str_replace("px", "", $gmap ['width'])."x".str_replace("px", "", $gmap ['height']); |
|
529 | 529 | //if (!$this->getConf( 'autoZoomMap')) { // no need for center & zoom params } |
530 | - $imgUrl .= "¢er=" . $gmap ['lat'] . "," . $gmap ['lon']; |
|
530 | + $imgUrl .= "¢er=".$gmap ['lat'].",".$gmap ['lon']; |
|
531 | 531 | // max is 21 (== building scale), but that's overkill.. |
532 | 532 | if ($gmap ['zoom'] > 17) { |
533 | 533 | $imgUrl .= "&zoom=17"; |
534 | 534 | } else { |
535 | - $imgUrl .= "&zoom=" . $gmap ['zoom']; |
|
535 | + $imgUrl .= "&zoom=".$gmap ['zoom']; |
|
536 | 536 | } |
537 | - if (! empty ( $overlay )) { |
|
537 | + if (!empty ($overlay)) { |
|
538 | 538 | $rowId = 0; |
539 | - foreach ( $overlay as $data ) { |
|
540 | - list ( $lat, $lon, $text, $angle, $opacity, $img ) = $data; |
|
541 | - $imgUrl .= "&markers=icon%3a" . $sUrl . "lib/plugins/openlayersmap/icons/" . $img . "%7c" . $lat . "," . $lon . "%7clabel%3a" . ++ $rowId; |
|
539 | + foreach ($overlay as $data) { |
|
540 | + list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
|
541 | + $imgUrl .= "&markers=icon%3a".$sUrl."lib/plugins/openlayersmap/icons/".$img."%7c".$lat.",".$lon."%7clabel%3a".++ $rowId; |
|
542 | 542 | } |
543 | 543 | } |
544 | - $imgUrl .= "&format=png&maptype=" . $maptype; |
|
544 | + $imgUrl .= "&format=png&maptype=".$maptype; |
|
545 | 545 | global $conf; |
546 | - $imgUrl .= "&language=" . $conf ['lang']; |
|
547 | - if ($this->getConf( 'googleAPIkey' )) { |
|
548 | - $imgUrl .= "&key=" . $this->getConf( 'googleAPIkey' ); |
|
546 | + $imgUrl .= "&language=".$conf ['lang']; |
|
547 | + if ($this->getConf('googleAPIkey')) { |
|
548 | + $imgUrl .= "&key=".$this->getConf('googleAPIkey'); |
|
549 | 549 | } |
550 | 550 | // dbglog($imgUrl,'syntax_plugin_openlayersmap_olmap::_getGoogle: Google image url is:'); |
551 | 551 | return $imgUrl; |
@@ -575,26 +575,26 @@ discard block |
||
575 | 575 | $maptype = 'Road'; |
576 | 576 | break; |
577 | 577 | } |
578 | - $imgUrl = "http://dev.virtualearth.net/REST/v1/Imagery/Map/" . $maptype;// . "/"; |
|
579 | - if ($this->getConf ( 'autoZoomMap' )) { |
|
580 | - $bbox = $this->_calcBBOX ( $overlay, $gmap ['lat'], $gmap ['lon'] ); |
|
578 | + $imgUrl = "http://dev.virtualearth.net/REST/v1/Imagery/Map/".$maptype; // . "/"; |
|
579 | + if ($this->getConf('autoZoomMap')) { |
|
580 | + $bbox = $this->_calcBBOX($overlay, $gmap ['lat'], $gmap ['lon']); |
|
581 | 581 | //$imgUrl .= "?ma=" . $bbox ['minlat'] . "," . $bbox ['minlon'] . "," . $bbox ['maxlat'] . "," . $bbox ['maxlon']; |
582 | - $imgUrl .= "?ma=" . $bbox ['minlat'] . "%2C" . $bbox ['minlon'] . "%2C" . $bbox ['maxlat'] . "%2C" . $bbox ['maxlon']; |
|
582 | + $imgUrl .= "?ma=".$bbox ['minlat']."%2C".$bbox ['minlon']."%2C".$bbox ['maxlat']."%2C".$bbox ['maxlon']; |
|
583 | 583 | $imgUrl .= "&dcl=1"; |
584 | 584 | } |
585 | - if (strpos ( $imgUrl, "?" ) === false) |
|
585 | + if (strpos($imgUrl, "?") === false) |
|
586 | 586 | $imgUrl .= "?"; |
587 | 587 | |
588 | 588 | //$imgUrl .= "&ms=" . str_replace ( "px", "", $gmap ['width'] ) . "," . str_replace ( "px", "", $gmap ['height'] ); |
589 | - $imgUrl .= "&ms=" . str_replace ( "px", "", $gmap ['width'] ) . "%2C" . str_replace ( "px", "", $gmap ['height'] ); |
|
590 | - $imgUrl .= "&key=" . $this->getConf ( 'bingAPIKey' ); |
|
591 | - if (! empty ( $overlay )) { |
|
589 | + $imgUrl .= "&ms=".str_replace("px", "", $gmap ['width'])."%2C".str_replace("px", "", $gmap ['height']); |
|
590 | + $imgUrl .= "&key=".$this->getConf('bingAPIKey'); |
|
591 | + if (!empty ($overlay)) { |
|
592 | 592 | $rowId = 0; |
593 | - foreach ( $overlay as $data ) { |
|
594 | - list ( $lat, $lon, $text, $angle, $opacity, $img ) = $data; |
|
593 | + foreach ($overlay as $data) { |
|
594 | + list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
|
595 | 595 | // TODO icon style lookup, see: http://msdn.microsoft.com/en-us/library/ff701719.aspx for iconStyle |
596 | 596 | $iconStyle = 32; |
597 | - $rowId ++; |
|
597 | + $rowId++; |
|
598 | 598 | // NOTE: the max number of pushpins is 18! or we have to use POST (http://msdn.microsoft.com/en-us/library/ff701724.aspx) |
599 | 599 | if ($rowId == 18) { |
600 | 600 | break; |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | } |
607 | 607 | global $conf; |
608 | 608 | $imgUrl .= "&fmt=png"; |
609 | - $imgUrl .= "&c=" . $conf ['lang']; |
|
609 | + $imgUrl .= "&c=".$conf ['lang']; |
|
610 | 610 | // dbglog($imgUrl,'syntax_plugin_openlayersmap_olmap::_getBing: bing image url is:'); |
611 | 611 | return $imgUrl; |
612 | 612 | } |
@@ -623,22 +623,22 @@ discard block |
||
623 | 623 | private function _getStaticOSM($gmap, $overlay) { |
624 | 624 | global $conf; |
625 | 625 | |
626 | - if ($this->getConf ( 'optionStaticMapGenerator' ) == 'local') { |
|
626 | + if ($this->getConf('optionStaticMapGenerator') == 'local') { |
|
627 | 627 | // using local basemap composer |
628 | - if (! $myMap = &plugin_load ( 'helper', 'openlayersmap_staticmap' )) { |
|
629 | - dbglog ( $myMap, 'syntax_plugin_openlayersmap_olmap::_getStaticOSM: openlayersmap_staticmap plugin is not available.' ); |
|
628 | + if (!$myMap = &plugin_load('helper', 'openlayersmap_staticmap')) { |
|
629 | + dbglog($myMap, 'syntax_plugin_openlayersmap_olmap::_getStaticOSM: openlayersmap_staticmap plugin is not available.'); |
|
630 | 630 | } |
631 | - if (! $geophp = &plugin_load ( 'helper', 'geophp' )) { |
|
632 | - dbglog ( $geophp, 'syntax_plugin_openlayersmap_olmap::_getStaticOSM: geophp plugin is not available.' ); |
|
631 | + if (!$geophp = &plugin_load('helper', 'geophp')) { |
|
632 | + dbglog($geophp, 'syntax_plugin_openlayersmap_olmap::_getStaticOSM: geophp plugin is not available.'); |
|
633 | 633 | } |
634 | - $size = str_replace ( "px", "", $gmap ['width'] ) . "x" . str_replace ( "px", "", $gmap ['height'] ); |
|
634 | + $size = str_replace("px", "", $gmap ['width'])."x".str_replace("px", "", $gmap ['height']); |
|
635 | 635 | |
636 | 636 | $markers = array(); |
637 | - if (! empty ( $overlay )) { |
|
638 | - foreach ( $overlay as $data ) { |
|
639 | - list ( $lat, $lon, $text, $angle, $opacity, $img ) = $data; |
|
640 | - $iconStyle = substr ( $img, 0, strlen ( $img ) - 4 ); |
|
641 | - $markers [] = array ( |
|
637 | + if (!empty ($overlay)) { |
|
638 | + foreach ($overlay as $data) { |
|
639 | + list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
|
640 | + $iconStyle = substr($img, 0, strlen($img) - 4); |
|
641 | + $markers [] = array( |
|
642 | 642 | 'lat' => $lat, |
643 | 643 | 'lon' => $lon, |
644 | 644 | 'type' => $iconStyle |
@@ -654,19 +654,19 @@ discard block |
||
654 | 654 | break; |
655 | 655 | case 'transport' : |
656 | 656 | $maptype = 'transport'; |
657 | - $apikey = $this->getConf ( 'tfApiKey' ); |
|
657 | + $apikey = $this->getConf('tfApiKey'); |
|
658 | 658 | break; |
659 | 659 | case 'landscape' : |
660 | 660 | $maptype = 'landscape'; |
661 | - $apikey = $this->getConf ( 'tfApiKey' ); |
|
661 | + $apikey = $this->getConf('tfApiKey'); |
|
662 | 662 | break; |
663 | 663 | case 'outdoors' : |
664 | 664 | $maptype = 'outdoors'; |
665 | - $apikey = $this->getConf ( 'tfApiKey' ); |
|
665 | + $apikey = $this->getConf('tfApiKey'); |
|
666 | 666 | break; |
667 | 667 | case 'cycle map' : |
668 | 668 | $maptype = 'cycle'; |
669 | - $apikey = $this->getConf ( 'tfApiKey' ); |
|
669 | + $apikey = $this->getConf('tfApiKey'); |
|
670 | 670 | break; |
671 | 671 | case 'hike and bike map' : |
672 | 672 | $maptype = 'hikeandbike'; |
@@ -681,33 +681,33 @@ discard block |
||
681 | 681 | break; |
682 | 682 | } |
683 | 683 | |
684 | - $result = $myMap->getMap ( $gmap ['lat'], $gmap ['lon'], $gmap ['zoom'], $size, $maptype, $markers, $gmap ['gpxfile'], $gmap ['kmlfile'], $gmap ['geojsonfile'] ); |
|
684 | + $result = $myMap->getMap($gmap ['lat'], $gmap ['lon'], $gmap ['zoom'], $size, $maptype, $markers, $gmap ['gpxfile'], $gmap ['kmlfile'], $gmap ['geojsonfile']); |
|
685 | 685 | } else { |
686 | 686 | // using external basemap composer |
687 | 687 | |
688 | 688 | // http://staticmap.openstreetmap.de/staticmap.php?center=47.000622235634,10.117187497601&zoom=5&size=500x350 |
689 | 689 | // &markers=48.999812532766,8.3593749976708,lightblue1|43.154850037315,17.499999997306,lightblue1|49.487527053077,10.820312497573,ltblu-pushpin|47.951071133739,15.917968747369,ol-marker|47.921629720114,18.027343747285,ol-marker-gold|47.951071133739,19.257812497236,ol-marker-blue|47.180141361692,19.257812497236,ol-marker-green |
690 | 690 | $imgUrl = "http://staticmap.openstreetmap.de/staticmap.php"; |
691 | - $imgUrl .= "?center=" . $gmap ['lat'] . "," . $gmap ['lon']; |
|
692 | - $imgUrl .= "&size=" . str_replace ( "px", "", $gmap ['width'] ) . "x" . str_replace ( "px", "", $gmap ['height'] ); |
|
691 | + $imgUrl .= "?center=".$gmap ['lat'].",".$gmap ['lon']; |
|
692 | + $imgUrl .= "&size=".str_replace("px", "", $gmap ['width'])."x".str_replace("px", "", $gmap ['height']); |
|
693 | 693 | |
694 | 694 | if ($gmap ['zoom'] > 16) { |
695 | 695 | // actually this could even be 18, but that seems overkill |
696 | 696 | $imgUrl .= "&zoom=16"; |
697 | 697 | } else { |
698 | - $imgUrl .= "&zoom=" . $gmap ['zoom']; |
|
698 | + $imgUrl .= "&zoom=".$gmap ['zoom']; |
|
699 | 699 | } |
700 | 700 | |
701 | - if (! empty ( $overlay )) { |
|
701 | + if (!empty ($overlay)) { |
|
702 | 702 | $rowId = 0; |
703 | 703 | $imgUrl .= "&markers="; |
704 | - foreach ( $overlay as $data ) { |
|
705 | - list ( $lat, $lon, $text, $angle, $opacity, $img ) = $data; |
|
706 | - $rowId ++; |
|
704 | + foreach ($overlay as $data) { |
|
705 | + list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
|
706 | + $rowId++; |
|
707 | 707 | $iconStyle = "lightblue$rowId"; |
708 | 708 | $imgUrl .= "$lat,$lon,$iconStyle%7c"; |
709 | 709 | } |
710 | - $imgUrl = substr ( $imgUrl, 0, - 3 ); |
|
710 | + $imgUrl = substr($imgUrl, 0, - 3); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | $result = $imgUrl; |
@@ -730,21 +730,21 @@ discard block |
||
730 | 730 | private function _calcBBOX($overlay, $lat, $lon) { |
731 | 731 | $lats = array($lat); |
732 | 732 | $lons = array($lon); |
733 | - foreach ( $overlay as $data ) { |
|
734 | - list ( $lat, $lon, $text, $angle, $opacity, $img ) = $data; |
|
733 | + foreach ($overlay as $data) { |
|
734 | + list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
|
735 | 735 | $lats [] = $lat; |
736 | 736 | $lons [] = $lon; |
737 | 737 | } |
738 | - sort ( $lats ); |
|
739 | - sort ( $lons ); |
|
738 | + sort($lats); |
|
739 | + sort($lons); |
|
740 | 740 | // TODO: make edge/wrap around cases work |
741 | - $centerlat = $lats [0] + ($lats [count ( $lats ) - 1] - $lats [0]); |
|
742 | - $centerlon = $lons [0] + ($lons [count ( $lats ) - 1] - $lons [0]); |
|
743 | - return array ( |
|
741 | + $centerlat = $lats [0] + ($lats [count($lats) - 1] - $lats [0]); |
|
742 | + $centerlon = $lons [0] + ($lons [count($lats) - 1] - $lons [0]); |
|
743 | + return array( |
|
744 | 744 | 'minlat' => $lats [0], |
745 | 745 | 'minlon' => $lons [0], |
746 | - 'maxlat' => $lats [count ( $lats ) - 1], |
|
747 | - 'maxlon' => $lons [count ( $lats ) - 1], |
|
746 | + 'maxlat' => $lats [count($lats) - 1], |
|
747 | + 'maxlon' => $lons [count($lats) - 1], |
|
748 | 748 | 'centerlat' => $centerlat, |
749 | 749 | 'centerlon' => $centerlon |
750 | 750 | ); |
@@ -756,12 +756,12 @@ discard block |
||
756 | 756 | * @param String $mediaLink |
757 | 757 | */ |
758 | 758 | private function getFileName($mediaLink) { |
759 | - $mediaLink = str_replace ( '[[', '', $mediaLink ); |
|
760 | - $mediaLink = str_replace ( ']]', '', $mediaLink ); |
|
761 | - $mediaLink = substr ( $mediaLink, 0, - 4 ); |
|
762 | - $parts = explode ( ':', $mediaLink ); |
|
763 | - $mediaLink = end ( $parts ); |
|
764 | - return str_replace ( '_', ' ', $mediaLink ); |
|
759 | + $mediaLink = str_replace('[[', '', $mediaLink); |
|
760 | + $mediaLink = str_replace(']]', '', $mediaLink); |
|
761 | + $mediaLink = substr($mediaLink, 0, - 4); |
|
762 | + $parts = explode(':', $mediaLink); |
|
763 | + $mediaLink = end($parts); |
|
764 | + return str_replace('_', ' ', $mediaLink); |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | /** |
@@ -772,11 +772,11 @@ discard block |
||
772 | 772 | * @return string dms |
773 | 773 | */ |
774 | 774 | private function _convertDDtoDMS($decimaldegrees) { |
775 | - $dms = floor ( $decimaldegrees ); |
|
775 | + $dms = floor($decimaldegrees); |
|
776 | 776 | $secs = ($decimaldegrees - $dms) * 3600; |
777 | - $min = floor ( $secs / 60 ); |
|
778 | - $sec = round ( $secs - ($min * 60), 3 ); |
|
779 | - $dms .= 'º' . $min . '\'' . $sec . '"'; |
|
777 | + $min = floor($secs / 60); |
|
778 | + $sec = round($secs - ($min * 60), 3); |
|
779 | + $dms .= 'º'.$min.'\''.$sec.'"'; |
|
780 | 780 | return $dms; |
781 | 781 | } |
782 | 782 | |
@@ -788,13 +788,13 @@ discard block |
||
788 | 788 | * @return string |
789 | 789 | */ |
790 | 790 | private function convertLat($decimaldegrees) { |
791 | - if (strpos ( $decimaldegrees, '-' ) !== false) { |
|
791 | + if (strpos($decimaldegrees, '-') !== false) { |
|
792 | 792 | $latPos = "S"; |
793 | 793 | } else { |
794 | 794 | $latPos = "N"; |
795 | 795 | } |
796 | - $dms = $this->_convertDDtoDMS ( abs ( floatval ( $decimaldegrees ) ) ); |
|
797 | - return hsc ( $dms . $latPos ); |
|
796 | + $dms = $this->_convertDDtoDMS(abs(floatval($decimaldegrees))); |
|
797 | + return hsc($dms.$latPos); |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | /** |
@@ -805,12 +805,12 @@ discard block |
||
805 | 805 | * @return string |
806 | 806 | */ |
807 | 807 | private function convertLon($decimaldegrees) { |
808 | - if (strpos ( $decimaldegrees, '-' ) !== false) { |
|
808 | + if (strpos($decimaldegrees, '-') !== false) { |
|
809 | 809 | $lonPos = "W"; |
810 | 810 | } else { |
811 | 811 | $lonPos = "E"; |
812 | 812 | } |
813 | - $dms = $this->_convertDDtoDMS ( abs ( floatval ( $decimaldegrees ) ) ); |
|
814 | - return hsc ( $dms . $lonPos ); |
|
813 | + $dms = $this->_convertDDtoDMS(abs(floatval($decimaldegrees))); |
|
814 | + return hsc($dms.$lonPos); |
|
815 | 815 | } |
816 | 816 | } |
@@ -14,10 +14,12 @@ discard block |
||
14 | 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
15 | 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | 16 | */ |
17 | -if (! defined ( 'DOKU_INC' )) |
|
17 | +if (! defined ( 'DOKU_INC' )) { |
|
18 | 18 | define ( 'DOKU_INC', realpath ( dirname ( __FILE__ ) . '/../../' ) . '/' ); |
19 | -if (! defined ( 'DOKU_PLUGIN' )) |
|
19 | +} |
|
20 | +if (! defined ( 'DOKU_PLUGIN' )) { |
|
20 | 21 | define ( 'DOKU_PLUGIN', DOKU_INC . 'lib/plugins/' ); |
22 | +} |
|
21 | 23 | require_once (DOKU_PLUGIN . 'syntax.php'); |
22 | 24 | |
23 | 25 | /** |
@@ -582,8 +584,9 @@ discard block |
||
582 | 584 | $imgUrl .= "?ma=" . $bbox ['minlat'] . "%2C" . $bbox ['minlon'] . "%2C" . $bbox ['maxlat'] . "%2C" . $bbox ['maxlon']; |
583 | 585 | $imgUrl .= "&dcl=1"; |
584 | 586 | } |
585 | - if (strpos ( $imgUrl, "?" ) === false) |
|
586 | - $imgUrl .= "?"; |
|
587 | + if (strpos ( $imgUrl, "?" ) === false) { |
|
588 | + $imgUrl .= "?"; |
|
589 | + } |
|
587 | 590 | |
588 | 591 | //$imgUrl .= "&ms=" . str_replace ( "px", "", $gmap ['width'] ) . "," . str_replace ( "px", "", $gmap ['height'] ); |
589 | 592 | $imgUrl .= "&ms=" . str_replace ( "px", "", $gmap ['width'] ) . "%2C" . str_replace ( "px", "", $gmap ['height'] ); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | 16 | */ |
17 | 17 | if (!defined('DOKU_INC')) die(); |
18 | -if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); |
|
18 | +if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); |
|
19 | 19 | require_once DOKU_PLUGIN.'openlayersmap/StaticMap.php'; |
20 | 20 | /** |
21 | 21 | * DokuWiki Plugin openlayersmap (staticmap Helper Component). |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @return array Information to all provided methods. |
36 | 36 | */ |
37 | - function getMethods(){ |
|
37 | + function getMethods() { |
|
38 | 38 | $result = array(); |
39 | 39 | $result[] = array( |
40 | 40 | 'name' => 'getMap', |
@@ -71,19 +71,19 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return the media id url |
73 | 73 | */ |
74 | - public function getMap($lat, $lon, $zoom, $size, $maptype, $markers, $gpx, $kml, $geojson, $apikey = ''){ |
|
74 | + public function getMap($lat, $lon, $zoom, $size, $maptype, $markers, $gpx, $kml, $geojson, $apikey = '') { |
|
75 | 75 | global $conf; |
76 | 76 | // dbglog($markers,'helper_plugin_openlayersmap_staticmap::getMap: markers :'); |
77 | 77 | |
78 | 78 | // normalize zoom |
79 | - $zoom = $zoom?intval($zoom):0; |
|
80 | - if($zoom > 18) $zoom = 18; |
|
79 | + $zoom = $zoom ?intval($zoom) : 0; |
|
80 | + if ($zoom > 18) $zoom = 18; |
|
81 | 81 | // normalize WxH |
82 | - list($width, $height) = explode('x',$size); |
|
82 | + list($width, $height) = explode('x', $size); |
|
83 | 83 | $width = intval($width); |
84 | - if($width > $this->maxWidth) $width = $this->maxWidth; |
|
84 | + if ($width > $this->maxWidth) $width = $this->maxWidth; |
|
85 | 85 | $height = intval($height); |
86 | - if($height > $this->maxHeight) $height = $this->maxHeight; |
|
86 | + if ($height > $this->maxHeight) $height = $this->maxHeight; |
|
87 | 87 | |
88 | 88 | // cleanup/validate gpx/kml |
89 | 89 | $kml = $this->mediaIdToPath($kml); |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | ); |
101 | 101 | |
102 | 102 | // return the media id url |
103 | - $mediaId = str_replace('/', ':', $map->getMap()); |
|
103 | + $mediaId = str_replace('/', ':', $map->getMap()); |
|
104 | 104 | // if($this->startsWith($mediaId,':')) { |
105 | 105 | // $mediaId = substr($mediaId, 1); |
106 | 106 | // } |
107 | 107 | return $mediaId; |
108 | 108 | } |
109 | 109 | |
110 | - private function startsWith($haystack, $needle) { |
|
110 | + private function startsWith($haystack, $needle) { |
|
111 | 111 | $length = strlen($needle); |
112 | 112 | return (substr($haystack, 0, $length) === $needle); |
113 | 113 | } |
@@ -117,17 +117,17 @@ discard block |
||
117 | 117 | * @param string $id the DW media id |
118 | 118 | * @return the path to the file |
119 | 119 | */ |
120 | - private function mediaIdToPath($id){ |
|
120 | + private function mediaIdToPath($id) { |
|
121 | 121 | global $conf; |
122 | - if(empty($id)) { |
|
122 | + if (empty($id)) { |
|
123 | 123 | return ""; |
124 | 124 | } |
125 | - $id=str_replace("[[","",$id); |
|
126 | - $id=str_replace("]]","",$id); |
|
127 | - if($this->startsWith($id,':')) { |
|
125 | + $id = str_replace("[[", "", $id); |
|
126 | + $id = str_replace("]]", "", $id); |
|
127 | + if ($this->startsWith($id, ':')) { |
|
128 | 128 | $id = substr($id, 1); |
129 | 129 | } |
130 | - $id=str_replace(":","/",$id); |
|
130 | + $id = str_replace(":", "/", $id); |
|
131 | 131 | return $conf['mediadir'].'/'.$id; |
132 | 132 | } |
133 | 133 | } |
@@ -14,8 +14,12 @@ discard block |
||
14 | 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
15 | 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | 16 | */ |
17 | -if (!defined('DOKU_INC')) die(); |
|
18 | -if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); |
|
17 | +if (!defined('DOKU_INC')) { |
|
18 | + die(); |
|
19 | +} |
|
20 | +if (!defined('DOKU_PLUGIN')) { |
|
21 | + define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); |
|
22 | +} |
|
19 | 23 | require_once DOKU_PLUGIN.'openlayersmap/StaticMap.php'; |
20 | 24 | /** |
21 | 25 | * DokuWiki Plugin openlayersmap (staticmap Helper Component). |
@@ -77,13 +81,19 @@ discard block |
||
77 | 81 | |
78 | 82 | // normalize zoom |
79 | 83 | $zoom = $zoom?intval($zoom):0; |
80 | - if($zoom > 18) $zoom = 18; |
|
84 | + if($zoom > 18) { |
|
85 | + $zoom = 18; |
|
86 | + } |
|
81 | 87 | // normalize WxH |
82 | 88 | list($width, $height) = explode('x',$size); |
83 | 89 | $width = intval($width); |
84 | - if($width > $this->maxWidth) $width = $this->maxWidth; |
|
90 | + if($width > $this->maxWidth) { |
|
91 | + $width = $this->maxWidth; |
|
92 | + } |
|
85 | 93 | $height = intval($height); |
86 | - if($height > $this->maxHeight) $height = $this->maxHeight; |
|
94 | + if($height > $this->maxHeight) { |
|
95 | + $height = $this->maxHeight; |
|
96 | + } |
|
87 | 97 | |
88 | 98 | // cleanup/validate gpx/kml |
89 | 99 | $kml = $this->mediaIdToPath($kml); |
@@ -31,7 +31,7 @@ |
||
31 | 31 | $lang['enableBing'] = 'Habilita Bing como proveedor de mapas'; |
32 | 32 | $lang['enableOSM'] = 'Habilita OpenStreetMap como proveedor de mapas'; |
33 | 33 | $lang['enableA11y'] = 'Habilita a11y/print para mapa estático, tabla de nombres'; |
34 | -$lang['optionStaticMapGenerator']='FIXME (translate)- Local or remote static map compiler. <b>Using \'local\' fails when the server can\'t go on the internet.</b>'; |
|
34 | +$lang['optionStaticMapGenerator'] = 'FIXME (translate)- Local or remote static map compiler. <b>Using \'local\' fails when the server can\'t go on the internet.</b>'; |
|
35 | 35 | $lang['autoZoomMap'] = 'FIXME (translate)- Enable auto zoom for the fallback map'; |
36 | 36 | $lang['displayformat'] = 'FIXME (translate)- Coordinates display format; decimal degrees or degrees, minutes, seconds'; |
37 | 37 | $lang['default_width'] = 'Default map width'; |
@@ -29,7 +29,7 @@ |
||
29 | 29 | $lang['enableBing'] = 'Activer l\'utilisation de Bing comme fournisseur de base de données cartographiques'; |
30 | 30 | $lang['enableOSM'] = 'Activer l\'utilisation d\'OpenStreetMap comme fournisseur de base de données cartographiques'; |
31 | 31 | $lang['enableA11y'] = 'Activer a11y/Sortie d\'impression (carte statique, table des légendes)'; |
32 | -$lang['optionStaticMapGenerator']='Compilateur de cartes statiques local ou distant. <b>L\'utilisation de \'local\' échoue lorsque le serveur ne peut pas accéder à Internet.</b>'; |
|
32 | +$lang['optionStaticMapGenerator'] = 'Compilateur de cartes statiques local ou distant. <b>L\'utilisation de \'local\' échoue lorsque le serveur ne peut pas accéder à Internet.</b>'; |
|
33 | 33 | $lang['autoZoomMap'] = 'Activer le zoom automatique pour la carte de secours'; |
34 | 34 | $lang['displayformat'] = 'Format d\'affichage des coordonnées; degrés décimaux ou degrés, minutes, secondes'; |
35 | 35 | $lang['default_width'] = 'Default map width'; |
@@ -29,7 +29,7 @@ |
||
29 | 29 | $lang['enableBing'] = 'Maak gebruik van Bing als basiskaart mogelijk'; |
30 | 30 | $lang['enableOSM'] = 'Maak gebruik van OpenStreetMap als basiskaart mogelijk'; |
31 | 31 | $lang['enableA11y'] = 'Maak a11y/print output (statische kaart, legenda tabel) mogelijk'; |
32 | -$lang['optionStaticMapGenerator']='Lokale of externe statische kaart generator. <b>Gebruik van \'local\' faalt als de webserver het internet niet op kan.</b>'; |
|
32 | +$lang['optionStaticMapGenerator'] = 'Lokale of externe statische kaart generator. <b>Gebruik van \'local\' faalt als de webserver het internet niet op kan.</b>'; |
|
33 | 33 | $lang['autoZoomMap'] = 'Zet automatisch zoomen aan voor de terugvalkaart'; |
34 | 34 | $lang['displayformat'] = 'Coördinaten weergave formaat; decimale graden of graden, minuten, seconden'; |
35 | 35 | $lang['default_width'] = 'Default map width'; |
@@ -30,7 +30,7 @@ |
||
30 | 30 | $lang['enableBing'] = 'Разрешить использование Bing как провайдера карт'; |
31 | 31 | $lang['enableOSM'] = 'Разрешить использование OpenStreetMap как провайдера карт'; |
32 | 32 | $lang['enableA11y'] = 'Разрешить вывод a11y/print (статическая карта, таблица с легендой)'; |
33 | -$lang['optionStaticMapGenerator']='Локальное (local) или удалённое (remote) хранилище статических карт. <b>Локальное хранилище не будет работать, если сервер не подключён к интернету.</b>'; |
|
33 | +$lang['optionStaticMapGenerator'] = 'Локальное (local) или удалённое (remote) хранилище статических карт. <b>Локальное хранилище не будет работать, если сервер не подключён к интернету.</b>'; |
|
34 | 34 | $lang['autoZoomMap'] = 'Разрешить автоматическое масштабирование для выпадающей карты'; |
35 | 35 | $lang['displayformat'] = 'Формат отображения координат: DD - градусы с дробной частью, DMS - градусы, минуты, секунды'; |
36 | 36 | $lang['default_width'] = 'Ширина карты по умолчанию'; |
@@ -29,7 +29,7 @@ |
||
29 | 29 | $lang['enableBing'] = 'Enable the use of Bing as basemap provider'; |
30 | 30 | $lang['enableOSM'] = 'Enable the use of OpenStreetMap as basemap provider'; |
31 | 31 | $lang['enableA11y'] = 'Enable a11y/print output (static map, legend table)'; |
32 | -$lang['optionStaticMapGenerator']='Local or remote static map compiler. <b>Using \'local\' fails when the server can\'t go on the internet.</b>'; |
|
32 | +$lang['optionStaticMapGenerator'] = 'Local or remote static map compiler. <b>Using \'local\' fails when the server can\'t go on the internet.</b>'; |
|
33 | 33 | $lang['autoZoomMap'] = 'Enable auto zoom for the fallback map'; |
34 | 34 | $lang['displayformat'] = 'Coordinates display format; decimal degrees or degrees, minutes, seconds'; |
35 | 35 | $lang['default_width'] = 'Default map width'; |
@@ -24,44 +24,44 @@ |
||
24 | 24 | */ |
25 | 25 | class general_plugin_openlayersmap_test extends DokuWikiTest { |
26 | 26 | |
27 | - protected $pluginsEnabled = array('openlayersmap','geophp'); |
|
27 | + protected $pluginsEnabled = array('openlayersmap','geophp'); |
|
28 | 28 | |
29 | - /** |
|
30 | - * Simple test to make sure the plugin.info.txt is in correct format |
|
31 | - */ |
|
32 | - public function test_plugininfo() { |
|
33 | - $file = __DIR__.'/../plugin.info.txt'; |
|
34 | - $this->assertFileExists($file); |
|
29 | + /** |
|
30 | + * Simple test to make sure the plugin.info.txt is in correct format |
|
31 | + */ |
|
32 | + public function test_plugininfo() { |
|
33 | + $file = __DIR__.'/../plugin.info.txt'; |
|
34 | + $this->assertFileExists($file); |
|
35 | 35 | |
36 | - $info = confToHash($file); |
|
36 | + $info = confToHash($file); |
|
37 | 37 | |
38 | - $this->assertArrayHasKey('base', $info); |
|
39 | - $this->assertArrayHasKey('author', $info); |
|
40 | - $this->assertArrayHasKey('email', $info); |
|
41 | - $this->assertArrayHasKey('date', $info); |
|
42 | - $this->assertArrayHasKey('name', $info); |
|
43 | - $this->assertArrayHasKey('desc', $info); |
|
44 | - $this->assertArrayHasKey('url', $info); |
|
38 | + $this->assertArrayHasKey('base', $info); |
|
39 | + $this->assertArrayHasKey('author', $info); |
|
40 | + $this->assertArrayHasKey('email', $info); |
|
41 | + $this->assertArrayHasKey('date', $info); |
|
42 | + $this->assertArrayHasKey('name', $info); |
|
43 | + $this->assertArrayHasKey('desc', $info); |
|
44 | + $this->assertArrayHasKey('url', $info); |
|
45 | 45 | |
46 | - $this->assertEquals('openlayersmap', $info['base']); |
|
47 | - $this->assertRegExp('/^https?:\/\//', $info['url']); |
|
48 | - $this->assertTrue(mail_isvalid($info['email'])); |
|
49 | - $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); |
|
50 | - $this->assertTrue(false !== strtotime($info['date'])); |
|
51 | - } |
|
46 | + $this->assertEquals('openlayersmap', $info['base']); |
|
47 | + $this->assertRegExp('/^https?:\/\//', $info['url']); |
|
48 | + $this->assertTrue(mail_isvalid($info['email'])); |
|
49 | + $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); |
|
50 | + $this->assertTrue(false !== strtotime($info['date'])); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * test if plugin is loaded. |
|
55 | - */ |
|
56 | - public function test_plugin_openlayersmap_isloaded() { |
|
57 | - global $plugin_controller; |
|
58 | - $this->assertTrue( |
|
59 | - in_array('geophp', $plugin_controller->getList()), |
|
60 | - "geophp plugin is loaded" |
|
61 | - ); |
|
62 | - $this->assertTrue( |
|
63 | - in_array('openlayersmap', $plugin_controller->getList()), |
|
64 | - "openlayersmap plugin is loaded" |
|
65 | - ); |
|
66 | - } |
|
53 | + /** |
|
54 | + * test if plugin is loaded. |
|
55 | + */ |
|
56 | + public function test_plugin_openlayersmap_isloaded() { |
|
57 | + global $plugin_controller; |
|
58 | + $this->assertTrue( |
|
59 | + in_array('geophp', $plugin_controller->getList()), |
|
60 | + "geophp plugin is loaded" |
|
61 | + ); |
|
62 | + $this->assertTrue( |
|
63 | + in_array('openlayersmap', $plugin_controller->getList()), |
|
64 | + "openlayersmap plugin is loaded" |
|
65 | + ); |
|
66 | + } |
|
67 | 67 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | */ |
25 | 25 | class general_plugin_openlayersmap_test extends DokuWikiTest { |
26 | 26 | |
27 | - protected $pluginsEnabled = array('openlayersmap','geophp'); |
|
27 | + protected $pluginsEnabled = array('openlayersmap', 'geophp'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Simple test to make sure the plugin.info.txt is in correct format |