diff --git a/plug/map_prof.zip b/plug/map_prof.zip deleted file mode 100644 index 64ebbfa..0000000 Binary files a/plug/map_prof.zip and /dev/null differ diff --git a/plug/map_prof/images/marker.png b/plug/map_prof/images/marker.png deleted file mode 100644 index bb6d6c9..0000000 Binary files a/plug/map_prof/images/marker.png and /dev/null differ diff --git a/plug/map_prof/images/marker_cluster.png b/plug/map_prof/images/marker_cluster.png deleted file mode 100644 index 0367cfc..0000000 Binary files a/plug/map_prof/images/marker_cluster.png and /dev/null differ diff --git a/plug/map_prof/map_prof_hooks.php b/plug/map_prof/map_prof_hooks.php deleted file mode 100644 index e023bf9..0000000 --- a/plug/map_prof/map_prof_hooks.php +++ /dev/null @@ -1,170 +0,0 @@ -categorie) === "array") { - // mp_console_log($event->categorie); - // } - // if (str_starts_with($event->categorie, '["')) { - // mp_console_log($event->categorie); - // } - //} - - $locations = mp_sort_events($events); // mp_get_locations.php - //mp_console_log("locations: "); - //mp_console_log($locations); - - $filters = mp_get_filters($events); // mp_get_filters.php - - // if post event instead of map page, change coordinate and zoom - mp_post_event_pages_setting(); - - mp_add_to_scripts(array( - "locations" => $locations, - "filters" => $filters, - "jipf_events" => $events, - )); - - return mp_create_div($filters); -} -add_shortcode('lejourduprof_map', 'mp_ljdp_map'); - -/* - script in divi : - - -*/ - - - - - -/** - * re-publish posts - */ - -// function mp_add_update_button() { -// return mp_create_republish_button(); -// } -// add_shortcode('ljdp_update_publish', 'mp_add_update_button'); - - - - - -/** - * errors map - */ - -function mp_errors_map() { - return mp_find_address_errors(); -} -add_shortcode('ljdp_errors_map', 'mp_errors_map'); - - - - - -/** - * when a post is saved or published or updated, - * find its coordinates - */ - -function post_published_coordinates($id, $post) { - - $location = mp_get_coordinates($id); - //mp_console_log("location: "); - //mp_console_log($location); - - if ( ! add_post_meta( $id, 'location', $location, true ) ) - update_post_meta( $id, 'location', $location ); - -} -add_action( 'publish_post', 'post_published_coordinates', 10, 2 ); - - - - - -/** - * menu plugin - */ - -function ljdp_map_menu() { - add_menu_page( - 'JIPF map', // page_title - 'JIPF map', // menu_title - 'manage_options', // capability - 'ljdp-map-plugin', // menu_slug - 'ljdp_map_plugin_content' // callback function to display page content - ); -} -add_action('admin_menu', 'ljdp_map_menu'); - -?> diff --git a/plug/map_prof/mp_enqueue.php b/plug/map_prof/mp_enqueue.php deleted file mode 100644 index 8e00caf..0000000 --- a/plug/map_prof/mp_enqueue.php +++ /dev/null @@ -1,26 +0,0 @@ - diff --git a/plug/map_prof/scripts/mp_create_filters.js b/plug/map_prof/scripts/mp_create_filters.js deleted file mode 100644 index fc7ad8e..0000000 --- a/plug/map_prof/scripts/mp_create_filters.js +++ /dev/null @@ -1,103 +0,0 @@ -function fill_filters(filters_div) { - - /* - * following variable are created by mp_add_to_script.php - * - * { } - * { [ ] } - * - filters: { - pays : [ { - _name : "" } ] } - * { [ { - villes : [] } ] } - * { [ { - categories: [] } ] } - * { [ { - mode : [] }, ...] } - * { [ ] } - * { } - * { [ ] } - * { - villes : [ { - _name : "" } ] } - * { [ { - pays : [] } ] } - * { [ { - categories: [] } ] } - * { [ { - mode : [] }, ...] } - * { [ ] } - * { } - * { [ ] } - * { - categories: [ { - _name : "" } ] } - * { [ { - pays : [] } ] } - * { [ { - villes : [] } ] } - * { [ { - mode : [] }, ...] } - * { [ ] } - * { } - * { } - * { [ ] } - * { - mode : [ { - _name : "" } ] } - * { [ { - pays : [] } ] } - * { [ { - villes : [] } ] } - * { [ { - categories: [] }, ...] } - * { [ ] } - * { } - * - */ - - let content = ""; - // use Object.keys to obtain an array of object keys - let keys = Object.keys(filters); - keys.forEach((key) => { - - // // version input checkbox - // - // content += ` - //
- // `; - - // // version select - // - // content += ` - // - // `; - - // // version div - // - content += ` - - `; - - }); - - filters_div.innerHTML = content; -} diff --git a/plug/map_prof/scripts/mp_create_map.js b/plug/map_prof/scripts/mp_create_map.js deleted file mode 100644 index ead03cc..0000000 --- a/plug/map_prof/scripts/mp_create_map.js +++ /dev/null @@ -1,41 +0,0 @@ - -function restrict_map(restrict) { - let map_restriction = { - latLngBounds: g_world_bound, - strictBounds: true, - }; - if (restrict) - g_map.setOptions({restriction: map_restriction,}); - else - g_map.setOptions({restriction: null,}); -}; - -function create_map(map_div) { - // default map center to france - let map_center = coordinates_default; - // map_center = {lat:-2.515748362923059, lng:32.93366215464864}; - let map_restriction = { - latLngBounds: g_world_bound, - strictBounds: true, - }; - let map_options = { - /* map options : https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions */ - disableDefaultUI: true, - zoomControl: true, - scaleControl: true, - zoom: map_zoom, - - //gestureHandling: "cooperative", - gestureHandling: "greedy", - //gestureHandling: "none", - //gestureHandling: "auto", - - //disableDoubleClickZoom: "false", // deprecated - //draggable: "true", // deprecated - - center: map_center, - restriction: map_restriction, - } - - return new google.maps.Map(map_div, map_options); -} diff --git a/plug/map_prof/scripts/mp_create_markers.js b/plug/map_prof/scripts/mp_create_markers.js deleted file mode 100644 index 00838d2..0000000 --- a/plug/map_prof/scripts/mp_create_markers.js +++ /dev/null @@ -1,57 +0,0 @@ -function create_markers(map, locations, infowindow) { - - /* - * following variable are created by mp_add_to_script.php - * - let icon_color = "" - * - let icon_color_back = "" - * - let icon_size = [x, y] - * - let cluster_size_factor = Number - * - let icon_stroke_width = Number - */ - - let icon_circle_radius = 40 - icon_stroke_width / 2; - - let markers = []; - for (loc of locations) { - - if (loc.coordinates == null) - continue; - - let count = loc.events.length; - - let marker_icon_size = [ - icon_size[0] + ( icon_size_factor * (count - 2) ), - icon_size[1] + ( icon_size_factor * (count - 2) ) - ]; - let svg_icon = window.btoa(` - - `); - let icon_options = { - url: `data:image/svg+xml;base64,${svg_icon}`, - scaledSize: new google.maps.Size(marker_icon_size[0], marker_icon_size[1]), - }; - let marker_label = { - text: String(count), - color: icon_color, - fontSize: "12px", - fontWeight: "bold", - }; - let marker_title = `address of ${count} events`; - - let marker = new google.maps.Marker({ - position: loc.coordinates, - map: map, - icon: icon_options, - title: marker_title, - label: marker_label, - }); - - attach_info_window(map, marker, loc.events, infowindow); - - markers.push(marker); - }; - - return markers; -} diff --git a/plug/map_prof/scripts/mp_draw_clusters.js b/plug/map_prof/scripts/mp_draw_clusters.js deleted file mode 100644 index 8f00a8a..0000000 --- a/plug/map_prof/scripts/mp_draw_clusters.js +++ /dev/null @@ -1,58 +0,0 @@ -function draw_clusters(map, markers) { - - /* - * following variable are created by mp_add_to_script.php - * - let icon_color = "" - * - let icon_color_back = "" - * - let icon_size = [x, y] - * - let icon_size_factor = Number - * - let icon_stroke_width = Number - */ - - let icon_circle_radius = 40 - icon_stroke_width / 2; - - let renderer = { - render({ count, position }, stats) { - - /* CLUSTERS SETTINGS */ - - let marker_icon_size = [ - icon_size[0] + ( icon_size_factor * (count - 2) ), - icon_size[1] + ( icon_size_factor * (count - 2) ) - ]; - let cluster_svg = window.btoa(` - - `); - let cluster_icon = { - url: `data:image/svg+xml;base64,${cluster_svg}`, - scaledSize: new google.maps.Size(marker_icon_size[0], marker_icon_size[1]), - }; - let cluster_label = { - text: String(count), - color: icon_color, - fontSize: "12px", - fontWeight: "bold", - }; - let cluster_title = `Cluster of ${count} markers`; - let cluster_zIndex = Number(google.maps.Marker.MAX_ZINDEX) + count; - - return new google.maps.Marker({ - position, - icon: cluster_icon, - label: cluster_label, - title: cluster_title, - zIndex: cluster_zIndex, - }); - } - } - - let onClusterClick = (_, cluster, map) => { - restrict_map(false); - map.fitBounds(cluster.bounds); - restrict_map(true); - }; - - return new markerClusterer.MarkerClusterer({ map, markers, renderer, onClusterClick }); -} diff --git a/plug/map_prof/scripts/mp_errors_map.js b/plug/map_prof/scripts/mp_errors_map.js deleted file mode 100644 index 4d868a6..0000000 --- a/plug/map_prof/scripts/mp_errors_map.js +++ /dev/null @@ -1,7 +0,0 @@ -function print_error(error) { - let div_map = document.getElementById("ljdp_map"); - let p_err = document.createElement('p'); - - p_err.textContent = error; - div_map.after(p_err); -} diff --git a/plug/map_prof/scripts/mp_filter_events.js b/plug/map_prof/scripts/mp_filter_events.js deleted file mode 100644 index e2a4f22..0000000 --- a/plug/map_prof/scripts/mp_filter_events.js +++ /dev/null @@ -1,278 +0,0 @@ - -// https://googlemaps.github.io/js-markerclusterer/classes/MarkerClusterer.html -// add true for noDraw -// bounds : https://stackoverflow.com/questions/19304574/center-set-zoom-of-map-to-cover-all-visible-markers/19304625#19304625 - - - -function array_first_not_in_second(first, second) { - let temp_array = []; - for (let index of first) { - if (second.indexOf(index) == -1) { - temp_array.push(index); - } - } - return temp_array; -} - -function filter_selection_indexes(menu, indexes, reverse, add) { - - if (indexes.length === 0) { - // if array of index is empty, delete menu - delete g_indexes[menu]; - } - else if (reverse) { - // if reverse is true, delete all indexes in g_indexes.menu - // https://stackoverflow.com/questions/5113374/javascript-check-if-variable-exists-is-defined-initialized - if ( typeof(g_indexes[menu]) !== "undefined" && g_indexes[menu] !== null ) { - // creates an array with all values of g_indexes[menu] minus indexes - let temp_array = array_first_not_in_second(g_indexes[menu], indexes); - if (temp_array.length === 0) - delete g_indexes[menu]; - else - g_indexes[menu] = [].concat(temp_array); - } - } - else { - if (add && typeof(g_indexes[menu]) !== "undefined") { - // add array of menus to g_indexes{} - // creates an array with all values of indexes that are not in g_indexes[menu] already - let temp_array = array_first_not_in_second(indexes, g_indexes[menu]); - g_indexes[menu] = g_indexes[menu].concat(temp_array); - } - else { - // replace or create array of menu in g_indexes{} - g_indexes[menu] = [].concat(indexes); - } - } - - // loop through all arrays of g_indexes to find intersection - // take first one as comparison - let keys = Object.keys(g_indexes); - let intersection = []; - let compare = []; - keys.forEach((key, i) => { - if (i == 0) { - intersection = g_indexes[key]; - } - else { - let temp = []; - compare = g_indexes[key]; - for (let index of intersection) { - if (compare.indexOf(index) != -1) - temp.push(index); - } - intersection = [].concat(temp); - } - }); - return intersection; -} - -function redraw_clusters(indexes) { - - let indexes_count = indexes.length; - - if (indexes_count !== 0) { - // if index array, hide all other markers, and if zoomin, zoom to new markers - g_marker_cluster.clearMarkers(true); - - let marker = g_markers[0]; - let current_bounds = g_map.getBounds(); - let bounds = new google.maps.LatLngBounds(); - - let outside_bounds = false; - for (let index of indexes) { - marker = g_markers[index]; - position = marker.getPosition(); - if (! current_bounds.contains(position)) - outside_bounds = true; - bounds.extend(position); - - g_marker_cluster.addMarker(marker, true); - } - if (outside_bounds) { - if (indexes_count === 1) { - g_map.setCenter(position); - g_map.setZoom(max_zoom); - } - else if (indexes_count > 1) { - g_map.fitBounds(bounds); - } - } - - } - else if ( Object.keys(g_indexes).length === 0 ) { - // object is empty, there are no filters - g_map.setCenter(coordinates_default); - g_map.setZoom(2); - g_marker_cluster.addMarkers(g_markers, true); - } - else { - // filters intersection lets no markers on the map - g_marker_cluster.clearMarkers(true); - } - - g_marker_cluster.render(); -} - -function html_item(menu_name, menu_item) { - let item = menu_item.replace(/ /g, "_"); - let html_id = `filter_${menu_name}_${item}`; - return document.getElementById(html_id); -} - -function toggle_menu_items(menu_name, x_abled) { - - let name = menu_name.replace(/ /g, "_"); - let class_name = `filter_menu_${name}`; - let items = document.getElementsByClassName(class_name); - - if (x_abled === "disable") { - for (let item of items) { - // if item is a menu title (like 'categorie' or 'pays') - // don't remove 'enable', instead add it, because it's not in the list of 'to_enable' - if (item.selected) { - item.classList.add('enable'); - } - else { - item.classList.remove('enable'); - } - if (item.classList.contains('to_enable')) { - item.classList.replace('to_enable', 'enable'); - item.removeAttribute('disabled'); - } - else if (! item.selected) - item.setAttribute('disabled', ''); - } - } - else { - for (let item of items) { - item.classList.remove('enable'); - item.removeAttribute('disabled'); - } - } -} - -function disable_menus(menu_name_ori, menu_item_ori, reverse, menu_index) { - - let menu_item_name = ""; - if (menu_item_ori == null) // it's a menu name - menu_item_name = menu_name_ori; - else - menu_item_name = menu_item_ori._name; - let item_ori_html = html_item(menu_name_ori, menu_item_name); - let is_enabled = item_ori_html.classList.contains('enable'); - - // in case it's a menu title, like "Pays" or "Categories", - // and it does'nt contains 'enable' - // just act like Reset button - // it's too bad it will also go through this menu items even though it's unnecessary - if (menu_index == 'menu_name') { // it's a menu name - if (! is_enabled) { - // "item" as a menu name will select all items in all menus - toggle_menu_items("item", "enable"); - } - return; - } - - // if it's Mode menu, - // and it was the first selection, meaning it does'nt contains 'enable' - // and both (irl and online) are abled or disabled, - // just act like Reset button - // it's too bas it will also go through this menu items even though it's unnecessary - if (menu_name_ori === "mode") { - let mode_menus = document.getElementsByClassName("filter_menu_mode"); - let state = 0; - for (let mode_menu of mode_menus) { - if (mode_menu.checked) - state++; - else - state--; - } - if (state != 0) { // state equal 0 if both have a different state, because (0 + 1 - 1 = 0) and (0 - 1 + 1 = 0) - if (! is_enabled) { - // "item" as a menu name will select all items in all menus - toggle_menu_items("item", "enable"); - return; - } - } - else if (reverse) { // menu is "mode" and only one item is selected and the action was to deselect one, so the action has trigered one item but really we want to see the options of the other item, so let's switch them - if (menu_index == 0) - menu_index++; - else - menu_index--; - menu_item_ori = filters[menu_name_ori][menu_index]; - } - } - - let keys = Object.keys(menu_item_ori); - // loop through list of other menu_items available for this menu_item - // loop though menu names (pays, categories, mode) - for (let menu_name of keys) { - if (menu_name === "_name") - continue; - if (menu_name === "indexes") - continue; - else if (! is_enabled) { - - // // it's too bad it will disable all and then enable certains, it would be better to check each time - // toggle_menu_items(menu_name, "disable"); - // // loop through items in menu names (ex. for "pays" : france, chili, cuba) - // for (let item of menu_item_ori[menu_name]) { - // let item_html = html_item(menu_name, item); - // item_html.classList.add('enable'); - // item_html.removeAttribute('disabled'); - // } - - for (let item of menu_item_ori[menu_name]) { - let item_html = html_item(menu_name, item); - item_html.classList.add('to_enable'); - } - toggle_menu_items(menu_name, "disable"); - } - } -} - -function filter_show_only(element, menu_name) { - - g_infowindow.close(); - - let menu_index = element.getAttribute("data-menu_index"); - let menu_item = null; - let indexes = []; - if (menu_index != "menu_name") { - menu_item = filters[menu_name][menu_index]; - indexes = menu_item.indexes; - } - - add = false; - reverse = false; - if (element.type === "checkbox") { - reverse = ! element.checked; - add = true; - } - - disable_menus(menu_name, menu_item, reverse, menu_index); - - let index_array = filter_selection_indexes(menu_name, indexes, reverse, add); - - redraw_clusters(index_array); -} - -function filter_show_all() { - - g_infowindow.close(); - - // "item" as a menu name will select all items in all menus - toggle_menu_items("item", "enable"); - - g_indexes = {}; - g_marker_cluster.clearMarkers(true); - g_marker_cluster.addMarkers(g_markers); - /* dont use fitBounds because it's not well centered */ - /* instead use setCenter and setZoom */ - //g_map.fitBounds(g__init_bounds); - g_map.setCenter(coordinates_default); - g_map.setZoom(2); -} - diff --git a/plug/map_prof/scripts/mp_info_window.js b/plug/map_prof/scripts/mp_info_window.js deleted file mode 100644 index bc75e5a..0000000 --- a/plug/map_prof/scripts/mp_info_window.js +++ /dev/null @@ -1,82 +0,0 @@ - -function attach_info_window(map, marker, events, infowindow) { - - /* - * https://developers.google.com/maps/documentation/javascript/infowindows - * https://stackoverflow.com/questions/11106671/google-maps-api-multiple-markers-with-infowindows - */ - - let window_content = ` -${events[0].location.address}
- -${events[key].title}
- - `; - }; - window_content += ` -article : "' - . $post->post_title . '"
- adresse fournie : "' - . get_field('adresse', $id) . ', ' - . get_field('ville', $id) . ', ' - . get_field('pays', $id) - . '"
- adresse trouvée : "' - . $location->address - . '"
'; - - return $message; -} - -function mp_find_address_errors() { - - $errors = ""; - $incompletes = ""; - $approximates = ""; - $count_errors = 0; - $count_incompletes = 0; - $count_approximates = 0; - - $get_posts_args = array( - 'numberposts' => -1, - 'post_status' => 'publish', - 'post_type' => 'post', - ); - $posts = get_posts($get_posts_args); - foreach ($posts as $post) { - $id = $post->ID; - $location = get_field('location', $id); - if (! mp_is_valid_address($post, $id, $location)) { - $count_errors++; - $errors .= mp_fill_address_message($post, $id, $location); - } - // else if (! mp_is_address_complete($post, $id, $location)) { - // $count_incompletes++; - // $incompletes .= mp_fill_address_message($post, $id, $location); - // } - else if (! mp_is_precise($post, $id, $location)) { - $count_approximates++; - $approximates .= mp_fill_address_message($post, $id, $location); - } - } - $message = "- ATTENTION ! -
- - -- - HTML; - echo "$all_posts"; - echo "$published_posts"; - echo ''; - if (count($posts) == 1) - echo " article n'a pas d'adresse :"; - else - echo " articles n'ont pas d'adresses :"; - echo << -
- ATTENTION ! -
- - -- - HTML; - echo "$all_posts"; - echo "$published_posts"; - echo ''; - if (count($posts) == 1) - echo " article à sa catégorie mal formatée :"; - else - echo " articles ont leur catégorie mal formatée :"; - echo << -
- INFORMATION : -
- - -- - HTML; - echo "$all_posts"; - echo "$published_posts"; - echo ''; - if (count($posts) == 1) - echo " article n'a pas de coordonnees :"; - else - echo " articles n'ont pas de coordonnees :"; - echo << -
- pour actualiser les coordonnees d'un article, il suffit de le remettre en "brouillon" puis de le publier a nouveau -
- - HTML; -} - - - -function mp_show_post_number($posts_list, $posts_published) { - - echo <<nombre d'articles au total : - HTML; - echo count($posts_list); - echo " (dont "; - echo count($posts_published) . ""; - if (count($posts_published) == 1) - echo " publié)"; - else - echo " publiés)"; -} - - - -function mp_show_api_key_n_ip() { - global $mp_api_key; - global $mp_api_key_geo; - - echo <<l'adresse ip du serveur est : - HTML; - $external_ip = mp_get_ip(); - echo $external_ip; - echo << - HTML; - - echo <<les cles api de google maps utilisees sont : -(elles sont inscrites dans ./settings/mp_required.php)
- HTML; - - // need to use an api key with special restrictions : - // https://stackoverflow.com/questions/42167695/api-key-browser-api-keys-cannot-have-referer-restrictions-when-used-with-this-ap - echo << - → pour la carte : - cette cle api peut etre restreinte par url, et par api avec l'api "Maps Javascript API" - -- → pour les coordonnees : - cette cle api ne doit pas etre restreinte par url, elle peut etre restreinte par adresse ip du serveur, et par api avec l'api "Geocoding API" -
-- → pour utiliser une seule cle api : - cette cle api ne doit pas etre restreinte ni par url ni par adresse ip, elle peut etre restreinte par api avec les deux apis "Maps Javascript API" et "Geocoding API" -
- HTML; -} - - - -function ljdp_map_plugin_content() { - - $posts_list = mp_get_all_posts(); - //mp_console_log("posts_list: "); - //mp_console_log($posts_list); - - $posts_published = mp_posts_published($posts_list); - - $posts_no_address = mp_have_no_address($posts_list); - //mp_console_log("posts_no_address: "); - //mp_console_log($posts_no_address); - - $posts_no_coordinates = mp_have_no_coordinates($posts_list); - //mp_console_log("posts_no_coordinates: "); - //mp_console_log($posts_no_coordinates); - - $posts_bad_categories = mp_bad_categories($posts_list); - //mp_console_log("posts_bad_categories: "); - //mp_console_log($posts_bad_categories); - - - echo << - li { - list-style-position: outside; - margin-left: 10px; - } - input.hide_not_published:checked ~ ul li:not(.jipf_post_publish) { - display: none; - } - .count_published_posts { - display: none; - } - input.hide_not_published:checked ~ p .count_all_posts { - display: none; - } - input.hide_not_published:checked ~ p .count_published_posts { - display: inline; - } - -
- cliquez sur ce bouton pour mettre a jour toutes les publications
-
- une nouvelle page vide va s\'ouvrir dans un nouvel onglet, vous pouvez la fermer
-