forked from opencaching/opencaching-pl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcachemap-mini.php
66 lines (56 loc) · 1.79 KB
/
cachemap-mini.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
use lib\Objects\GeoCache\GeoCache;
/**
* cachemap-mini.php
*
* Used only from viewcache.php to get small map for cache on a way:
* cachemap-mini.php?cacheId=1234
*
* Params
* @param cacheId
*
* alternatively:
* @param inputZoom
* @param lat
* @param lon
*
*/
require_once('./lib/common.inc.php');
require_once('./lib/cachemap3_common.php');
// check if user logged in
handleUserLogged();
tpl_set_tplname('cachemap-mini');
$view = tpl_getView();
// only logged user point of view is supported here
$mapForUserId = $usr['userid']; // $usr is stored in sessions
tpl_set_var('userid', $mapForUserId);
// first look for cacheId param
if (isset($_REQUEST['cacheId'])) {
/** @var GeoCache $geocache **/
$geocache = GeoCache::fromCacheIdFactory($_REQUEST['cacheId']);
if ($geocache) {
tpl_set_var('coords', $geocache->getCoordinates()->getLatitude() . "," . $geocache->getCoordinates()->getLongitude());
}
} else {
// no cacheId - try to look for coords
if (isset($_REQUEST['lat']) && $_REQUEST['lat'] != "" && isset($_REQUEST['lon']) && $_REQUEST['lon'] != "") {
// use cords from request
tpl_set_var('coords', $_REQUEST['lat'] . "," . $_REQUEST['lon']);
} else {
tpl_set_var('coords', $country_coordinates);
}
}
// zoom param is required here
if (isset($_REQUEST['inputZoom']) && $_REQUEST['inputZoom'] != "") {
tpl_set_var('zoom', $_REQUEST['inputZoom']);
} else {
tpl_set_var('zoom', $config['maps']['cache_mini_map']['zoom']); // this is default zoom
}
// parse PowerTrail filter in url
parsePowerTrailFilter(false);
setTheRestOfCommonVars(); // open current cache
tpl_set_var('map_type', "0"); // fixed to default map
$view->loadJQuery();
$view->loadGMapApi();
// ...and lest run template in fullscrean mode...
tpl_BuildTemplate(true);