diff --git a/srcs/plugins/map_prof/map_prof_hooks.php b/srcs/plugins/map_prof/map_prof_hooks.php index ae71118..12f70e3 100644 --- a/srcs/plugins/map_prof/map_prof_hooks.php +++ b/srcs/plugins/map_prof/map_prof_hooks.php @@ -57,12 +57,12 @@ function mp_ljdp_map() { mp_enqueue_scripts_and_styles(); $events = mp_get_published_events(); // mp_get_events.php - //mp_console_log("events :"); - //mp_console_log($events); + mp_console_log("events: " . $events); //foreach ($events as $event) // mp_console_log($event); $locations = mp_sort_events($events); // mp_get_locations.php + mp_console_log("locations: " . $locations); $filters = mp_get_filters($events); // mp_get_filters.php @@ -72,12 +72,27 @@ function mp_ljdp_map() { mp_add_to_scripts(array( "locations" => $locations, "filters" => $filters, + "events" => $events, )); return mp_create_div($filters); } add_shortcode('lejourduprof_map', 'mp_ljdp_map'); +/* + script in divi : + + +*/ + diff --git a/srcs/plugins/map_prof/scripts/mp_init_map.js b/srcs/plugins/map_prof/scripts/mp_init_map.js index 1e652ab..6eda725 100644 --- a/srcs/plugins/map_prof/scripts/mp_init_map.js +++ b/srcs/plugins/map_prof/scripts/mp_init_map.js @@ -11,42 +11,42 @@ const g_world_bound = { east: 180, }; +/* + * following variable are created by mp_add_to_script.php + * - let events + * - let locations = [ + * { + * coordinates: {} + * events : [{}, ...] + * }, + * ... + * ] + * + * { } + * { [ ] } + * - let filters: { - pays : [ { - _name : "" } ] } + * { [ { - villes : [] } ] } + * { [ { - categories: [] } ] } + * { [ { - indexes : [] } ] } + * { [ { - mode : [] }, ...] } + * { [ ] } + * { } + * { - villes : ... } + * { - categories: ... } + * { - mode : ... } + * { } + * + * - let coordinates_default = {lat: ,lng: } + * - let icon_color = "" + * - let icon_color_back = "" + * - let icon_size = [x, y] + * - let cluster_size_factor = Number + * - let map_zoom = x + * - let max_zoom = x + */ + function mp_init_map() { - /* - * following variable are created by mp_add_to_script.php - * - let locations = [ - * { - * coordinates: {} - * events : [{}, ...] - * }, - * ... - * ] - * - * { } - * { [ ] } - * - filters: { - pays : [ { - _name : "" } ] } - * { [ { - villes : [] } ] } - * { [ { - categories: [] } ] } - * { [ { - indexes : [] } ] } - * { [ { - mode : [] }, ...] } - * { [ ] } - * { } - * { - villes : ... } - * { - categories: ... } - * { - mode : ... } - * { } - * - * - let coordinates_default = {lat: ,lng: } - * - let icon_color = "" - * - let icon_color_back = "" - * - let icon_size = [x, y] - * - let cluster_size_factor = Number - * - let map_zoom = x - * - let max_zoom = x - */ - - let map_div = document.getElementById("ljdp_map"); //let filters_div = document.getElementById("ljdp_map_filters"); g_infowindow = new google.maps.InfoWindow(); diff --git a/srcs/plugins/map_prof/settings/mp_required.php b/srcs/plugins/map_prof/settings/mp_required.php index f7d159e..de1f3f8 100644 --- a/srcs/plugins/map_prof/settings/mp_required.php +++ b/srcs/plugins/map_prof/settings/mp_required.php @@ -5,10 +5,11 @@ */ /* cle api google maps pour "Maps Javascript API" */ -//$mp_api_key = 'AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE'; // fabien -$mp_api_key = 'AIzaSyDAZv8QNRQjnVY6kdzJRxWmZDaNIcgYp9E'; +$mp_api_key = 'AIzaSyA19YahRe_mcbtc-IiLCr0U6tMwzYiQjLA'; // hugo +//$mp_api_key = 'AIzaSyDAZv8QNRQjnVY6kdzJRxWmZDaNIcgYp9E'; /* cle api google maps pour "Geocoding API" */ -$mp_api_key_geo = 'AIzaSyBskxuBhowQdLjJmIj2gc66KoP1GLO3SEg'; +$mp_api_key_geo = 'AIzaSyA19YahRe_mcbtc-IiLCr0U6tMwzYiQjLA'; // hugo +//$mp_api_key_geo = 'AIzaSyBskxuBhowQdLjJmIj2gc66KoP1GLO3SEg'; ?> diff --git a/srcs/plugins/map_prof/srcs/map/mp_get_filters.php b/srcs/plugins/map_prof/srcs/map/mp_get_filters.php index 94a5993..a2282f0 100644 --- a/srcs/plugins/map_prof/srcs/map/mp_get_filters.php +++ b/srcs/plugins/map_prof/srcs/map/mp_get_filters.php @@ -35,7 +35,7 @@ function mp_already_in_menu(&$menu, $name) { * menu : [ { _name:"", field_1:[], field_2:[] }, ... ] * index : index of this event in locations[] array */ -function mp_fill_name($fields, $name, &$menu, $index) { +function mp_fill_name($fields, $name, &$menu, $index, &$event) { if ($fields[$name] == null) return; if (gettype($fields[$name]) != 'string') @@ -53,8 +53,12 @@ function mp_fill_name($fields, $name, &$menu, $index) { continue; if (! isset($menu_item->$key_field) ) $menu_item->$key_field = []; - if (!is_string($value)) + if (!is_string($value)) { + //mp_console_log("pour l'article '$event->title', le champ '$key_field' est supposé être de type 'string', mais il est de type '" . gettype($value) . "'"); + //if ( ! add_post_meta( $id, 'problem', "$value", true ) ) + // update_post_meta( $id, 'problem', "" ); continue; + } if (strlen($value) != 0) { if (! in_array($value, $menu_item->$key_field) ) array_push($menu_item->$key_field, $value); @@ -73,8 +77,10 @@ function mp_fill_name($fields, $name, &$menu, $index) { if ($key_field == $name) continue; $menu_item->$key_field = []; - if (!is_string($value)) + if (!is_string($value)) { + //mp_console_log("pour l'article '$event->title', le champ '$key_field' est supposé être de type 'string', mais il est de type '" . gettype($value) . "'"); continue; + } if (strlen($value) != 0) array_push($menu_item->$key_field, $value); } @@ -102,12 +108,14 @@ function mp_get_filters(&$events) { "Catégories" => $event->categorie, "mode" => ($event->irl)? "En présentiel" : "En ligne", ); + //mp_console_log("event: "); + //mp_console_log($event); // fill all menu with other menus without doubles foreach ($fields as $name => $value) { if (! isset($filters->$name)) $filters->$name = []; - mp_fill_name($fields, $name, $filters->$name, $index); + mp_fill_name($fields, $name, $filters->$name, $index, $event); } } @@ -132,29 +140,30 @@ filters: { - countries : [ { - _name : "" } ] } */ /* - event : {} + event : {} - heure_de_debut : ""; - heure_de_fin : ""; - - categorie : ""; - - date : ""; - - pays : ""; - - ville : ""; - - adresse : ""; - - prenom : ""; - - nom : ""; - - irl : bool; - - id : x; - - index : x; - - title : ""; - - location : {} - - street : ""; - - city : ""; - - country : ""; - - address : ""; - - approximate : bool; - - coordinates : {} - - lat : x; - - lng : x; + - categorie : ""; + - date : ""; + - pays : ""; + - ville : ""; + - adresse : ""; + - prenom : ""; + - nom : ""; + - irl : bool; + - id : x; + - index : x; + - url : ""; + - title : ""; + - location : {} + - street : ""; + - city : ""; + - country : ""; + - address : ""; + - approximate : bool; + - coordinates : {} + - lat : x; + - lng : x; */ ?> diff --git a/srcs/plugins/map_prof/srcs/menu/mp_menu_content.php b/srcs/plugins/map_prof/srcs/menu/mp_menu_content.php index 5bb8c81..a6e1608 100644 --- a/srcs/plugins/map_prof/srcs/menu/mp_menu_content.php +++ b/srcs/plugins/map_prof/srcs/menu/mp_menu_content.php @@ -55,6 +55,23 @@ function mp_have_no_coordinates($posts_list) { +function mp_bad_categories($posts_list) { + + $posts_bad_categories = []; + foreach ($posts_list as $post) { + $value = get_field("categorie", $post->ID); + if (! is_string($value)) { + array_push($posts_bad_categories, $post); + //mp_console_log("categorie:"); + //mp_console_log($value); + } + } + return $posts_bad_categories; +} + + + + function mp_show_list_posts_no_address($posts) { echo << +
+ ATTENTION ! +
++ + HTML; + echo count($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 << +