[3447] | 1 | <?php |
---|
[12701] | 2 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
[3447] | 3 | |
---|
| 4 | include_once( dirname(__FILE__).'/../include/functions_map.php' ); |
---|
| 5 | |
---|
[8367] | 6 | if ( isset($_POST['submit']) ) |
---|
[3447] | 7 | { |
---|
[12700] | 8 | if (isset($_POST['gmaps_api_key'])) |
---|
| 9 | { |
---|
| 10 | $query = ' |
---|
[3447] | 11 | UPDATE '.CONFIG_TABLE.' |
---|
| 12 | SET value="'.$_POST['gmaps_api_key'].'" |
---|
| 13 | WHERE param="gmaps_api_key" |
---|
| 14 | LIMIT 1'; |
---|
[12700] | 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 | } |
---|
[3447] | 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']; |
---|
[23083] | 34 | $gm_config['map_type'] = $_POST['map_type']; |
---|
| 35 | |
---|
[3447] | 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 | |
---|
[26331] | 42 | $query = 'SELECT COUNT(*) FROM '.IMAGES_TABLE.' WHERE latitude IS NOT NULL'; |
---|
[20515] | 43 | list($nb_geotagged) = pwg_db_fetch_array( pwg_query($query) ); |
---|
[3447] | 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), |
---|
[23083] | 51 | 'MAP_TYPE' => rvm_get_config_var('map_type','ROADMAP'), |
---|
[3447] | 52 | ) |
---|
| 53 | ); |
---|
| 54 | |
---|
[12706] | 55 | $files = array(); |
---|
[3447] | 56 | $path=PHPWG_PLUGINS_PATH.$rvm_dir.'/template/markers/'; |
---|
| 57 | $dir_contents = opendir($path); |
---|
| 58 | while (($filename = readdir($dir_contents)) !== false) |
---|
| 59 | { |
---|
| 60 | if (!is_file($path.'/'.$filename) or get_extension($filename)!='tpl') |
---|
| 61 | continue; |
---|
[12706] | 62 | $files[] = get_filename_wo_extension($filename); |
---|
| 63 | } |
---|
| 64 | closedir($dir_contents); |
---|
| 65 | |
---|
| 66 | sort($files); |
---|
| 67 | foreach($files as $file) |
---|
| 68 | { |
---|
| 69 | $template->append('marker_icons', |
---|
[3447] | 70 | array( |
---|
[12706] | 71 | $file => str_replace( '_', ' ', $file), |
---|
[3447] | 72 | ), |
---|
| 73 | true |
---|
| 74 | ); |
---|
| 75 | } |
---|
[23083] | 76 | |
---|
[3447] | 77 | $template->assign('selected_marker_icon', rvm_get_config_var('marker_icon', '') ); |
---|
| 78 | |
---|
[23083] | 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); |
---|
[3447] | 86 | ?> |
---|