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

Last change on this file since 12700 was 12700, checked in by rvelices, 12 years ago

rv_gmaps towards full maps api v3 migration

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 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']) )
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  mkgetdir( dirname(rvm_get_config_file_name()) );
47  $fp = fopen( rvm_get_config_file_name(), 'w');
48  fwrite( $fp, serialize($gm_config) );
49  fclose($fp);
50}
51
52$query = 'SELECT COUNT(*) FROM '.IMAGES_TABLE.' WHERE lat IS NOT NULL';
53list($nb_geotagged) = mysql_fetch_array( pwg_query($query) );
54
55$template->assign(
56    array(
57      'NB_GEOTAGGED' => $nb_geotagged,
58      'GMAPS_API_KEY' => $conf['gmaps_api_key'],
59      'GMAPS_AUTO_SYNC' => isset($conf['gmaps_auto_sync']) ? 1:0,
60      'NB_MARKERS' => rvm_get_config_var('nb_markers',40),
61      'NB_IMAGES_PER_MARKER' => rvm_get_config_var('nb_images_per_marker',20),
62    )
63  );
64
65$path=PHPWG_PLUGINS_PATH.$rvm_dir.'/template/markers/';
66$dir_contents = opendir($path);
67while (($filename = readdir($dir_contents)) !== false)
68{
69  if (!is_file($path.'/'.$filename) or get_extension($filename)!='tpl')
70    continue;
71  $filename = get_filename_wo_extension( $filename );
72  $template->append('marker_icons',
73      array(
74        $filename => str_replace( '_', ' ', $filename),
75      ),
76      true
77    );
78}
79$template->assign('selected_marker_icon', rvm_get_config_var('marker_icon', '') );
80
81closedir($dir_contents);
82?>
Note: See TracBrowser for help on using the repository browser.