forked from opencaching/opencaching-pl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.zip.inc.php
80 lines (68 loc) · 2.87 KB
/
search.zip.inc.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/* * *************************************************************************
./lib/search.zip.inc.php
* ************************************************************************* */
/* * *************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ************************************************************************* */
/* * **************************************************************************
Unicode Reminder ??
Garmin zip search output (gpx + images for garmin devices)
based on search.*.inc.php
by Limak (opencaching.pl)
* ************************************************************************** */
function call_okapi($usr, $waypoints, $lang, $file_base_name, $zip_part)
{
$okapi_params = array('cache_codes' => $waypoints, 'langpref' => $lang,
'location_source' => 'alt_wpt:user-coords', 'location_change_prefix' => '(F)');
// TODO: limit log entries per geocache?
if (isset($_GET['format']))
$okapi_params['caches_format'] = $_GET['format'];
$okapi_response = \okapi\Facade::service_call('services/caches/formatters/garmin', $usr['userid'], $okapi_params);
// Modifying OKAPI's default HTTP Response headers.
$okapi_response->content_disposition = 'attachment; filename=' . $file_base_name . (($zip_part != 0) ? '-' . $zip_part : '') . '.zip';
return $okapi_response;
}
function generate_link_content($queryid, $file_base_name, $zip_part)
{
if (isset($_GET['format']))
$format = '&format=' . $_GET['format'];
else
$format = '';
$zipname = 'ocpl' . $queryid . '.zip?startat=0&count=max&zippart=' . $zip_part . $format . (isset($_GET['okapidebug']) ? '&okapidebug' : '');
$link_content = '<li><a class="links" href="' . $zipname . '" title="Garmin ZIP file (part ' . $zip_part . ')">' . $file_base_name . '-' . $zip_part . '.zip</a></li>';
return $link_content;
}
// reflect okapi limit of allowed geocache codes per invocation
function get_max_caches_per_call()
{
if (isset($_REQUEST['okapidebug']))
return 500;
else
return 50;
}
function get_pagination_template()
{
if (isset($_GET['format'])) {
switch ($_GET['format']) {
case 'gpx': return 'garminzip';
default: return 'garminzip-' . $_GET['format'];
}
}
return 'garminzip';
}
function get_pagination_page_title()
{
switch (get_pagination_template()) {
case 'garminzip': return tr('GarminZip_01') . ': Garmin ZIP';
case 'garminzip-ggz': return tr('GarminZip_01') . ': Garmin ' . tr('format_ggz_pict');
}
}
// all the logic is done here
include 'search.okapi.inc.php';
?>