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

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

use pwg_db_fetch_array

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 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  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) = pwg_db_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$files = array();
66$path=PHPWG_PLUGINS_PATH.$rvm_dir.'/template/markers/';
67$dir_contents = opendir($path);
68while (($filename = readdir($dir_contents)) !== false)
69{
70  if (!is_file($path.'/'.$filename) or get_extension($filename)!='tpl')
71    continue;
72        $files[] = get_filename_wo_extension($filename);
73 }
74closedir($dir_contents);
75
76sort($files);
77foreach($files as $file)
78{
79        $template->append('marker_icons',
80      array(
81        $file => str_replace( '_', ' ', $file),
82      ),
83      true
84    );
85}
86$template->assign('selected_marker_icon', rvm_get_config_var('marker_icon', '') );
87
88
89?>
Note: See TracBrowser for help on using the repository browser.