diff --git a/soundmap/css/soundmap-admin.css b/soundmap/css/soundmap-admin.css index e44d1ba..43b9ac7 100644 --- a/soundmap/css/soundmap-admin.css +++ b/soundmap/css/soundmap-admin.css @@ -1,5 +1,5 @@ -#map_canvas{width:100%; height:400px;} +#map_canvas, #map_canvas_options{width:100%; height:400px;} #sound-att-table {width:100%; table-layout: fixed; word-break: break-word; border-collapse: collapse;} #sound-att-table th{text-align:left;} #sound-att-table .soundmap-att-left{width:60%; padding-right:6px} diff --git a/soundmap/js/soundmap-admin.js b/soundmap/js/soundmap-admin.js index bab92a6..7f11fd8 100644 --- a/soundmap/js/soundmap-admin.js +++ b/soundmap/js/soundmap-admin.js @@ -2,10 +2,25 @@ jQuery(document).ready(function($) { // $() will work as an alias for jQuery() inside of this function var map_canvas = $('#map_canvas'); - + var or_latln= new google.maps.LatLng(WP_Params.lat, WP_Params.lng); + var or_maptype; + switch (WP_Params.mapType){ + case 'ROADMAP': + or_maptype = google.maps.MapTypeId.ROADMAP; + break; + case 'HYBRID': + or_maptype = google.maps.MapTypeId.HYBRID; + break; + case 'TERRAIN': + or_maptype = google.maps.MapTypeId.TERRAIN; + break; + case 'SATELLITE': + or_maptype = google.maps.MapTypeId.SATELLITE; + break; + } var soundmark; if (map_canvas){ - $('#map_canvas').gmap({'callback': function(map){ + $('#map_canvas').gmap({'center': or_latln, 'zoom' : Number(WP_Params.zoom),'mapTypeId': or_maptype, 'callback': function(map){ if($('#soundmap-marker-lat').val()!=""){ var latlng = new google.maps.LatLng($('#soundmap-marker-lat').val(), $('#soundmap-marker-lng').val()); map.panTo(latlng); @@ -33,6 +48,69 @@ jQuery(document).ready(function($) { }}); } + var map_canvas_options = $('#map_canvas_options'); + if (map_canvas_options){ + $('#map_canvas_options').gmap({'center': or_latln, 'zoom' : Number(WP_Params.zoom), 'mapTypeId': or_maptype, 'callback': function(map){ + $(map).dragend(function(event){ + var new_center = map.getCenter(); + $('#soundmap_op_origin_lat').val(new_center.lat()); + $('#soundmap_op_origin_lng').val(new_center.lng()); + }); + $(map).addEventListener('zoom_changed', function(event){ + var new_zoom = map.getZoom(); + $('#soundmap_op_origin_zoom').val(new_zoom); + }); + $(map).addEventListener('maptypeid_changed',function(event){ + var new_type = map.getMapTypeId(); + switch (new_type) + { + case google.maps.MapTypeId.ROADMAP: + $('#soundmap_op_origin_type').children('option[value|="ROADMAP"]').attr('selected','selected'); + break; + case google.maps.MapTypeId.HYBRID: + $('#soundmap_op_origin_type').children('option[value|="HYBRID"]').attr('selected','selected'); + break; + case google.maps.MapTypeId.TERRAIN: + $('#soundmap_op_origin_type').children('option[value|="TERRAIN"]').attr('selected','selected'); + break; + case google.maps.MapTypeId.SATELLITE: + $('#soundmap_op_origin_type').children('option[value|="SATELLITE"]').attr('selected','selected'); + break; + } + }); + + } + }); + $('#soundmap_op_origin_lat, #soundmap_op_origin_lng, #soundmap_op_origin_zoom', '#soundmap_op_origin_type').change(function(){ + var latlng = new google.maps.LatLng($('#soundmap_op_origin_lat').val(), $('#soundmap_op_origin_lng').val()); + var z = $('#soundmap_op_origin_zoom').val(); + map = map_canvas_options.gmap('getMap'); + map.panTo(latlng); + map.setCenter(latlng); + map.setZoom(Number(z)); + }); + $('#soundmap_op_origin_type').change(function(){ + var t = $('#soundmap_op_origin_type').val(); + map = map_canvas_options.gmap('getMap'); + switch (t){ + case 'ROADMAP': + mt = google.maps.MapTypeId.ROADMAP; + break; + case 'HYBRID': + mt = google.maps.MapTypeId.HYBRID; + break; + case 'TERRAIN': + mt = google.maps.MapTypeId.TERRAIN; + break; + case 'SATELLITE': + mt = google.maps.MapTypeId.SATELLITE; + break; + } + map.setMapTypeId(mt); + + }); + } + $('#soundmap-marker-lat, #soundmap-marker-lng').change(function(){ var latlng = new google.maps.LatLng($('#soundmap-marker-lat').val(), $('#soundmap-marker-lng').val()); map = map_canvas.gmap('getMap'); diff --git a/soundmap/js/soundmap-wp.js b/soundmap/js/soundmap-wp.js index af480da..7cee0c2 100644 --- a/soundmap/js/soundmap-wp.js +++ b/soundmap/js/soundmap-wp.js @@ -3,10 +3,26 @@ jQuery(document).ready(function($) { // $() will work as an alias for jQuery() inside of this function var map_canvas = $('.map_canvas'); var g_map; + var or_latln= new google.maps.LatLng(WP_Params.lat, WP_Params.lng); + var or_maptype; + switch (WP_Params.mapType){ + case 'ROADMAP': + or_maptype = google.maps.MapTypeId.ROADMAP; + break; + case 'HYBRID': + or_maptype = google.maps.MapTypeId.HYBRID; + break; + case 'TERRAIN': + or_maptype = google.maps.MapTypeId.TERRAIN; + break; + case 'SATELLITE': + or_maptype = google.maps.MapTypeId.SATELLITE; + break; + } map_canvas.after('
') info_w = false; if (map_canvas){ - markers_map = $('.map_canvas').gmap({'callback': function(map){ + markers_map = $('.map_canvas').gmap({'center': or_latln, 'zoom' : Number(WP_Params.zoom),'mapTypeId': or_maptype, 'callback': function(map){ g_map=map; info_w = new google.maps.InfoWindow({content: ' '}); diff --git a/soundmap/modules/module.jplayer.php b/soundmap/modules/module.jplayer.php index 287c73c..5f0f18c 100644 --- a/soundmap/modules/module.jplayer.php +++ b/soundmap/modules/module.jplayer.php @@ -16,8 +16,7 @@ class sm_jPlayer extends SoundMap_Player{ } function print_audio_content($files, $id){ - - + $playlist = FALSE; $total_files = count($files); diff --git a/soundmap/soundmap.php b/soundmap/soundmap.php index 9e40f6b..38bf056 100644 --- a/soundmap/soundmap.php +++ b/soundmap/soundmap.php @@ -65,8 +65,8 @@ function soundmap_init() { register_taxonomy_for_object_type('category', 'marker'); register_taxonomy_for_object_type('post_tag', 'marker'); - soundmap_check_map_page(); - + _soundmap_load_options(); + soundmap_check_map_page(); soundmap_create_player_instance(); if(!is_admin()){ @@ -77,32 +77,32 @@ function soundmap_init() { function soundmap_create_player_instance(){ - global $soundmap_Player; - + global $soundmap_Player, $soundmap; + $plugins = get_option( 'active_plugins', array() ); if (!is_array($plugins)) return; - if(in_array('audio-player/audio-player.php', $plugins) && class_exists('sm_AudioPlayer')){ + if(in_array('audio-player/audio-player.php', $plugins) && class_exists('sm_AudioPlayer') && $soundmap['player_plugin'] =="audio-player/audio-player.php"){ //Audio player active $soundmap_Player = new sm_AudioPlayer(); return; } - if(in_array('haiku-minimalist-audio-player/haiku-player.php', $plugins) && class_exists('sm_HaikuPlayer')){ + if(in_array('haiku-minimalist-audio-player/haiku-player.php', $plugins) && class_exists('sm_HaikuPlayer') && $soundmap['player_plugin'] =='haiku-minimalist-audio-player/haiku-player.php'){ //Audio player active $soundmap_Player = new sm_HaikuPlayer(); return; } - if(in_array('wp-audio-gallery-playlist/wp-audio-gallery-playlist.php', $plugins) && class_exists('sm_AudioGallery_Player')){ + if(in_array('wp-audio-gallery-playlist/wp-audio-gallery-playlist.php', $plugins) && class_exists('sm_AudioGallery_Player') && $soundmap['player_plugin'] =='wp-audio-gallery-playlist/wp-audio-gallery-playlist.php'){ //Audio player active $soundmap_Player = new sm_AudioGallery_Player(); return; } - if(in_array('jplayer/jplayer.php', $plugins) && class_exists('sm_jPlayer')){ + if(in_array('jplayer/jplayer.php', $plugins) && class_exists('sm_jPlayer') && $soundmap['player_plugin'] =='jplayer/jplayer.php'){ //Audio player active $soundmap_Player = new sm_jPlayer(); return; @@ -113,9 +113,21 @@ function soundmap_create_player_instance(){ function soundmap_check_map_page(){ global $soundmap; $uri = get_uri(); - if (end($uri) == 'map/'){ + $page = $soundmap['map_Page']; + if ($page == "[home]"){ + // for consistency, check to see if trailing slash exists in URI request + if (is_home()) $soundmap['on_page'] = TRUE; + + }else{ + if (substr($page, -1)!="/") { + $page = $page."/"; + } + if (end($uri) == $page){ + $soundmap['on_page'] = TRUE; + } } + } function soundmap_register_scripts(){ @@ -223,24 +235,66 @@ function soundmap_admin_enqueue_scripts() { wp_enqueue_script('soundmap-admin'); wp_enqueue_style('soundmap-admin'); + global $soundmap; + $params = array(); - $params['plugin_url'] = WP_PLUGIN_URL . '/soundmap/'; + $params['plugin_url'] = WP_PLUGIN_URL . '/soundmap/'; + $params += $soundmap['origin']; + $params ['mapType'] = $soundmap['mapType']; wp_localize_script('soundmap-admin','WP_Params',$params); } function soundmap_wp_enqueue_scripts() { + + global $soundmap; + + $params = array(); + $params['ajaxurl'] = admin_url( 'admin-ajax.php' ); + $params += $soundmap['origin']; + $params ['mapType'] = $soundmap['mapType']; + wp_enqueue_script('soundmap'); - - wp_localize_script( 'soundmap', 'WP_Params', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); + wp_localize_script( 'soundmap', 'WP_Params', $params ); } -function soundmap_save_options(){ +function _soundmap_save_options(){ + $_soundmap = array(); + global $soundmap; + //Load defaults; + + $_soundmap ['origin']['lat'] = $_POST['soundmap_op_origin_lat']; + $_soundmap ['origin']['lng'] = $_POST['soundmap_op_origin_lng']; + $_soundmap ['origin']['zoom'] = $_POST['soundmap_op_origin_zoom']; + $_soundmap ['mapType'] = $_POST['soundmap_op_origin_type']; + $_soundmap ['map_Page'] = $_POST['soundmap_op_page']; + if(isset($_POST['soundmap_op_plugin'])) + $_soundmap ['player_plugin'] = $_POST['soundmap_op_plugin']; + + update_option('soundmap',maybe_serialize($_soundmap)); + $soundmap = wp_parse_args($_soundmap, $soundmap); } -function soundmap_load_options(){ + +function _soundmap_load_options(){ + $_soundmap = array(); + global $soundmap; + //Load defaults; + $defaults = array(); + $defaults['on_page'] = FALSE; + $defaults['origin']['lat'] = 0; + $defaults['origin']['lng'] = 0; + $defaults['origin']['zoom'] = 10; + $defaults['mapType'] = 'ROADMAP'; + $defaults['map_Page'] = 'map'; + $defaults['player_plugin'] = ""; + $_soundmap = maybe_unserialize(get_option('soundmap')); + + $_soundmap = wp_parse_args($_soundmap, $defaults); + + $soundmap = $_soundmap; } function soundmap_save_post($post_id) { @@ -406,12 +460,17 @@ function soundmap_attach_file($att, $post_id){ function soundmap_template_redirect(){ global $soundmap; + $page = $soundmap['map_Page']; + if ($page == '[home]'){ + + }else{ + if ($soundmap['on_page']){ + if ($theme=soundmap_get_template_include($page)) + include ($theme); + exit(); + } + } - if ($soundmap['on_page']){ - if ($theme=soundmap_get_template_include('map')) - include ($theme); - exit(); - } } function soundmap_get_template_include($templ){ @@ -453,10 +512,12 @@ function soundmap_load_infowindow(){ $files = get_post_meta($marker_id, 'soundmap_attachments_id', FALSE); foreach ($files as $key => $value){ $file = array(); + $att = get_post($value); $file['id'] = $value; $file['fileURI'] = wp_get_attachment_url($value); $file['filePath'] = get_attached_file($value); $file['info'] = soundmap_get_id3info($file['filePath']); + $file['name'] = $att->post_name; $info['m_files'][] = $file; } if ($theme=soundmap_get_template_include('window')) @@ -464,12 +525,135 @@ function soundmap_load_infowindow(){ die(); } +function soundmap_admin_menu(){ + add_options_page(__('Sound Map Configuration','soundmap'), __('Sound Map','soundmap'), 'manage_options', 'soundmap-options-menu','soundmap_menu_page_callback'); +} + +function soundmap_menu_page_callback(){ + + if (!current_user_can('manage_options')) { + wp_die( __('You do not have sufficient permissions to access this page.') ); + } + + // verify this came from the our screen and with proper authorization, + // because save_post can be triggered at other times + if (isset($_POST['soundmap_op_noncename'])){ + if ( !wp_verify_nonce( $_POST['soundmap_op_noncename'], plugin_basename( __FILE__ ) ) ) + return; + _soundmap_save_options(); + } + + global $soundmap; + + ?> +'. $plugin['Description'] .'
+ | + | + |
---|