Completed
Push — master ( 335f76...be150c )
by Mark
18s queued 14s
created
helper/search.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
         // parent::__construct ();
60 60
         global $conf;
61 61
 
62
-        if(!$geophp = plugin_load('helper', 'geophp')) {
62
+        if (!$geophp = plugin_load('helper', 'geophp')) {
63 63
             $message = 'helper_plugin_spatialhelper_search::spatialhelper_search: geophp plugin is not available.';
64 64
             msg($message, -1);
65 65
         }
66 66
 
67 67
         $idx_dir = $conf ['indexdir'];
68
-        if(!@file_exists($idx_dir . '/spatial.idx')) {
68
+        if (!@file_exists($idx_dir . '/spatial.idx')) {
69 69
             $indexer = plugin_load('helper', 'spatialhelper_index');
70 70
         }
71 71
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public function findNearby(string $geohash, geoPHP\Geometry\Point $p = null): array {
98 98
         $_geohashClass = new geoPHP\Adapter\Geohash();
99
-        if(!$p) {
99
+        if (!$p) {
100 100
             $decodedPoint = $_geohashClass->read($geohash);
101 101
         } else {
102 102
             $decodedPoint = $p;
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 
118 118
         // find all the pages in the index that overlap with the adjacent hashes
119 119
         $docIds = array();
120
-        foreach($adjacent as $adjHash) {
121
-            if(is_array($this->spatial_idx)) {
122
-                foreach($this->spatial_idx as $_geohash => $_docIds) {
123
-                    if(strpos($_geohash, $adjHash) !== false) {
120
+        foreach ($adjacent as $adjHash) {
121
+            if (is_array($this->spatial_idx)) {
122
+                foreach ($this->spatial_idx as $_geohash => $_docIds) {
123
+                    if (strpos($_geohash, $adjHash) !== false) {
124 124
                         // dbglog ( "Found adjacent geo hash: $adjHash in $_geohash" );
125 125
                         // if $adjHash similar to geohash
126 126
                         $docIds = array_merge($docIds, $_docIds);
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
         $media   = array();
137 137
         $indexer = plugin_load('helper', 'spatialhelper_index');
138 138
 
139
-        foreach($docIds as $id) {
140
-            if(strpos($id, 'media__', 0) === 0) {
139
+        foreach ($docIds as $id) {
140
+            if (strpos($id, 'media__', 0) === 0) {
141 141
                 $id = substr($id, strlen('media__'));
142
-                if(auth_quickaclcheck($id) >= /*AUTH_READ*/ 1) {
142
+                if (auth_quickaclcheck($id) >= /*AUTH_READ*/ 1) {
143 143
                     $point    = $indexer->getCoordsFromExif($id);
144 144
                     $line     = new geoPHP\Geometry\LineString(
145 145
                         [
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
                     );
150 150
                     $media [] = array(
151 151
                         'id'       => $id,
152
-                        'distance' => (int) ($line->greatCircleLength()),
152
+                        'distance' => ( int ) ($line->greatCircleLength()),
153 153
                         'lat'      => $point->y(),
154 154
                         'lon'      => $point->x()
155 155
                         // optionally add other meta such as tag, description...
156 156
                     );
157 157
                 }
158 158
             } else {
159
-                if(auth_quickaclcheck($id) >= /*AUTH_READ*/ 1) {
159
+                if (auth_quickaclcheck($id) >= /*AUTH_READ*/ 1) {
160 160
                     $geotags  = p_get_metadata($id, 'geo');
161 161
                     $point    = new geoPHP\Geometry\Point($geotags ['lon'], $geotags ['lat']);
162 162
                     $line     = new geoPHP\Geometry\LineString(
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
                     );
168 168
                     $pages [] = array(
169 169
                         'id'          => $id,
170
-                        'distance'    => (int) ($line->greatCircleLength()),
170
+                        'distance'    => ( int ) ($line->greatCircleLength()),
171 171
                         'description' => p_get_metadata($id, 'description')['abstract'],
172 172
                         'lat'         => $geotags ['lat'],
173 173
                         'lon'         => $geotags ['lon']
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
 
180 180
         // sort all the pages/media using distance
181 181
         usort(
182
-            $pages, static function ($a, $b) {
182
+            $pages, static function($a, $b) {
183 183
             return strnatcmp($a ['distance'], $b ['distance']);
184 184
         }
185 185
         );
186 186
         usort(
187
-            $media, static function ($a, $b) {
187
+            $media, static function($a, $b) {
188 188
             return strnatcmp($a ['distance'], $b ['distance']);
189 189
         }
190 190
         );
Please login to merge, or discard this patch.