Passed
Pull Request — master (#10)
by Mark
08:11
created
syntax/osmlayer.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -117,13 +117,13 @@
 block discarded – undo
117 117
         static $overlaynumber = 0;
118 118
 
119 119
         list ($id, $url, $name, $visible) = $data;
120
-        $renderer->doc .= DOKU_LF . '<script defer="defer" src="data:text/javascript;base64,';
121
-        $str           = '{';
120
+        $renderer->doc .= DOKU_LF.'<script defer="defer" src="data:text/javascript;base64,';
121
+        $str = '{';
122 122
         foreach ($data as $key => $val) {
123
-            $str .= "'" . $key . "' : '" . $val . "',";
123
+            $str .= "'".$key."' : '".$val."',";
124 124
         }
125 125
         $str           .= '"type":"osm"}';
126
-        $renderer->doc .= base64_encode("olMapOverlays['osm" . $overlaynumber . "'] = " . $str . ";")
126
+        $renderer->doc .= base64_encode("olMapOverlays['osm".$overlaynumber."'] = ".$str.";")
127 127
             . '"></script>';
128 128
         $overlaynumber++;
129 129
         return true;
Please login to merge, or discard this patch.
syntax/agslayer.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -121,13 +121,13 @@
 block discarded – undo
121 121
         static $overlaynumber = 0;
122 122
 
123 123
         list ($id, $url, $name, $visible) = $data;
124
-        $renderer->doc .= DOKU_LF . '<script defer="defer" src="data:text/javascript;base64,';
125
-        $str           = '{';
124
+        $renderer->doc .= DOKU_LF.'<script defer="defer" src="data:text/javascript;base64,';
125
+        $str = '{';
126 126
         foreach ($data as $key => $val) {
127
-            $str .= "'" . $key . "' : '" . $val . "',";
127
+            $str .= "'".$key."' : '".$val."',";
128 128
         }
129 129
         $str           .= "'type':'ags'}";
130
-        $renderer->doc .= base64_encode("olMapOverlays['ags" . $overlaynumber . "'] = " . $str . ";")
130
+        $renderer->doc .= base64_encode("olMapOverlays['ags".$overlaynumber."'] = ".$str.";")
131 131
             . '"></script>';
132 132
         $overlaynumber++;
133 133
         return true;
Please login to merge, or discard this patch.
syntax/wmslayer.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -120,13 +120,13 @@
 block discarded – undo
120 120
         static $overlaynumber = 0;
121 121
 
122 122
         list ($id, $url, $name, $visible) = $data;
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':'wms'}";
129
-        $renderer->doc .= base64_encode("olMapOverlays['wms" . $overlaynumber . "'] = " . $str . ";")
129
+        $renderer->doc .= base64_encode("olMapOverlays['wms".$overlaynumber."'] = ".$str.";")
130 130
             . '"></script>';
131 131
         $overlaynumber++;
132 132
         return true;
Please login to merge, or discard this patch.
syntax/olmap.php 1 patch
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             // Google
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 .= "&center=" . $gmap ['lat'] . "," . $gmap ['lon'];
379
+        $imgUrl .= "&center=".$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
 block discarded – undo
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,26 +506,26 @@  discard block
 block discarded – undo
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';
513 513
                     break;
514 514
                 case 'transport' :
515 515
                     $maptype = 'transport';
516
-                    $apikey  = '?apikey=' . $this->getConf('tfApiKey');
516
+                    $apikey  = '?apikey='.$this->getConf('tfApiKey');
517 517
                     break;
518 518
                 case 'landscape' :
519 519
                     $maptype = 'landscape';
520
-                    $apikey  = '?apikey=' . $this->getConf('tfApiKey');
520
+                    $apikey  = '?apikey='.$this->getConf('tfApiKey');
521 521
                     break;
522 522
                 case 'outdoors' :
523 523
                     $maptype = 'outdoors';
524
-                    $apikey  = '?apikey=' . $this->getConf('tfApiKey');
524
+                    $apikey  = '?apikey='.$this->getConf('tfApiKey');
525 525
                     break;
526 526
                 case 'cycle map' :
527 527
                     $maptype = 'cycle';
528
-                    $apikey  = '?apikey=' . $this->getConf('tfApiKey');
528
+                    $apikey  = '?apikey='.$this->getConf('tfApiKey');
529 529
                     break;
530 530
                 case 'hike and bike map' :
531 531
                     $maptype = 'hikeandbike';
@@ -554,25 +554,25 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,60 +761,60 @@  discard block
 block discarded – undo
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
             $stamenEnable = $this->getConf('enableStamen');
767 767
             $osmEnable    = $this->getConf('enableOSM');
768 768
             $enableBing   = $this->getConf('enableBing');
769 769
 
770 770
             $scriptEnable = '';
771
-            if(!$initialised) {
771
+            if (!$initialised) {
772 772
                 $initialised = true;
773 773
                 // render necessary script tags only once
774
-                $olscript = '<script defer="defer" src="' . DOKU_BASE . 'lib/plugins/openlayersmap/ol6/ol.js"></script>
775
-<script defer="defer" src="' . DOKU_BASE . 'lib/plugins/openlayersmap/ol6/ol-layerswitcher.js"></script>';
774
+                $olscript = '<script defer="defer" src="'.DOKU_BASE.'lib/plugins/openlayersmap/ol6/ol.js"></script>
775
+<script defer="defer" src="' . DOKU_BASE.'lib/plugins/openlayersmap/ol6/ol-layerswitcher.js"></script>';
776 776
 
777 777
                 $scriptEnable = '<script defer="defer" src="data:text/javascript;base64,';
778 778
                 $scriptSrc    = $olscript ? 'const olEnable=true;' : 'const olEnable=false;';
779
-                $scriptSrc    .= 'const osmEnable=' . ($osmEnable ? 'true' : 'false') . ';';
780
-                $scriptSrc    .= 'const stamenEnable=' . ($stamenEnable ? 'true' : 'false') . ';';
781
-                $scriptSrc    .= 'const bEnable=' . ($enableBing ? 'true' : 'false') . ';';
782
-                $scriptSrc    .= 'const bApiKey="' . $this->getConf('bingAPIKey') . '";';
783
-                $scriptSrc    .= 'const tfApiKey="' . $this->getConf('tfApiKey') . '";';
784
-                $scriptSrc    .= 'const gApiKey="' . $this->getConf('googleAPIkey') . '";';
779
+                $scriptSrc    .= 'const osmEnable='.($osmEnable ? 'true' : 'false').';';
780
+                $scriptSrc    .= 'const stamenEnable='.($stamenEnable ? 'true' : 'false').';';
781
+                $scriptSrc    .= 'const bEnable='.($enableBing ? 'true' : 'false').';';
782
+                $scriptSrc    .= 'const bApiKey="'.$this->getConf('bingAPIKey').'";';
783
+                $scriptSrc    .= 'const tfApiKey="'.$this->getConf('tfApiKey').'";';
784
+                $scriptSrc    .= 'const gApiKey="'.$this->getConf('googleAPIkey').'";';
785 785
                 $scriptSrc    .= 'olMapData = []; let olMaps = {}; let olMapOverlays = {};';
786 786
                 $scriptEnable .= base64_encode($scriptSrc);
787 787
                 $scriptEnable .= '"></script>';
788 788
             }
789 789
             $renderer->doc .= "$olscript\n$scriptEnable";
790
-            $renderer->doc .= '<div class="olMapHelp">' . $this->locale_xhtml("help") . '</div>';
791
-            if($this->getConf('enableA11y')) {
792
-                $renderer->doc .= '<div id="' . $mapid . '-static" class="olStaticMap">'
793
-                    . p_render($format, p_get_instructions($staticImgUrl), $info) . '</div>';
790
+            $renderer->doc .= '<div class="olMapHelp">'.$this->locale_xhtml("help").'</div>';
791
+            if ($this->getConf('enableA11y')) {
792
+                $renderer->doc .= '<div id="'.$mapid.'-static" class="olStaticMap">'
793
+                    . p_render($format, p_get_instructions($staticImgUrl), $info).'</div>';
794 794
             }
795
-            $renderer->doc .= '<div id="' . $mapid . '-clearer" class="clearer"><p>&nbsp;</p></div>';
796
-            if($this->getConf('enableA11y')) {
795
+            $renderer->doc .= '<div id="'.$mapid.'-clearer" class="clearer"><p>&nbsp;</p></div>';
796
+            if ($this->getConf('enableA11y')) {
797 797
                 // render a table of the POI for the print and a11y presentation, it is hidden using javascript
798 798
                 $renderer->doc .= '
799
-                <div class="olPOItableSpan" id="' . $mapid . '-table-span">
800
-                    <table class="olPOItable" id="' . $mapid . '-table">
801
-                    <caption class="olPOITblCaption">' . $this->getLang('olmapPOItitle') . '</caption>
799
+                <div class="olPOItableSpan" id="' . $mapid.'-table-span">
800
+                    <table class="olPOItable" id="' . $mapid.'-table">
801
+                    <caption class="olPOITblCaption">' . $this->getLang('olmapPOItitle').'</caption>
802 802
                     <thead class="olPOITblHeader">
803 803
                     <tr>
804 804
                     <th class="rowId" scope="col">id</th>
805
-                    <th class="icon" scope="col">' . $this->getLang('olmapPOIicon') . '</th>
806
-                    <th class="lat" scope="col" title="' . $this->getLang('olmapPOIlatTitle') . '">'
807
-                    . $this->getLang('olmapPOIlat') . '</th>
808
-                    <th class="lon" scope="col" title="' . $this->getLang('olmapPOIlonTitle') . '">'
809
-                    . $this->getLang('olmapPOIlon') . '</th>
810
-                    <th class="txt" scope="col">' . $this->getLang('olmapPOItxt') . '</th>
805
+                    <th class="icon" scope="col">' . $this->getLang('olmapPOIicon').'</th>
806
+                    <th class="lat" scope="col" title="' . $this->getLang('olmapPOIlatTitle').'">'
807
+                    . $this->getLang('olmapPOIlat').'</th>
808
+                    <th class="lon" scope="col" title="' . $this->getLang('olmapPOIlonTitle').'">'
809
+                    . $this->getLang('olmapPOIlon').'</th>
810
+                    <th class="txt" scope="col">' . $this->getLang('olmapPOItxt').'</th>
811 811
                     </tr>
812 812
                     </thead>';
813
-                if($poitabledesc != '') {
814
-                    $renderer->doc .= '<tfoot class="olPOITblFooter"><tr><td colspan="5">' . $poitabledesc
813
+                if ($poitabledesc != '') {
814
+                    $renderer->doc .= '<tfoot class="olPOITblFooter"><tr><td colspan="5">'.$poitabledesc
815 815
                         . '</td></tr></tfoot>';
816 816
                 }
817
-                $renderer->doc .= '<tbody class="olPOITblBody">' . $poitable . '</tbody>
817
+                $renderer->doc .= '<tbody class="olPOITblBody">'.$poitable.'</tbody>
818 818
                     </table>
819 819
                 </div>';
820 820
                 $renderer->doc .= "\n";
@@ -825,28 +825,28 @@  discard block
 block discarded – undo
825 825
             $renderer->doc .= '"></script>';
826 826
             $mapnumber++;
827 827
             return true;
828
-        } elseif($format == 'metadata') {
829
-            if(!(($this->dflt ['lat'] == $mainLat) && ($this->dflt ['lon'] == $mainLon))) {
828
+        } elseif ($format == 'metadata') {
829
+            if (!(($this->dflt ['lat'] == $mainLat) && ($this->dflt ['lon'] == $mainLon))) {
830 830
                 // render geo metadata, unless they are the default
831 831
                 $renderer->meta ['geo'] ['lat'] = $mainLat;
832 832
                 $renderer->meta ['geo'] ['lon'] = $mainLon;
833
-                if($geophp = plugin_load('helper', 'geophp')) {
833
+                if ($geophp = plugin_load('helper', 'geophp')) {
834 834
                     // if we have the geoPHP helper, add the geohash
835 835
 
836 836
                     // fails with older php versions..
837 837
                     // $renderer->meta['geo']['geohash'] = (new Point($mainLon,$mainLat))->out('geohash');
838
-                    $p                                  = new Point ($mainLon, $mainLat);
838
+                    $p                                  = new Point($mainLon, $mainLat);
839 839
                     $renderer->meta ['geo'] ['geohash'] = $p->out('geohash');
840 840
                 }
841 841
             }
842 842
 
843
-            if(($this->getConf('enableA11y')) && (!empty ($_firstimage))) {
843
+            if (($this->getConf('enableA11y')) && (!empty ($_firstimage))) {
844 844
                 // add map local image into relation/firstimage if not already filled and when it is a local image
845 845
 
846 846
                 global $ID;
847 847
                 $rel = p_get_metadata($ID, 'relation', METADATA_RENDER_USING_CACHE);
848 848
                 $img = $rel ['firstimage'];
849
-                if(empty ($img) /* || $img == $_firstimage*/) {
849
+                if (empty ($img) /* || $img == $_firstimage*/) {
850 850
                     //dbglog ( $_firstimage,
851 851
                     // 'olmap::render#rendering image relation metadata for _firstimage as $img was empty or same.' );
852 852
                     // This seems to never work; the firstimage entry in the .meta file is empty
Please login to merge, or discard this patch.
StaticMap.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 // phpcs:disable PSR1.Files.SideEffects
23 23
 // TODO resolve side effect
24
-include_once(realpath(__DIR__) . '/../geophp/geoPHP/geoPHP.inc');
24
+include_once(realpath(__DIR__).'/../geophp/geoPHP/geoPHP.inc');
25 25
 
26 26
 /**
27 27
  *
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
         $this->height = $height;
206 206
         // validate + set maptype
207 207
         $this->maptype = $this->tileDefaultSrc;
208
-        if(array_key_exists($maptype, $this->tileInfo)) {
208
+        if (array_key_exists($maptype, $this->tileInfo)) {
209 209
             $this->maptype = $maptype;
210 210
         }
211 211
         $this->markers          = $markers;
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
         $this->gpxFileName      = $gpx;
214 214
         $this->geojsonFileName  = $geojson;
215 215
         $this->mediaBaseDir     = $mediaDir;
216
-        $this->tileCacheBaseDir = $tileCacheBaseDir . '/olmaptiles';
216
+        $this->tileCacheBaseDir = $tileCacheBaseDir.'/olmaptiles';
217 217
         $this->useTileCache     = $this->tileCacheBaseDir !== '';
218
-        $this->mapCacheBaseDir  = $mediaDir . '/olmapmaps';
218
+        $this->mapCacheBaseDir  = $mediaDir.'/olmapmaps';
219 219
         $this->autoZoomExtent   = $autoZoomExtent;
220 220
         $this->apikey           = $apikey;
221 221
     }
@@ -227,15 +227,15 @@  discard block
 block discarded – undo
227 227
      */
228 228
     public function getMap(): string {
229 229
         try {
230
-            if($this->autoZoomExtent) {
230
+            if ($this->autoZoomExtent) {
231 231
                 $this->autoZoom();
232 232
             }
233
-        } catch(Exception $e) {
233
+        } catch (Exception $e) {
234 234
             dbglog($e);
235 235
         }
236 236
 
237 237
         // use map cache, so check cache for map
238
-        if(!$this->checkMapCache()) {
238
+        if (!$this->checkMapCache()) {
239 239
             // map is not in cache, needs to be build
240 240
             $this->makeMap();
241 241
             $this->mkdirRecursive(dirname($this->mapCacheIDToFilename()), 0777);
@@ -258,37 +258,37 @@  discard block
 block discarded – undo
258 258
      */
259 259
     private function autoZoom(float $paddingFactor = 1.0): void {
260 260
         $geoms    = array();
261
-        $geoms [] = new Point ($this->lon, $this->lat);
262
-        if(!empty ($this->markers)) {
263
-            foreach($this->markers as $marker) {
264
-                $geoms [] = new Point ($marker ['lon'], $marker ['lat']);
261
+        $geoms [] = new Point($this->lon, $this->lat);
262
+        if (!empty ($this->markers)) {
263
+            foreach ($this->markers as $marker) {
264
+                $geoms [] = new Point($marker ['lon'], $marker ['lat']);
265 265
             }
266 266
         }
267
-        if(file_exists($this->kmlFileName)) {
267
+        if (file_exists($this->kmlFileName)) {
268 268
             $g = geoPHP::load(file_get_contents($this->kmlFileName), 'kml');
269
-            if($g !== false) {
269
+            if ($g !== false) {
270 270
                 $geoms [] = $g;
271 271
             }
272 272
         }
273
-        if(file_exists($this->gpxFileName)) {
273
+        if (file_exists($this->gpxFileName)) {
274 274
             $g = geoPHP::load(file_get_contents($this->gpxFileName), 'gpx');
275
-            if($g !== false) {
275
+            if ($g !== false) {
276 276
                 $geoms [] = $g;
277 277
             }
278 278
         }
279
-        if(file_exists($this->geojsonFileName)) {
279
+        if (file_exists($this->geojsonFileName)) {
280 280
             $g = geoPHP::load(file_get_contents($this->geojsonFileName), 'geojson');
281
-            if($g !== false) {
281
+            if ($g !== false) {
282 282
                 $geoms [] = $g;
283 283
             }
284 284
         }
285 285
 
286
-        if(count($geoms) <= 1) {
286
+        if (count($geoms) <= 1) {
287 287
             dbglog($geoms, "StaticMap::autoZoom: Skip setting autozoom options");
288 288
             return;
289 289
         }
290 290
 
291
-        $geom     = new GeometryCollection ($geoms);
291
+        $geom     = new GeometryCollection($geoms);
292 292
         $centroid = $geom->centroid();
293 293
         $bbox     = $geom->getBBox();
294 294
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
         $vy0 = log(tan(M_PI * (0.25 + $bbox ['miny'] / 360)));
298 298
         $vy1 = log(tan(M_PI * (0.25 + $bbox ['maxy'] / 360)));
299 299
         dbglog("StaticMap::autoZoom: vertical resolution: $vy0, $vy1");
300
-        if ($vy1 - $vy0 === 0.0){
300
+        if ($vy1 - $vy0 === 0.0) {
301 301
             $resolutionVertical = 0;
302 302
             dbglog("StaticMap::autoZoom: using $resolutionVertical");
303 303
         } else {
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
         $resolution           = max($resolutionHorizontal, $resolutionVertical) * $paddingFactor;
311 311
         $zoom                 = log(360 / ($resolution * $this->tileSize), 2);
312 312
 
313
-        if(is_finite($zoom) && $zoom < 15 && $zoom > 2) {
313
+        if (is_finite($zoom) && $zoom < 15 && $zoom > 2) {
314 314
             $this->zoom = floor($zoom);
315 315
         }
316 316
         $this->lon = $centroid->getX();
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
     }
344 344
 
345 345
     public function mapCacheIDToFilename(): string {
346
-        if(!$this->mapCacheFile) {
347
-            $this->mapCacheFile = $this->mapCacheBaseDir . "/" . $this->maptype . "/" . $this->zoom . "/cache_"
348
-                . substr($this->mapCacheID, 0, 2) . "/" . substr($this->mapCacheID, 2, 2)
349
-                . "/" . substr($this->mapCacheID, 4);
346
+        if (!$this->mapCacheFile) {
347
+            $this->mapCacheFile = $this->mapCacheBaseDir."/".$this->maptype."/".$this->zoom."/cache_"
348
+                . substr($this->mapCacheID, 0, 2)."/".substr($this->mapCacheID, 2, 2)
349
+                . "/".substr($this->mapCacheID, 4);
350 350
         }
351
-        return $this->mapCacheFile . "." . $this->mapCacheExtension;
351
+        return $this->mapCacheFile.".".$this->mapCacheExtension;
352 352
     }
353 353
 
354 354
     /**
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
     public function makeMap(): void {
358 358
         $this->initCoords();
359 359
         $this->createBaseMap();
360
-        if(!empty ($this->markers)) {
360
+        if (!empty ($this->markers)) {
361 361
             $this->placeMarkers();
362 362
         }
363 363
         if (file_exists($this->kmlFileName)) {
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
         $this->offsetX += floor($startX - floor($this->centerX)) * $this->tileSize;
431 431
         $this->offsetY += floor($startY - floor($this->centerY)) * $this->tileSize;
432 432
 
433
-        for($x = $startX; $x <= $endX; $x++) {
434
-            for($y = $startY; $y <= $endY; $y++) {
433
+        for ($x = $startX; $x <= $endX; $x++) {
434
+            for ($y = $startY; $y <= $endY; $y++) {
435 435
                 $url = str_replace(
436 436
                     array(
437 437
                         '{Z}',
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
                 );
446 446
 
447 447
                 $tileData = $this->fetchTile($url);
448
-                if($tileData) {
448
+                if ($tileData) {
449 449
                     $tileImage = imagecreatefromstring($tileData);
450 450
                 } else {
451 451
                     $tileImage = imagecreate($this->tileSize, $this->tileSize);
@@ -471,17 +471,17 @@  discard block
 block discarded – undo
471 471
      *          for better proxy handling...
472 472
      */
473 473
     public function fetchTile(string $url) {
474
-        if($this->useTileCache && ($cached = $this->checkTileCache($url)))
474
+        if ($this->useTileCache && ($cached = $this->checkTileCache($url)))
475 475
             return $cached;
476 476
 
477
-        $_UA = 'Mozilla/4.0 (compatible; DokuWikiSpatial HTTP Client; ' . PHP_OS . ')';
478
-        if(function_exists("curl_init")) {
477
+        $_UA = 'Mozilla/4.0 (compatible; DokuWikiSpatial HTTP Client; '.PHP_OS.')';
478
+        if (function_exists("curl_init")) {
479 479
             // use cUrl
480 480
             $ch = curl_init();
481 481
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
482 482
             curl_setopt($ch, CURLOPT_USERAGENT, $_UA);
483 483
             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
484
-            curl_setopt($ch, CURLOPT_URL, $url . $this->apikey);
484
+            curl_setopt($ch, CURLOPT_URL, $url.$this->apikey);
485 485
             dbglog("StaticMap::fetchTile: getting: $url using curl_exec");
486 486
             $tile = curl_exec($ch);
487 487
             curl_close($ch);
@@ -491,21 +491,21 @@  discard block
 block discarded – undo
491 491
             $opts = array(
492 492
                 'http' => array(
493 493
                     'method'          => "GET",
494
-                    'header'          => "Accept-language: en\r\n" . "User-Agent: $_UA\r\n" . "accept: image/png\r\n",
494
+                    'header'          => "Accept-language: en\r\n"."User-Agent: $_UA\r\n"."accept: image/png\r\n",
495 495
                     'request_fulluri' => true
496 496
                 )
497 497
             );
498
-            if(isset($conf['proxy']['host'], $conf['proxy']['port'])
498
+            if (isset($conf['proxy']['host'], $conf['proxy']['port'])
499 499
                 && $conf['proxy']['host'] !== ''
500 500
                 && $conf['proxy']['port'] !== '') {
501
-                $opts['http'] += ['proxy' => "tcp://" . $conf['proxy']['host'] . ":" . $conf['proxy']['port']];
501
+                $opts['http'] += ['proxy' => "tcp://".$conf['proxy']['host'].":".$conf['proxy']['port']];
502 502
             }
503 503
 
504 504
             $context = stream_context_create($opts);
505 505
             dbglog("StaticMap::fetchTile: getting: $url . $this->apikey using file_get_contents and options $opts");
506
-            $tile = file_get_contents($url . $this->apikey, false, $context);
506
+            $tile = file_get_contents($url.$this->apikey, false, $context);
507 507
         }
508
-        if($tile && $this->useTileCache) {
508
+        if ($tile && $this->useTileCache) {
509 509
             $this->writeTileToCache($url, $tile);
510 510
         }
511 511
         return $tile;
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
      */
519 519
     public function checkTileCache(string $url) {
520 520
         $filename = $this->tileUrlToFilename($url);
521
-        if(file_exists($filename)) {
521
+        if (file_exists($filename)) {
522 522
             return file_get_contents($filename);
523 523
         }
524 524
         return false;
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
      * @return string
531 531
      */
532 532
     public function tileUrlToFilename(string $url): string {
533
-        return $this->tileCacheBaseDir . "/" . substr($url, strpos($url, '/') + 1);
533
+        return $this->tileCacheBaseDir."/".substr($url, strpos($url, '/') + 1);
534 534
     }
535 535
 
536 536
     /**
@@ -565,14 +565,14 @@  discard block
 block discarded – undo
565 565
         $count         = 0;
566 566
         $color         = imagecolorallocate($this->image, 0, 0, 0);
567 567
         $bgcolor       = imagecolorallocate($this->image, 200, 200, 200);
568
-        $markerBaseDir = __DIR__ . '/icons';
568
+        $markerBaseDir = __DIR__.'/icons';
569 569
         $markerImageOffsetX  = 0;
570 570
         $markerImageOffsetY  = 0;
571 571
         $markerShadowOffsetX = 0;
572 572
         $markerShadowOffsetY = 0;
573 573
         $markerShadowImg     = null;
574 574
         // loop thru marker array
575
-        foreach($this->markers as $marker) {
575
+        foreach ($this->markers as $marker) {
576 576
             // set some local variables
577 577
             $markerLat  = $marker ['lat'];
578 578
             $markerLon  = $marker ['lon'];
@@ -582,18 +582,18 @@  discard block
 block discarded – undo
582 582
             $markerShadow   = '';
583 583
             $matches        = false;
584 584
             // check for marker type, get settings from markerPrototypes
585
-            if($markerType) {
586
-                foreach($this->markerPrototypes as $markerPrototype) {
587
-                    if(preg_match($markerPrototype ['regex'], $markerType, $matches)) {
588
-                        $markerFilename = $matches [0] . $markerPrototype ['extension'];
589
-                        if($markerPrototype ['offsetImage']) {
585
+            if ($markerType) {
586
+                foreach ($this->markerPrototypes as $markerPrototype) {
587
+                    if (preg_match($markerPrototype ['regex'], $markerType, $matches)) {
588
+                        $markerFilename = $matches [0].$markerPrototype ['extension'];
589
+                        if ($markerPrototype ['offsetImage']) {
590 590
                             list ($markerImageOffsetX, $markerImageOffsetY) = explode(
591 591
                                 ",",
592 592
                                 $markerPrototype ['offsetImage']
593 593
                             );
594 594
                         }
595 595
                         $markerShadow = $markerPrototype ['shadow'];
596
-                        if($markerShadow) {
596
+                        if ($markerShadow) {
597 597
                             list ($markerShadowOffsetX, $markerShadowOffsetY) = explode(
598 598
                                 ",",
599 599
                                 $markerPrototype ['offsetShadow']
@@ -603,14 +603,14 @@  discard block
 block discarded – undo
603 603
                 }
604 604
             }
605 605
             // create img resource
606
-            if(file_exists($markerBaseDir . '/' . $markerFilename)) {
607
-                $markerImg = imagecreatefrompng($markerBaseDir . '/' . $markerFilename);
606
+            if (file_exists($markerBaseDir.'/'.$markerFilename)) {
607
+                $markerImg = imagecreatefrompng($markerBaseDir.'/'.$markerFilename);
608 608
             } else {
609
-                $markerImg = imagecreatefrompng($markerBaseDir . '/marker.png');
609
+                $markerImg = imagecreatefrompng($markerBaseDir.'/marker.png');
610 610
             }
611 611
             // check for shadow + create shadow recource
612
-            if($markerShadow && file_exists($markerBaseDir . '/' . $markerShadow)) {
613
-                $markerShadowImg = imagecreatefrompng($markerBaseDir . '/' . $markerShadow);
612
+            if ($markerShadow && file_exists($markerBaseDir.'/'.$markerShadow)) {
613
+                $markerShadowImg = imagecreatefrompng($markerBaseDir.'/'.$markerShadow);
614 614
             }
615 615
             // calc position
616 616
             $destX = floor(
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
                 $this->tileSize * ($this->centerY - $this->latToTile($markerLat, $this->zoom))
623 623
             );
624 624
             // copy shadow on basemap
625
-            if($markerShadow && $markerShadowImg) {
625
+            if ($markerShadow && $markerShadowImg) {
626 626
                 imagecopy(
627 627
                     $this->image,
628 628
                     $markerShadowImg,
@@ -683,14 +683,14 @@  discard block
 block discarded – undo
683 683
      *            drawing colour
684 684
      */
685 685
     private function drawGeometry(Geometry $geom, int $colour): void {
686
-        if(empty($geom)) {
686
+        if (empty($geom)) {
687 687
             return;
688 688
         }
689 689
 
690
-        switch($geom->geometryType()) {
690
+        switch ($geom->geometryType()) {
691 691
             case 'GeometryCollection' :
692 692
                 // recursively draw part of the collection
693
-                for($i = 1; $i < $geom->numGeometries() + 1; $i++) {
693
+                for ($i = 1; $i < $geom->numGeometries() + 1; $i++) {
694 694
                     $_geom = $geom->geometryN($i);
695 695
                     $this->drawGeometry($_geom, $colour);
696 696
                 }
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
         // extring is a linestring actually..
733 733
         $extRing = $polygon->exteriorRing();
734 734
 
735
-        for($i = 1; $i < $extRing->numGeometries(); $i++) {
735
+        for ($i = 1; $i < $extRing->numGeometries(); $i++) {
736 736
             $p1           = $extRing->geometryN($i);
737 737
             $x            = floor(
738 738
                 ($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($p1->x(), $this->zoom))
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
      */
759 759
     private function drawLineString($line, $colour) {
760 760
         imagesetthickness($this->image, 2);
761
-        for($p = 1; $p < $line->numGeometries(); $p++) {
761
+        for ($p = 1; $p < $line->numGeometries(); $p++) {
762 762
             // get first pair of points
763 763
             $p1 = $line->geometryN($p);
764 764
             $p2 = $line->geometryN($p + 1);
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
      * add copyright and origin notice and icons to the map.
830 830
      */
831 831
     public function drawCopyright() {
832
-        $logoBaseDir = dirname(__FILE__) . '/' . 'logo/';
833
-        $logoImg     = imagecreatefrompng($logoBaseDir . $this->tileInfo ['openstreetmap'] ['logo']);
832
+        $logoBaseDir = dirname(__FILE__).'/'.'logo/';
833
+        $logoImg     = imagecreatefrompng($logoBaseDir.$this->tileInfo ['openstreetmap'] ['logo']);
834 834
         $textcolor   = imagecolorallocate($this->image, 0, 0, 0);
835 835
         $bgcolor     = imagecolorallocate($this->image, 200, 200, 200);
836 836
 
@@ -863,11 +863,11 @@  discard block
 block discarded – undo
863 863
 
864 864
         // additional tile source info, ie. who created/hosted the tiles
865 865
         $xIconOffset = 0;
866
-        if($this->maptype === 'openstreetmap') {
866
+        if ($this->maptype === 'openstreetmap') {
867 867
             $mapAuthor = "(c) OpenStreetMap maps/CC BY-SA";
868 868
         } else {
869 869
             $mapAuthor   = $this->tileInfo [$this->maptype] ['txt'];
870
-            $iconImg     = imagecreatefrompng($logoBaseDir . $this->tileInfo [$this->maptype] ['logo']);
870
+            $iconImg     = imagecreatefrompng($logoBaseDir.$this->tileInfo [$this->maptype] ['logo']);
871 871
             $xIconOffset = imagesx($iconImg);
872 872
             imagecopy(
873 873
                 $this->image,
Please login to merge, or discard this patch.