added irl to filters, and fixed broken sort
This commit is contained in:
@@ -67,9 +67,16 @@ function mp_ljdp_map() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$events = mp_get_published_events();
|
$events = mp_get_published_events();
|
||||||
|
//mp_console_log("php events:");
|
||||||
|
//mp_console_log($events);
|
||||||
|
|
||||||
$locations = mp_sort_events($events);
|
$locations = mp_sort_events($events);
|
||||||
|
//mp_console_log("php locations:");
|
||||||
|
//mp_console_log($locations);
|
||||||
|
|
||||||
$filters = mp_get_filters($events);
|
$filters = mp_get_filters($events);
|
||||||
|
mp_console_log("php filters:");
|
||||||
|
mp_console_log($filters);
|
||||||
|
|
||||||
$to_add = array(
|
$to_add = array(
|
||||||
"locations" => $locations,
|
"locations" => $locations,
|
||||||
|
|||||||
@@ -174,8 +174,6 @@ function mp_get_published_events() {
|
|||||||
$event->title = trim($post->post_title, " ");
|
$event->title = trim($post->post_title, " ");
|
||||||
array_push($events, $event);
|
array_push($events, $event);
|
||||||
}
|
}
|
||||||
mp_console_log("events:");
|
|
||||||
mp_console_log($events);
|
|
||||||
return $events;
|
return $events;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ function mp_fill_name($fields, $name, &$menu) {
|
|||||||
foreach ($fields as $key_field => $value) {
|
foreach ($fields as $key_field => $value) {
|
||||||
if ($key_field == $name)
|
if ($key_field == $name)
|
||||||
continue;
|
continue;
|
||||||
|
if (! isset($menu_field->$key_field) )
|
||||||
|
$menu_field->$key_field = [];
|
||||||
if (strlen($value) != 0) {
|
if (strlen($value) != 0) {
|
||||||
if (! in_array($value, $menu_field->$key_field) )
|
if (! in_array($value, $menu_field->$key_field) )
|
||||||
array_push($menu_field->$key_field, $value);
|
array_push($menu_field->$key_field, $value);
|
||||||
@@ -51,30 +53,30 @@ function mp_fill_name($fields, $name, &$menu) {
|
|||||||
|
|
||||||
function mp_get_filters($events) {
|
function mp_get_filters($events) {
|
||||||
$filters = (object)[];
|
$filters = (object)[];
|
||||||
$filters->countries = [];
|
|
||||||
$filters->cities = [];
|
|
||||||
$filters->categories = [];
|
|
||||||
|
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
$fields = array(
|
$fields = array(
|
||||||
"countries" => $event->location->country,
|
"countries" => $event->location->country,
|
||||||
"cities" => $event->location->city,
|
"cities" => $event->location->city,
|
||||||
"categories" => $event->categorie,
|
"categories" => $event->categorie,
|
||||||
|
"mode" => ($event->irl)? "En présentiel" : "En ligne",
|
||||||
);
|
);
|
||||||
foreach ($fields as $key => $value) {
|
foreach ($fields as $key => $value) {
|
||||||
|
if (! isset($filters->$key))
|
||||||
|
$filters->$key = [];
|
||||||
mp_fill_name($fields, $key, $filters->$key);
|
mp_fill_name($fields, $key, $filters->$key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($filters as $filter) {
|
foreach ($filters as $key => $value) {
|
||||||
usort($filters->$filter, mp_filter_compare);
|
usort($filters->$key, mp_filter_compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_console_log("filters:");
|
return $filters;
|
||||||
mp_console_log($filters);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
{ }
|
||||||
{ [ ] }
|
{ [ ] }
|
||||||
{ [ { - _name : "" } ] }
|
{ [ { - _name : "" } ] }
|
||||||
{ - countries : [ { - cities : [] }, ... ] }
|
{ - countries : [ { - cities : [] }, ... ] }
|
||||||
@@ -92,23 +94,7 @@ filters: { - cities : [ { - countries : [] }, ... ] }
|
|||||||
{ - categories: [ { - countries : [] }, ... ] }
|
{ - categories: [ { - countries : [] }, ... ] }
|
||||||
{ [ { - cities : [] } ] }
|
{ [ { - cities : [] } ] }
|
||||||
{ [ ] }
|
{ [ ] }
|
||||||
*/
|
{ }
|
||||||
|
|
||||||
/*
|
|
||||||
$country = (object)[];
|
|
||||||
$country->_name = "";
|
|
||||||
$country->cities = [];
|
|
||||||
$country->categories = [];
|
|
||||||
|
|
||||||
$city = (object)[];
|
|
||||||
$city->_name = "";
|
|
||||||
$city->countries = [];
|
|
||||||
$city->categories = [];
|
|
||||||
|
|
||||||
$category = (object)[];
|
|
||||||
$category->_name = "";
|
|
||||||
$category->countries = [];
|
|
||||||
$category->cities = [];
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -16,8 +16,10 @@ function mp_init_map() {
|
|||||||
* - let cluster_size_factor = Number
|
* - let cluster_size_factor = Number
|
||||||
*/
|
*/
|
||||||
|
|
||||||
console.log("locations:");
|
//console.log("locations:");
|
||||||
console.log(locations);
|
//console.log(locations);
|
||||||
|
//console.log("filters:");
|
||||||
|
//console.log(filters);
|
||||||
|
|
||||||
// default map center to france
|
// default map center to france
|
||||||
let map_center = coordinates_default;
|
let map_center = coordinates_default;
|
||||||
@@ -54,11 +56,11 @@ function mp_init_map() {
|
|||||||
|
|
||||||
let map = new google.maps.Map(map_div, map_options);
|
let map = new google.maps.Map(map_div, map_options);
|
||||||
let markers = create_markers(map, locations, infowindow);
|
let markers = create_markers(map, locations, infowindow);
|
||||||
|
draw_clusters(map, markers);
|
||||||
|
|
||||||
// add listener to close infowindow at any click on map
|
// add listener to close infowindow at any click on map
|
||||||
map.addListener('click', function() {
|
map.addListener('click', function() {
|
||||||
infowindow.close();
|
infowindow.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
draw_clusters(map, markers);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user