source: extensions/rv_gmaps/trunk/admin/admin_config.php @ 23963

Last change on this file since 23963 was 23083, checked in by rvelices, 11 years ago

rv_gmaps:

  • admin can choose default map type (roadmap, satellite, ...)
  • auto center and zoom when viewing map for the entire gallery
  • fix kml namespace
  • attempt to fix uage with https on the photo page (need test)
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1<?php 
2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
3
4include_once( dirname(__FILE__).'/../include/functions_map.php' );
5
6if ( isset($_POST['submit']) )
7{
8  if (isset($_POST['gmaps_api_key']))
9  {
10    $query = '
11UPDATE '.CONFIG_TABLE.'
12  SET value="'.$_POST['gmaps_api_key'].'"
13  WHERE param="gmaps_api_key"
14  LIMIT 1';
15    pwg_query($query);
16    list($conf['gmaps_api_key']) = array_from_query('SELECT value FROM '.CONFIG_TABLE.' WHERE param="gmaps_api_key"', 'value');
17  }
18
19  if (isset($_POST['gmaps_auto_sync']))
20  {
21    conf_update_param('gmaps_auto_sync', "1");
22    $conf['gmaps_auto_sync']=1;
23  }
24  else
25  {
26    $query = 'DELETE FROM '.CONFIG_TABLE.' WHERE param="gmaps_auto_sync"';
27    pwg_query($query);
28    unset($conf['gmaps_auto_sync']);
29  }
30 
31  $gm_config = rvm_get_config();
32
33  $n  = intval($_POST['nb_markers']);
34  if ($n>0)
35    $gm_config['nb_markers'] = $n;
36  else
37    $page['errors'][] = 'The number of markers must be >0';
38
39  $n  = intval($_POST['nb_images_per_marker']);
40  if ($n>1)
41    $gm_config['nb_images_per_marker'] = $n;
42  else
43    $page['errors'][] = 'The number of iamges per marker must be >1';
44
45  $gm_config['marker_icon'] = $_POST['marker_icon'];
46        $gm_config['map_type'] = $_POST['map_type'];
47
48  mkgetdir( dirname(rvm_get_config_file_name()) );
49  $fp = fopen( rvm_get_config_file_name(), 'w');
50  fwrite( $fp, serialize($gm_config) );
51  fclose($fp);
52}
53
54$query = 'SELECT COUNT(*) FROM '.IMAGES_TABLE.' WHERE lat IS NOT NULL';
55list($nb_geotagged) = pwg_db_fetch_array( pwg_query($query) );
56
57$template->assign(
58    array(
59      'NB_GEOTAGGED' => $nb_geotagged,
60      'GMAPS_API_KEY' => $conf['gmaps_api_key'],
61      'GMAPS_AUTO_SYNC' => isset($conf['gmaps_auto_sync']) ? 1:0,
62      'NB_MARKERS' => rvm_get_config_var('nb_markers',40),
63      'NB_IMAGES_PER_MARKER' => rvm_get_config_var('nb_images_per_marker',20),
64                        'MAP_TYPE' => rvm_get_config_var('map_type','ROADMAP'),
65    )
66  );
67
68$files = array();
69$path=PHPWG_PLUGINS_PATH.$rvm_dir.'/template/markers/';
70$dir_contents = opendir($path);
71while (($filename = readdir($dir_contents)) !== false)
72{
73  if (!is_file($path.'/'.$filename) or get_extension($filename)!='tpl')
74    continue;
75        $files[] = get_filename_wo_extension($filename);
76 }
77closedir($dir_contents);
78
79sort($files);
80foreach($files as $file)
81{
82        $template->append('marker_icons',
83      array(
84        $file => str_replace( '_', ' ', $file),
85      ),
86      true
87    );
88}
89
90$template->assign('selected_marker_icon', rvm_get_config_var('marker_icon', '') );
91
92$map_types = array(
93        "ROADMAP" => "Roadmap (Default)",
94        "SATELLITE" => "Satellite",
95        "HYBRID" => "Hybrid",
96        "TERRAIN" => "Terrain",
97);
98$template->assign('map_types', $map_types);
99?>
Note: See TracBrowser for help on using the repository browser.