@@ -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); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | public function getMenuIcon(): string { |
36 | 36 | $plugin = $this->getPluginName(); |
37 | - return DOKU_PLUGIN . $plugin . '/admin/purge.svg'; |
|
37 | + return DOKU_PLUGIN.$plugin.'/admin/purge.svg'; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -43,18 +43,18 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function handle(): void { |
45 | 45 | global $conf; |
46 | - if(!isset($_REQUEST['continue']) || !checkSecurityToken()) { |
|
46 | + if (!isset($_REQUEST['continue']) || !checkSecurityToken()) { |
|
47 | 47 | return; |
48 | 48 | } |
49 | - if(isset($_REQUEST['purgetiles'])) { |
|
50 | - $path = $conf['cachedir'] . '/olmaptiles'; |
|
51 | - if($this->rrmdir($path)) { |
|
49 | + if (isset($_REQUEST['purgetiles'])) { |
|
50 | + $path = $conf['cachedir'].'/olmaptiles'; |
|
51 | + if ($this->rrmdir($path)) { |
|
52 | 52 | msg($this->getLang('admin_purged_tiles'), 0); |
53 | 53 | } |
54 | 54 | } |
55 | - if(isset($_REQUEST['purgemaps'])) { |
|
56 | - $path = $conf['mediadir'] . '/olmapmaps'; |
|
57 | - if($this->rrmdir($path)) { |
|
55 | + if (isset($_REQUEST['purgemaps'])) { |
|
56 | + $path = $conf['mediadir'].'/olmapmaps'; |
|
57 | + if ($this->rrmdir($path)) { |
|
58 | 58 | msg($this->getLang('admin_purged_maps'), 0); |
59 | 59 | } |
60 | 60 | } |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | * @return boolean true when succesful |
67 | 67 | */ |
68 | 68 | private function rrmdir(string $sDir): bool { |
69 | - if(is_dir($sDir)) { |
|
69 | + if (is_dir($sDir)) { |
|
70 | 70 | dbglog($sDir, 'admin_plugin_openlayersmap_purge::rrmdir: recursively removing path: '); |
71 | 71 | $sDir = rtrim($sDir, '/'); |
72 | 72 | $oDir = dir($sDir); |
73 | - while(($sFile = $oDir->read()) !== false) { |
|
74 | - if($sFile !== '.' && $sFile !== '..') { |
|
73 | + while (($sFile = $oDir->read()) !== false) { |
|
74 | + if ($sFile !== '.' && $sFile !== '..') { |
|
75 | 75 | (!is_link("$sDir/$sFile") && is_dir("$sDir/$sFile")) ? |
76 | 76 | $this->rrmdir("$sDir/$sFile") : unlink("$sDir/$sFile"); |
77 | 77 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | '<input id="purgetiles" name="purgetiles" type="checkbox" value="1" class="checkbox" />' |
99 | 99 | ); |
100 | 100 | $form->addElement( |
101 | - '<label for="purgetiles" class="label">' . $this->getLang('admin_purge_tiles') |
|
101 | + '<label for="purgetiles" class="label">'.$this->getLang('admin_purge_tiles') |
|
102 | 102 | . '</label>' |
103 | 103 | ); |
104 | 104 | $form->addElement('</p>'); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $form->addElement('<p>'); |
109 | 109 | $form->addElement('<input id="purgemaps" name="purgemaps" type="checkbox" value="1" class="checkbox" />'); |
110 | 110 | $form->addElement( |
111 | - '<label for="purgemaps" class="label">' . $this->getLang('admin_purge_maps') . '</label>' |
|
111 | + '<label for="purgemaps" class="label">'.$this->getLang('admin_purge_maps').'</label>' |
|
112 | 112 | ); |
113 | 113 | $form->addElement('</p>'); |
114 | 114 | $form->endFieldset(); |
@@ -119,13 +119,13 @@ |
||
119 | 119 | // incremented for each olmap_wmslayer tag in the page source |
120 | 120 | static $overlaynumber = 0; |
121 | 121 | |
122 | - $renderer->doc .= DOKU_LF . '<script defer="defer" src="data:text/javascript;base64,'; |
|
123 | - $str = '{'; |
|
122 | + $renderer->doc .= DOKU_LF.'<script defer="defer" src="data:text/javascript;base64,'; |
|
123 | + $str = '{'; |
|
124 | 124 | foreach ($data as $key => $val) { |
125 | - $str .= "'" . $key . "' : '" . $val . "',"; |
|
125 | + $str .= "'".$key."' : '".$val."',"; |
|
126 | 126 | } |
127 | 127 | $str .= "'type':'wms'}"; |
128 | - $renderer->doc .= base64_encode("olMapOverlays['wms" . $overlaynumber . "'] = " . $str . ";") |
|
128 | + $renderer->doc .= base64_encode("olMapOverlays['wms".$overlaynumber."'] = ".$str.";") |
|
129 | 129 | . '"></script>'; |
130 | 130 | $overlaynumber++; |
131 | 131 | return true; |
@@ -116,13 +116,13 @@ |
||
116 | 116 | // incremented for each olmap_osmlayer tag in the page source |
117 | 117 | static $overlaynumber = 0; |
118 | 118 | |
119 | - $renderer->doc .= DOKU_LF . '<script defer="defer" src="data:text/javascript;base64,'; |
|
120 | - $str = '{'; |
|
119 | + $renderer->doc .= DOKU_LF.'<script defer="defer" src="data:text/javascript;base64,'; |
|
120 | + $str = '{'; |
|
121 | 121 | foreach ($data as $key => $val) { |
122 | - $str .= "'" . $key . "' : '" . $val . "',"; |
|
122 | + $str .= "'".$key."' : '".$val."',"; |
|
123 | 123 | } |
124 | 124 | $str .= '"type":"osm"}'; |
125 | - $renderer->doc .= base64_encode("olMapOverlays['osm" . $overlaynumber . "'] = " . $str . ";") |
|
125 | + $renderer->doc .= base64_encode("olMapOverlays['osm".$overlaynumber."'] = ".$str.";") |
|
126 | 126 | . '"></script>'; |
127 | 127 | $overlaynumber++; |
128 | 128 | return true; |
@@ -120,13 +120,13 @@ |
||
120 | 120 | // incremented for each olmap_agslayer tag in the page source |
121 | 121 | static $overlaynumber = 0; |
122 | 122 | |
123 | - $renderer->doc .= DOKU_LF . '<script defer="defer" src="data:text/javascript;base64,'; |
|
124 | - $str = '{'; |
|
123 | + $renderer->doc .= DOKU_LF.'<script defer="defer" src="data:text/javascript;base64,'; |
|
124 | + $str = '{'; |
|
125 | 125 | foreach ($data as $key => $val) { |
126 | - $str .= "'" . $key . "' : '" . $val . "',"; |
|
126 | + $str .= "'".$key."' : '".$val."',"; |
|
127 | 127 | } |
128 | 128 | $str .= "'type':'ags'}"; |
129 | - $renderer->doc .= base64_encode("olMapOverlays['ags" . $overlaynumber . "'] = " . $str . ";") |
|
129 | + $renderer->doc .= base64_encode("olMapOverlays['ags".$overlaynumber."'] = ".$str.";") |
|
130 | 130 | . '"></script>'; |
131 | 131 | $overlaynumber++; |
132 | 132 | return true; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $conf['plugin']['openlayersmap']['optionStaticMapGenerator'] = 'local'; |
39 | 39 | $conf['plugin']['openlayersmap']['autoZoomMap'] = 1; |
40 | 40 | |
41 | - TestUtils::rcopy(TMP_DIR, __DIR__ . '/data/'); |
|
41 | + TestUtils::rcopy(TMP_DIR, __DIR__.'/data/'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | final public function setUp(): void { |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | // foreach($data as $val) { |
51 | 51 | // idx_addPage($val['id']); |
52 | 52 | // } |
53 | - if($conf['allowdebug']) { |
|
54 | - if(mkdir(DOKU_TMP_DATA . 'data/log/debug/', 0777, true)) { |
|
55 | - touch(DOKU_TMP_DATA . 'data/log/debug/' . date('Y-m-d') . '.log'); |
|
53 | + if ($conf['allowdebug']) { |
|
54 | + if (mkdir(DOKU_TMP_DATA.'data/log/debug/', 0777, true)) { |
|
55 | + touch(DOKU_TMP_DATA.'data/log/debug/'.date('Y-m-d').'.log'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | } |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | |
64 | 64 | global $conf; |
65 | 65 | // try to get the debug log after running the test, print and clear |
66 | - if($conf['allowdebug']) { |
|
66 | + if ($conf['allowdebug']) { |
|
67 | 67 | print "\n"; |
68 | - readfile(DOKU_TMP_DATA . 'data/log/debug/' . date('Y-m-d') . '.log'); |
|
69 | - unlink(DOKU_TMP_DATA . 'data/log/debug/' . date('Y-m-d') . '.log'); |
|
68 | + readfile(DOKU_TMP_DATA.'data/log/debug/'.date('Y-m-d').'.log'); |
|
69 | + unlink(DOKU_TMP_DATA.'data/log/debug/'.date('Y-m-d').'.log'); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $this->height = $height; |
216 | 216 | // validate + set maptype |
217 | 217 | $this->maptype = $this->tileDefaultSrc; |
218 | - if(array_key_exists($maptype, $this->tileInfo)) { |
|
218 | + if (array_key_exists($maptype, $this->tileInfo)) { |
|
219 | 219 | $this->maptype = $maptype; |
220 | 220 | } |
221 | 221 | $this->markers = $markers; |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | $this->gpxFileName = $gpx; |
224 | 224 | $this->geojsonFileName = $geojson; |
225 | 225 | $this->mediaBaseDir = $mediaDir; |
226 | - $this->tileCacheBaseDir = $tileCacheBaseDir . '/olmaptiles'; |
|
226 | + $this->tileCacheBaseDir = $tileCacheBaseDir.'/olmaptiles'; |
|
227 | 227 | $this->useTileCache = $this->tileCacheBaseDir !== ''; |
228 | - $this->mapCacheBaseDir = $mediaDir . '/olmapmaps'; |
|
228 | + $this->mapCacheBaseDir = $mediaDir.'/olmapmaps'; |
|
229 | 229 | $this->autoZoomExtent = $autoZoomExtent; |
230 | 230 | $this->apikey = $apikey; |
231 | 231 | } |
@@ -237,15 +237,15 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function getMap(): string { |
239 | 239 | try { |
240 | - if($this->autoZoomExtent) { |
|
240 | + if ($this->autoZoomExtent) { |
|
241 | 241 | $this->autoZoom(); |
242 | 242 | } |
243 | - } catch(Exception $e) { |
|
243 | + } catch (Exception $e) { |
|
244 | 244 | dbglog($e); |
245 | 245 | } |
246 | 246 | |
247 | 247 | // use map cache, so check cache for map |
248 | - if(!$this->checkMapCache()) { |
|
248 | + if (!$this->checkMapCache()) { |
|
249 | 249 | // map is not in cache, needs to be build |
250 | 250 | $this->makeMap(); |
251 | 251 | $this->mkdirRecursive(dirname($this->mapCacheIDToFilename()), 0777); |
@@ -265,37 +265,37 @@ discard block |
||
265 | 265 | */ |
266 | 266 | private function autoZoom(float $paddingFactor = 1.0): void { |
267 | 267 | $geoms = array(); |
268 | - $geoms [] = new Point ($this->lon, $this->lat); |
|
269 | - if(!empty ($this->markers)) { |
|
270 | - foreach($this->markers as $marker) { |
|
271 | - $geoms [] = new Point ($marker ['lon'], $marker ['lat']); |
|
268 | + $geoms [] = new Point($this->lon, $this->lat); |
|
269 | + if (!empty ($this->markers)) { |
|
270 | + foreach ($this->markers as $marker) { |
|
271 | + $geoms [] = new Point($marker ['lon'], $marker ['lat']); |
|
272 | 272 | } |
273 | 273 | } |
274 | - if(file_exists($this->kmlFileName)) { |
|
274 | + if (file_exists($this->kmlFileName)) { |
|
275 | 275 | $g = geoPHP::load(file_get_contents($this->kmlFileName), 'kml'); |
276 | - if($g !== false) { |
|
276 | + if ($g !== false) { |
|
277 | 277 | $geoms [] = $g; |
278 | 278 | } |
279 | 279 | } |
280 | - if(file_exists($this->gpxFileName)) { |
|
280 | + if (file_exists($this->gpxFileName)) { |
|
281 | 281 | $g = geoPHP::load(file_get_contents($this->gpxFileName), 'gpx'); |
282 | - if($g !== false) { |
|
282 | + if ($g !== false) { |
|
283 | 283 | $geoms [] = $g; |
284 | 284 | } |
285 | 285 | } |
286 | - if(file_exists($this->geojsonFileName)) { |
|
286 | + if (file_exists($this->geojsonFileName)) { |
|
287 | 287 | $g = geoPHP::load(file_get_contents($this->geojsonFileName), 'geojson'); |
288 | - if($g !== false) { |
|
288 | + if ($g !== false) { |
|
289 | 289 | $geoms [] = $g; |
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | - if(count($geoms) <= 1) { |
|
293 | + if (count($geoms) <= 1) { |
|
294 | 294 | dbglog($geoms, "StaticMap::autoZoom: Skip setting autozoom options"); |
295 | 295 | return; |
296 | 296 | } |
297 | 297 | |
298 | - $geom = new GeometryCollection ($geoms); |
|
298 | + $geom = new GeometryCollection($geoms); |
|
299 | 299 | $centroid = $geom->centroid(); |
300 | 300 | $bbox = $geom->getBBox(); |
301 | 301 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | $vy0 = log(tan(M_PI * (0.25 + $bbox ['miny'] / 360))); |
305 | 305 | $vy1 = log(tan(M_PI * (0.25 + $bbox ['maxy'] / 360))); |
306 | 306 | dbglog("StaticMap::autoZoom: vertical resolution: $vy0, $vy1"); |
307 | - if ($vy1 - $vy0 === 0.0){ |
|
307 | + if ($vy1 - $vy0 === 0.0) { |
|
308 | 308 | $resolutionVertical = 0; |
309 | 309 | dbglog("StaticMap::autoZoom: using $resolutionVertical"); |
310 | 310 | } else { |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | dbglog("StaticMap::autoZoom: using $resolutionHorizontal"); |
317 | 317 | $resolution = max($resolutionHorizontal, $resolutionVertical) * $paddingFactor; |
318 | 318 | $zoom = $this->zoom; |
319 | - if ($resolution > 0){ |
|
319 | + if ($resolution > 0) { |
|
320 | 320 | $zoom = log(360 / ($resolution * $this->tileSize), 2); |
321 | 321 | } |
322 | 322 | |
323 | - if(is_finite($zoom) && $zoom < 15 && $zoom > 2) { |
|
323 | + if (is_finite($zoom) && $zoom < 15 && $zoom > 2) { |
|
324 | 324 | $this->zoom = floor($zoom); |
325 | 325 | } |
326 | 326 | $this->lon = $centroid->getX(); |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | public function mapCacheIDToFilename(): string { |
356 | - if(!$this->mapCacheFile) { |
|
357 | - $this->mapCacheFile = $this->mapCacheBaseDir . "/" . $this->maptype . "/" . $this->zoom . "/cache_" |
|
358 | - . substr($this->mapCacheID, 0, 2) . "/" . substr($this->mapCacheID, 2, 2) |
|
359 | - . "/" . substr($this->mapCacheID, 4); |
|
356 | + if (!$this->mapCacheFile) { |
|
357 | + $this->mapCacheFile = $this->mapCacheBaseDir."/".$this->maptype."/".$this->zoom."/cache_" |
|
358 | + . substr($this->mapCacheID, 0, 2)."/".substr($this->mapCacheID, 2, 2) |
|
359 | + . "/".substr($this->mapCacheID, 4); |
|
360 | 360 | } |
361 | - return $this->mapCacheFile . "." . $this->mapCacheExtension; |
|
361 | + return $this->mapCacheFile.".".$this->mapCacheExtension; |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | public function makeMap(): void { |
368 | 368 | $this->initCoords(); |
369 | 369 | $this->createBaseMap(); |
370 | - if(!empty ($this->markers)) { |
|
370 | + if (!empty ($this->markers)) { |
|
371 | 371 | $this->placeMarkers(); |
372 | 372 | } |
373 | 373 | if (file_exists($this->kmlFileName)) { |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | $this->offsetX += floor($startX - floor($this->centerX)) * $this->tileSize; |
441 | 441 | $this->offsetY += floor($startY - floor($this->centerY)) * $this->tileSize; |
442 | 442 | |
443 | - for($x = $startX; $x <= $endX; $x++) { |
|
444 | - for($y = $startY; $y <= $endY; $y++) { |
|
443 | + for ($x = $startX; $x <= $endX; $x++) { |
|
444 | + for ($y = $startY; $y <= $endY; $y++) { |
|
445 | 445 | $url = str_replace( |
446 | 446 | array( |
447 | 447 | '{Z}', |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | ); |
456 | 456 | |
457 | 457 | $tileData = $this->fetchTile($url); |
458 | - if($tileData) { |
|
458 | + if ($tileData) { |
|
459 | 459 | $tileImage = imagecreatefromstring($tileData); |
460 | 460 | } else { |
461 | 461 | $tileImage = imagecreate($this->tileSize, $this->tileSize); |
@@ -481,17 +481,17 @@ discard block |
||
481 | 481 | * for better proxy handling... |
482 | 482 | */ |
483 | 483 | public function fetchTile(string $url) { |
484 | - if($this->useTileCache && ($cached = $this->checkTileCache($url))) |
|
484 | + if ($this->useTileCache && ($cached = $this->checkTileCache($url))) |
|
485 | 485 | return $cached; |
486 | 486 | |
487 | - $_UA = 'Mozilla/4.0 (compatible; DokuWikiSpatial HTTP Client; ' . PHP_OS . ')'; |
|
488 | - if(function_exists("curl_init")) { |
|
487 | + $_UA = 'Mozilla/4.0 (compatible; DokuWikiSpatial HTTP Client; '.PHP_OS.')'; |
|
488 | + if (function_exists("curl_init")) { |
|
489 | 489 | // use cUrl |
490 | 490 | $ch = curl_init(); |
491 | 491 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
492 | 492 | curl_setopt($ch, CURLOPT_USERAGENT, $_UA); |
493 | 493 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); |
494 | - curl_setopt($ch, CURLOPT_URL, $url . $this->apikey); |
|
494 | + curl_setopt($ch, CURLOPT_URL, $url.$this->apikey); |
|
495 | 495 | dbglog("StaticMap::fetchTile: getting: $url using curl_exec"); |
496 | 496 | $tile = curl_exec($ch); |
497 | 497 | curl_close($ch); |
@@ -501,21 +501,21 @@ discard block |
||
501 | 501 | $opts = array( |
502 | 502 | 'http' => array( |
503 | 503 | 'method' => "GET", |
504 | - 'header' => "Accept-language: en\r\n" . "User-Agent: $_UA\r\n" . "accept: image/png\r\n", |
|
504 | + 'header' => "Accept-language: en\r\n"."User-Agent: $_UA\r\n"."accept: image/png\r\n", |
|
505 | 505 | 'request_fulluri' => true |
506 | 506 | ) |
507 | 507 | ); |
508 | - if(isset($conf['proxy']['host'], $conf['proxy']['port']) |
|
508 | + if (isset($conf['proxy']['host'], $conf['proxy']['port']) |
|
509 | 509 | && $conf['proxy']['host'] !== '' |
510 | 510 | && $conf['proxy']['port'] !== '') { |
511 | - $opts['http'] += ['proxy' => "tcp://" . $conf['proxy']['host'] . ":" . $conf['proxy']['port']]; |
|
511 | + $opts['http'] += ['proxy' => "tcp://".$conf['proxy']['host'].":".$conf['proxy']['port']]; |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | $context = stream_context_create($opts); |
515 | 515 | // dbglog("StaticMap::fetchTile: getting: $url . $this->apikey using file_get_contents and options $opts"); |
516 | - $tile = file_get_contents($url . $this->apikey, false, $context); |
|
516 | + $tile = file_get_contents($url.$this->apikey, false, $context); |
|
517 | 517 | } |
518 | - if($tile && $this->useTileCache) { |
|
518 | + if ($tile && $this->useTileCache) { |
|
519 | 519 | $this->writeTileToCache($url, $tile); |
520 | 520 | } |
521 | 521 | return $tile; |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | */ |
529 | 529 | public function checkTileCache(string $url) { |
530 | 530 | $filename = $this->tileUrlToFilename($url); |
531 | - if(file_exists($filename)) { |
|
531 | + if (file_exists($filename)) { |
|
532 | 532 | return file_get_contents($filename); |
533 | 533 | } |
534 | 534 | return false; |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | * @return string |
541 | 541 | */ |
542 | 542 | public function tileUrlToFilename(string $url): string { |
543 | - return $this->tileCacheBaseDir . "/" . substr($url, strpos($url, '/') + 1); |
|
543 | + return $this->tileCacheBaseDir."/".substr($url, strpos($url, '/') + 1); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -575,14 +575,14 @@ discard block |
||
575 | 575 | $count = 0; |
576 | 576 | $color = imagecolorallocate($this->image, 0, 0, 0); |
577 | 577 | $bgcolor = imagecolorallocate($this->image, 200, 200, 200); |
578 | - $markerBaseDir = __DIR__ . '/icons'; |
|
578 | + $markerBaseDir = __DIR__.'/icons'; |
|
579 | 579 | $markerImageOffsetX = 0; |
580 | 580 | $markerImageOffsetY = 0; |
581 | 581 | $markerShadowOffsetX = 0; |
582 | 582 | $markerShadowOffsetY = 0; |
583 | 583 | $markerShadowImg = null; |
584 | 584 | // loop thru marker array |
585 | - foreach($this->markers as $marker) { |
|
585 | + foreach ($this->markers as $marker) { |
|
586 | 586 | // set some local variables |
587 | 587 | $markerLat = $marker ['lat']; |
588 | 588 | $markerLon = $marker ['lon']; |
@@ -592,18 +592,18 @@ discard block |
||
592 | 592 | $markerShadow = ''; |
593 | 593 | $matches = false; |
594 | 594 | // check for marker type, get settings from markerPrototypes |
595 | - if($markerType) { |
|
596 | - foreach($this->markerPrototypes as $markerPrototype) { |
|
597 | - if(preg_match($markerPrototype ['regex'], $markerType, $matches)) { |
|
598 | - $markerFilename = $matches [0] . $markerPrototype ['extension']; |
|
599 | - if($markerPrototype ['offsetImage']) { |
|
595 | + if ($markerType) { |
|
596 | + foreach ($this->markerPrototypes as $markerPrototype) { |
|
597 | + if (preg_match($markerPrototype ['regex'], $markerType, $matches)) { |
|
598 | + $markerFilename = $matches [0].$markerPrototype ['extension']; |
|
599 | + if ($markerPrototype ['offsetImage']) { |
|
600 | 600 | list ($markerImageOffsetX, $markerImageOffsetY) = explode( |
601 | 601 | ",", |
602 | 602 | $markerPrototype ['offsetImage'] |
603 | 603 | ); |
604 | 604 | } |
605 | 605 | $markerShadow = $markerPrototype ['shadow']; |
606 | - if($markerShadow) { |
|
606 | + if ($markerShadow) { |
|
607 | 607 | list ($markerShadowOffsetX, $markerShadowOffsetY) = explode( |
608 | 608 | ",", |
609 | 609 | $markerPrototype ['offsetShadow'] |
@@ -613,14 +613,14 @@ discard block |
||
613 | 613 | } |
614 | 614 | } |
615 | 615 | // create img resource |
616 | - if(file_exists($markerBaseDir . '/' . $markerFilename)) { |
|
617 | - $markerImg = imagecreatefrompng($markerBaseDir . '/' . $markerFilename); |
|
616 | + if (file_exists($markerBaseDir.'/'.$markerFilename)) { |
|
617 | + $markerImg = imagecreatefrompng($markerBaseDir.'/'.$markerFilename); |
|
618 | 618 | } else { |
619 | - $markerImg = imagecreatefrompng($markerBaseDir . '/marker.png'); |
|
619 | + $markerImg = imagecreatefrompng($markerBaseDir.'/marker.png'); |
|
620 | 620 | } |
621 | 621 | // check for shadow + create shadow recource |
622 | - if($markerShadow && file_exists($markerBaseDir . '/' . $markerShadow)) { |
|
623 | - $markerShadowImg = imagecreatefrompng($markerBaseDir . '/' . $markerShadow); |
|
622 | + if ($markerShadow && file_exists($markerBaseDir.'/'.$markerShadow)) { |
|
623 | + $markerShadowImg = imagecreatefrompng($markerBaseDir.'/'.$markerShadow); |
|
624 | 624 | } |
625 | 625 | // calc position |
626 | 626 | $destX = floor( |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | $this->tileSize * ($this->centerY - $this->latToTile($markerLat, $this->zoom)) |
633 | 633 | ); |
634 | 634 | // copy shadow on basemap |
635 | - if($markerShadow && $markerShadowImg) { |
|
635 | + if ($markerShadow && $markerShadowImg) { |
|
636 | 636 | imagecopy( |
637 | 637 | $this->image, |
638 | 638 | $markerShadowImg, |
@@ -694,14 +694,14 @@ discard block |
||
694 | 694 | * drawing colour |
695 | 695 | */ |
696 | 696 | private function drawGeometry(Geometry $geom, int $colour): void { |
697 | - if(empty($geom)) { |
|
697 | + if (empty($geom)) { |
|
698 | 698 | return; |
699 | 699 | } |
700 | 700 | |
701 | - switch($geom->geometryType()) { |
|
701 | + switch ($geom->geometryType()) { |
|
702 | 702 | case 'GeometryCollection' : |
703 | 703 | // recursively draw part of the collection |
704 | - for($i = 1; $i < $geom->numGeometries() + 1; $i++) { |
|
704 | + for ($i = 1; $i < $geom->numGeometries() + 1; $i++) { |
|
705 | 705 | $_geom = $geom->geometryN($i); |
706 | 706 | $this->drawGeometry($_geom, $colour); |
707 | 707 | } |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | // extring is a linestring actually.. |
744 | 744 | $extRing = $polygon->exteriorRing(); |
745 | 745 | |
746 | - for($i = 1; $i < $extRing->numGeometries(); $i++) { |
|
746 | + for ($i = 1; $i < $extRing->numGeometries(); $i++) { |
|
747 | 747 | $p1 = $extRing->geometryN($i); |
748 | 748 | $x = floor( |
749 | 749 | ($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($p1->x(), $this->zoom)) |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | */ |
770 | 770 | private function drawLineString($line, $colour) { |
771 | 771 | imagesetthickness($this->image, 2); |
772 | - for($p = 1; $p < $line->numGeometries(); $p++) { |
|
772 | + for ($p = 1; $p < $line->numGeometries(); $p++) { |
|
773 | 773 | // get first pair of points |
774 | 774 | $p1 = $line->geometryN($p); |
775 | 775 | $p2 = $line->geometryN($p + 1); |
@@ -842,8 +842,8 @@ discard block |
||
842 | 842 | * add copyright and origin notice and icons to the map. |
843 | 843 | */ |
844 | 844 | public function drawCopyright() { |
845 | - $logoBaseDir = dirname(__FILE__) . '/' . 'logo/'; |
|
846 | - $logoImg = imagecreatefrompng($logoBaseDir . $this->tileInfo ['openstreetmap'] ['logo']); |
|
845 | + $logoBaseDir = dirname(__FILE__).'/'.'logo/'; |
|
846 | + $logoImg = imagecreatefrompng($logoBaseDir.$this->tileInfo ['openstreetmap'] ['logo']); |
|
847 | 847 | $textcolor = imagecolorallocate($this->image, 0, 0, 0); |
848 | 848 | $bgcolor = imagecolorallocate($this->image, 200, 200, 200); |
849 | 849 | |
@@ -876,11 +876,11 @@ discard block |
||
876 | 876 | |
877 | 877 | // additional tile source info, ie. who created/hosted the tiles |
878 | 878 | $xIconOffset = 0; |
879 | - if($this->maptype === 'openstreetmap') { |
|
879 | + if ($this->maptype === 'openstreetmap') { |
|
880 | 880 | $mapAuthor = "(c) OpenStreetMap maps/CC BY-SA"; |
881 | 881 | } else { |
882 | 882 | $mapAuthor = $this->tileInfo [$this->maptype] ['txt']; |
883 | - $iconImg = imagecreatefrompng($logoBaseDir . $this->tileInfo [$this->maptype] ['logo']); |
|
883 | + $iconImg = imagecreatefrompng($logoBaseDir.$this->tileInfo [$this->maptype] ['logo']); |
|
884 | 884 | $xIconOffset = imagesx($iconImg); |
885 | 885 | imagecopy( |
886 | 886 | $this->image, |