1 | <?php |
---|
2 | if ( !defined('PHPWG_ROOT_PATH') ) |
---|
3 | define('PHPWG_ROOT_PATH','../../'); |
---|
4 | |
---|
5 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
6 | include_once( dirname(__FILE__) .'/include/functions.php'); |
---|
7 | include_once( dirname(__FILE__) .'/include/functions_map.php'); |
---|
8 | |
---|
9 | check_status(ACCESS_GUEST); |
---|
10 | if (!isset($rvm_dir)) |
---|
11 | access_denied( 'Plugin not installed' ); |
---|
12 | |
---|
13 | rvm_load_language(); |
---|
14 | |
---|
15 | $section = ''; |
---|
16 | if ( $conf['question_mark_in_urls']==false and |
---|
17 | isset($_SERVER["PATH_INFO"]) and !empty($_SERVER["PATH_INFO"]) ) |
---|
18 | { |
---|
19 | $section = $_SERVER["PATH_INFO"]; |
---|
20 | $section = str_replace('//', '/', $section); |
---|
21 | $path_count = count( explode('/', $section) ); |
---|
22 | $page['root_path'] = PHPWG_ROOT_PATH.str_repeat('../', $path_count-1); |
---|
23 | if ( strncmp($page['root_path'], './', 2) == 0 ) |
---|
24 | { |
---|
25 | $page['root_path'] = substr($page['root_path'], 2); |
---|
26 | } |
---|
27 | } |
---|
28 | else |
---|
29 | { |
---|
30 | foreach ($_GET as $key=>$value) |
---|
31 | { |
---|
32 | if (!strlen($value)) $section=$key; |
---|
33 | break; |
---|
34 | } |
---|
35 | } |
---|
36 | |
---|
37 | // deleting first "/" if displayed |
---|
38 | $tokens = explode( |
---|
39 | '/', |
---|
40 | preg_replace('#^/#', '', $section) |
---|
41 | ); |
---|
42 | $next_token = 0; |
---|
43 | $result = rvm_parse_map_data_url($tokens, $next_token); |
---|
44 | $page = array_merge( $page, $result ); |
---|
45 | |
---|
46 | |
---|
47 | if (isset($page['category'])) |
---|
48 | check_restrictions($page['category']['id']); |
---|
49 | |
---|
50 | if ( !isset($_GET['ll']) and ($page['section']!='categories' or isset($page['category']) ) ) |
---|
51 | { |
---|
52 | $img_fields = 'MIN(i.lat) s, MIN(i.lon) w, MAX(i.lat) n, MAX(i.lon) e'; |
---|
53 | $page['flat']=true; |
---|
54 | rvm_build_section_items($img_fields, null, RVM_BUILD_AGGREGATE); |
---|
55 | //var_export( $page['items'] ); |
---|
56 | if ( count($page['items']) ) |
---|
57 | $template->assign('initial_bounds', $page['items'][0] ); |
---|
58 | unset( $page['items'] ); |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | $map_data_url = get_absolute_root_url().'plugins/'.$rvm_dir.'/map_data.php?'; |
---|
63 | $map_data_url .= $section; |
---|
64 | |
---|
65 | $template->set_filename( 'map', dirname(__FILE__).'/template/map.tpl' ); |
---|
66 | |
---|
67 | $template->assign( |
---|
68 | array( |
---|
69 | 'CONTENT_ENCODING' => get_pwg_charset(), |
---|
70 | 'RVM_PLUGIN_VERSION' => RVM_PLUGIN_VERSION, |
---|
71 | 'GMAPS_API_KEY' => $conf['gmaps_api_key'], |
---|
72 | 'PLUGIN_ROOT_URL' => get_absolute_root_url().'plugins/'.$rvm_dir, |
---|
73 | 'PLUGIN_LOCATION' => 'plugins/'.$rvm_dir, |
---|
74 | 'U_MAP_DATA' => $map_data_url, |
---|
75 | 'GALLERY_TITLE' => $conf['gallery_title'], |
---|
76 | 'U_HOME' => make_index_url(), |
---|
77 | 'U_HOME_MAP' => rvm_make_map_index_url(), |
---|
78 | ) |
---|
79 | ); |
---|
80 | |
---|
81 | $marker_js_file = rvm_get_config_var('marker_icon', ''); |
---|
82 | if ( !empty($marker_js_file) ) |
---|
83 | $marker_js_file = dirname(__FILE__).'/template/markers/'.$marker_js_file.'.tpl'; |
---|
84 | if ( !empty($marker_js_file) and file_exists($marker_js_file) ) |
---|
85 | { |
---|
86 | $template->set_filename( 'map_marker_icon', $marker_js_file ); |
---|
87 | $template->assign_var_from_handle('MAP_MARKER_ICON_JS', 'map_marker_icon'); |
---|
88 | } |
---|
89 | else |
---|
90 | $template->assign('MAP_MARKER_ICON_JS', 'new PwgSingleStyler()'); |
---|
91 | |
---|
92 | $template->pparse('map'); |
---|
93 | $template->p(); |
---|
94 | ?> |
---|