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

Last change on this file since 26331 was 26331, checked in by rvelices, 7 years ago

rv_gmaps compatible with nez latitude/longitude fields in piwigo core 2.6

  • 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  $gm_config = rvm_get_config();
20
21  $n  = intval($_POST['nb_markers']);
22  if ($n>0)
23    $gm_config['nb_markers'] = $n;
24  else
25    $page['errors'][] = 'The number of markers must be >0';
26
27  $n  = intval($_POST['nb_images_per_marker']);
28  if ($n>1)
29    $gm_config['nb_images_per_marker'] = $n;
30  else
31    $page['errors'][] = 'The number of iamges per marker must be >1';
32
33  $gm_config['marker_icon'] = $_POST['marker_icon'];
34        $gm_config['map_type'] = $_POST['map_type'];
35
36  mkgetdir( dirname(rvm_get_config_file_name()) );
37  $fp = fopen( rvm_get_config_file_name(), 'w');
38  fwrite( $fp, serialize($gm_config) );
39  fclose($fp);
40}
41
42$query = 'SELECT COUNT(*) FROM '.IMAGES_TABLE.' WHERE latitude IS NOT NULL';
43list($nb_geotagged) = pwg_db_fetch_array( pwg_query($query) );
44
45$template->assign(
46    array(
47      'NB_GEOTAGGED' => $nb_geotagged,
48      'GMAPS_API_KEY' => $conf['gmaps_api_key'],
49      'NB_MARKERS' => rvm_get_config_var('nb_markers',40),
50      'NB_IMAGES_PER_MARKER' => rvm_get_config_var('nb_images_per_marker',20),
51                        'MAP_TYPE' => rvm_get_config_var('map_type','ROADMAP'),
52    )
53  );
54
55$files = array();
56$path=PHPWG_PLUGINS_PATH.$rvm_dir.'/template/markers/';
57$dir_contents = opendir($path);
58while (($filename = readdir($dir_contents)) !== false)
59{
60  if (!is_file($path.'/'.$filename) or get_extension($filename)!='tpl')
61    continue;
62        $files[] = get_filename_wo_extension($filename);
63 }
64closedir($dir_contents);
65
66sort($files);
67foreach($files as $file)
68{
69        $template->append('marker_icons',
70      array(
71        $file => str_replace( '_', ' ', $file),
72      ),
73      true
74    );
75}
76
77$template->assign('selected_marker_icon', rvm_get_config_var('marker_icon', '') );
78
79$map_types = array(
80        "ROADMAP" => "Roadmap (Default)",
81        "SATELLITE" => "Satellite",
82        "HYBRID" => "Hybrid",
83        "TERRAIN" => "Terrain",
84);
85$template->assign('map_types', $map_types);
86?>
Note: See TracBrowser for help on using the repository browser.