source: extensions/rv_gmaps/branches/2.3/map.php @ 29334

Last change on this file since 29334 was 12719, checked in by rvelices, 13 years ago

rv_gmaps can show now different markers based on number of photos at the location

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