@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | 16 | */ |
17 | 17 | |
18 | -if(!defined('DOKU_LF')) { |
|
18 | +if (!defined('DOKU_LF')) { |
|
19 | 19 | define('DOKU_LF', "\n"); |
20 | 20 | } |
21 | 21 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | public function __construct() { |
38 | 38 | global $conf; |
39 | 39 | $idx_dir = $conf['indexdir']; |
40 | - if(!@file_exists($idx_dir . '/spatial.idx')) { |
|
40 | + if (!@file_exists($idx_dir . '/spatial.idx')) { |
|
41 | 41 | $indexer = plugin_load('helper', 'spatialhelper_index'); |
42 | 42 | $indexer->generateSpatialIndex(); |
43 | 43 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $RSSstart .= '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss" '; |
85 | 85 | $RSSstart .= 'xmlns:dc="http://purl.org/dc/elements/1.1/">' . DOKU_LF; |
86 | 86 | $RSSstart .= '<title>' . $conf['title'] . ' spatial feed</title>' . DOKU_LF; |
87 | - if(!empty($conf['tagline'])) { |
|
87 | + if (!empty($conf['tagline'])) { |
|
88 | 88 | $RSSstart .= '<subtitle>' . $conf['tagline'] . '</subtitle>' . DOKU_LF; |
89 | 89 | } |
90 | 90 | $RSSstart .= '<dc:publisher>' . $conf['title'] . '</dc:publisher>' . DOKU_LF; |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | $fh = fopen(mediaFN($mediaID), 'w'); |
104 | 104 | fwrite($fh, $RSSstart); |
105 | 105 | |
106 | - foreach($this->spatial_idx as $idxEntry) { |
|
106 | + foreach ($this->spatial_idx as $idxEntry) { |
|
107 | 107 | // get list of id's |
108 | - foreach($idxEntry as $id) { |
|
108 | + foreach ($idxEntry as $id) { |
|
109 | 109 | // for document item in the index |
110 | - if(strpos($id, 'media__', 0) !== 0) { |
|
111 | - if($this->skipPage($id, $namespace)) { |
|
110 | + if (strpos($id, 'media__', 0) !== 0) { |
|
111 | + if ($this->skipPage($id, $namespace)) { |
|
112 | 112 | continue; |
113 | 113 | } |
114 | 114 | |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | $entry .= ' <summary>' . $desc . '</summary>' . DOKU_LF; |
123 | 123 | $entry .= ' <georss:point>' . $meta['geo']['lat'] . ' ' . $meta['geo']['lon'] |
124 | 124 | . '</georss:point>' . DOKU_LF; |
125 | - if($meta['geo']['alt']) { |
|
125 | + if ($meta['geo']['alt']) { |
|
126 | 126 | $entry .= ' <georss:elev>' . $meta['geo']['alt'] . '</georss:elev>' . DOKU_LF; |
127 | 127 | } |
128 | 128 | $entry .= ' <link href="' . wl($id) . '" rel="alternate" type="text/html" />' . DOKU_LF; |
129 | - if(empty($meta['creator'])) { |
|
129 | + if (empty($meta['creator'])) { |
|
130 | 130 | $meta['creator'] = $conf['title']; |
131 | 131 | } |
132 | 132 | $entry .= ' <author><name>' . $meta['creator'] . '</name></author>' . DOKU_LF; |
@@ -149,16 +149,16 @@ discard block |
||
149 | 149 | */ |
150 | 150 | private function skipPage($id, $namespace) { |
151 | 151 | dbglog("helper_plugin_spatialhelper_sitemap::skipPage, check for $id in $namespace"); |
152 | - if(isHiddenPage($id)) { |
|
152 | + if (isHiddenPage($id)) { |
|
153 | 153 | return true; |
154 | 154 | } |
155 | - if(auth_aclcheck($id, '', '') < AUTH_READ) { |
|
155 | + if (auth_aclcheck($id, '', '') < AUTH_READ) { |
|
156 | 156 | return true; |
157 | 157 | } |
158 | 158 | |
159 | - if(!empty($namespace)) { |
|
159 | + if (!empty($namespace)) { |
|
160 | 160 | // only if id is in or below namespace |
161 | - if(0 !== strpos(getNS($id), $namespace)) { |
|
161 | + if (0 !== strpos(getNS($id), $namespace)) { |
|
162 | 162 | // dbglog("helper_plugin_spatialhelper_sitemap::skipPage, skipping $id, not in $namespace"); |
163 | 163 | return true; |
164 | 164 | } |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | $fh = fopen(mediaFN($mediaID), 'w'); |
200 | 200 | fwrite($fh, $KMLstart); |
201 | 201 | |
202 | - foreach($this->spatial_idx as $idxEntry) { |
|
202 | + foreach ($this->spatial_idx as $idxEntry) { |
|
203 | 203 | // get list of id's |
204 | - foreach($idxEntry as $id) { |
|
204 | + foreach ($idxEntry as $id) { |
|
205 | 205 | // for document item in the index |
206 | - if(strpos($id, 'media__', 0) !== 0) { |
|
207 | - if($this->skipPage($id, $namespace)) { |
|
206 | + if (strpos($id, 'media__', 0) !== 0) { |
|
207 | + if ($this->skipPage($id, $namespace)) { |
|
208 | 208 | continue; |
209 | 209 | } |
210 | 210 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | // TODO escape quotes in: title="' . $meta['title'] . '" |
221 | 221 | $plcm .= ' <atom:link href="' . wl($id, '' . true) . '" rel="alternate" type="text/html" />' |
222 | 222 | . DOKU_LF; |
223 | - if(!empty($meta['creator'])) { |
|
223 | + if (!empty($meta['creator'])) { |
|
224 | 224 | $entry .= ' <atom:author><atom:name>' . $meta['creator'] . '</atom:name></atom:author>' |
225 | 225 | . DOKU_LF; |
226 | 226 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $plcm .= ' <styleUrl>#icon</styleUrl>' . DOKU_LF; |
230 | 230 | |
231 | 231 | $plcm .= ' <Point><coordinates>' . $meta['geo']['lon'] . ',' . $meta['geo']['lat']; |
232 | - if($meta['geo']['alt']) { |
|
232 | + if ($meta['geo']['alt']) { |
|
233 | 233 | $plcm .= ',' . $meta['geo']['alt']; |
234 | 234 | } |
235 | 235 | $plcm .= '</coordinates></Point>' . DOKU_LF; |
@@ -59,14 +59,14 @@ discard block |
||
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 | return ""; |
66 | 66 | } |
67 | 67 | |
68 | 68 | $idx_dir = $conf ['indexdir']; |
69 | - if(!@file_exists($idx_dir . '/spatial.idx')) { |
|
69 | + if (!@file_exists($idx_dir . '/spatial.idx')) { |
|
70 | 70 | $indexer = plugin_load('helper', 'spatialhelper_index'); |
71 | 71 | } |
72 | 72 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function findNearby($geohash, Point $p = null) { |
99 | 99 | $_geohashClass = new Geohash(); |
100 | - if(!$p) { |
|
100 | + if (!$p) { |
|
101 | 101 | $decodedPoint = $_geohashClass->read($geohash); |
102 | 102 | } else { |
103 | 103 | $decodedPoint = $p; |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | |
119 | 119 | // find all the pages in the index that overlap with the adjacent hashes |
120 | 120 | $docIds = array(); |
121 | - foreach($adjacent as $adjHash) { |
|
122 | - if(is_array($this->spatial_idx)) { |
|
123 | - foreach($this->spatial_idx as $_geohash => $_docIds) { |
|
124 | - if(strstr($_geohash, $adjHash)) { |
|
121 | + foreach ($adjacent as $adjHash) { |
|
122 | + if (is_array($this->spatial_idx)) { |
|
123 | + foreach ($this->spatial_idx as $_geohash => $_docIds) { |
|
124 | + if (strstr($_geohash, $adjHash)) { |
|
125 | 125 | // dbglog ( "Found adjacent geo hash: $adjHash in $_geohash" ); |
126 | 126 | // if $adjHash similar to geohash |
127 | 127 | $docIds = array_merge($docIds, $_docIds); |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | $media = array(); |
138 | 138 | $indexer = plugin_load('helper', 'spatialhelper_index'); |
139 | 139 | |
140 | - foreach($docIds as $id) { |
|
141 | - if(strpos($id, 'media__', 0) === 0) { |
|
140 | + foreach ($docIds as $id) { |
|
141 | + if (strpos($id, 'media__', 0) === 0) { |
|
142 | 142 | $id = substr($id, strlen('media__')); |
143 | - if(auth_quickaclcheck($id) >= /*AUTH_READ*/ 1) { |
|
143 | + if (auth_quickaclcheck($id) >= /*AUTH_READ*/ 1) { |
|
144 | 144 | $point = $indexer->getCoordsFromExif($id); |
145 | 145 | $line = new LineString( |
146 | 146 | [ |
@@ -150,14 +150,14 @@ discard block |
||
150 | 150 | ); |
151 | 151 | $media [] = array( |
152 | 152 | 'id' => $id, |
153 | - 'distance' => (int) ($line->greatCircleLength()), |
|
153 | + 'distance' => ( int ) ($line->greatCircleLength()), |
|
154 | 154 | 'lat' => $point->y(), |
155 | 155 | 'lon' => $point->x() |
156 | 156 | // optionally add other meta such as tag, description... |
157 | 157 | ); |
158 | 158 | } |
159 | 159 | } else { |
160 | - if(auth_quickaclcheck($id) >= /*AUTH_READ*/ 1) { |
|
160 | + if (auth_quickaclcheck($id) >= /*AUTH_READ*/ 1) { |
|
161 | 161 | $geotags = p_get_metadata($id, 'geo'); |
162 | 162 | $point = new Point($geotags ['lon'], $geotags ['lat']); |
163 | 163 | $line = new LineString( |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | ); |
169 | 169 | $pages [] = array( |
170 | 170 | 'id' => $id, |
171 | - 'distance' => (int) ($line->greatCircleLength()), |
|
171 | + 'distance' => ( int ) ($line->greatCircleLength()), |
|
172 | 172 | 'description' => p_get_metadata($id, 'description')['abstract'], |
173 | 173 | 'lat' => $geotags ['lat'], |
174 | 174 | 'lon' => $geotags ['lon'] |
@@ -180,12 +180,12 @@ discard block |
||
180 | 180 | |
181 | 181 | // sort all the pages/media using distance |
182 | 182 | usort( |
183 | - $pages, function ($a, $b) { |
|
183 | + $pages, function($a, $b) { |
|
184 | 184 | return strnatcmp($a ['distance'], $b ['distance']); |
185 | 185 | } |
186 | 186 | ); |
187 | 187 | usort( |
188 | - $media, function ($a, $b) { |
|
188 | + $media, function($a, $b) { |
|
189 | 189 | return strnatcmp($a ['distance'], $b ['distance']); |
190 | 190 | } |
191 | 191 | ); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * Constructor, initialises the spatial index. |
47 | 47 | */ |
48 | 48 | public function __construct() { |
49 | - if(!$geophp = &plugin_load('helper', 'geophp')) { |
|
49 | + if (!$geophp = &plugin_load('helper', 'geophp')) { |
|
50 | 50 | $message = 'helper_plugin_spatialhelper_index::spatialhelper_index: geophp plugin is not available.'; |
51 | 51 | msg($message, -1); |
52 | 52 | return ""; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | global $conf; |
56 | 56 | $this->idx_dir = $conf ['indexdir']; |
57 | 57 | // test if there is a spatialindex, if not build one for the wiki |
58 | - if(!@file_exists($this->idx_dir . '/spatial.idx')) { |
|
58 | + if (!@file_exists($this->idx_dir . '/spatial.idx')) { |
|
59 | 59 | // creates and stores the index |
60 | 60 | $this->generateSpatialIndex(); |
61 | 61 | } else { |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | require_once(DOKU_INC . 'inc/search.php'); |
75 | 75 | $pages = array(); |
76 | 76 | search($pages, $conf ['datadir'], 'search_allpages', array()); |
77 | - foreach($pages as $page) { |
|
77 | + foreach ($pages as $page) { |
|
78 | 78 | $this->updateSpatialIndex($page ['id']); |
79 | 79 | } |
80 | 80 | // media |
81 | 81 | $media = array(); |
82 | 82 | search($media, $conf ['mediadir'], 'search_media', array()); |
83 | - foreach($media as $medium) { |
|
84 | - if($medium ['isimg']) { |
|
83 | + foreach ($media as $medium) { |
|
84 | + if ($medium ['isimg']) { |
|
85 | 85 | $this->indexImage($medium); |
86 | 86 | } |
87 | 87 | } |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function updateSpatialIndex($id) { |
98 | 98 | $geotags = p_get_metadata($id, 'geo'); |
99 | - if(empty ($geotags)) { |
|
99 | + if (empty ($geotags)) { |
|
100 | 100 | return false; |
101 | 101 | } |
102 | - if(empty ($geotags ['lon']) || empty ($geotags ['lat'])) { |
|
102 | + if (empty ($geotags ['lon']) || empty ($geotags ['lat'])) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | dbglog($geotags, "Geo metadata found for page $id"); |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | private function addToIndex($geohash, $id) { |
121 | 121 | $pageIds = array(); |
122 | 122 | // check index for key/geohash |
123 | - if(!array_key_exists($geohash, $this->spatial_idx)) { |
|
123 | + if (!array_key_exists($geohash, $this->spatial_idx)) { |
|
124 | 124 | dbglog("Geohash $geohash not in index, just add $id."); |
125 | 125 | $pageIds [] = $id; |
126 | 126 | } else { |
127 | 127 | dbglog('Geohash for document is in index, find it.'); |
128 | 128 | // check the index for document |
129 | 129 | $knownHashes = $this->findHashesForId($id, $this->spatial_idx); |
130 | - if(empty ($knownHashes)) { |
|
130 | + if (empty ($knownHashes)) { |
|
131 | 131 | dbglog("No index record found for document $id, just add"); |
132 | 132 | $pageIds = $this->spatial_idx [$geohash]; |
133 | 133 | $pageIds [] = $id; |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | // TODO shortcut, need to make sure there is only one element, if not the index is corrupt |
136 | 136 | $knownHash = $knownHashes [0]; |
137 | 137 | |
138 | - if($knownHash == $geohash) { |
|
138 | + if ($knownHash == $geohash) { |
|
139 | 139 | dbglog("Document $id was found in index and has the same geohash, nothing to do."); |
140 | 140 | return true; |
141 | 141 | } |
142 | 142 | |
143 | - if(!empty ($knownHash)) { |
|
143 | + if (!empty ($knownHash)) { |
|
144 | 144 | dbglog("Document/media $id was found in index but has different geohash (it moved)."); |
145 | 145 | $knownIds = $this->spatial_idx [$knownHash]; |
146 | 146 | dbglog($knownIds, "Known id's for this hash:"); |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | */ |
170 | 170 | public function findHashesForId($id, $index) { |
171 | 171 | $hashes = array(); |
172 | - foreach($index as $hash => $docIds) { |
|
173 | - if(in_array($id, $docIds, false)) { |
|
172 | + foreach ($index as $hash => $docIds) { |
|
173 | + if (in_array($id, $docIds, false)) { |
|
174 | 174 | $hashes [] = $hash; |
175 | 175 | } |
176 | 176 | } |
@@ -196,14 +196,14 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function indexImage($img) { |
198 | 198 | // test for supported files (jpeg only) |
199 | - if( |
|
199 | + if ( |
|
200 | 200 | (substr($img ['file'], -strlen('.jpg')) !== '.jpg') and |
201 | 201 | (substr($img ['file'], -strlen('.jpeg')) !== '.jpeg')) { |
202 | 202 | return false; |
203 | 203 | } |
204 | 204 | |
205 | 205 | $geometry = $this->getCoordsFromExif($img ['id']); |
206 | - if(!$geometry) { |
|
206 | + if (!$geometry) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | $geohash = $geometry->out('geohash'); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function getCoordsFromExif($id) { |
224 | 224 | $exif = exif_read_data(mediaFN($id), 0, true); |
225 | - if(empty ($exif ['GPS'])) { |
|
225 | + if (empty ($exif ['GPS'])) { |
|
226 | 226 | return false; |
227 | 227 | } |
228 | 228 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @return number |
255 | 255 | */ |
256 | 256 | public function convertDMStoD($param) { |
257 | - if(!is_array($param)) { |
|
257 | + if (!is_array($param)) { |
|
258 | 258 | $param = array($param); |
259 | 259 | } |
260 | 260 | $deg = $this->convertRationaltoFloat($param [0]); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | public function convertRationaltoFloat($param) { |
269 | 269 | // rational64u |
270 | 270 | $nums = explode('/', $param); |
271 | - if(intval($nums[1]) > 0) { |
|
271 | + if (intval($nums[1]) > 0) { |
|
272 | 272 | return intval($nums[0]) / intval($nums[1]); |
273 | 273 | } else { |
274 | 274 | return intval($nums[0]); |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | public function deleteFromIndex($id) { |
285 | 285 | // check the index for document |
286 | 286 | $knownHashes = $this->findHashesForId($id, $this->spatial_idx); |
287 | - if(empty ($knownHashes)) { |
|
287 | + if (empty ($knownHashes)) { |
|
288 | 288 | return; |
289 | 289 | } |
290 | 290 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | dbglog("removing: $knownIds[$i] from the index."); |
296 | 296 | unset ($knownIds [$i]); |
297 | 297 | $this->spatial_idx [$knownHash] = $knownIds; |
298 | - if(empty ($this->spatial_idx [$knownHash])) { |
|
298 | + if (empty ($this->spatial_idx [$knownHash])) { |
|
299 | 299 | // dbglog ( "removing key: $knownHash from the index." ); |
300 | 300 | unset ($this->spatial_idx [$knownHash]); |
301 | 301 | } |
@@ -101,18 +101,18 @@ discard block |
||
101 | 101 | // $data[3] – rev: The page revision, false for current wiki pages. |
102 | 102 | |
103 | 103 | dbglog($event->data, "Event data in removeFromIndex."); |
104 | - if(@file_exists($event->data [0] [0])) { |
|
104 | + if (@file_exists($event->data [0] [0])) { |
|
105 | 105 | // file not new |
106 | - if(!$event->data [0] [1]) { |
|
106 | + if (!$event->data [0] [1]) { |
|
107 | 107 | // file is empty, page is being deleted |
108 | - if(empty ($event->data [1])) { |
|
108 | + if (empty ($event->data [1])) { |
|
109 | 109 | // root namespace |
110 | 110 | $id = $event->data [2]; |
111 | 111 | } else { |
112 | 112 | $id = $event->data [1] . ":" . $event->data [2]; |
113 | 113 | } |
114 | 114 | $indexer = &plugin_load('helper', 'spatialhelper_index'); |
115 | - if($indexer) { |
|
115 | + if ($indexer) { |
|
116 | 116 | $indexer->deleteFromIndex($id); |
117 | 117 | } |
118 | 118 | } |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | // $event→data['items']: Array of SitemapItem instances, the array of sitemap items that already |
146 | 146 | // contains all public pages of the wiki |
147 | 147 | // $event→data['sitemap']: The path of the file the sitemap will be saved to. |
148 | - if($helper = &plugin_load('helper', 'spatialhelper_sitemap')) { |
|
148 | + if ($helper = &plugin_load('helper', 'spatialhelper_sitemap')) { |
|
149 | 149 | // dbglog($helper, "createSpatialSitemap loaded helper."); |
150 | 150 | |
151 | 151 | $kml = $helper->createKMLSitemap($this->getConf('media_kml')); |
152 | 152 | $rss = $helper->createGeoRSSSitemap($this->getConf('media_georss')); |
153 | 153 | |
154 | - if(!empty ($this->getConf('sitemap_namespaces'))) { |
|
154 | + if (!empty ($this->getConf('sitemap_namespaces'))) { |
|
155 | 155 | $namespaces = array_map('trim', explode("\n", $this->getConf('sitemap_namespaces'))); |
156 | - foreach($namespaces as $namespace) { |
|
156 | + foreach ($namespaces as $namespace) { |
|
157 | 157 | $kmlN = $helper->createKMLSitemap($namespace . $this->getConf('media_kml')); |
158 | 158 | $rssN = $helper->createGeoRSSSitemap($namespace . $this->getConf('media_georss')); |
159 | 159 | dbglog( |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * not used |
179 | 179 | */ |
180 | 180 | public function handleActionActPreprocess(Doku_Event $event, $param) { |
181 | - if($event->data != 'findnearby') { |
|
181 | + if ($event->data != 'findnearby') { |
|
182 | 182 | return; |
183 | 183 | } |
184 | 184 | $event->preventDefault(); |
@@ -194,16 +194,16 @@ discard block |
||
194 | 194 | * 'format'=> HTML | JSON |
195 | 195 | */ |
196 | 196 | public function findnearby(Doku_Event &$event, $param) { |
197 | - if($event->data != 'findnearby') { |
|
197 | + if ($event->data != 'findnearby') { |
|
198 | 198 | return; |
199 | 199 | } |
200 | 200 | $event->preventDefault(); |
201 | 201 | |
202 | 202 | global $INPUT; |
203 | - if($helper = &plugin_load('helper', 'spatialhelper_search')) { |
|
204 | - if($INPUT->has('lat') && $INPUT->has('lon')) { |
|
203 | + if ($helper = &plugin_load('helper', 'spatialhelper_search')) { |
|
204 | + if ($INPUT->has('lat') && $INPUT->has('lon')) { |
|
205 | 205 | $results = $helper->findNearbyLatLon($INPUT->param('lat'), $INPUT->param('lon')); |
206 | - } elseif($INPUT->has('geohash')) { |
|
206 | + } elseif ($INPUT->has('geohash')) { |
|
207 | 207 | $results = $helper->findNearby($INPUT->str('geohash')); |
208 | 208 | } else { |
209 | 209 | $results = array( |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | $showMedia = $INPUT->bool('showMedia', true); |
216 | 216 | |
217 | - switch($param['format']) { |
|
217 | + switch ($param['format']) { |
|
218 | 218 | case 'JSON' : |
219 | 219 | $this->printJSON($results); |
220 | 220 | break; |
@@ -245,13 +245,13 @@ discard block |
||
245 | 245 | * @param boolean $showMedia |
246 | 246 | */ |
247 | 247 | private function printHTML($searchresults, $showMedia = true) { |
248 | - $pages = (array) ($searchresults ['pages']); |
|
249 | - $media = (array) $searchresults ['media']; |
|
250 | - $lat = (float) $searchresults ['lat']; |
|
251 | - $lon = (float) $searchresults ['lon']; |
|
252 | - $geohash = (string) $searchresults ['geohash']; |
|
248 | + $pages = ( array ) ($searchresults ['pages']); |
|
249 | + $media = ( array ) $searchresults ['media']; |
|
250 | + $lat = ( float ) $searchresults ['lat']; |
|
251 | + $lon = ( float ) $searchresults ['lon']; |
|
252 | + $geohash = ( string ) $searchresults ['geohash']; |
|
253 | 253 | |
254 | - if(isset ($searchresults ['error'])) { |
|
254 | + if (isset ($searchresults ['error'])) { |
|
255 | 255 | print '<div class="level1"><p>' . hsc($results ['error']) . '</p></div>'; |
256 | 256 | return; |
257 | 257 | } |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | // print a HTML list |
260 | 260 | print '<h1>' . $this->getLang('results_header') . '</h1>' . DOKU_LF; |
261 | 261 | print '<div class="level1">' . DOKU_LF; |
262 | - if(!empty ($pages)) { |
|
262 | + if (!empty ($pages)) { |
|
263 | 263 | $pagelist = '<ol>' . DOKU_LF; |
264 | - foreach($pages as $page) { |
|
264 | + foreach ($pages as $page) { |
|
265 | 265 | $pagelist .= '<li>' . html_wikilink( |
266 | 266 | ':' . $page ['id'], useHeading('navigation') ? null : |
267 | 267 | noNS($page ['id']) |
@@ -281,14 +281,14 @@ discard block |
||
281 | 281 | print '<p>' . hsc($this->getLang('nothingfound')) . '</p>'; |
282 | 282 | } |
283 | 283 | |
284 | - if(!empty ($media) && $showMedia) { |
|
284 | + if (!empty ($media) && $showMedia) { |
|
285 | 285 | $pagelist = '<ol>' . DOKU_LF; |
286 | - foreach($media as $m) { |
|
286 | + foreach ($media as $m) { |
|
287 | 287 | $opts = array(); |
288 | 288 | $link = ml($m ['id'], $opts, false, '&', false); |
289 | 289 | $opts ['w'] = '100'; |
290 | 290 | $src = ml($m ['id'], $opts); |
291 | - $pagelist .= '<li><a href="' . $link . '"><img src="' . $src . '"></a> (' |
|
291 | + $pagelist .= '<li><a href="' . $link . '"><img src="' . $src . '"></a> (' |
|
292 | 292 | . $this->getLang('results_distance_prefix') . $page ['distance'] . ' m) ' . hsc($desc) |
293 | 293 | . '</li>' . DOKU_LF; |
294 | 294 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | print '</div>' . DOKU_LF; |
304 | 304 | } |
305 | 305 | print '<p>' . $this->getLang('results_precision') . $searchresults ['precision'] . ' m. '; |
306 | - if(strlen($geohash) > 1) { |
|
306 | + if (strlen($geohash) > 1) { |
|
307 | 307 | $url = wl( |
308 | 308 | getID(), array( |
309 | 309 | 'do' => 'findnearby', |
@@ -335,9 +335,9 @@ discard block |
||
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], $event->data [1]); |
342 | 342 | } |
343 | 343 | } |
@@ -358,7 +358,7 @@ discard block |
||
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 | } |
@@ -64,18 +64,18 @@ discard block |
||
64 | 64 | public function handle($match, $state, $pos, Doku_Handler $handler) { |
65 | 65 | $data = array(); |
66 | 66 | $data [0] = trim(substr($match, strlen('{{findnearby>'), -2)); |
67 | - if(strlen($data [0]) < 1) { |
|
67 | + if (strlen($data [0]) < 1) { |
|
68 | 68 | $data [0] = $this->getLang('search_findnearby'); |
69 | 69 | } |
70 | 70 | $meta = p_get_metadata(getID(), 'geo'); |
71 | - if($meta) { |
|
72 | - if($meta ['lat'] && $meta ['lon']) { |
|
71 | + if ($meta) { |
|
72 | + if ($meta ['lat'] && $meta ['lon']) { |
|
73 | 73 | $data [1] = array( |
74 | 74 | 'do' => 'findnearby', |
75 | 75 | 'lat' => $meta ['lat'], |
76 | 76 | 'lon' => $meta ['lon'] |
77 | 77 | ); |
78 | - } elseif($meta ['geohash']) { |
|
78 | + } elseif ($meta ['geohash']) { |
|
79 | 79 | $data [1] = array( |
80 | 80 | 'do' => 'findnearby', |
81 | 81 | 'geohash' => $meta ['geohash'] |
@@ -92,16 +92,16 @@ discard block |
||
92 | 92 | * @see DokuWiki_Syntax_Plugin::render() |
93 | 93 | */ |
94 | 94 | public function render($mode, Doku_Renderer $renderer, $data) { |
95 | - if($data === false) { |
|
95 | + if ($data === false) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | - if($mode == 'xhtml') { |
|
99 | + if ($mode == 'xhtml') { |
|
100 | 100 | $renderer->doc .= '<a href="' . wl(getID(), $data [1]) . '" class="findnearby">' . hsc($data [0]) . '</a>'; |
101 | 101 | return true; |
102 | - } elseif($mode == 'metadata') { |
|
102 | + } elseif ($mode == 'metadata') { |
|
103 | 103 | return false; |
104 | - } elseif($mode == 'odt') { |
|
104 | + } elseif ($mode == 'odt') { |
|
105 | 105 | // don't render anything in ODT |
106 | 106 | return false; |
107 | 107 | } |
@@ -49,11 +49,11 @@ |
||
49 | 49 | */ |
50 | 50 | public function handle() { |
51 | 51 | global $conf; |
52 | - if(isset ($_REQUEST ['purgeindex'])) { |
|
52 | + if (isset ($_REQUEST ['purgeindex'])) { |
|
53 | 53 | global $conf; |
54 | 54 | $path = $conf ['indexdir'] . '/spatial.idx'; |
55 | - if(file_exists($path)) { |
|
56 | - if(unlink($path)) { |
|
55 | + if (file_exists($path)) { |
|
56 | + if (unlink($path)) { |
|
57 | 57 | msg($this->getLang('admin_purged_tiles'), 0); |
58 | 58 | } |
59 | 59 | } |