source: extensions/rv_gmaps/trunk/map.php @ 21011

Last change on this file since 21011 was 14181, checked in by rvelices, 13 years ago

rv_gmaps - small template updates

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
RevLine 
[3447]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
[14181]17                 isset($_SERVER["PATH_INFO"]) and !empty($_SERVER["PATH_INFO"]) )
[3447]18{
[14181]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        }
[3447]27}
28else
29{
[14181]30        foreach ($_GET as $key=>$value)
31        {
32                if (!strlen($value)) $section=$key;
33                break;
34        }
[3447]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
47if (isset($page['category']))
48  check_restrictions($page['category']['id']);
49
50if ( !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,
[8304]73                'PLUGIN_LOCATION' => 'plugins/'.$rvm_dir,
[3447]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', '');
82if ( !empty($marker_js_file) )
83  $marker_js_file = dirname(__FILE__).'/template/markers/'.$marker_js_file.'.tpl';
84if ( !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}
89else
[12719]90  $template->assign('MAP_MARKER_ICON_JS', 'new PwgSingleStyler()');
[3447]91
92$template->pparse('map');
93$template->p();
94?>
Note: See TracBrowser for help on using the repository browser.