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