@@ -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); |
@@ -617,8 +617,9 @@ |
||
617 | 617 | . "%2C" . $bbox ['maxlon']; |
618 | 618 | $imgUrl .= "&dcl=1"; |
619 | 619 | } |
620 | - if(strpos($imgUrl, "?") === false) |
|
621 | - $imgUrl .= "?"; |
|
620 | + if(strpos($imgUrl, "?") === false) { |
|
621 | + $imgUrl .= "?"; |
|
622 | + } |
|
622 | 623 | |
623 | 624 | //$imgUrl .= "&ms=" . str_replace ( "px", "", $gmap ['width'] ) . "," |
624 | 625 | // . str_replace ( "px", "", $gmap ['height'] ); |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | preg_match('(lon[:|=]\"-?\d*\.?\d*\")', $match, $mainLon); |
94 | 94 | $mainLat = substr($mainLat [0], 5, -1); |
95 | 95 | $mainLon = substr($mainLon [0], 5, -1); |
96 | - if(!is_numeric($mainLat)) { |
|
96 | + if (!is_numeric($mainLat)) { |
|
97 | 97 | $mainLat = $this->dflt ['lat']; |
98 | 98 | } |
99 | - if(!is_numeric($mainLon)) { |
|
99 | + if (!is_numeric($mainLon)) { |
|
100 | 100 | $mainLon = $this->dflt ['lon']; |
101 | 101 | } |
102 | 102 | |
@@ -107,23 +107,23 @@ discard block |
||
107 | 107 | $_nocache = false; |
108 | 108 | // choose maptype based on the specified tag |
109 | 109 | $imgUrl = "{{"; |
110 | - if(stripos($gmap ['baselyr'], 'google') !== false) { |
|
110 | + if (stripos($gmap ['baselyr'], 'google') !== false) { |
|
111 | 111 | |
112 | 112 | $imgUrl .= $this->getGoogle($gmap, $overlay); |
113 | 113 | $imgUrl .= "&.png"; |
114 | - } elseif(stripos($gmap ['baselyr'], 'bing') !== false) { |
|
114 | + } elseif (stripos($gmap ['baselyr'], 'bing') !== false) { |
|
115 | 115 | // Bing |
116 | - if(!$this->getConf('bingAPIKey')) { |
|
116 | + if (!$this->getConf('bingAPIKey')) { |
|
117 | 117 | // in case there is no Bing api key we'll use OSM |
118 | 118 | $_firstimageID = $this->getStaticOSM($gmap, $overlay); |
119 | - $imgUrl .= $_firstimageID; |
|
120 | - if($this->getConf('optionStaticMapGenerator') == 'remote') { |
|
119 | + $imgUrl .= $_firstimageID; |
|
120 | + if ($this->getConf('optionStaticMapGenerator') == 'remote') { |
|
121 | 121 | $imgUrl .= "&.png"; |
122 | 122 | } |
123 | 123 | } else { |
124 | 124 | // seems that Bing doesn't like the DW client, turn off caching |
125 | 125 | $_nocache = true; |
126 | - $imgUrl .= $this->getBing($gmap, $overlay) . "&.png"; |
|
126 | + $imgUrl .= $this->getBing($gmap, $overlay)."&.png"; |
|
127 | 127 | } |
128 | 128 | } /* elseif (stripos ( $gmap ['baselyr'], 'mapquest' ) !== false) { |
129 | 129 | // MapQuest |
@@ -141,33 +141,33 @@ discard block |
||
141 | 141 | } */ else { |
142 | 142 | // default OSM |
143 | 143 | $_firstimageID = $this->getStaticOSM($gmap, $overlay); |
144 | - $imgUrl .= $_firstimageID; |
|
145 | - if($this->getConf('optionStaticMapGenerator') == 'remote') { |
|
144 | + $imgUrl .= $_firstimageID; |
|
145 | + if ($this->getConf('optionStaticMapGenerator') == 'remote') { |
|
146 | 146 | $imgUrl .= "&.png"; |
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | // append dw p_render specific params and render |
151 | - $imgUrl .= "?" . str_replace("px", "", $gmap ['width']) . "x" |
|
151 | + $imgUrl .= "?".str_replace("px", "", $gmap ['width'])."x" |
|
152 | 152 | . str_replace("px", "", $gmap ['height']); |
153 | 153 | $imgUrl .= "&nolink"; |
154 | 154 | |
155 | 155 | // add nocache option for selected services |
156 | - if($_nocache) { |
|
156 | + if ($_nocache) { |
|
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)) { |
|
170 | + if (!empty ($param)) { |
|
171 | 171 | $param = substr($param, 0, -2); |
172 | 172 | } |
173 | 173 | unset ($gmap ['id']); |
@@ -176,13 +176,13 @@ discard block |
||
176 | 176 | $poi = ''; |
177 | 177 | $poitable = ''; |
178 | 178 | $rowId = 0; |
179 | - if(!empty ($overlay)) { |
|
180 | - foreach($overlay as $data) { |
|
179 | + if (!empty ($overlay)) { |
|
180 | + foreach ($overlay as $data) { |
|
181 | 181 | list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
182 | 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') { |
|
185 | + if ($this->getConf('displayformat') === 'DMS') { |
|
186 | 186 | $lat = $this->convertLat($lat); |
187 | 187 | $lon = $this->convertLon($lon); |
188 | 188 | } else { |
@@ -192,52 +192,52 @@ 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="' |
|
197 | - . substr($img, 0, -4) . $this->getlang('alt_legend_poi') . '" /></td> |
|
198 | - <td class="lat" title="' . $this->getLang('olmapPOIlatTitle') . '">' . $lat . '</td> |
|
199 | - <td class="lon" title="' . $this->getLang('olmapPOIlonTitle') . '">' . $lon . '</td> |
|
200 | - <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="' |
|
197 | + . substr($img, 0, -4).$this->getlang('alt_legend_poi').'" /></td> |
|
198 | + <td class="lat" title="' . $this->getLang('olmapPOIlatTitle').'">'.$lat.'</td> |
|
199 | + <td class="lon" title="' . $this->getLang('olmapPOIlonTitle').'">'.$lon.'</td> |
|
200 | + <td class="txt">' . $text.'</td> |
|
201 | 201 | </tr>'; |
202 | 202 | } |
203 | 203 | $poi = substr($poi, 2); |
204 | 204 | } |
205 | - if(!empty ($gmap ['kmlfile'])) { |
|
205 | + if (!empty ($gmap ['kmlfile'])) { |
|
206 | 206 | $poitable .= ' |
207 | 207 | <tr> |
208 | 208 | <td class="rowId"><img src="' . DOKU_BASE |
209 | 209 | . 'lib/plugins/openlayersmap/toolbar/kml_file.png" alt="KML file" /></td> |
210 | - <td class="icon"><img src="' . DOKU_BASE . 'lib/plugins/openlayersmap/toolbar/kml_line.png" alt="' |
|
211 | - . $this->getlang('alt_legend_kml') . '" /></td> |
|
212 | - <td class="txt" colspan="3">KML track: ' . $this->getFileName($gmap ['kmlfile']) . '</td> |
|
210 | + <td class="icon"><img src="' . DOKU_BASE.'lib/plugins/openlayersmap/toolbar/kml_line.png" alt="' |
|
211 | + . $this->getlang('alt_legend_kml').'" /></td> |
|
212 | + <td class="txt" colspan="3">KML track: ' . $this->getFileName($gmap ['kmlfile']).'</td> |
|
213 | 213 | </tr>'; |
214 | 214 | } |
215 | - if(!empty ($gmap ['gpxfile'])) { |
|
215 | + if (!empty ($gmap ['gpxfile'])) { |
|
216 | 216 | $poitable .= ' |
217 | 217 | <tr> |
218 | 218 | <td class="rowId"><img src="' . DOKU_BASE |
219 | 219 | . 'lib/plugins/openlayersmap/toolbar/gpx_file.png" alt="GPX file" /></td> |
220 | 220 | <td class="icon"><img src="' . DOKU_BASE |
221 | 221 | . 'lib/plugins/openlayersmap/toolbar/gpx_line.png" alt="' |
222 | - . $this->getlang('alt_legend_gpx') . '" /></td> |
|
223 | - <td class="txt" colspan="3">GPX track: ' . $this->getFileName($gmap ['gpxfile']) . '</td> |
|
222 | + . $this->getlang('alt_legend_gpx').'" /></td> |
|
223 | + <td class="txt" colspan="3">GPX track: ' . $this->getFileName($gmap ['gpxfile']).'</td> |
|
224 | 224 | </tr>'; |
225 | 225 | } |
226 | - if(!empty ($gmap ['geojsonfile'])) { |
|
226 | + if (!empty ($gmap ['geojsonfile'])) { |
|
227 | 227 | $poitable .= ' |
228 | 228 | <tr> |
229 | 229 | <td class="rowId"><img src="' . DOKU_BASE |
230 | 230 | . 'lib/plugins/openlayersmap/toolbar/geojson_file.png" alt="GeoJSON file" /></td> |
231 | 231 | <td class="icon"><img src="' . DOKU_BASE |
232 | 232 | . 'lib/plugins/openlayersmap/toolbar/geojson_line.png" alt="' |
233 | - . $this->getlang('alt_legend_geojson') . '" /></td> |
|
234 | - <td class="txt" colspan="3">GeoJSON track: ' . $this->getFileName($gmap ['geojsonfile']) . '</td> |
|
233 | + . $this->getlang('alt_legend_geojson').'" /></td> |
|
234 | + <td class="txt" colspan="3">GeoJSON track: ' . $this->getFileName($gmap ['geojsonfile']).'</td> |
|
235 | 235 | </tr>'; |
236 | 236 | } |
237 | 237 | |
238 | 238 | $autozoom = empty ($gmap ['autozoom']) ? $this->getConf('autoZoomMap') : $gmap ['autozoom']; |
239 | - $js = "{mapOpts: {" . $param . ", displayformat: '" . $this->getConf('displayformat') |
|
240 | - . "', autozoom: " . $autozoom . "}, poi: [$poi]};"; |
|
239 | + $js = "{mapOpts: {".$param.", displayformat: '".$this->getConf('displayformat') |
|
240 | + . "', autozoom: ".$autozoom."}, poi: [$poi]};"; |
|
241 | 241 | // unescape the json |
242 | 242 | $poitable = stripslashes($poitable); |
243 | 243 | |
@@ -265,21 +265,21 @@ discard block |
||
265 | 265 | preg_match_all('/(\w*)="(.*?)"/us', $str_params, $param, PREG_SET_ORDER); |
266 | 266 | // parse match for instructions, break into key value pairs |
267 | 267 | $gmap = $this->dflt; |
268 | - foreach($gmap as $key => &$value) { |
|
269 | - $defval = $this->getConf('default_' . $key); |
|
270 | - if($defval !== '') { |
|
268 | + foreach ($gmap as $key => &$value) { |
|
269 | + $defval = $this->getConf('default_'.$key); |
|
270 | + if ($defval !== '') { |
|
271 | 271 | $value = $defval; |
272 | 272 | } |
273 | 273 | } |
274 | 274 | unset ($value); |
275 | - foreach($param as $kvpair) { |
|
275 | + foreach ($param as $kvpair) { |
|
276 | 276 | list ($match, $key, $val) = $kvpair; |
277 | 277 | $key = strtolower($key); |
278 | - if(isset ($gmap [$key])) { |
|
279 | - if($key == 'summary') { |
|
278 | + if (isset ($gmap [$key])) { |
|
279 | + if ($key == 'summary') { |
|
280 | 280 | // preserve case for summary field |
281 | 281 | $gmap [$key] = $val; |
282 | - } elseif($key == 'id') { |
|
282 | + } elseif ($key == 'id') { |
|
283 | 283 | // preserve case for id field |
284 | 284 | $gmap [$key] = $val; |
285 | 285 | } else { |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | ); |
316 | 316 | // create poi array |
317 | 317 | $overlay = array(); |
318 | - foreach($point as $pt) { |
|
318 | + foreach ($point as $pt) { |
|
319 | 319 | list ($match, $lat, $lon, $angle, $opacity, $img, $text) = $pt; |
320 | 320 | $lat = is_numeric($lat) ? $lat : 0; |
321 | 321 | $lon = is_numeric($lon) ? $lon : 0; |
@@ -349,10 +349,10 @@ discard block |
||
349 | 349 | */ |
350 | 350 | private function getGoogle(array $gmap, array $overlay): string { |
351 | 351 | $sUrl = $this->getConf('iconUrlOverload'); |
352 | - if(!$sUrl) { |
|
352 | + if (!$sUrl) { |
|
353 | 353 | $sUrl = DOKU_URL; |
354 | 354 | } |
355 | - switch($gmap ['baselyr']) { |
|
355 | + switch ($gmap ['baselyr']) { |
|
356 | 356 | case 'google hybrid' : |
357 | 357 | $maptype = 'hybrid'; |
358 | 358 | break; |
@@ -372,29 +372,29 @@ discard block |
||
372 | 372 | // see: https://developers.google.com/maps/documentation/staticmaps/index#Viewports |
373 | 373 | // 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 |
374 | 374 | $imgUrl = "https://maps.googleapis.com/maps/api/staticmap?"; |
375 | - $imgUrl .= "&size=" . str_replace("px", "", $gmap ['width']) . "x" |
|
375 | + $imgUrl .= "&size=".str_replace("px", "", $gmap ['width'])."x" |
|
376 | 376 | . str_replace("px", "", $gmap ['height']); |
377 | 377 | //if (!$this->getConf( 'autoZoomMap')) { // no need for center & zoom params } |
378 | - $imgUrl .= "¢er=" . $gmap ['lat'] . "," . $gmap ['lon']; |
|
378 | + $imgUrl .= "¢er=".$gmap ['lat'].",".$gmap ['lon']; |
|
379 | 379 | // max is 21 (== building scale), but that's overkill.. |
380 | - if($gmap ['zoom'] > 17) { |
|
380 | + if ($gmap ['zoom'] > 17) { |
|
381 | 381 | $imgUrl .= "&zoom=17"; |
382 | 382 | } else { |
383 | - $imgUrl .= "&zoom=" . $gmap ['zoom']; |
|
383 | + $imgUrl .= "&zoom=".$gmap ['zoom']; |
|
384 | 384 | } |
385 | - if(!empty ($overlay)) { |
|
385 | + if (!empty ($overlay)) { |
|
386 | 386 | $rowId = 0; |
387 | - foreach($overlay as $data) { |
|
387 | + foreach ($overlay as $data) { |
|
388 | 388 | list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
389 | - $imgUrl .= "&markers=icon%3a" . $sUrl . "lib/plugins/openlayersmap/icons/" . $img . "%7c" |
|
390 | - . $lat . "," . $lon . "%7clabel%3a" . ++$rowId; |
|
389 | + $imgUrl .= "&markers=icon%3a".$sUrl."lib/plugins/openlayersmap/icons/".$img."%7c" |
|
390 | + . $lat.",".$lon."%7clabel%3a".++$rowId; |
|
391 | 391 | } |
392 | 392 | } |
393 | - $imgUrl .= "&format=png&maptype=" . $maptype; |
|
393 | + $imgUrl .= "&format=png&maptype=".$maptype; |
|
394 | 394 | global $conf; |
395 | - $imgUrl .= "&language=" . $conf ['lang']; |
|
396 | - if($this->getConf('googleAPIkey')) { |
|
397 | - $imgUrl .= "&key=" . $this->getConf('googleAPIkey'); |
|
395 | + $imgUrl .= "&language=".$conf ['lang']; |
|
396 | + if ($this->getConf('googleAPIkey')) { |
|
397 | + $imgUrl .= "&key=".$this->getConf('googleAPIkey'); |
|
398 | 398 | } |
399 | 399 | // dbglog($imgUrl,'syntax_plugin_openlayersmap_olmap::getGoogle: Google image url is:'); |
400 | 400 | return $imgUrl; |
@@ -477,23 +477,23 @@ discard block |
||
477 | 477 | private function getStaticOSM(array $gmap, array $overlay) { |
478 | 478 | global $conf; |
479 | 479 | |
480 | - if($this->getConf('optionStaticMapGenerator') == 'local') { |
|
480 | + if ($this->getConf('optionStaticMapGenerator') == 'local') { |
|
481 | 481 | // using local basemap composer |
482 | - if(!$myMap = plugin_load('helper', 'openlayersmap_staticmap')) { |
|
482 | + if (!$myMap = plugin_load('helper', 'openlayersmap_staticmap')) { |
|
483 | 483 | dbglog( |
484 | 484 | $myMap, |
485 | 485 | 'openlayersmap_staticmap plugin is not available for use.' |
486 | 486 | ); |
487 | 487 | } |
488 | - if(!$geophp = plugin_load('helper', 'geophp')) { |
|
488 | + if (!$geophp = plugin_load('helper', 'geophp')) { |
|
489 | 489 | dbglog($geophp, 'geophp plugin is not available for use.'); |
490 | 490 | } |
491 | - $size = str_replace("px", "", $gmap ['width']) . "x" |
|
491 | + $size = str_replace("px", "", $gmap ['width'])."x" |
|
492 | 492 | . str_replace("px", "", $gmap ['height']); |
493 | 493 | |
494 | 494 | $markers = array(); |
495 | - if(!empty ($overlay)) { |
|
496 | - foreach($overlay as $data) { |
|
495 | + if (!empty ($overlay)) { |
|
496 | + foreach ($overlay as $data) { |
|
497 | 497 | list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
498 | 498 | $iconStyle = substr($img, 0, strlen($img) - 4); |
499 | 499 | $markers [] = array( |
@@ -505,26 +505,26 @@ discard block |
||
505 | 505 | } |
506 | 506 | |
507 | 507 | $apikey = ''; |
508 | - switch($gmap ['baselyr']) { |
|
508 | + switch ($gmap ['baselyr']) { |
|
509 | 509 | case 'mapnik' : |
510 | 510 | case 'openstreetmap' : |
511 | 511 | $maptype = 'openstreetmap'; |
512 | 512 | break; |
513 | 513 | case 'transport' : |
514 | 514 | $maptype = 'transport'; |
515 | - $apikey = '?apikey=' . $this->getConf('tfApiKey'); |
|
515 | + $apikey = '?apikey='.$this->getConf('tfApiKey'); |
|
516 | 516 | break; |
517 | 517 | case 'landscape' : |
518 | 518 | $maptype = 'landscape'; |
519 | - $apikey = '?apikey=' . $this->getConf('tfApiKey'); |
|
519 | + $apikey = '?apikey='.$this->getConf('tfApiKey'); |
|
520 | 520 | break; |
521 | 521 | case 'outdoors' : |
522 | 522 | $maptype = 'outdoors'; |
523 | - $apikey = '?apikey=' . $this->getConf('tfApiKey'); |
|
523 | + $apikey = '?apikey='.$this->getConf('tfApiKey'); |
|
524 | 524 | break; |
525 | 525 | case 'cycle map' : |
526 | 526 | $maptype = 'cycle'; |
527 | - $apikey = '?apikey=' . $this->getConf('tfApiKey'); |
|
527 | + $apikey = '?apikey='.$this->getConf('tfApiKey'); |
|
528 | 528 | break; |
529 | 529 | case 'hike and bike map' : |
530 | 530 | $maptype = 'hikeandbike'; |
@@ -553,25 +553,25 @@ discard block |
||
553 | 553 | // ol-marker|47.921629720114,18.027343747285,ol-marker-gold|47.951071133739,19.257812497236, |
554 | 554 | // ol-marker-blue|47.180141361692,19.257812497236,ol-marker-green |
555 | 555 | $imgUrl = "https://staticmap.openstreetmap.de/staticmap.php"; |
556 | - $imgUrl .= "?center=" . $gmap ['lat'] . "," . $gmap ['lon']; |
|
557 | - $imgUrl .= "&size=" . str_replace("px", "", $gmap ['width']) . "x" |
|
556 | + $imgUrl .= "?center=".$gmap ['lat'].",".$gmap ['lon']; |
|
557 | + $imgUrl .= "&size=".str_replace("px", "", $gmap ['width'])."x" |
|
558 | 558 | . str_replace("px", "", $gmap ['height']); |
559 | 559 | |
560 | - if($gmap ['zoom'] > 16) { |
|
560 | + if ($gmap ['zoom'] > 16) { |
|
561 | 561 | // actually this could even be 18, but that seems overkill |
562 | 562 | $imgUrl .= "&zoom=16"; |
563 | 563 | } else { |
564 | - $imgUrl .= "&zoom=" . $gmap ['zoom']; |
|
564 | + $imgUrl .= "&zoom=".$gmap ['zoom']; |
|
565 | 565 | } |
566 | 566 | |
567 | - if(!empty ($overlay)) { |
|
568 | - $rowId = 0; |
|
567 | + if (!empty ($overlay)) { |
|
568 | + $rowId = 0; |
|
569 | 569 | $imgUrl .= "&markers="; |
570 | - foreach($overlay as $data) { |
|
570 | + foreach ($overlay as $data) { |
|
571 | 571 | list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
572 | 572 | $rowId++; |
573 | 573 | $iconStyle = "lightblue$rowId"; |
574 | - $imgUrl .= "$lat,$lon,$iconStyle%7c"; |
|
574 | + $imgUrl .= "$lat,$lon,$iconStyle%7c"; |
|
575 | 575 | } |
576 | 576 | $imgUrl = substr($imgUrl, 0, -3); |
577 | 577 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * @return string |
591 | 591 | */ |
592 | 592 | private function getBing(array $gmap, array $overlay): string { |
593 | - switch($gmap ['baselyr']) { |
|
593 | + switch ($gmap ['baselyr']) { |
|
594 | 594 | case 've hybrid' : |
595 | 595 | case 'bing hybrid' : |
596 | 596 | $maptype = 'AerialWithLabels'; |
@@ -607,33 +607,33 @@ discard block |
||
607 | 607 | $maptype = 'Road'; |
608 | 608 | break; |
609 | 609 | } |
610 | - $imgUrl = "https://dev.virtualearth.net/REST/v1/Imagery/Map/" . $maptype;// . "/"; |
|
611 | - if($this->getConf('autoZoomMap')) { |
|
610 | + $imgUrl = "https://dev.virtualearth.net/REST/v1/Imagery/Map/".$maptype; // . "/"; |
|
611 | + if ($this->getConf('autoZoomMap')) { |
|
612 | 612 | $bbox = $this->calcBBOX($overlay, $gmap ['lat'], $gmap ['lon']); |
613 | 613 | //$imgUrl .= "?ma=" . $bbox ['minlat'] . "," . $bbox ['minlon'] . "," |
614 | 614 | // . $bbox ['maxlat'] . "," . $bbox ['maxlon']; |
615 | - $imgUrl .= "?ma=" . $bbox ['minlat'] . "%2C" . $bbox ['minlon'] . "%2C" . $bbox ['maxlat'] |
|
616 | - . "%2C" . $bbox ['maxlon']; |
|
615 | + $imgUrl .= "?ma=".$bbox ['minlat']."%2C".$bbox ['minlon']."%2C".$bbox ['maxlat'] |
|
616 | + . "%2C".$bbox ['maxlon']; |
|
617 | 617 | $imgUrl .= "&dcl=1"; |
618 | 618 | } |
619 | - if(strpos($imgUrl, "?") === false) |
|
619 | + if (strpos($imgUrl, "?") === false) |
|
620 | 620 | $imgUrl .= "?"; |
621 | 621 | |
622 | 622 | //$imgUrl .= "&ms=" . str_replace ( "px", "", $gmap ['width'] ) . "," |
623 | 623 | // . str_replace ( "px", "", $gmap ['height'] ); |
624 | - $imgUrl .= "&ms=" . str_replace("px", "", $gmap ['width']) . "%2C" |
|
624 | + $imgUrl .= "&ms=".str_replace("px", "", $gmap ['width'])."%2C" |
|
625 | 625 | . str_replace("px", "", $gmap ['height']); |
626 | - $imgUrl .= "&key=" . $this->getConf('bingAPIKey'); |
|
627 | - if(!empty ($overlay)) { |
|
626 | + $imgUrl .= "&key=".$this->getConf('bingAPIKey'); |
|
627 | + if (!empty ($overlay)) { |
|
628 | 628 | $rowId = 0; |
629 | - foreach($overlay as $data) { |
|
629 | + foreach ($overlay as $data) { |
|
630 | 630 | list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
631 | 631 | // TODO icon style lookup, see: http://msdn.microsoft.com/en-us/library/ff701719.aspx for iconStyle |
632 | 632 | $iconStyle = 32; |
633 | 633 | $rowId++; |
634 | 634 | // NOTE: the max number of pushpins is 18! or we have to use POST |
635 | 635 | // (http://msdn.microsoft.com/en-us/library/ff701724.aspx) |
636 | - if($rowId == 18) { |
|
636 | + if ($rowId == 18) { |
|
637 | 637 | break; |
638 | 638 | } |
639 | 639 | //$imgUrl .= "&pp=$lat,$lon;$iconStyle;$rowId"; |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | } |
644 | 644 | global $conf; |
645 | 645 | $imgUrl .= "&fmt=png"; |
646 | - $imgUrl .= "&c=" . $conf ['lang']; |
|
646 | + $imgUrl .= "&c=".$conf ['lang']; |
|
647 | 647 | // dbglog($imgUrl,'syntax_plugin_openlayersmap_olmap::getBing: bing image url is:'); |
648 | 648 | return $imgUrl; |
649 | 649 | } |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | private function calcBBOX(array $overlay, float $lat, float $lon): array { |
663 | 663 | $lats = array($lat); |
664 | 664 | $lons = array($lon); |
665 | - foreach($overlay as $data) { |
|
665 | + foreach ($overlay as $data) { |
|
666 | 666 | list ($lat, $lon, $text, $angle, $opacity, $img) = $data; |
667 | 667 | $lats [] = $lat; |
668 | 668 | $lons [] = $lon; |
@@ -690,13 +690,13 @@ discard block |
||
690 | 690 | * @todo move this into a shared library |
691 | 691 | */ |
692 | 692 | private function convertLat(float $decimaldegrees): string { |
693 | - if(strpos($decimaldegrees, '-') !== false) { |
|
693 | + if (strpos($decimaldegrees, '-') !== false) { |
|
694 | 694 | $latPos = "S"; |
695 | 695 | } else { |
696 | 696 | $latPos = "N"; |
697 | 697 | } |
698 | 698 | $dms = $this->convertDDtoDMS(abs($decimaldegrees)); |
699 | - return hsc($dms . $latPos); |
|
699 | + return hsc($dms.$latPos); |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | /** |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | $secs = ($decimaldegrees - $dms) * 3600; |
712 | 712 | $min = floor($secs / 60); |
713 | 713 | $sec = round($secs - ($min * 60), 3); |
714 | - $dms .= 'º' . $min . '\'' . $sec . '"'; |
|
714 | + $dms .= 'º'.$min.'\''.$sec.'"'; |
|
715 | 715 | return $dms; |
716 | 716 | } |
717 | 717 | |
@@ -723,13 +723,13 @@ discard block |
||
723 | 723 | * @todo move this into a shared library |
724 | 724 | */ |
725 | 725 | private function convertLon(float $decimaldegrees): string { |
726 | - if(strpos($decimaldegrees, '-') !== false) { |
|
726 | + if (strpos($decimaldegrees, '-') !== false) { |
|
727 | 727 | $lonPos = "W"; |
728 | 728 | } else { |
729 | 729 | $lonPos = "E"; |
730 | 730 | } |
731 | 731 | $dms = $this->convertDDtoDMS(abs($decimaldegrees)); |
732 | - return hsc($dms . $lonPos); |
|
732 | + return hsc($dms.$lonPos); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | /** |
@@ -760,60 +760,60 @@ discard block |
||
760 | 760 | // dbglog($data, 'olmap::render() data.'); |
761 | 761 | list ($mapid, $param, $mainLat, $mainLon, $poitable, $poitabledesc, $staticImgUrl, $_firstimage) = $data; |
762 | 762 | |
763 | - if($format == 'xhtml') { |
|
763 | + if ($format == 'xhtml') { |
|
764 | 764 | $olscript = ''; |
765 | 765 | $stamenEnable = $this->getConf('enableStamen'); |
766 | 766 | $osmEnable = $this->getConf('enableOSM'); |
767 | 767 | $enableBing = $this->getConf('enableBing'); |
768 | 768 | |
769 | 769 | $scriptEnable = ''; |
770 | - if(!$initialised) { |
|
770 | + if (!$initialised) { |
|
771 | 771 | $initialised = true; |
772 | 772 | // render necessary script tags only once |
773 | - $olscript = '<script defer="defer" src="' . DOKU_BASE . 'lib/plugins/openlayersmap/ol7/ol.js"></script> |
|
774 | -<script defer="defer" src="' . DOKU_BASE . 'lib/plugins/openlayersmap/ol7/ol-layerswitcher.js"></script>'; |
|
773 | + $olscript = '<script defer="defer" src="'.DOKU_BASE.'lib/plugins/openlayersmap/ol7/ol.js"></script> |
|
774 | +<script defer="defer" src="' . DOKU_BASE.'lib/plugins/openlayersmap/ol7/ol-layerswitcher.js"></script>'; |
|
775 | 775 | |
776 | 776 | $scriptEnable = '<script defer="defer" src="data:text/javascript;base64,'; |
777 | 777 | $scriptSrc = $olscript ? 'const olEnable=true;' : 'const olEnable=false;'; |
778 | - $scriptSrc .= 'const osmEnable=' . ($osmEnable ? 'true' : 'false') . ';'; |
|
779 | - $scriptSrc .= 'const stamenEnable=' . ($stamenEnable ? 'true' : 'false') . ';'; |
|
780 | - $scriptSrc .= 'const bEnable=' . ($enableBing ? 'true' : 'false') . ';'; |
|
781 | - $scriptSrc .= 'const bApiKey="' . $this->getConf('bingAPIKey') . '";'; |
|
782 | - $scriptSrc .= 'const tfApiKey="' . $this->getConf('tfApiKey') . '";'; |
|
783 | - $scriptSrc .= 'const gApiKey="' . $this->getConf('googleAPIkey') . '";'; |
|
778 | + $scriptSrc .= 'const osmEnable='.($osmEnable ? 'true' : 'false').';'; |
|
779 | + $scriptSrc .= 'const stamenEnable='.($stamenEnable ? 'true' : 'false').';'; |
|
780 | + $scriptSrc .= 'const bEnable='.($enableBing ? 'true' : 'false').';'; |
|
781 | + $scriptSrc .= 'const bApiKey="'.$this->getConf('bingAPIKey').'";'; |
|
782 | + $scriptSrc .= 'const tfApiKey="'.$this->getConf('tfApiKey').'";'; |
|
783 | + $scriptSrc .= 'const gApiKey="'.$this->getConf('googleAPIkey').'";'; |
|
784 | 784 | $scriptSrc .= 'olMapData = []; let olMaps = {}; let olMapOverlays = {};'; |
785 | 785 | $scriptEnable .= base64_encode($scriptSrc); |
786 | 786 | $scriptEnable .= '"></script>'; |
787 | 787 | } |
788 | 788 | $renderer->doc .= "$olscript\n$scriptEnable"; |
789 | - $renderer->doc .= '<div class="olMapHelp">' . $this->locale_xhtml("help") . '</div>'; |
|
790 | - if($this->getConf('enableA11y')) { |
|
791 | - $renderer->doc .= '<div id="' . $mapid . '-static" class="olStaticMap">' |
|
792 | - . p_render($format, p_get_instructions($staticImgUrl), $info) . '</div>'; |
|
789 | + $renderer->doc .= '<div class="olMapHelp">'.$this->locale_xhtml("help").'</div>'; |
|
790 | + if ($this->getConf('enableA11y')) { |
|
791 | + $renderer->doc .= '<div id="'.$mapid.'-static" class="olStaticMap">' |
|
792 | + . p_render($format, p_get_instructions($staticImgUrl), $info).'</div>'; |
|
793 | 793 | } |
794 | - $renderer->doc .= '<div id="' . $mapid . '-clearer" class="clearer"><p> </p></div>'; |
|
795 | - if($this->getConf('enableA11y')) { |
|
794 | + $renderer->doc .= '<div id="'.$mapid.'-clearer" class="clearer"><p> </p></div>'; |
|
795 | + if ($this->getConf('enableA11y')) { |
|
796 | 796 | // render a table of the POI for the print and a11y presentation, it is hidden using javascript |
797 | 797 | $renderer->doc .= ' |
798 | - <div class="olPOItableSpan" id="' . $mapid . '-table-span"> |
|
799 | - <table class="olPOItable" id="' . $mapid . '-table"> |
|
800 | - <caption class="olPOITblCaption">' . $this->getLang('olmapPOItitle') . '</caption> |
|
798 | + <div class="olPOItableSpan" id="' . $mapid.'-table-span"> |
|
799 | + <table class="olPOItable" id="' . $mapid.'-table"> |
|
800 | + <caption class="olPOITblCaption">' . $this->getLang('olmapPOItitle').'</caption> |
|
801 | 801 | <thead class="olPOITblHeader"> |
802 | 802 | <tr> |
803 | 803 | <th class="rowId" scope="col">id</th> |
804 | - <th class="icon" scope="col">' . $this->getLang('olmapPOIicon') . '</th> |
|
805 | - <th class="lat" scope="col" title="' . $this->getLang('olmapPOIlatTitle') . '">' |
|
806 | - . $this->getLang('olmapPOIlat') . '</th> |
|
807 | - <th class="lon" scope="col" title="' . $this->getLang('olmapPOIlonTitle') . '">' |
|
808 | - . $this->getLang('olmapPOIlon') . '</th> |
|
809 | - <th class="txt" scope="col">' . $this->getLang('olmapPOItxt') . '</th> |
|
804 | + <th class="icon" scope="col">' . $this->getLang('olmapPOIicon').'</th> |
|
805 | + <th class="lat" scope="col" title="' . $this->getLang('olmapPOIlatTitle').'">' |
|
806 | + . $this->getLang('olmapPOIlat').'</th> |
|
807 | + <th class="lon" scope="col" title="' . $this->getLang('olmapPOIlonTitle').'">' |
|
808 | + . $this->getLang('olmapPOIlon').'</th> |
|
809 | + <th class="txt" scope="col">' . $this->getLang('olmapPOItxt').'</th> |
|
810 | 810 | </tr> |
811 | 811 | </thead>'; |
812 | - if($poitabledesc != '') { |
|
813 | - $renderer->doc .= '<tfoot class="olPOITblFooter"><tr><td colspan="5">' . $poitabledesc |
|
812 | + if ($poitabledesc != '') { |
|
813 | + $renderer->doc .= '<tfoot class="olPOITblFooter"><tr><td colspan="5">'.$poitabledesc |
|
814 | 814 | . '</td></tr></tfoot>'; |
815 | 815 | } |
816 | - $renderer->doc .= '<tbody class="olPOITblBody">' . $poitable . '</tbody> |
|
816 | + $renderer->doc .= '<tbody class="olPOITblBody">'.$poitable.'</tbody> |
|
817 | 817 | </table> |
818 | 818 | </div>'; |
819 | 819 | $renderer->doc .= "\n"; |
@@ -824,28 +824,28 @@ discard block |
||
824 | 824 | $renderer->doc .= '"></script>'; |
825 | 825 | $mapnumber++; |
826 | 826 | return true; |
827 | - } elseif($format == 'metadata') { |
|
828 | - if(!(($this->dflt ['lat'] == $mainLat) && ($this->dflt ['lon'] == $mainLon))) { |
|
827 | + } elseif ($format == 'metadata') { |
|
828 | + if (!(($this->dflt ['lat'] == $mainLat) && ($this->dflt ['lon'] == $mainLon))) { |
|
829 | 829 | // render geo metadata, unless they are the default |
830 | 830 | $renderer->meta ['geo'] ['lat'] = $mainLat; |
831 | 831 | $renderer->meta ['geo'] ['lon'] = $mainLon; |
832 | - if($geophp = plugin_load('helper', 'geophp')) { |
|
832 | + if ($geophp = plugin_load('helper', 'geophp')) { |
|
833 | 833 | // if we have the geoPHP helper, add the geohash |
834 | 834 | |
835 | 835 | // fails with older php versions.. |
836 | 836 | // $renderer->meta['geo']['geohash'] = (new Point($mainLon,$mainLat))->out('geohash'); |
837 | - $p = new Point ($mainLon, $mainLat); |
|
837 | + $p = new Point($mainLon, $mainLat); |
|
838 | 838 | $renderer->meta ['geo'] ['geohash'] = $p->out('geohash'); |
839 | 839 | } |
840 | 840 | } |
841 | 841 | |
842 | - if(($this->getConf('enableA11y')) && (!empty ($_firstimage))) { |
|
842 | + if (($this->getConf('enableA11y')) && (!empty ($_firstimage))) { |
|
843 | 843 | // add map local image into relation/firstimage if not already filled and when it is a local image |
844 | 844 | |
845 | 845 | global $ID; |
846 | 846 | $rel = p_get_metadata($ID, 'relation', METADATA_RENDER_USING_CACHE); |
847 | 847 | $img = $rel ['firstimage']; |
848 | - if(empty ($img) /* || $img == $_firstimage*/) { |
|
848 | + if (empty ($img) /* || $img == $_firstimage*/) { |
|
849 | 849 | //dbglog ( $_firstimage, |
850 | 850 | // 'olmap::render#rendering image relation metadata for _firstimage as $img was empty or same.' ); |
851 | 851 | // This seems to never work; the firstimage entry in the .meta file is empty |
@@ -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(); |
@@ -471,8 +471,9 @@ |
||
471 | 471 | * for better proxy handling... |
472 | 472 | */ |
473 | 473 | public function fetchTile(string $url) { |
474 | - if($this->useTileCache && ($cached = $this->checkTileCache($url))) |
|
475 | - return $cached; |
|
474 | + if($this->useTileCache && ($cached = $this->checkTileCache($url))) { |
|
475 | + return $cached; |
|
476 | + } |
|
476 | 477 | |
477 | 478 | $_UA = 'Mozilla/4.0 (compatible; DokuWikiSpatial HTTP Client; ' . PHP_OS . ')'; |
478 | 479 | if(function_exists("curl_init")) { |
@@ -331,17 +331,17 @@ |
||
331 | 331 | public function serializeParams(): string { |
332 | 332 | return implode( |
333 | 333 | "&", array( |
334 | - $this->zoom, |
|
335 | - $this->lat, |
|
336 | - $this->lon, |
|
337 | - $this->width, |
|
338 | - $this->height, |
|
339 | - serialize($this->markers), |
|
340 | - $this->maptype, |
|
341 | - $this->kmlFileName, |
|
342 | - $this->gpxFileName, |
|
343 | - $this->geojsonFileName |
|
344 | - ) |
|
334 | + $this->zoom, |
|
335 | + $this->lat, |
|
336 | + $this->lon, |
|
337 | + $this->width, |
|
338 | + $this->height, |
|
339 | + serialize($this->markers), |
|
340 | + $this->maptype, |
|
341 | + $this->kmlFileName, |
|
342 | + $this->gpxFileName, |
|
343 | + $this->geojsonFileName |
|
344 | + ) |
|
345 | 345 | ); |
346 | 346 | } |
347 | 347 |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $this->height = $height; |
215 | 215 | // validate + set maptype |
216 | 216 | $this->maptype = $this->tileDefaultSrc; |
217 | - if(array_key_exists($maptype, $this->tileInfo)) { |
|
217 | + if (array_key_exists($maptype, $this->tileInfo)) { |
|
218 | 218 | $this->maptype = $maptype; |
219 | 219 | } |
220 | 220 | $this->markers = $markers; |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | $this->gpxFileName = $gpx; |
223 | 223 | $this->geojsonFileName = $geojson; |
224 | 224 | $this->mediaBaseDir = $mediaDir; |
225 | - $this->tileCacheBaseDir = $tileCacheBaseDir . '/olmaptiles'; |
|
225 | + $this->tileCacheBaseDir = $tileCacheBaseDir.'/olmaptiles'; |
|
226 | 226 | $this->useTileCache = $this->tileCacheBaseDir !== ''; |
227 | - $this->mapCacheBaseDir = $mediaDir . '/olmapmaps'; |
|
227 | + $this->mapCacheBaseDir = $mediaDir.'/olmapmaps'; |
|
228 | 228 | $this->autoZoomExtent = $autoZoomExtent; |
229 | 229 | $this->apikey = $apikey; |
230 | 230 | } |
@@ -236,15 +236,15 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function getMap(): string { |
238 | 238 | try { |
239 | - if($this->autoZoomExtent) { |
|
239 | + if ($this->autoZoomExtent) { |
|
240 | 240 | $this->autoZoom(); |
241 | 241 | } |
242 | - } catch(Exception $e) { |
|
242 | + } catch (Exception $e) { |
|
243 | 243 | dbglog($e); |
244 | 244 | } |
245 | 245 | |
246 | 246 | // use map cache, so check cache for map |
247 | - if(!$this->checkMapCache()) { |
|
247 | + if (!$this->checkMapCache()) { |
|
248 | 248 | // map is not in cache, needs to be build |
249 | 249 | $this->makeMap(); |
250 | 250 | $this->mkdirRecursive(dirname($this->mapCacheIDToFilename()), 0777); |
@@ -264,37 +264,37 @@ discard block |
||
264 | 264 | */ |
265 | 265 | private function autoZoom(float $paddingFactor = 1.0): void { |
266 | 266 | $geoms = array(); |
267 | - $geoms [] = new Point ($this->lon, $this->lat); |
|
268 | - if(!empty ($this->markers)) { |
|
269 | - foreach($this->markers as $marker) { |
|
270 | - $geoms [] = new Point ($marker ['lon'], $marker ['lat']); |
|
267 | + $geoms [] = new Point($this->lon, $this->lat); |
|
268 | + if (!empty ($this->markers)) { |
|
269 | + foreach ($this->markers as $marker) { |
|
270 | + $geoms [] = new Point($marker ['lon'], $marker ['lat']); |
|
271 | 271 | } |
272 | 272 | } |
273 | - if(file_exists($this->kmlFileName)) { |
|
273 | + if (file_exists($this->kmlFileName)) { |
|
274 | 274 | $g = geoPHP::load(file_get_contents($this->kmlFileName), 'kml'); |
275 | - if($g !== false) { |
|
275 | + if ($g !== false) { |
|
276 | 276 | $geoms [] = $g; |
277 | 277 | } |
278 | 278 | } |
279 | - if(file_exists($this->gpxFileName)) { |
|
279 | + if (file_exists($this->gpxFileName)) { |
|
280 | 280 | $g = geoPHP::load(file_get_contents($this->gpxFileName), 'gpx'); |
281 | - if($g !== false) { |
|
281 | + if ($g !== false) { |
|
282 | 282 | $geoms [] = $g; |
283 | 283 | } |
284 | 284 | } |
285 | - if(file_exists($this->geojsonFileName)) { |
|
285 | + if (file_exists($this->geojsonFileName)) { |
|
286 | 286 | $g = geoPHP::load(file_get_contents($this->geojsonFileName), 'geojson'); |
287 | - if($g !== false) { |
|
287 | + if ($g !== false) { |
|
288 | 288 | $geoms [] = $g; |
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
292 | - if(count($geoms) <= 1) { |
|
292 | + if (count($geoms) <= 1) { |
|
293 | 293 | dbglog($geoms, "StaticMap::autoZoom: Skip setting autozoom options"); |
294 | 294 | return; |
295 | 295 | } |
296 | 296 | |
297 | - $geom = new GeometryCollection ($geoms); |
|
297 | + $geom = new GeometryCollection($geoms); |
|
298 | 298 | $centroid = $geom->centroid(); |
299 | 299 | $bbox = $geom->getBBox(); |
300 | 300 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $vy0 = log(tan(M_PI * (0.25 + $bbox ['miny'] / 360))); |
304 | 304 | $vy1 = log(tan(M_PI * (0.25 + $bbox ['maxy'] / 360))); |
305 | 305 | dbglog("StaticMap::autoZoom: vertical resolution: $vy0, $vy1"); |
306 | - if ($vy1 - $vy0 === 0.0){ |
|
306 | + if ($vy1 - $vy0 === 0.0) { |
|
307 | 307 | $resolutionVertical = 0; |
308 | 308 | dbglog("StaticMap::autoZoom: using $resolutionVertical"); |
309 | 309 | } else { |
@@ -315,11 +315,11 @@ discard block |
||
315 | 315 | dbglog("StaticMap::autoZoom: using $resolutionHorizontal"); |
316 | 316 | $resolution = max($resolutionHorizontal, $resolutionVertical) * $paddingFactor; |
317 | 317 | $zoom = $this->zoom; |
318 | - if ($resolution > 0){ |
|
318 | + if ($resolution > 0) { |
|
319 | 319 | $zoom = log(360 / ($resolution * $this->tileSize), 2); |
320 | 320 | } |
321 | 321 | |
322 | - if(is_finite($zoom) && $zoom < 15 && $zoom > 2) { |
|
322 | + if (is_finite($zoom) && $zoom < 15 && $zoom > 2) { |
|
323 | 323 | $this->zoom = floor($zoom); |
324 | 324 | } |
325 | 325 | $this->lon = $centroid->getX(); |
@@ -352,12 +352,12 @@ discard block |
||
352 | 352 | } |
353 | 353 | |
354 | 354 | public function mapCacheIDToFilename(): string { |
355 | - if(!$this->mapCacheFile) { |
|
356 | - $this->mapCacheFile = $this->mapCacheBaseDir . "/" . $this->maptype . "/" . $this->zoom . "/cache_" |
|
357 | - . substr($this->mapCacheID, 0, 2) . "/" . substr($this->mapCacheID, 2, 2) |
|
358 | - . "/" . substr($this->mapCacheID, 4); |
|
355 | + if (!$this->mapCacheFile) { |
|
356 | + $this->mapCacheFile = $this->mapCacheBaseDir."/".$this->maptype."/".$this->zoom."/cache_" |
|
357 | + . substr($this->mapCacheID, 0, 2)."/".substr($this->mapCacheID, 2, 2) |
|
358 | + . "/".substr($this->mapCacheID, 4); |
|
359 | 359 | } |
360 | - return $this->mapCacheFile . "." . $this->mapCacheExtension; |
|
360 | + return $this->mapCacheFile.".".$this->mapCacheExtension; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | public function makeMap(): void { |
367 | 367 | $this->initCoords(); |
368 | 368 | $this->createBaseMap(); |
369 | - if(!empty ($this->markers)) { |
|
369 | + if (!empty ($this->markers)) { |
|
370 | 370 | $this->placeMarkers(); |
371 | 371 | } |
372 | 372 | if (file_exists($this->kmlFileName)) { |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | $this->offsetX += floor($startX - floor($this->centerX)) * $this->tileSize; |
440 | 440 | $this->offsetY += floor($startY - floor($this->centerY)) * $this->tileSize; |
441 | 441 | |
442 | - for($x = $startX; $x <= $endX; $x++) { |
|
443 | - for($y = $startY; $y <= $endY; $y++) { |
|
442 | + for ($x = $startX; $x <= $endX; $x++) { |
|
443 | + for ($y = $startY; $y <= $endY; $y++) { |
|
444 | 444 | $url = str_replace( |
445 | 445 | array( |
446 | 446 | '{Z}', |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | ); |
455 | 455 | |
456 | 456 | $tileData = $this->fetchTile($url); |
457 | - if($tileData) { |
|
457 | + if ($tileData) { |
|
458 | 458 | $tileImage = imagecreatefromstring($tileData); |
459 | 459 | } else { |
460 | 460 | $tileImage = imagecreate($this->tileSize, $this->tileSize); |
@@ -480,17 +480,17 @@ discard block |
||
480 | 480 | * for better proxy handling... |
481 | 481 | */ |
482 | 482 | public function fetchTile(string $url) { |
483 | - if($this->useTileCache && ($cached = $this->checkTileCache($url))) |
|
483 | + if ($this->useTileCache && ($cached = $this->checkTileCache($url))) |
|
484 | 484 | return $cached; |
485 | 485 | |
486 | - $_UA = 'Mozilla/4.0 (compatible; DokuWikiSpatial HTTP Client; ' . PHP_OS . ')'; |
|
487 | - if(function_exists("curl_init")) { |
|
486 | + $_UA = 'Mozilla/4.0 (compatible; DokuWikiSpatial HTTP Client; '.PHP_OS.')'; |
|
487 | + if (function_exists("curl_init")) { |
|
488 | 488 | // use cUrl |
489 | 489 | $ch = curl_init(); |
490 | 490 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
491 | 491 | curl_setopt($ch, CURLOPT_USERAGENT, $_UA); |
492 | 492 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); |
493 | - curl_setopt($ch, CURLOPT_URL, $url . $this->apikey); |
|
493 | + curl_setopt($ch, CURLOPT_URL, $url.$this->apikey); |
|
494 | 494 | dbglog("StaticMap::fetchTile: getting: $url using curl_exec"); |
495 | 495 | $tile = curl_exec($ch); |
496 | 496 | curl_close($ch); |
@@ -500,21 +500,21 @@ discard block |
||
500 | 500 | $opts = array( |
501 | 501 | 'http' => array( |
502 | 502 | 'method' => "GET", |
503 | - 'header' => "Accept-language: en\r\n" . "User-Agent: $_UA\r\n" . "accept: image/png\r\n", |
|
503 | + 'header' => "Accept-language: en\r\n"."User-Agent: $_UA\r\n"."accept: image/png\r\n", |
|
504 | 504 | 'request_fulluri' => true |
505 | 505 | ) |
506 | 506 | ); |
507 | - if(isset($conf['proxy']['host'], $conf['proxy']['port']) |
|
507 | + if (isset($conf['proxy']['host'], $conf['proxy']['port']) |
|
508 | 508 | && $conf['proxy']['host'] !== '' |
509 | 509 | && $conf['proxy']['port'] !== '') { |
510 | - $opts['http'] += ['proxy' => "tcp://" . $conf['proxy']['host'] . ":" . $conf['proxy']['port']]; |
|
510 | + $opts['http'] += ['proxy' => "tcp://".$conf['proxy']['host'].":".$conf['proxy']['port']]; |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | $context = stream_context_create($opts); |
514 | 514 | dbglog("StaticMap::fetchTile: getting: $url . $this->apikey using file_get_contents and options $opts"); |
515 | - $tile = file_get_contents($url . $this->apikey, false, $context); |
|
515 | + $tile = file_get_contents($url.$this->apikey, false, $context); |
|
516 | 516 | } |
517 | - if($tile && $this->useTileCache) { |
|
517 | + if ($tile && $this->useTileCache) { |
|
518 | 518 | $this->writeTileToCache($url, $tile); |
519 | 519 | } |
520 | 520 | return $tile; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | */ |
528 | 528 | public function checkTileCache(string $url) { |
529 | 529 | $filename = $this->tileUrlToFilename($url); |
530 | - if(file_exists($filename)) { |
|
530 | + if (file_exists($filename)) { |
|
531 | 531 | return file_get_contents($filename); |
532 | 532 | } |
533 | 533 | return false; |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | * @return string |
540 | 540 | */ |
541 | 541 | public function tileUrlToFilename(string $url): string { |
542 | - return $this->tileCacheBaseDir . "/" . substr($url, strpos($url, '/') + 1); |
|
542 | + return $this->tileCacheBaseDir."/".substr($url, strpos($url, '/') + 1); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | /** |
@@ -574,14 +574,14 @@ discard block |
||
574 | 574 | $count = 0; |
575 | 575 | $color = imagecolorallocate($this->image, 0, 0, 0); |
576 | 576 | $bgcolor = imagecolorallocate($this->image, 200, 200, 200); |
577 | - $markerBaseDir = __DIR__ . '/icons'; |
|
577 | + $markerBaseDir = __DIR__.'/icons'; |
|
578 | 578 | $markerImageOffsetX = 0; |
579 | 579 | $markerImageOffsetY = 0; |
580 | 580 | $markerShadowOffsetX = 0; |
581 | 581 | $markerShadowOffsetY = 0; |
582 | 582 | $markerShadowImg = null; |
583 | 583 | // loop thru marker array |
584 | - foreach($this->markers as $marker) { |
|
584 | + foreach ($this->markers as $marker) { |
|
585 | 585 | // set some local variables |
586 | 586 | $markerLat = $marker ['lat']; |
587 | 587 | $markerLon = $marker ['lon']; |
@@ -591,18 +591,18 @@ discard block |
||
591 | 591 | $markerShadow = ''; |
592 | 592 | $matches = false; |
593 | 593 | // check for marker type, get settings from markerPrototypes |
594 | - if($markerType) { |
|
595 | - foreach($this->markerPrototypes as $markerPrototype) { |
|
596 | - if(preg_match($markerPrototype ['regex'], $markerType, $matches)) { |
|
597 | - $markerFilename = $matches [0] . $markerPrototype ['extension']; |
|
598 | - if($markerPrototype ['offsetImage']) { |
|
594 | + if ($markerType) { |
|
595 | + foreach ($this->markerPrototypes as $markerPrototype) { |
|
596 | + if (preg_match($markerPrototype ['regex'], $markerType, $matches)) { |
|
597 | + $markerFilename = $matches [0].$markerPrototype ['extension']; |
|
598 | + if ($markerPrototype ['offsetImage']) { |
|
599 | 599 | list ($markerImageOffsetX, $markerImageOffsetY) = explode( |
600 | 600 | ",", |
601 | 601 | $markerPrototype ['offsetImage'] |
602 | 602 | ); |
603 | 603 | } |
604 | 604 | $markerShadow = $markerPrototype ['shadow']; |
605 | - if($markerShadow) { |
|
605 | + if ($markerShadow) { |
|
606 | 606 | list ($markerShadowOffsetX, $markerShadowOffsetY) = explode( |
607 | 607 | ",", |
608 | 608 | $markerPrototype ['offsetShadow'] |
@@ -612,14 +612,14 @@ discard block |
||
612 | 612 | } |
613 | 613 | } |
614 | 614 | // create img resource |
615 | - if(file_exists($markerBaseDir . '/' . $markerFilename)) { |
|
616 | - $markerImg = imagecreatefrompng($markerBaseDir . '/' . $markerFilename); |
|
615 | + if (file_exists($markerBaseDir.'/'.$markerFilename)) { |
|
616 | + $markerImg = imagecreatefrompng($markerBaseDir.'/'.$markerFilename); |
|
617 | 617 | } else { |
618 | - $markerImg = imagecreatefrompng($markerBaseDir . '/marker.png'); |
|
618 | + $markerImg = imagecreatefrompng($markerBaseDir.'/marker.png'); |
|
619 | 619 | } |
620 | 620 | // check for shadow + create shadow recource |
621 | - if($markerShadow && file_exists($markerBaseDir . '/' . $markerShadow)) { |
|
622 | - $markerShadowImg = imagecreatefrompng($markerBaseDir . '/' . $markerShadow); |
|
621 | + if ($markerShadow && file_exists($markerBaseDir.'/'.$markerShadow)) { |
|
622 | + $markerShadowImg = imagecreatefrompng($markerBaseDir.'/'.$markerShadow); |
|
623 | 623 | } |
624 | 624 | // calc position |
625 | 625 | $destX = floor( |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | $this->tileSize * ($this->centerY - $this->latToTile($markerLat, $this->zoom)) |
632 | 632 | ); |
633 | 633 | // copy shadow on basemap |
634 | - if($markerShadow && $markerShadowImg) { |
|
634 | + if ($markerShadow && $markerShadowImg) { |
|
635 | 635 | imagecopy( |
636 | 636 | $this->image, |
637 | 637 | $markerShadowImg, |
@@ -693,14 +693,14 @@ discard block |
||
693 | 693 | * drawing colour |
694 | 694 | */ |
695 | 695 | private function drawGeometry(Geometry $geom, int $colour): void { |
696 | - if(empty($geom)) { |
|
696 | + if (empty($geom)) { |
|
697 | 697 | return; |
698 | 698 | } |
699 | 699 | |
700 | - switch($geom->geometryType()) { |
|
700 | + switch ($geom->geometryType()) { |
|
701 | 701 | case 'GeometryCollection' : |
702 | 702 | // recursively draw part of the collection |
703 | - for($i = 1; $i < $geom->numGeometries() + 1; $i++) { |
|
703 | + for ($i = 1; $i < $geom->numGeometries() + 1; $i++) { |
|
704 | 704 | $_geom = $geom->geometryN($i); |
705 | 705 | $this->drawGeometry($_geom, $colour); |
706 | 706 | } |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | // extring is a linestring actually.. |
743 | 743 | $extRing = $polygon->exteriorRing(); |
744 | 744 | |
745 | - for($i = 1; $i < $extRing->numGeometries(); $i++) { |
|
745 | + for ($i = 1; $i < $extRing->numGeometries(); $i++) { |
|
746 | 746 | $p1 = $extRing->geometryN($i); |
747 | 747 | $x = floor( |
748 | 748 | ($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($p1->x(), $this->zoom)) |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | */ |
769 | 769 | private function drawLineString($line, $colour) { |
770 | 770 | imagesetthickness($this->image, 2); |
771 | - for($p = 1; $p < $line->numGeometries(); $p++) { |
|
771 | + for ($p = 1; $p < $line->numGeometries(); $p++) { |
|
772 | 772 | // get first pair of points |
773 | 773 | $p1 = $line->geometryN($p); |
774 | 774 | $p2 = $line->geometryN($p + 1); |
@@ -841,8 +841,8 @@ discard block |
||
841 | 841 | * add copyright and origin notice and icons to the map. |
842 | 842 | */ |
843 | 843 | public function drawCopyright() { |
844 | - $logoBaseDir = dirname(__FILE__) . '/' . 'logo/'; |
|
845 | - $logoImg = imagecreatefrompng($logoBaseDir . $this->tileInfo ['openstreetmap'] ['logo']); |
|
844 | + $logoBaseDir = dirname(__FILE__).'/'.'logo/'; |
|
845 | + $logoImg = imagecreatefrompng($logoBaseDir.$this->tileInfo ['openstreetmap'] ['logo']); |
|
846 | 846 | $textcolor = imagecolorallocate($this->image, 0, 0, 0); |
847 | 847 | $bgcolor = imagecolorallocate($this->image, 200, 200, 200); |
848 | 848 | |
@@ -875,11 +875,11 @@ discard block |
||
875 | 875 | |
876 | 876 | // additional tile source info, ie. who created/hosted the tiles |
877 | 877 | $xIconOffset = 0; |
878 | - if($this->maptype === 'openstreetmap') { |
|
878 | + if ($this->maptype === 'openstreetmap') { |
|
879 | 879 | $mapAuthor = "(c) OpenStreetMap maps/CC BY-SA"; |
880 | 880 | } else { |
881 | 881 | $mapAuthor = $this->tileInfo [$this->maptype] ['txt']; |
882 | - $iconImg = imagecreatefrompng($logoBaseDir . $this->tileInfo [$this->maptype] ['logo']); |
|
882 | + $iconImg = imagecreatefrompng($logoBaseDir.$this->tileInfo [$this->maptype] ['logo']); |
|
883 | 883 | $xIconOffset = imagesx($iconImg); |
884 | 884 | imagecopy( |
885 | 885 | $this->image, |
@@ -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" controls="1" '; |
44 | 44 | $strOpen .= 'baselyr="OpenStreetMap" gpxfile="" kmlfile="" geojsonfile="" summary="" >\n'; |
45 | 45 | $strOpen .= '~~ Plugin olmap help.\n'; |
@@ -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; |