1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | include_once( dirname(__FILE__).'/../include/functions_map.php' ); |
---|
5 | |
---|
6 | if ( isset($_POST['submit']) and !is_adviser() ) |
---|
7 | { |
---|
8 | $query = ' |
---|
9 | UPDATE '.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'; |
---|
38 | list($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); |
---|
51 | while (($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 | |
---|
65 | closedir($dir_contents); |
---|
66 | ?> |
---|