diff --git a/README.md b/README.md index 1def692..49f1807 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,17 @@ - # MAP -### verifications: +#### todo +- [/] copy recent site version +- [ ] create links +- [ ] make links having map +- [ ] transform filter list in select +- [ ] make two infowindow size +if time: +- [ ] deal with error double event irl and online +- [ ] deal with multiplication of filters +- [ ] deal with window size + +#### verifications: - api only for this site on fabien's google account - erased tmp css on site headers diff --git a/srcs/plugins/map_prof/map_prof_hooks.php b/srcs/plugins/map_prof/map_prof_hooks.php index a92e69d..e0dd0cb 100644 --- a/srcs/plugins/map_prof/map_prof_hooks.php +++ b/srcs/plugins/map_prof/map_prof_hooks.php @@ -26,7 +26,7 @@ require_once(dirname(__FILE__) . '/mp_url_api.php'); require_once(dirname(__FILE__) . '/mp_add_to_scripts.php'); require_once(dirname(__FILE__) . '/mp_get_coordinates.php'); require_once(dirname(__FILE__) . '/mp_get_events.php'); -require_once(dirname(__FILE__) . '/mp_sort_events.php'); +require_once(dirname(__FILE__) . '/mp_get_locations.php'); require_once(dirname(__FILE__) . '/mp_get_filters.php'); require_once(dirname(__FILE__) . '/mp_address_errors.php'); require_once(dirname(__FILE__) . '/mp_create_div.php'); @@ -127,14 +127,6 @@ add_shortcode('ljdp_errors_map', 'mp_errors_map'); function post_published_coordinates($id, $post) { $location = mp_get_coordinates($id); - /* - coordinates; - street; - city; - country; - address; - approximate; - */ if ( ! add_post_meta( $id, 'location', $location, true ) ) update_post_meta( $id, 'location', $location ); diff --git a/srcs/plugins/map_prof/mp_get_coordinates.php b/srcs/plugins/map_prof/mp_get_coordinates.php index 911dbc7..164f22c 100644 --- a/srcs/plugins/map_prof/mp_get_coordinates.php +++ b/srcs/plugins/map_prof/mp_get_coordinates.php @@ -33,29 +33,32 @@ function mp_get_coordinates($id) { // extract coordinates from json // https://developers.google.com/maps/documentation/geocoding/requests-geocoding#Types $content = json_decode($jsoncontent); - $location->coordinates = trim($content->results[0]->geometry->location, " "); - $location->address = trim($content->results[0]->formatted_address, " "); + $location->coordinates = $content->results[0]->geometry->location; + $location->address = $content->results[0]->formatted_address; foreach ($content->results[0]->address_components as $component) { if (in_array("street_number", $component->types)) - $location->street = trim($component->long_name, " "); + $location->street = $component->long_name; else if (in_array("route", $component->types)) { if (strlen($location->street) != 0) $location->street .= " "; - $location->street .= trim($component->long_name, " "); + $location->street .= $component->long_name; } else if (in_array("locality", $component->types)) - $location->city = trim($component->long_name, " "); + $location->city = $component->long_name; else if (in_array("postal_town", $component->types)) { if (strlen($location->city) != 0) $location->city .= "/"; - $location->city .= trim($component->long_name, " "); + $location->city .= $component->long_name; } else if (in_array("country", $component->types)) - $location->country = trim($component->long_name, " "); + $location->country = $component->long_name; } if ($content->results[0]->geometry->location_type == "APPROXIMATE") $location->approximate = true; + foreach ($location as $value) { + if (gettype($value) != "string") + continue; $value = trim($value, " "); mp_console_log($value); } diff --git a/srcs/plugins/map_prof/mp_get_events.php b/srcs/plugins/map_prof/mp_get_events.php index bf72adf..89101da 100644 --- a/srcs/plugins/map_prof/mp_get_events.php +++ b/srcs/plugins/map_prof/mp_get_events.php @@ -76,24 +76,6 @@ to_ping: "" */ -// FUNCTION TO RETRIEVE FORMS FIELDS -// not used anymore -// -//function mp_get_form_fields() { -// $get_form_args = array( -// 'numberposts' => -1, -// 'post_status' => 'publish', -// 'post_type' => 'acf-field', -// ); -// $forms = get_posts($get_form_args); -// $fields = []; -// foreach ($forms as $form) { -// $field = $form->post_excerpt; -// array_push($fields, $field); -// } -// return $fields; -//} - function mp_get_published_posts() { // FOR TESTS @@ -117,7 +99,6 @@ function mp_get_published_posts() { $get_posts_args = array( 'numberposts' => -1, 'post_status' => 'publish', - //'post_status' => 'draft', 'post_type' => 'post', ); $posts_published = get_posts($get_posts_args); @@ -162,6 +143,9 @@ function mp_fill_fields_value($id) { if ($presentiel[0] === "En présentiel") $event->irl = true; + // add post url + $event->url = get_post_permalink($id); + return $event; } @@ -193,6 +177,7 @@ function mp_get_published_events() { - id : x; - index : x (default null); - title : ""; + - url : ""; - location : {} - street : ""; - city : ""; diff --git a/srcs/plugins/map_prof/mp_sort_events.php b/srcs/plugins/map_prof/mp_get_locations.php similarity index 100% rename from srcs/plugins/map_prof/mp_sort_events.php rename to srcs/plugins/map_prof/mp_get_locations.php diff --git a/srcs/plugins/map_prof/scripts/mp_info_window.js b/srcs/plugins/map_prof/scripts/mp_info_window.js index 19351d3..804d126 100644 --- a/srcs/plugins/map_prof/scripts/mp_info_window.js +++ b/srcs/plugins/map_prof/scripts/mp_info_window.js @@ -14,12 +14,9 @@ function attach_info_window(map, marker, events, infowindow) { presence = "en presentiel"; window_content += ` -
- ${events[key].title} -
-- ${presence} -
+ +${events[key].title}
+ `; }; window_content += '';