source: extensions/piwigo-openstreetmap/include/functions.php @ 24677

Last change on this file since 24677 was 24677, checked in by ddtddt, 11 years ago

[extensions] - piwigo-openstreetmap - add file for translate

File size: 3.3 KB
Line 
1<?php
2/***********************************************
3* File      :   functions.php
4* Project   :   piwigo-openstreetmap
5* Descr     :   Read Geotag Metdata
6* Base on   :   RV Maps & Earth plugin
7*
8* Created   :   30.05.2013
9*
10* Copyright 2013 <xbgmsharp@gmail.com>
11*
12* This program is free software: you can redistribute it and/or modify
13* it under the terms of the GNU General Public License as published by
14* the Free Software Foundation, either version 3 of the License, or
15* (at your option) any later version.
16*
17* This program is distributed in the hope that it will be useful,
18* but WITHOUT ANY WARRANTY; without even the implied warranty of
19* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20* GNU General Public License for more details.
21*
22* You should have received a copy of the GNU General Public License
23* along with this program.  If not, see <http://www.gnu.org/licenses/>.
24*
25************************************************/
26
27function osm_get_cache_file_name()
28{
29        global $conf;
30        return PHPWG_ROOT_PATH.$conf['data_location'].'/tmp/_rvgm_cat_cache.dat';
31}
32
33function osm_invalidate_cache()
34{
35        @unlink(  osm_get_cache_file_name() );
36}
37
38function osm_load_language()
39{
40        global $lang,$lang_info,$conf;
41        if ( isset($lang['Map']) or ($lang_info['code']=='en' and !$conf['debug_l10n']) )
42                return;
43        load_language('lang', dirname(__FILE__).'/../');
44}
45
46function osm_items_have_latlon($items)
47{
48  $query = '
49SELECT id FROM '.IMAGES_TABLE.'
50WHERE lat IS NOT NULL
51  AND id IN ('.implode(',', $items).')
52ORDER BY NULL
53LIMIT 0,1';
54        if ( pwg_db_num_rows(pwg_query($query))> 0)
55                return true;
56        return false;
57}
58
59function osm_make_map_picture_url($params)
60{
61        $map_url = make_picture_url($params);
62        return add_url_params($map_url, array('map'=>null) );
63}
64
65function osm_duplicate_map_picture_url()
66{
67        $map_url = duplicate_picture_url();
68        return add_url_params($map_url, array('map'=>null) );
69}
70
71function osm_make_map_index_url($params=array())
72{
73        global $conf, $osm_dir;
74        $url = get_root_url().'osmmap';
75        if ($conf['php_extension_in_urls'])
76                $url .= '.php';
77        if ($conf['question_mark_in_urls'])
78                $url .= '?';
79        $url .= make_section_in_url($params);
80        $url = add_well_known_params_in_url($url, array_intersect_key($params, array('flat'=>1) ) );
81        return $url;
82}
83
84function osm_duplicate_map_index_url($redefined=array(), $removed=array())
85{
86        return osm_make_map_index_url(
87                params_for_duplication($redefined, $removed)
88        );
89}
90
91function osm_duplicate_kml_index_url($redefined=array(), $removed=array())
92{
93        return osm_make_kml_index_url(
94                params_for_duplication($redefined, $removed)
95        );
96}
97
98function osm_make_kml_index_url($params)
99{
100        global $conf, $osm_dir;
101        $url = get_root_url().'plugins/'.$osm_dir.'/kml.php';
102        if ($conf['question_mark_in_urls'])
103                $url .= '?';
104
105        $url .= make_section_in_url($params);
106        unset( $params['start'] );
107        if ( 'categories'!=$params['section']) unset( $params['flat'] );
108        $url = add_well_known_params_in_url($url, $params);
109        $get_params = array();
110        if ( isset($params['box']) and !empty($params['box']) )
111        {
112                include_once( dirname(__FILE__).'/functions_map.php' );
113                if ( ! bounds_is_world($params['box']) )
114                        $get_params['box'] = bounds_to_url($params['box']);
115        }
116        if ( isset($params['ll']) and !empty($params['ll']) )
117                $get_params['ll'] = $params['ll']['lat'].','.$params['ll']['lon'];
118        $url = add_url_params($url, $get_params );
119        return $url;
120}
121?>
Note: See TracBrowser for help on using the repository browser.