@@ -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 | * |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $this->height = $height; |
175 | 175 | // validate + set maptype |
176 | 176 | $this->maptype = $this->tileDefaultSrc; |
177 | - if(array_key_exists($maptype, $this->tileInfo)) { |
|
177 | + if (array_key_exists($maptype, $this->tileInfo)) { |
|
178 | 178 | $this->maptype = $maptype; |
179 | 179 | } |
180 | 180 | $this->markers = $markers; |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | $this->gpxFileName = $gpx; |
183 | 183 | $this->geojsonFileName = $geojson; |
184 | 184 | $this->mediaBaseDir = $mediaDir; |
185 | - $this->tileCacheBaseDir = $tileCacheBaseDir . '/olmaptiles'; |
|
185 | + $this->tileCacheBaseDir = $tileCacheBaseDir.'/olmaptiles'; |
|
186 | 186 | $this->useTileCache = $this->tileCacheBaseDir !== ''; |
187 | - $this->mapCacheBaseDir = $mediaDir . '/olmapmaps'; |
|
187 | + $this->mapCacheBaseDir = $mediaDir.'/olmapmaps'; |
|
188 | 188 | $this->autoZoomExtent = $autoZoomExtent; |
189 | 189 | $this->apikey = $apikey; |
190 | 190 | } |
@@ -196,15 +196,15 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function getMap() { |
198 | 198 | try { |
199 | - if($this->autoZoomExtent) { |
|
199 | + if ($this->autoZoomExtent) { |
|
200 | 200 | $this->autoZoom(); |
201 | 201 | } |
202 | - } catch(Exception $e) { |
|
202 | + } catch (Exception $e) { |
|
203 | 203 | dbglog($e); |
204 | 204 | } |
205 | 205 | |
206 | 206 | // use map cache, so check cache for map |
207 | - if(!$this->checkMapCache()) { |
|
207 | + if (!$this->checkMapCache()) { |
|
208 | 208 | // map is not in cache, needs to be build |
209 | 209 | $this->makeMap(); |
210 | 210 | $this->mkdir_recursive(dirname($this->mapCacheIDToFilename()), 0777); |
@@ -226,38 +226,38 @@ discard block |
||
226 | 226 | */ |
227 | 227 | private function autoZoom($paddingFactor = 1.0) { |
228 | 228 | $geoms = array(); |
229 | - $geoms [] = new Point ($this->lon, $this->lat); |
|
230 | - if(!empty ($this->markers)) { |
|
231 | - foreach($this->markers as $marker) { |
|
232 | - $geoms [] = new Point ($marker ['lon'], $marker ['lat']); |
|
229 | + $geoms [] = new Point($this->lon, $this->lat); |
|
230 | + if (!empty ($this->markers)) { |
|
231 | + foreach ($this->markers as $marker) { |
|
232 | + $geoms [] = new Point($marker ['lon'], $marker ['lat']); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | $g = false; |
236 | - if(file_exists($this->kmlFileName)) { |
|
236 | + if (file_exists($this->kmlFileName)) { |
|
237 | 237 | $g = geoPHP::load(file_get_contents($this->kmlFileName), 'kml'); |
238 | - if($g !== false) { |
|
238 | + if ($g !== false) { |
|
239 | 239 | $geoms [] = $g; |
240 | 240 | } |
241 | 241 | } |
242 | - if(file_exists($this->gpxFileName)) { |
|
242 | + if (file_exists($this->gpxFileName)) { |
|
243 | 243 | $g = geoPHP::load(file_get_contents($this->gpxFileName), 'gpx'); |
244 | - if($g !== false) { |
|
244 | + if ($g !== false) { |
|
245 | 245 | $geoms [] = $g; |
246 | 246 | } |
247 | 247 | } |
248 | - if(file_exists($this->geojsonFileName)) { |
|
248 | + if (file_exists($this->geojsonFileName)) { |
|
249 | 249 | $g = geoPHP::load(file_get_contents($this->geojsonFileName), 'geojson'); |
250 | - if($g !== false) { |
|
250 | + if ($g !== false) { |
|
251 | 251 | $geoms [] = $g; |
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | - if(count($geoms) <= 1) { |
|
255 | + if (count($geoms) <= 1) { |
|
256 | 256 | dbglog($geoms, "StaticMap::autoZoom: Skip setting autozoom options"); |
257 | 257 | return; |
258 | 258 | } |
259 | 259 | |
260 | - $geom = new GeometryCollection ($geoms); |
|
260 | + $geom = new GeometryCollection($geoms); |
|
261 | 261 | $centroid = $geom->centroid(); |
262 | 262 | $bbox = $geom->getBBox(); |
263 | 263 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $resolution = max($resolutionHorizontal, $resolutionVertical) * $paddingFactor; |
274 | 274 | $zoom = log(360 / ($resolution * $this->tileSize), 2); |
275 | 275 | |
276 | - if(is_finite($zoom) && $zoom < 15 && $zoom > 2) { |
|
276 | + if (is_finite($zoom) && $zoom < 15 && $zoom > 2) { |
|
277 | 277 | $this->zoom = floor($zoom); |
278 | 278 | } |
279 | 279 | $this->lon = $centroid->getX(); |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | public function checkMapCache() { |
285 | 285 | $this->mapCacheID = md5($this->serializeParams()); |
286 | 286 | $filename = $this->mapCacheIDToFilename(); |
287 | - if(file_exists($filename)) |
|
287 | + if (file_exists($filename)) |
|
288 | 288 | return true; |
289 | 289 | } |
290 | 290 | |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | } |
307 | 307 | |
308 | 308 | public function mapCacheIDToFilename() { |
309 | - if(!$this->mapCacheFile) { |
|
310 | - $this->mapCacheFile = $this->mapCacheBaseDir . "/" . $this->maptype . "/" . $this->zoom . "/cache_" |
|
311 | - . substr($this->mapCacheID, 0, 2) . "/" . substr($this->mapCacheID, 2, 2) |
|
312 | - . "/" . substr($this->mapCacheID, 4); |
|
309 | + if (!$this->mapCacheFile) { |
|
310 | + $this->mapCacheFile = $this->mapCacheBaseDir."/".$this->maptype."/".$this->zoom."/cache_" |
|
311 | + . substr($this->mapCacheID, 0, 2)."/".substr($this->mapCacheID, 2, 2) |
|
312 | + . "/".substr($this->mapCacheID, 4); |
|
313 | 313 | } |
314 | - return $this->mapCacheFile . "." . $this->mapCacheExtension; |
|
314 | + return $this->mapCacheFile.".".$this->mapCacheExtension; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -320,13 +320,13 @@ discard block |
||
320 | 320 | public function makeMap() { |
321 | 321 | $this->initCoords(); |
322 | 322 | $this->createBaseMap(); |
323 | - if(!empty ($this->markers)) |
|
323 | + if (!empty ($this->markers)) |
|
324 | 324 | $this->placeMarkers(); |
325 | - if(file_exists($this->kmlFileName)) |
|
325 | + if (file_exists($this->kmlFileName)) |
|
326 | 326 | $this->drawKML(); |
327 | - if(file_exists($this->gpxFileName)) |
|
327 | + if (file_exists($this->gpxFileName)) |
|
328 | 328 | $this->drawGPX(); |
329 | - if(file_exists($this->geojsonFileName)) |
|
329 | + if (file_exists($this->geojsonFileName)) |
|
330 | 330 | $this->drawGeojson(); |
331 | 331 | |
332 | 332 | $this->drawCopyright(); |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | $this->offsetX += floor($startX - floor($this->centerX)) * $this->tileSize; |
378 | 378 | $this->offsetY += floor($startY - floor($this->centerY)) * $this->tileSize; |
379 | 379 | |
380 | - for($x = $startX; $x <= $endX; $x++) { |
|
381 | - for($y = $startY; $y <= $endY; $y++) { |
|
380 | + for ($x = $startX; $x <= $endX; $x++) { |
|
381 | + for ($y = $startY; $y <= $endY; $y++) { |
|
382 | 382 | $url = str_replace( |
383 | 383 | array( |
384 | 384 | '{Z}', |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | $url .= $this->apikey; |
394 | 394 | |
395 | 395 | $tileData = $this->fetchTile($url); |
396 | - if($tileData) { |
|
396 | + if ($tileData) { |
|
397 | 397 | $tileImage = imagecreatefromstring($tileData); |
398 | 398 | } else { |
399 | 399 | $tileImage = imagecreate($this->tileSize, $this->tileSize); |
@@ -417,11 +417,11 @@ discard block |
||
417 | 417 | * @param string $url |
418 | 418 | */ |
419 | 419 | public function fetchTile($url) { |
420 | - if($this->useTileCache && ($cached = $this->checkTileCache($url))) |
|
420 | + if ($this->useTileCache && ($cached = $this->checkTileCache($url))) |
|
421 | 421 | return $cached; |
422 | 422 | |
423 | - $_UA = 'Mozilla/4.0 (compatible; DokuWikiSpatial HTTP Client; ' . PHP_OS . ')'; |
|
424 | - if(function_exists("curl_init")) { |
|
423 | + $_UA = 'Mozilla/4.0 (compatible; DokuWikiSpatial HTTP Client; '.PHP_OS.')'; |
|
424 | + if (function_exists("curl_init")) { |
|
425 | 425 | // use cUrl |
426 | 426 | $ch = curl_init(); |
427 | 427 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
@@ -433,18 +433,18 @@ discard block |
||
433 | 433 | } else { |
434 | 434 | // use file_get_contents |
435 | 435 | global $conf; |
436 | - $opts = array( |
|
436 | + $opts = array( |
|
437 | 437 | 'http' => array( |
438 | 438 | 'method' => "GET", |
439 | - 'header' => "Accept-language: en\r\n" . "User-Agent: $_UA\r\n" . "accept: image/png\r\n", |
|
440 | - 'proxy' => "tcp://" . $conf ['proxy'] ['host'] . ":" . $conf ['proxy'] ['port'], |
|
439 | + 'header' => "Accept-language: en\r\n"."User-Agent: $_UA\r\n"."accept: image/png\r\n", |
|
440 | + 'proxy' => "tcp://".$conf ['proxy'] ['host'].":".$conf ['proxy'] ['port'], |
|
441 | 441 | 'request_fulluri' => true |
442 | 442 | ) |
443 | 443 | ); |
444 | 444 | $context = stream_context_create($opts); |
445 | 445 | $tile = file_get_contents($url, false, $context); |
446 | 446 | } |
447 | - if($tile && $this->useTileCache) { |
|
447 | + if ($tile && $this->useTileCache) { |
|
448 | 448 | $this->writeTileToCache($url, $tile); |
449 | 449 | } |
450 | 450 | return $tile; |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | */ |
457 | 457 | public function checkTileCache($url) { |
458 | 458 | $filename = $this->tileUrlToFilename($url); |
459 | - if(file_exists($filename)) { |
|
459 | + if (file_exists($filename)) { |
|
460 | 460 | return file_get_contents($filename); |
461 | 461 | } |
462 | 462 | } |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | * @return string |
468 | 468 | */ |
469 | 469 | public function tileUrlToFilename($url) { |
470 | - return $this->tileCacheBaseDir . "/" . str_replace( |
|
470 | + return $this->tileCacheBaseDir."/".str_replace( |
|
471 | 471 | array( |
472 | 472 | 'http://' |
473 | 473 | ), '', $url |
@@ -506,9 +506,9 @@ discard block |
||
506 | 506 | $count = 0; |
507 | 507 | $color = imagecolorallocate($this->image, 0, 0, 0); |
508 | 508 | $bgcolor = imagecolorallocate($this->image, 200, 200, 200); |
509 | - $markerBaseDir = dirname(__FILE__) . '/icons'; |
|
509 | + $markerBaseDir = dirname(__FILE__).'/icons'; |
|
510 | 510 | // loop thru marker array |
511 | - foreach($this->markers as $marker) { |
|
511 | + foreach ($this->markers as $marker) { |
|
512 | 512 | // set some local variables |
513 | 513 | $markerLat = $marker ['lat']; |
514 | 514 | $markerLon = $marker ['lon']; |
@@ -518,18 +518,18 @@ discard block |
||
518 | 518 | $markerShadow = ''; |
519 | 519 | $matches = false; |
520 | 520 | // check for marker type, get settings from markerPrototypes |
521 | - if($markerType) { |
|
522 | - foreach($this->markerPrototypes as $markerPrototype) { |
|
523 | - if(preg_match($markerPrototype ['regex'], $markerType, $matches)) { |
|
524 | - $markerFilename = $matches [0] . $markerPrototype ['extension']; |
|
525 | - if($markerPrototype ['offsetImage']) { |
|
521 | + if ($markerType) { |
|
522 | + foreach ($this->markerPrototypes as $markerPrototype) { |
|
523 | + if (preg_match($markerPrototype ['regex'], $markerType, $matches)) { |
|
524 | + $markerFilename = $matches [0].$markerPrototype ['extension']; |
|
525 | + if ($markerPrototype ['offsetImage']) { |
|
526 | 526 | list ($markerImageOffsetX, $markerImageOffsetY) = explode( |
527 | 527 | ",", |
528 | 528 | $markerPrototype ['offsetImage'] |
529 | 529 | ); |
530 | 530 | } |
531 | 531 | $markerShadow = $markerPrototype ['shadow']; |
532 | - if($markerShadow) { |
|
532 | + if ($markerShadow) { |
|
533 | 533 | list ($markerShadowOffsetX, $markerShadowOffsetY) = explode( |
534 | 534 | ",", |
535 | 535 | $markerPrototype ['offsetShadow'] |
@@ -539,20 +539,20 @@ discard block |
||
539 | 539 | } |
540 | 540 | } |
541 | 541 | // create img resource |
542 | - if(file_exists($markerBaseDir . '/' . $markerFilename)) { |
|
543 | - $markerImg = imagecreatefrompng($markerBaseDir . '/' . $markerFilename); |
|
542 | + if (file_exists($markerBaseDir.'/'.$markerFilename)) { |
|
543 | + $markerImg = imagecreatefrompng($markerBaseDir.'/'.$markerFilename); |
|
544 | 544 | } else { |
545 | - $markerImg = imagecreatefrompng($markerBaseDir . '/marker.png'); |
|
545 | + $markerImg = imagecreatefrompng($markerBaseDir.'/marker.png'); |
|
546 | 546 | } |
547 | 547 | // check for shadow + create shadow recource |
548 | - if($markerShadow && file_exists($markerBaseDir . '/' . $markerShadow)) { |
|
549 | - $markerShadowImg = imagecreatefrompng($markerBaseDir . '/' . $markerShadow); |
|
548 | + if ($markerShadow && file_exists($markerBaseDir.'/'.$markerShadow)) { |
|
549 | + $markerShadowImg = imagecreatefrompng($markerBaseDir.'/'.$markerShadow); |
|
550 | 550 | } |
551 | 551 | // calc position |
552 | 552 | $destX = floor(($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($markerLon, $this->zoom))); |
553 | 553 | $destY = floor(($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile($markerLat, $this->zoom))); |
554 | 554 | // copy shadow on basemap |
555 | - if($markerShadow && $markerShadowImg) { |
|
555 | + if ($markerShadow && $markerShadowImg) { |
|
556 | 556 | imagecopy($this->image, $markerShadowImg, $destX + intval($markerShadowOffsetX), $destY + intval($markerShadowOffsetY), 0, 0, imagesx($markerShadowImg), imagesy($markerShadowImg)); |
557 | 557 | } |
558 | 558 | // copy marker on basemap above shadow |
@@ -581,12 +581,12 @@ discard block |
||
581 | 581 | * drawing colour |
582 | 582 | */ |
583 | 583 | private function drawGeometry($geom, $colour) { |
584 | - if(empty($geom)) return; |
|
584 | + if (empty($geom)) return; |
|
585 | 585 | |
586 | - switch($geom->geometryType()) { |
|
586 | + switch ($geom->geometryType()) { |
|
587 | 587 | case 'GeometryCollection' : |
588 | 588 | // recursively draw part of the collection |
589 | - for($i = 1; $i < $geom->numGeometries() + 1; $i++) { |
|
589 | + for ($i = 1; $i < $geom->numGeometries() + 1; $i++) { |
|
590 | 590 | $_geom = $geom->geometryN($i); |
591 | 591 | $this->drawGeometry($_geom, $colour); |
592 | 592 | } |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | // extring is a linestring actually.. |
629 | 629 | $extRing = $polygon->exteriorRing(); |
630 | 630 | |
631 | - for($i = 1; $i < $extRing->numGeometries(); $i++) { |
|
631 | + for ($i = 1; $i < $extRing->numGeometries(); $i++) { |
|
632 | 632 | $p1 = $extRing->geometryN($i); |
633 | 633 | $x = floor(($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($p1->x(), $this->zoom))); |
634 | 634 | $y = floor(($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile($p1->y(), $this->zoom))); |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | */ |
651 | 651 | private function drawLineString($line, $colour) { |
652 | 652 | imagesetthickness($this->image, 2); |
653 | - for($p = 1; $p < $line->numGeometries(); $p++) { |
|
653 | + for ($p = 1; $p < $line->numGeometries(); $p++) { |
|
654 | 654 | // get first pair of points |
655 | 655 | $p1 = $line->geometryN($p); |
656 | 656 | $p2 = $line->geometryN($p + 1); |
@@ -709,8 +709,8 @@ discard block |
||
709 | 709 | * add copyright and origin notice and icons to the map. |
710 | 710 | */ |
711 | 711 | public function drawCopyright() { |
712 | - $logoBaseDir = dirname(__FILE__) . '/' . 'logo/'; |
|
713 | - $logoImg = imagecreatefrompng($logoBaseDir . $this->tileInfo ['openstreetmap'] ['logo']); |
|
712 | + $logoBaseDir = dirname(__FILE__).'/'.'logo/'; |
|
713 | + $logoImg = imagecreatefrompng($logoBaseDir.$this->tileInfo ['openstreetmap'] ['logo']); |
|
714 | 714 | $textcolor = imagecolorallocate($this->image, 0, 0, 0); |
715 | 715 | $bgcolor = imagecolorallocate($this->image, 200, 200, 200); |
716 | 716 | |
@@ -719,8 +719,8 @@ discard block |
||
719 | 719 | imagestring($this->image, 1, imagesx($logoImg) + 1, imagesy($this->image) - imagesy($logoImg), $this->tileInfo ['openstreetmap'] ['txt'], $textcolor); |
720 | 720 | |
721 | 721 | // additional tile source info, ie. who created/hosted the tiles |
722 | - if($this->maptype != 'openstreetmap') { |
|
723 | - $iconImg = imagecreatefrompng($logoBaseDir . $this->tileInfo [$this->maptype] ['logo']); |
|
722 | + if ($this->maptype != 'openstreetmap') { |
|
723 | + $iconImg = imagecreatefrompng($logoBaseDir.$this->tileInfo [$this->maptype] ['logo']); |
|
724 | 724 | imagecopy($this->image, $iconImg, imagesx($logoImg) + 1, imagesy($this->image) - imagesy($iconImg), 0, 0, imagesx($iconImg), imagesy($iconImg)); |
725 | 725 | imagestring($this->image, 1, imagesx($logoImg) + imagesx($iconImg) + 4, imagesy($this->image) - ceil(imagesy($logoImg) / 2) + 1, $this->tileInfo [$this->maptype] ['txt'], $bgcolor); |
726 | 726 | imagestring($this->image, 1, imagesx($logoImg) + imagesx($iconImg) + 3, imagesy($this->image) - ceil(imagesy($logoImg) / 2), $this->tileInfo [$this->maptype] ['txt'], $textcolor); |
@@ -39,7 +39,7 @@ |
||
39 | 39 | * @param Doku_Event $event the DokuWiki event |
40 | 40 | */ |
41 | 41 | public function insertButton(Doku_Event $event, $param) { |
42 | - $strOpen = '<olmap id="olMapOne" width="550px" height="450px" lat="50.0" '; |
|
42 | + $strOpen = '<olmap id="olMapOne" width="550px" height="450px" lat="50.0" '; |
|
43 | 43 | $strOpen .= 'lon="5.1" zoom="12" statusbar="1" controls="1" poihoverstyle="0" '; |
44 | 44 | $strOpen .= 'baselyr="OpenStreetMap" gpxfile="" kmlfile="" geojsonfile="" summary="" >\n'; |
45 | 45 | $strOpen .= '~~ Plugin olmap help.\n'; |
@@ -42,8 +42,8 @@ |
||
42 | 42 | </head> |
43 | 43 | <body> |
44 | 44 | <div class="box"><?php |
45 | - foreach(glob('*.png') as $img) { |
|
46 | - echo '<img src="' . $img . '" alt="' . $img . '" title="' . $img . '" /> '; |
|
45 | + foreach (glob('*.png') as $img) { |
|
46 | + echo '<img src="'.$img.'" alt="'.$img.'" title="'.$img.'" /> '; |
|
47 | 47 | } |
48 | 48 | ?></div> |
49 | 49 | </body> |
@@ -80,17 +80,17 @@ discard block |
||
80 | 80 | |
81 | 81 | // normalize zoom |
82 | 82 | $zoom = $zoom ?: 0; |
83 | - if($zoom > 18) { |
|
83 | + if ($zoom > 18) { |
|
84 | 84 | $zoom = 18; |
85 | 85 | } |
86 | 86 | // normalize WxH |
87 | 87 | list($width, $height) = explode('x', $size); |
88 | 88 | $width = (int) $width; |
89 | - if($width > $this->maxWidth) { |
|
89 | + if ($width > $this->maxWidth) { |
|
90 | 90 | $width = $this->maxWidth; |
91 | 91 | } |
92 | 92 | $height = (int) $height; |
93 | - if($height > $this->maxHeight) { |
|
93 | + if ($height > $this->maxHeight) { |
|
94 | 94 | $height = $this->maxHeight; |
95 | 95 | } |
96 | 96 | |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | */ |
126 | 126 | private function mediaIdToPath(string $id): string { |
127 | 127 | global $conf; |
128 | - if(empty($id)) { |
|
128 | + if (empty($id)) { |
|
129 | 129 | return ""; |
130 | 130 | } |
131 | 131 | $id = str_replace(array("[[", "]]"), "", $id); |
132 | - if((strpos($id, ':') === 0)) { |
|
132 | + if ((strpos($id, ':') === 0)) { |
|
133 | 133 | $id = substr($id, 1); |
134 | 134 | } |
135 | 135 | $id = str_replace(":", "/", $id); |
136 | - return $conf['mediadir'] . '/' . $id; |
|
136 | + return $conf['mediadir'].'/'.$id; |
|
137 | 137 | } |
138 | 138 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | * Simple test to make sure the plugin.info.txt is in correct format. |
31 | 31 | */ |
32 | 32 | final public function test_plugininfo(): void { |
33 | - $file = __DIR__ . '/../plugin.info.txt'; |
|
33 | + $file = __DIR__.'/../plugin.info.txt'; |
|
34 | 34 | self::assertFileExists($file); |
35 | 35 | |
36 | 36 | $info = confToHash($file); |
@@ -38,18 +38,18 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function handle(): void { |
40 | 40 | global $conf; |
41 | - if(!isset($_REQUEST['continue']) || !checkSecurityToken()) { |
|
41 | + if (!isset($_REQUEST['continue']) || !checkSecurityToken()) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | - if(isset($_REQUEST['purgetiles'])) { |
|
45 | - $path = $conf['cachedir'] . '/olmaptiles'; |
|
46 | - if($this->rrmdir($path)) { |
|
44 | + if (isset($_REQUEST['purgetiles'])) { |
|
45 | + $path = $conf['cachedir'].'/olmaptiles'; |
|
46 | + if ($this->rrmdir($path)) { |
|
47 | 47 | msg($this->getLang('admin_purged_tiles'), 0); |
48 | 48 | } |
49 | 49 | } |
50 | - if(isset($_REQUEST['purgemaps'])) { |
|
51 | - $path = $conf['mediadir'] . '/olmapmaps'; |
|
52 | - if($this->rrmdir($path)) { |
|
50 | + if (isset($_REQUEST['purgemaps'])) { |
|
51 | + $path = $conf['mediadir'].'/olmapmaps'; |
|
52 | + if ($this->rrmdir($path)) { |
|
53 | 53 | msg($this->getLang('admin_purged_maps'), 0); |
54 | 54 | } |
55 | 55 | } |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | * @return boolean true when succesful |
62 | 62 | */ |
63 | 63 | private function rrmdir(string $sDir): bool { |
64 | - if(is_dir($sDir)) { |
|
64 | + if (is_dir($sDir)) { |
|
65 | 65 | dbglog($sDir, 'admin_plugin_openlayersmap_purge::rrmdir: recursively removing path: '); |
66 | 66 | $sDir = rtrim($sDir, '/'); |
67 | 67 | $oDir = dir($sDir); |
68 | - while(($sFile = $oDir->read()) !== false) { |
|
69 | - if($sFile !== '.' && $sFile !== '..') { |
|
68 | + while (($sFile = $oDir->read()) !== false) { |
|
69 | + if ($sFile !== '.' && $sFile !== '..') { |
|
70 | 70 | (!is_link("$sDir/$sFile") && is_dir("$sDir/$sFile")) ? |
71 | 71 | $this->rrmdir("$sDir/$sFile") : unlink("$sDir/$sFile"); |
72 | 72 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | '<input id="purgetiles" name="purgetiles" type="checkbox" value="1" class="checkbox" />' |
94 | 94 | ); |
95 | 95 | $form->addElement( |
96 | - '<label for="purgetiles" class="label">' . $this->getLang('admin_purge_tiles') |
|
96 | + '<label for="purgetiles" class="label">'.$this->getLang('admin_purge_tiles') |
|
97 | 97 | . '</label>' |
98 | 98 | ); |
99 | 99 | $form->addElement('</p>'); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $form->addElement('<p>'); |
104 | 104 | $form->addElement('<input id="purgemaps" name="purgemaps" type="checkbox" value="1" class="checkbox" />'); |
105 | 105 | $form->addElement( |
106 | - '<label for="purgemaps" class="label">' . $this->getLang('admin_purge_maps') . '</label>' |
|
106 | + '<label for="purgemaps" class="label">'.$this->getLang('admin_purge_maps').'</label>' |
|
107 | 107 | ); |
108 | 108 | $form->addElement('</p>'); |
109 | 109 | $form->endFieldset(); |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | preg_match('(lon[:|=]\"-?\d*\.?\d*\")', $match, $mainLon); |
95 | 95 | $mainLat = substr($mainLat [0], 5, -1); |
96 | 96 | $mainLon = substr($mainLon [0], 5, -1); |
97 | - if(!is_numeric($mainLat)) { |
|
97 | + if (!is_numeric($mainLat)) { |
|
98 | 98 | $mainLat = $this->dflt ['lat']; |
99 | 99 | } |
100 | - if(!is_numeric($mainLon)) { |
|
100 | + if (!is_numeric($mainLon)) { |
|
101 | 101 | $mainLon = $this->dflt ['lon']; |
102 | 102 | } |
103 | 103 | |
@@ -108,23 +108,23 @@ discard block |
||
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 | 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 | 119 | $_firstimageID = $this->getStaticOSM($gmap, $overlay); |
120 | - $imgUrl .= $_firstimageID; |
|
121 | - if($this->getConf('optionStaticMapGenerator') == 'remote') { |
|
120 | + $imgUrl .= $_firstimageID; |
|
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 |
@@ -142,33 +142,33 @@ discard block |
||
142 | 142 | } */ else { |
143 | 143 | // default OSM |
144 | 144 | $_firstimageID = $this->getStaticOSM($gmap, $overlay); |
145 | - $imgUrl .= $_firstimageID; |
|
146 | - if($this->getConf('optionStaticMapGenerator') == 'remote') { |
|
145 | + $imgUrl .= $_firstimageID; |
|
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" |
|
152 | + $imgUrl .= "?".str_replace("px", "", $gmap ['width'])."x" |
|
153 | 153 | . str_replace("px", "", $gmap ['height']); |
154 | 154 | $imgUrl .= "&nolink"; |
155 | 155 | |
156 | 156 | // add nocache option for selected services |
157 | - if($_nocache) { |
|
157 | + if ($_nocache) { |
|
158 | 158 | $imgUrl .= "&nocache"; |
159 | 159 | } |
160 | 160 | |
161 | - $imgUrl .= " |" . $gmap ['summary'] . " }}"; |
|
161 | + $imgUrl .= " |".$gmap ['summary']." }}"; |
|
162 | 162 | |
163 | 163 | // dbglog($imgUrl,"complete image tags is:"); |
164 | 164 | |
165 | 165 | $mapid = $gmap ['id']; |
166 | 166 | // create a javascript parameter string for the map |
167 | 167 | $param = ''; |
168 | - foreach($gmap as $key => $val) { |
|
169 | - $param .= is_numeric($val) ? "$key: $val, " : "$key: '" . hsc($val) . "', "; |
|
168 | + foreach ($gmap as $key => $val) { |
|
169 | + $param .= is_numeric($val) ? "$key: $val, " : "$key: '".hsc($val)."', "; |
|
170 | 170 | } |
171 | - if(!empty ($param)) { |
|
171 | + if (!empty ($param)) { |
|
172 | 172 | $param = substr($param, 0, -2); |
173 | 173 | } |
174 | 174 | unset ($gmap ['id']); |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | $poi = ''; |
178 | 178 | $poitable = ''; |
179 | 179 | $rowId = 0; |
180 | - if(!empty ($overlay)) { |
|
181 | - foreach($overlay as $data) { |
|
180 | + if (!empty ($overlay)) { |
|
181 | + foreach ($overlay as $data) { |
|
182 | 182 | list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
183 | 183 | $rowId++; |
184 | 184 | $poi .= ", {lat:$lat,lon:$lon,txt:'$text',angle:$angle,opacity:$opacity,img:'$img',rowId: $rowId}"; |
185 | 185 | |
186 | - if($this->getConf('displayformat') === 'DMS') { |
|
186 | + if ($this->getConf('displayformat') === 'DMS') { |
|
187 | 187 | $lat = $this->convertLat($lat); |
188 | 188 | $lon = $this->convertLon($lon); |
189 | 189 | } else { |
@@ -193,52 +193,52 @@ discard block |
||
193 | 193 | |
194 | 194 | $poitable .= ' |
195 | 195 | <tr> |
196 | - <td class="rowId">' . $rowId . '</td> |
|
197 | - <td class="icon"><img src="' . DOKU_BASE . 'lib/plugins/openlayersmap/icons/' . $img . '" alt="' |
|
198 | - . substr($img, 0, -4) . $this->getlang('alt_legend_poi') . ' " /></td> |
|
199 | - <td class="lat" title="' . $this->getLang('olmapPOIlatTitle') . '">' . $lat . '</td> |
|
200 | - <td class="lon" title="' . $this->getLang('olmapPOIlonTitle') . '">' . $lon . '</td> |
|
201 | - <td class="txt">' . $text . '</td> |
|
196 | + <td class="rowId">' . $rowId.'</td> |
|
197 | + <td class="icon"><img src="' . DOKU_BASE.'lib/plugins/openlayersmap/icons/'.$img.'" alt="' |
|
198 | + . substr($img, 0, -4).$this->getlang('alt_legend_poi').' " /></td> |
|
199 | + <td class="lat" title="' . $this->getLang('olmapPOIlatTitle').'">'.$lat.'</td> |
|
200 | + <td class="lon" title="' . $this->getLang('olmapPOIlonTitle').'">'.$lon.'</td> |
|
201 | + <td class="txt">' . $text.'</td> |
|
202 | 202 | </tr>'; |
203 | 203 | } |
204 | 204 | $poi = substr($poi, 2); |
205 | 205 | } |
206 | - if(!empty ($gmap ['kmlfile'])) { |
|
206 | + if (!empty ($gmap ['kmlfile'])) { |
|
207 | 207 | $poitable .= ' |
208 | 208 | <tr> |
209 | 209 | <td class="rowId"><img src="' . DOKU_BASE |
210 | 210 | . 'lib/plugins/openlayersmap/toolbar/kml_file.png" alt="KML file" /></td> |
211 | - <td class="icon"><img src="' . DOKU_BASE . 'lib/plugins/openlayersmap/toolbar/kml_line.png" alt="' |
|
212 | - . $this->getlang('alt_legend_kml') . '" /></td> |
|
213 | - <td class="txt" colspan="3">KML track: ' . $this->getFileName($gmap ['kmlfile']) . '</td> |
|
211 | + <td class="icon"><img src="' . DOKU_BASE.'lib/plugins/openlayersmap/toolbar/kml_line.png" alt="' |
|
212 | + . $this->getlang('alt_legend_kml').'" /></td> |
|
213 | + <td class="txt" colspan="3">KML track: ' . $this->getFileName($gmap ['kmlfile']).'</td> |
|
214 | 214 | </tr>'; |
215 | 215 | } |
216 | - if(!empty ($gmap ['gpxfile'])) { |
|
216 | + if (!empty ($gmap ['gpxfile'])) { |
|
217 | 217 | $poitable .= ' |
218 | 218 | <tr> |
219 | 219 | <td class="rowId"><img src="' . DOKU_BASE |
220 | 220 | . 'lib/plugins/openlayersmap/toolbar/gpx_file.png" alt="GPX file" /></td> |
221 | 221 | <td class="icon"><img src="' . DOKU_BASE |
222 | 222 | . 'lib/plugins/openlayersmap/toolbar/gpx_line.png" alt="' |
223 | - . $this->getlang('alt_legend_gpx') . '" /></td> |
|
224 | - <td class="txt" colspan="3">GPX track: ' . $this->getFileName($gmap ['gpxfile']) . '</td> |
|
223 | + . $this->getlang('alt_legend_gpx').'" /></td> |
|
224 | + <td class="txt" colspan="3">GPX track: ' . $this->getFileName($gmap ['gpxfile']).'</td> |
|
225 | 225 | </tr>'; |
226 | 226 | } |
227 | - if(!empty ($gmap ['geojsonfile'])) { |
|
227 | + if (!empty ($gmap ['geojsonfile'])) { |
|
228 | 228 | $poitable .= ' |
229 | 229 | <tr> |
230 | 230 | <td class="rowId"><img src="' . DOKU_BASE |
231 | 231 | . 'lib/plugins/openlayersmap/toolbar/geojson_file.png" alt="GeoJSON file" /></td> |
232 | 232 | <td class="icon"><img src="' . DOKU_BASE |
233 | 233 | . 'lib/plugins/openlayersmap/toolbar/geojson_line.png" alt="' |
234 | - . $this->getlang('alt_legend_geojson') . '" /></td> |
|
235 | - <td class="txt" colspan="3">GeoJSON track: ' . $this->getFileName($gmap ['geojsonfile']) . '</td> |
|
234 | + . $this->getlang('alt_legend_geojson').'" /></td> |
|
235 | + <td class="txt" colspan="3">GeoJSON track: ' . $this->getFileName($gmap ['geojsonfile']).'</td> |
|
236 | 236 | </tr>'; |
237 | 237 | } |
238 | 238 | |
239 | 239 | $autozoom = empty ($gmap ['autozoom']) ? $this->getConf('autoZoomMap') : $gmap ['autozoom']; |
240 | - $js = "{mapOpts: {" . $param . ", displayformat: '" . $this->getConf('displayformat') |
|
241 | - . "', autozoom: " . $autozoom . "}, poi: [$poi]};"; |
|
240 | + $js = "{mapOpts: {".$param.", displayformat: '".$this->getConf('displayformat') |
|
241 | + . "', autozoom: ".$autozoom."}, poi: [$poi]};"; |
|
242 | 242 | // unescape the json |
243 | 243 | $poitable = stripslashes($poitable); |
244 | 244 | |
@@ -266,21 +266,21 @@ discard block |
||
266 | 266 | preg_match_all('/(\w*)="(.*?)"/us', $str_params, $param, PREG_SET_ORDER); |
267 | 267 | // parse match for instructions, break into key value pairs |
268 | 268 | $gmap = $this->dflt; |
269 | - foreach($gmap as $key => &$value) { |
|
270 | - $defval = $this->getConf('default_' . $key); |
|
271 | - if($defval !== '') { |
|
269 | + foreach ($gmap as $key => &$value) { |
|
270 | + $defval = $this->getConf('default_'.$key); |
|
271 | + if ($defval !== '') { |
|
272 | 272 | $value = $defval; |
273 | 273 | } |
274 | 274 | } |
275 | 275 | unset ($value); |
276 | - foreach($param as $kvpair) { |
|
276 | + foreach ($param as $kvpair) { |
|
277 | 277 | list ($match, $key, $val) = $kvpair; |
278 | 278 | $key = strtolower($key); |
279 | - if(isset ($gmap [$key])) { |
|
280 | - if($key == 'summary') { |
|
279 | + if (isset ($gmap [$key])) { |
|
280 | + if ($key == 'summary') { |
|
281 | 281 | // preserve case for summary field |
282 | 282 | $gmap [$key] = $val; |
283 | - } elseif($key == 'id') { |
|
283 | + } elseif ($key == 'id') { |
|
284 | 284 | // preserve case for id field |
285 | 285 | $gmap [$key] = $val; |
286 | 286 | } else { |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | ); |
317 | 317 | // create poi array |
318 | 318 | $overlay = array(); |
319 | - foreach($point as $pt) { |
|
319 | + foreach ($point as $pt) { |
|
320 | 320 | list ($match, $lat, $lon, $angle, $opacity, $img, $text) = $pt; |
321 | 321 | $lat = is_numeric($lat) ? $lat : 0; |
322 | 322 | $lon = is_numeric($lon) ? $lon : 0; |
@@ -350,10 +350,10 @@ discard block |
||
350 | 350 | */ |
351 | 351 | private function getGoogle(array $gmap, array $overlay): string { |
352 | 352 | $sUrl = $this->getConf('iconUrlOverload'); |
353 | - if(!$sUrl) { |
|
353 | + if (!$sUrl) { |
|
354 | 354 | $sUrl = DOKU_URL; |
355 | 355 | } |
356 | - switch($gmap ['baselyr']) { |
|
356 | + switch ($gmap ['baselyr']) { |
|
357 | 357 | case 'google hybrid' : |
358 | 358 | $maptype = 'hybrid'; |
359 | 359 | break; |
@@ -373,29 +373,29 @@ discard block |
||
373 | 373 | // see: https://developers.google.com/maps/documentation/staticmaps/index#Viewports |
374 | 374 | // 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 |
375 | 375 | $imgUrl = "https://maps.googleapis.com/maps/api/staticmap?"; |
376 | - $imgUrl .= "&size=" . str_replace("px", "", $gmap ['width']) . "x" |
|
376 | + $imgUrl .= "&size=".str_replace("px", "", $gmap ['width'])."x" |
|
377 | 377 | . str_replace("px", "", $gmap ['height']); |
378 | 378 | //if (!$this->getConf( 'autoZoomMap')) { // no need for center & zoom params } |
379 | - $imgUrl .= "¢er=" . $gmap ['lat'] . "," . $gmap ['lon']; |
|
379 | + $imgUrl .= "¢er=".$gmap ['lat'].",".$gmap ['lon']; |
|
380 | 380 | // max is 21 (== building scale), but that's overkill.. |
381 | - if($gmap ['zoom'] > 17) { |
|
381 | + if ($gmap ['zoom'] > 17) { |
|
382 | 382 | $imgUrl .= "&zoom=17"; |
383 | 383 | } else { |
384 | - $imgUrl .= "&zoom=" . $gmap ['zoom']; |
|
384 | + $imgUrl .= "&zoom=".$gmap ['zoom']; |
|
385 | 385 | } |
386 | - if(!empty ($overlay)) { |
|
386 | + if (!empty ($overlay)) { |
|
387 | 387 | $rowId = 0; |
388 | - foreach($overlay as $data) { |
|
388 | + foreach ($overlay as $data) { |
|
389 | 389 | list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
390 | - $imgUrl .= "&markers=icon%3a" . $sUrl . "lib/plugins/openlayersmap/icons/" . $img . "%7c" |
|
391 | - . $lat . "," . $lon . "%7clabel%3a" . ++$rowId; |
|
390 | + $imgUrl .= "&markers=icon%3a".$sUrl."lib/plugins/openlayersmap/icons/".$img."%7c" |
|
391 | + . $lat.",".$lon."%7clabel%3a".++$rowId; |
|
392 | 392 | } |
393 | 393 | } |
394 | - $imgUrl .= "&format=png&maptype=" . $maptype; |
|
394 | + $imgUrl .= "&format=png&maptype=".$maptype; |
|
395 | 395 | global $conf; |
396 | - $imgUrl .= "&language=" . $conf ['lang']; |
|
397 | - if($this->getConf('googleAPIkey')) { |
|
398 | - $imgUrl .= "&key=" . $this->getConf('googleAPIkey'); |
|
396 | + $imgUrl .= "&language=".$conf ['lang']; |
|
397 | + if ($this->getConf('googleAPIkey')) { |
|
398 | + $imgUrl .= "&key=".$this->getConf('googleAPIkey'); |
|
399 | 399 | } |
400 | 400 | // dbglog($imgUrl,'syntax_plugin_openlayersmap_olmap::getGoogle: Google image url is:'); |
401 | 401 | return $imgUrl; |
@@ -478,23 +478,23 @@ discard block |
||
478 | 478 | private function getStaticOSM(array $gmap, array $overlay) { |
479 | 479 | global $conf; |
480 | 480 | |
481 | - if($this->getConf('optionStaticMapGenerator') == 'local') { |
|
481 | + if ($this->getConf('optionStaticMapGenerator') == 'local') { |
|
482 | 482 | // using local basemap composer |
483 | - if(!$myMap = plugin_load('helper', 'openlayersmap_staticmap')) { |
|
483 | + if (!$myMap = plugin_load('helper', 'openlayersmap_staticmap')) { |
|
484 | 484 | dbglog( |
485 | 485 | $myMap, |
486 | 486 | 'openlayersmap_staticmap plugin is not available for use.' |
487 | 487 | ); |
488 | 488 | } |
489 | - if(!$geophp = plugin_load('helper', 'geophp')) { |
|
489 | + if (!$geophp = plugin_load('helper', 'geophp')) { |
|
490 | 490 | dbglog($geophp, 'geophp plugin is not available for use.'); |
491 | 491 | } |
492 | - $size = str_replace("px", "", $gmap ['width']) . "x" |
|
492 | + $size = str_replace("px", "", $gmap ['width'])."x" |
|
493 | 493 | . str_replace("px", "", $gmap ['height']); |
494 | 494 | |
495 | 495 | $markers = array(); |
496 | - if(!empty ($overlay)) { |
|
497 | - foreach($overlay as $data) { |
|
496 | + if (!empty ($overlay)) { |
|
497 | + foreach ($overlay as $data) { |
|
498 | 498 | list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
499 | 499 | $iconStyle = substr($img, 0, strlen($img) - 4); |
500 | 500 | $markers [] = array( |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | } |
507 | 507 | |
508 | 508 | $apikey = ''; |
509 | - switch($gmap ['baselyr']) { |
|
509 | + switch ($gmap ['baselyr']) { |
|
510 | 510 | case 'mapnik' : |
511 | 511 | case 'openstreetmap' : |
512 | 512 | $maptype = 'openstreetmap'; |
@@ -554,25 +554,25 @@ discard block |
||
554 | 554 | // ol-marker|47.921629720114,18.027343747285,ol-marker-gold|47.951071133739,19.257812497236, |
555 | 555 | // ol-marker-blue|47.180141361692,19.257812497236,ol-marker-green |
556 | 556 | $imgUrl = "https://staticmap.openstreetmap.de/staticmap.php"; |
557 | - $imgUrl .= "?center=" . $gmap ['lat'] . "," . $gmap ['lon']; |
|
558 | - $imgUrl .= "&size=" . str_replace("px", "", $gmap ['width']) . "x" |
|
557 | + $imgUrl .= "?center=".$gmap ['lat'].",".$gmap ['lon']; |
|
558 | + $imgUrl .= "&size=".str_replace("px", "", $gmap ['width'])."x" |
|
559 | 559 | . str_replace("px", "", $gmap ['height']); |
560 | 560 | |
561 | - if($gmap ['zoom'] > 16) { |
|
561 | + if ($gmap ['zoom'] > 16) { |
|
562 | 562 | // actually this could even be 18, but that seems overkill |
563 | 563 | $imgUrl .= "&zoom=16"; |
564 | 564 | } else { |
565 | - $imgUrl .= "&zoom=" . $gmap ['zoom']; |
|
565 | + $imgUrl .= "&zoom=".$gmap ['zoom']; |
|
566 | 566 | } |
567 | 567 | |
568 | - if(!empty ($overlay)) { |
|
569 | - $rowId = 0; |
|
568 | + if (!empty ($overlay)) { |
|
569 | + $rowId = 0; |
|
570 | 570 | $imgUrl .= "&markers="; |
571 | - foreach($overlay as $data) { |
|
571 | + foreach ($overlay as $data) { |
|
572 | 572 | list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
573 | 573 | $rowId++; |
574 | 574 | $iconStyle = "lightblue$rowId"; |
575 | - $imgUrl .= "$lat,$lon,$iconStyle%7c"; |
|
575 | + $imgUrl .= "$lat,$lon,$iconStyle%7c"; |
|
576 | 576 | } |
577 | 577 | $imgUrl = substr($imgUrl, 0, -3); |
578 | 578 | } |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | * @return string |
592 | 592 | */ |
593 | 593 | private function getBing(array $gmap, array $overlay): string { |
594 | - switch($gmap ['baselyr']) { |
|
594 | + switch ($gmap ['baselyr']) { |
|
595 | 595 | case 've hybrid' : |
596 | 596 | case 'bing hybrid' : |
597 | 597 | $maptype = 'AerialWithLabels'; |
@@ -608,33 +608,33 @@ discard block |
||
608 | 608 | $maptype = 'Road'; |
609 | 609 | break; |
610 | 610 | } |
611 | - $imgUrl = "https://dev.virtualearth.net/REST/v1/Imagery/Map/" . $maptype;// . "/"; |
|
612 | - if($this->getConf('autoZoomMap')) { |
|
611 | + $imgUrl = "https://dev.virtualearth.net/REST/v1/Imagery/Map/".$maptype; // . "/"; |
|
612 | + if ($this->getConf('autoZoomMap')) { |
|
613 | 613 | $bbox = $this->calcBBOX($overlay, $gmap ['lat'], $gmap ['lon']); |
614 | 614 | //$imgUrl .= "?ma=" . $bbox ['minlat'] . "," . $bbox ['minlon'] . "," |
615 | 615 | // . $bbox ['maxlat'] . "," . $bbox ['maxlon']; |
616 | - $imgUrl .= "?ma=" . $bbox ['minlat'] . "%2C" . $bbox ['minlon'] . "%2C" . $bbox ['maxlat'] |
|
617 | - . "%2C" . $bbox ['maxlon']; |
|
616 | + $imgUrl .= "?ma=".$bbox ['minlat']."%2C".$bbox ['minlon']."%2C".$bbox ['maxlat'] |
|
617 | + . "%2C".$bbox ['maxlon']; |
|
618 | 618 | $imgUrl .= "&dcl=1"; |
619 | 619 | } |
620 | - if(strpos($imgUrl, "?") === false) |
|
620 | + if (strpos($imgUrl, "?") === false) |
|
621 | 621 | $imgUrl .= "?"; |
622 | 622 | |
623 | 623 | //$imgUrl .= "&ms=" . str_replace ( "px", "", $gmap ['width'] ) . "," |
624 | 624 | // . str_replace ( "px", "", $gmap ['height'] ); |
625 | - $imgUrl .= "&ms=" . str_replace("px", "", $gmap ['width']) . "%2C" |
|
625 | + $imgUrl .= "&ms=".str_replace("px", "", $gmap ['width'])."%2C" |
|
626 | 626 | . str_replace("px", "", $gmap ['height']); |
627 | - $imgUrl .= "&key=" . $this->getConf('bingAPIKey'); |
|
628 | - if(!empty ($overlay)) { |
|
627 | + $imgUrl .= "&key=".$this->getConf('bingAPIKey'); |
|
628 | + if (!empty ($overlay)) { |
|
629 | 629 | $rowId = 0; |
630 | - foreach($overlay as $data) { |
|
630 | + foreach ($overlay as $data) { |
|
631 | 631 | list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
632 | 632 | // TODO icon style lookup, see: http://msdn.microsoft.com/en-us/library/ff701719.aspx for iconStyle |
633 | 633 | $iconStyle = 32; |
634 | 634 | $rowId++; |
635 | 635 | // NOTE: the max number of pushpins is 18! or we have to use POST |
636 | 636 | // (http://msdn.microsoft.com/en-us/library/ff701724.aspx) |
637 | - if($rowId == 18) { |
|
637 | + if ($rowId == 18) { |
|
638 | 638 | break; |
639 | 639 | } |
640 | 640 | //$imgUrl .= "&pp=$lat,$lon;$iconStyle;$rowId"; |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | } |
645 | 645 | global $conf; |
646 | 646 | $imgUrl .= "&fmt=png"; |
647 | - $imgUrl .= "&c=" . $conf ['lang']; |
|
647 | + $imgUrl .= "&c=".$conf ['lang']; |
|
648 | 648 | // dbglog($imgUrl,'syntax_plugin_openlayersmap_olmap::getBing: bing image url is:'); |
649 | 649 | return $imgUrl; |
650 | 650 | } |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | private function calcBBOX(array $overlay, float $lat, float $lon): array { |
664 | 664 | $lats = array($lat); |
665 | 665 | $lons = array($lon); |
666 | - foreach($overlay as $data) { |
|
666 | + foreach ($overlay as $data) { |
|
667 | 667 | list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
668 | 668 | $lats [] = $lat; |
669 | 669 | $lons [] = $lon; |
@@ -691,13 +691,13 @@ discard block |
||
691 | 691 | * @todo move this into a shared library |
692 | 692 | */ |
693 | 693 | private function convertLat(float $decimaldegrees): string { |
694 | - if(strpos($decimaldegrees, '-') !== false) { |
|
694 | + if (strpos($decimaldegrees, '-') !== false) { |
|
695 | 695 | $latPos = "S"; |
696 | 696 | } else { |
697 | 697 | $latPos = "N"; |
698 | 698 | } |
699 | 699 | $dms = $this->convertDDtoDMS(abs($decimaldegrees)); |
700 | - return hsc($dms . $latPos); |
|
700 | + return hsc($dms.$latPos); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | $secs = ($decimaldegrees - $dms) * 3600; |
713 | 713 | $min = floor($secs / 60); |
714 | 714 | $sec = round($secs - ($min * 60), 3); |
715 | - $dms .= 'º' . $min . '\'' . $sec . '"'; |
|
715 | + $dms .= 'º'.$min.'\''.$sec.'"'; |
|
716 | 716 | return $dms; |
717 | 717 | } |
718 | 718 | |
@@ -724,13 +724,13 @@ discard block |
||
724 | 724 | * @todo move this into a shared library |
725 | 725 | */ |
726 | 726 | private function convertLon(float $decimaldegrees): string { |
727 | - if(strpos($decimaldegrees, '-') !== false) { |
|
727 | + if (strpos($decimaldegrees, '-') !== false) { |
|
728 | 728 | $lonPos = "W"; |
729 | 729 | } else { |
730 | 730 | $lonPos = "E"; |
731 | 731 | } |
732 | 732 | $dms = $this->convertDDtoDMS(abs($decimaldegrees)); |
733 | - return hsc($dms . $lonPos); |
|
733 | + return hsc($dms.$lonPos); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | /** |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | // dbglog($data, 'olmap::render() data.'); |
762 | 762 | list ($mapid, $param, $mainLat, $mainLon, $poitable, $poitabledesc, $staticImgUrl, $_firstimage) = $data; |
763 | 763 | |
764 | - if($format == 'xhtml') { |
|
764 | + if ($format == 'xhtml') { |
|
765 | 765 | $olscript = ''; |
766 | 766 | $olEnable = false; |
767 | 767 | $gscript = ''; |
@@ -771,56 +771,56 @@ discard block |
||
771 | 771 | $enableBing = $this->getConf('enableBing'); |
772 | 772 | |
773 | 773 | $scriptEnable = ''; |
774 | - if(!$initialised) { |
|
774 | + if (!$initialised) { |
|
775 | 775 | $initialised = true; |
776 | 776 | // render necessary script tags |
777 | - if($gEnable) { |
|
777 | + if ($gEnable) { |
|
778 | 778 | $gscript = '<script charset="utf-8" defer="defer" src="//maps.google.com/maps/api/js?v=3.29&key=' |
779 | - . $this->getConf('googleAPIkey') . '"></script>'; |
|
779 | + . $this->getConf('googleAPIkey').'"></script>'; |
|
780 | 780 | } |
781 | - $olscript = '<script charset="utf-8" defer="defer" src="' . DOKU_BASE |
|
781 | + $olscript = '<script charset="utf-8" defer="defer" src="'.DOKU_BASE |
|
782 | 782 | . 'lib/plugins/openlayersmap/lib/OpenLayers.js"></script>'; |
783 | 783 | |
784 | 784 | $scriptEnable = '<script defer="defer" charset="utf-8" src="data:text/javascript;base64,'; |
785 | 785 | $scriptSrc = $olscript ? 'olEnable = true;' : 'olEnable = false;'; |
786 | - $scriptSrc .= 'gEnable = ' . ($gEnable ? 'true' : 'false') . ';'; |
|
787 | - $scriptSrc .= 'osmEnable = ' . ($osmEnable ? 'true' : 'false') . ';'; |
|
788 | - $scriptSrc .= 'stamenEnable = ' . ($stamenEnable ? 'true' : 'false') . ';'; |
|
789 | - $scriptSrc .= 'bEnable = ' . ($enableBing ? 'true' : 'false') . ';'; |
|
790 | - $scriptSrc .= 'bApiKey="' . $this->getConf('bingAPIKey') . '";'; |
|
791 | - $scriptSrc .= 'tfApiKey="' . $this->getConf('tfApiKey') . '";'; |
|
792 | - $scriptSrc .= 'gApiKey="' . $this->getConf('googleAPIkey') . '";'; |
|
786 | + $scriptSrc .= 'gEnable = '.($gEnable ? 'true' : 'false').';'; |
|
787 | + $scriptSrc .= 'osmEnable = '.($osmEnable ? 'true' : 'false').';'; |
|
788 | + $scriptSrc .= 'stamenEnable = '.($stamenEnable ? 'true' : 'false').';'; |
|
789 | + $scriptSrc .= 'bEnable = '.($enableBing ? 'true' : 'false').';'; |
|
790 | + $scriptSrc .= 'bApiKey="'.$this->getConf('bingAPIKey').'";'; |
|
791 | + $scriptSrc .= 'tfApiKey="'.$this->getConf('tfApiKey').'";'; |
|
792 | + $scriptSrc .= 'gApiKey="'.$this->getConf('googleAPIkey').'";'; |
|
793 | 793 | $scriptEnable .= base64_encode($scriptSrc); |
794 | 794 | $scriptEnable .= '"></script>'; |
795 | 795 | } |
796 | 796 | $renderer->doc .= "$gscript\n$olscript\n$scriptEnable"; |
797 | - $renderer->doc .= '<div class="olMapHelp">' . $this->locale_xhtml("help") . '</div>'; |
|
798 | - if($this->getConf('enableA11y')) { |
|
799 | - $renderer->doc .= '<div id="' . $mapid . '-static" class="olStaticMap">' |
|
800 | - . p_render($format, p_get_instructions($staticImgUrl), $info) . '</div>'; |
|
797 | + $renderer->doc .= '<div class="olMapHelp">'.$this->locale_xhtml("help").'</div>'; |
|
798 | + if ($this->getConf('enableA11y')) { |
|
799 | + $renderer->doc .= '<div id="'.$mapid.'-static" class="olStaticMap">' |
|
800 | + . p_render($format, p_get_instructions($staticImgUrl), $info).'</div>'; |
|
801 | 801 | } |
802 | - $renderer->doc .= '<div id="' . $mapid . '-clearer" class="clearer"><p> </p></div>'; |
|
803 | - if($this->getConf('enableA11y')) { |
|
802 | + $renderer->doc .= '<div id="'.$mapid.'-clearer" class="clearer"><p> </p></div>'; |
|
803 | + if ($this->getConf('enableA11y')) { |
|
804 | 804 | // render a table of the POI for the print and a11y presentation, it is hidden using javascript |
805 | - $renderer->doc .= '<div class="olPOItableSpan" id="' . $mapid . '-table-span"> |
|
806 | - <table class="olPOItable" id="' . $mapid . '-table"> |
|
807 | - <caption class="olPOITblCaption">' . $this->getLang('olmapPOItitle') . '</caption> |
|
805 | + $renderer->doc .= '<div class="olPOItableSpan" id="'.$mapid.'-table-span"> |
|
806 | + <table class="olPOItable" id="' . $mapid.'-table"> |
|
807 | + <caption class="olPOITblCaption">' . $this->getLang('olmapPOItitle').'</caption> |
|
808 | 808 | <thead class="olPOITblHeader"> |
809 | 809 | <tr> |
810 | 810 | <th class="rowId" scope="col">id</th> |
811 | - <th class="icon" scope="col">' . $this->getLang('olmapPOIicon') . '</th> |
|
812 | - <th class="lat" scope="col" title="' . $this->getLang('olmapPOIlatTitle') . '">' |
|
813 | - . $this->getLang('olmapPOIlat') . '</th> |
|
814 | - <th class="lon" scope="col" title="' . $this->getLang('olmapPOIlonTitle') . '">' |
|
815 | - . $this->getLang('olmapPOIlon') . '</th> |
|
816 | - <th class="txt" scope="col">' . $this->getLang('olmapPOItxt') . '</th> |
|
811 | + <th class="icon" scope="col">' . $this->getLang('olmapPOIicon').'</th> |
|
812 | + <th class="lat" scope="col" title="' . $this->getLang('olmapPOIlatTitle').'">' |
|
813 | + . $this->getLang('olmapPOIlat').'</th> |
|
814 | + <th class="lon" scope="col" title="' . $this->getLang('olmapPOIlonTitle').'">' |
|
815 | + . $this->getLang('olmapPOIlon').'</th> |
|
816 | + <th class="txt" scope="col">' . $this->getLang('olmapPOItxt').'</th> |
|
817 | 817 | </tr> |
818 | 818 | </thead>'; |
819 | - if($poitabledesc != '') { |
|
820 | - $renderer->doc .= '<tfoot class="olPOITblFooter"><tr><td colspan="5">' . $poitabledesc |
|
819 | + if ($poitabledesc != '') { |
|
820 | + $renderer->doc .= '<tfoot class="olPOITblFooter"><tr><td colspan="5">'.$poitabledesc |
|
821 | 821 | . '</td></tr></tfoot>'; |
822 | 822 | } |
823 | - $renderer->doc .= '<tbody class="olPOITblBody">' . $poitable . '</tbody> |
|
823 | + $renderer->doc .= '<tbody class="olPOITblBody">'.$poitable.'</tbody> |
|
824 | 824 | </table></div>'; |
825 | 825 | } |
826 | 826 | // render inline mapscript parts |
@@ -829,28 +829,28 @@ discard block |
||
829 | 829 | $renderer->doc .= '"></script>'; |
830 | 830 | $mapnumber++; |
831 | 831 | return true; |
832 | - } elseif($format == 'metadata') { |
|
833 | - if(!(($this->dflt ['lat'] == $mainLat) && ($this->dflt ['lon'] == $mainLon))) { |
|
832 | + } elseif ($format == 'metadata') { |
|
833 | + if (!(($this->dflt ['lat'] == $mainLat) && ($this->dflt ['lon'] == $mainLon))) { |
|
834 | 834 | // render geo metadata, unless they are the default |
835 | 835 | $renderer->meta ['geo'] ['lat'] = $mainLat; |
836 | 836 | $renderer->meta ['geo'] ['lon'] = $mainLon; |
837 | - if($geophp = plugin_load('helper', 'geophp')) { |
|
837 | + if ($geophp = plugin_load('helper', 'geophp')) { |
|
838 | 838 | // if we have the geoPHP helper, add the geohash |
839 | 839 | |
840 | 840 | // fails with older php versions.. |
841 | 841 | // $renderer->meta['geo']['geohash'] = (new Point($mainLon,$mainLat))->out('geohash'); |
842 | - $p = new Point ($mainLon, $mainLat); |
|
842 | + $p = new Point($mainLon, $mainLat); |
|
843 | 843 | $renderer->meta ['geo'] ['geohash'] = $p->out('geohash'); |
844 | 844 | } |
845 | 845 | } |
846 | 846 | |
847 | - if(($this->getConf('enableA11y')) && (!empty ($_firstimage))) { |
|
847 | + if (($this->getConf('enableA11y')) && (!empty ($_firstimage))) { |
|
848 | 848 | // add map local image into relation/firstimage if not already filled and when it is a local image |
849 | 849 | |
850 | 850 | global $ID; |
851 | 851 | $rel = p_get_metadata($ID, 'relation', METADATA_RENDER_USING_CACHE); |
852 | 852 | $img = $rel ['firstimage']; |
853 | - if(empty ($img) /* || $img == $_firstimage*/) { |
|
853 | + if (empty ($img) /* || $img == $_firstimage*/) { |
|
854 | 854 | //dbglog ( $_firstimage, |
855 | 855 | // 'olmap::render#rendering image relation metadata for _firstimage as $img was empty or same.' ); |
856 | 856 | // This seems to never work; the firstimage entry in the .meta file is empty |