Completed
Pull Request — master (#40)
by Mark
26s
created
action.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -102,18 +102,18 @@  discard block
 block discarded – undo
102 102
         // $data[3] – rev: The page revision, false for current wiki pages.
103 103
 
104 104
         dbglog($event->data, "Event data in removeFromIndex.");
105
-        if(@file_exists($event->data [0] [0])) {
105
+        if (@file_exists($event->data [0] [0])) {
106 106
             // file not new
107
-            if(!$event->data [0] [1]) {
107
+            if (!$event->data [0] [1]) {
108 108
                 // file is empty, page is being deleted
109
-                if(empty ($event->data [1])) {
109
+                if (empty ($event->data [1])) {
110 110
                     // root namespace
111 111
                     $id = $event->data [2];
112 112
                 } else {
113 113
                     $id = $event->data [1] . ":" . $event->data [2];
114 114
                 }
115 115
                 $indexer = plugin_load('helper', 'spatialhelper_index');
116
-                if($indexer) {
116
+                if ($indexer) {
117 117
                     $indexer->deleteFromIndex($id);
118 118
                 }
119 119
             }
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
         // $event→data['items']: Array of SitemapItem instances, the array of sitemap items that already
147 147
         //      contains all public pages of the wiki
148 148
         // $event→data['sitemap']: The path of the file the sitemap will be saved to.
149
-        if($helper = plugin_load('helper', 'spatialhelper_sitemap')) {
149
+        if ($helper = plugin_load('helper', 'spatialhelper_sitemap')) {
150 150
             // dbglog($helper, "createSpatialSitemap loaded helper.");
151 151
 
152 152
             $kml = $helper->createKMLSitemap($this->getConf('media_kml'));
153 153
             $rss = $helper->createGeoRSSSitemap($this->getConf('media_georss'));
154 154
 
155
-            if(!empty ($this->getConf('sitemap_namespaces'))) {
155
+            if (!empty ($this->getConf('sitemap_namespaces'))) {
156 156
                 $namespaces = array_map('trim', explode("\n", $this->getConf('sitemap_namespaces')));
157
-                foreach($namespaces as $namespace) {
157
+                foreach ($namespaces as $namespace) {
158 158
                     $kmlN = $helper->createKMLSitemap($namespace . $this->getConf('media_kml'));
159 159
                     $rssN = $helper->createGeoRSSSitemap($namespace . $this->getConf('media_georss'));
160 160
                     dbglog(
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      *          not used
180 180
      */
181 181
     public function handleActionActPreprocess(Doku_Event $event, $param): void {
182
-        if($event->data !== 'findnearby') {
182
+        if ($event->data !== 'findnearby') {
183 183
             return;
184 184
         }
185 185
         $event->preventDefault();
@@ -195,16 +195,16 @@  discard block
 block discarded – undo
195 195
      *          'format'=> HTML | JSON
196 196
      */
197 197
     public function findnearby(Doku_Event $event, $param): void {
198
-        if($event->data !== 'findnearby') {
198
+        if ($event->data !== 'findnearby') {
199 199
             return;
200 200
         }
201 201
         $event->preventDefault();
202 202
         $results = array();
203 203
         global $INPUT;
204
-        if($helper = plugin_load('helper', 'spatialhelper_search')) {
205
-            if($INPUT->has('lat') && $INPUT->has('lon')) {
204
+        if ($helper = plugin_load('helper', 'spatialhelper_search')) {
205
+            if ($INPUT->has('lat') && $INPUT->has('lon')) {
206 206
                 $results = $helper->findNearbyLatLon($INPUT->param('lat'), $INPUT->param('lon'));
207
-            } elseif($INPUT->has('geohash')) {
207
+            } elseif ($INPUT->has('geohash')) {
208 208
                 $results = $helper->findNearby($INPUT->str('geohash'));
209 209
             } else {
210 210
                 $results = array(
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
         $showMedia = $INPUT->bool('showMedia', true);
217 217
 
218
-        switch($param['format']) {
218
+        switch ($param['format']) {
219 219
             case 'JSON' :
220 220
                 $this->printJSON($results);
221 221
                 break;
@@ -246,13 +246,13 @@  discard block
 block discarded – undo
246 246
      * @param bool  $showMedia
247 247
      */
248 248
     private function printHTML(array $searchresults, bool $showMedia = true): void {
249
-        $pages   = (array) ($searchresults ['pages']);
250
-        $media   = (array) $searchresults ['media'];
251
-        $lat     = (float) $searchresults ['lat'];
252
-        $lon     = (float) $searchresults ['lon'];
253
-        $geohash = (string) $searchresults ['geohash'];
249
+        $pages   = ( array ) ($searchresults ['pages']);
250
+        $media   = ( array ) $searchresults ['media'];
251
+        $lat     = ( float ) $searchresults ['lat'];
252
+        $lon     = ( float ) $searchresults ['lon'];
253
+        $geohash = ( string ) $searchresults ['geohash'];
254 254
 
255
-        if(isset ($searchresults ['error'])) {
255
+        if (isset ($searchresults ['error'])) {
256 256
             print '<div class="level1"><p>' . hsc($searchresults ['error']) . '</p></div>';
257 257
             return;
258 258
         }
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
         // print a HTML list
261 261
         print '<h1>' . $this->getLang('results_header') . '</h1>' . DOKU_LF;
262 262
         print '<div class="level1">' . DOKU_LF;
263
-        if(!empty ($pages)) {
263
+        if (!empty ($pages)) {
264 264
             $pagelist = '<ol>' . DOKU_LF;
265
-            foreach($pages as $page) {
265
+            foreach ($pages as $page) {
266 266
                 $pagelist .= '<li>' . html_wikilink(
267 267
                         ':' . $page ['id'], useHeading('navigation') ? null :
268 268
                         noNS($page ['id'])
@@ -282,14 +282,14 @@  discard block
 block discarded – undo
282 282
             print '<p>' . hsc($this->getLang('nothingfound')) . '</p>';
283 283
         }
284 284
 
285
-        if(!empty ($media) && $showMedia) {
285
+        if (!empty ($media) && $showMedia) {
286 286
             $pagelist = '<ol>' . DOKU_LF;
287
-            foreach($media as $m) {
287
+            foreach ($media as $m) {
288 288
                 $opts       = array();
289 289
                 $link       = ml($m ['id'], $opts, false, '&amp;', false);
290 290
                 $opts ['w'] = '100';
291 291
                 $src        = ml($m ['id'], $opts);
292
-                $pagelist   .= '<li><a href="' . $link . '"><img src="' . $src . '"></a> ('
292
+                $pagelist .= '<li><a href="' . $link . '"><img src="' . $src . '"></a> ('
293 293
                     . $this->getLang('results_distance_prefix') . $page ['distance'] . '&nbsp;m) ' . hsc($desc)
294 294
                     . '</li>' . DOKU_LF;
295 295
             }
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
             print '</div>' . DOKU_LF;
305 305
         }
306 306
         print '<p>' . $this->getLang('results_precision') . $searchresults ['precision'] . ' m. ';
307
-        if(strlen($geohash) > 1) {
307
+        if (strlen($geohash) > 1) {
308 308
             $url = wl(
309 309
                 getID(), array(
310 310
                            'do'      => 'findnearby',
@@ -335,9 +335,9 @@  discard block
 block discarded – undo
335 335
 
336 336
         // check the list of mimetypes
337 337
         // if it's a supported type call appropriate index function
338
-        if(substr_compare($event->data [3], 'image/jpeg', 0)) {
338
+        if (substr_compare($event->data [3], 'image/jpeg', 0)) {
339 339
             $indexer = plugin_load('helper', 'spatialhelper_index');
340
-            if($indexer) {
340
+            if ($indexer) {
341 341
                 $indexer->indexImage($event->data [2]);
342 342
             }
343 343
         }
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 
359 359
         // remove the media id from the index
360 360
         $indexer = plugin_load('helper', 'spatialhelper_index');
361
-        if($indexer) {
361
+        if ($indexer) {
362 362
             $indexer->deleteFromIndex('media__' . $event->data ['id']);
363 363
         }
364 364
     }
Please login to merge, or discard this patch.