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

Last change on this file since 6400 was 3447, checked in by rvelices, 15 years ago
  • added RV Map & Earth extension
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1<?php 
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4include_once( dirname(__FILE__).'/../include/functions_map.php' );
5
6if ( isset($_POST['submit']) and !is_adviser() )
7{
8  $query = '
9UPDATE '.CONFIG_TABLE.'
10  SET value="'.$_POST['gmaps_api_key'].'"
11  WHERE param="gmaps_api_key"
12  LIMIT 1';
13  pwg_query($query);
14  list($conf['gmaps_api_key']) = array_from_query('SELECT value FROM '.CONFIG_TABLE.' WHERE param="gmaps_api_key"', 'value');
15
16  $gm_config = rvm_get_config();
17
18  $n  = intval($_POST['nb_markers']);
19  if ($n>0)
20    $gm_config['nb_markers'] = $n;
21  else
22    $page['errors'][] = 'The number of markers must be >0';
23
24  $n  = intval($_POST['nb_images_per_marker']);
25  if ($n>1)
26    $gm_config['nb_images_per_marker'] = $n;
27  else
28    $page['errors'][] = 'The number of iamges per marker must be >1';
29
30  $gm_config['marker_icon'] = $_POST['marker_icon'];
31  mkgetdir( dirname(rvm_get_config_file_name()) );
32  $fp = fopen( rvm_get_config_file_name(), 'w');
33  fwrite( $fp, serialize($gm_config) );
34  fclose($fp);
35}
36
37$query = 'SELECT COUNT(*) FROM '.IMAGES_TABLE.' WHERE lat IS NOT NULL';
38list($nb_geotagged) = mysql_fetch_array( pwg_query($query) );
39
40$template->assign(
41    array(
42      'NB_GEOTAGGED' => $nb_geotagged,
43      'GMAPS_API_KEY' => $conf['gmaps_api_key'],
44      'NB_MARKERS' => rvm_get_config_var('nb_markers',40),
45      'NB_IMAGES_PER_MARKER' => rvm_get_config_var('nb_images_per_marker',20),
46    )
47  );
48
49$path=PHPWG_PLUGINS_PATH.$rvm_dir.'/template/markers/';
50$dir_contents = opendir($path);
51while (($filename = readdir($dir_contents)) !== false)
52{
53  if (!is_file($path.'/'.$filename) or get_extension($filename)!='tpl')
54    continue;
55  $filename = get_filename_wo_extension( $filename );
56  $template->append('marker_icons',
57      array(
58        $filename => str_replace( '_', ' ', $filename),
59      ),
60      true
61    );
62}
63$template->assign('selected_marker_icon', rvm_get_config_var('marker_icon', '') );
64
65closedir($dir_contents);
66?>
Note: See TracBrowser for help on using the repository browser.