added location indexes to filters
This commit is contained in:
@@ -81,14 +81,9 @@ function mp_ljdp_map() {
|
|||||||
//mp_console_log("php locations:");
|
//mp_console_log("php locations:");
|
||||||
//mp_console_log($locations);
|
//mp_console_log($locations);
|
||||||
|
|
||||||
mp_console_log("php events:");
|
|
||||||
mp_console_log($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("php filters:");
|
||||||
//mp_console_log($filters);
|
mp_console_log($filters);
|
||||||
|
|
||||||
$to_add = array(
|
$to_add = array(
|
||||||
"locations" => $locations,
|
"locations" => $locations,
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ function mp_get_published_events() {
|
|||||||
- nom : "";
|
- nom : "";
|
||||||
- irl : bool;
|
- irl : bool;
|
||||||
- id : x;
|
- id : x;
|
||||||
|
(- index : x;) // not there for now
|
||||||
- title : "";
|
- title : "";
|
||||||
- location : {}
|
- location : {}
|
||||||
- street : "";
|
- street : "";
|
||||||
|
|||||||
@@ -17,37 +17,48 @@ function mp_already_in_menu(&$menu, $name) {
|
|||||||
fields: [ countries:"", cities:"", categories:"", ... ]
|
fields: [ countries:"", cities:"", categories:"", ... ]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function mp_fill_name($fields, $name, &$menu) {
|
function mp_fill_name($fields, $name, &$menu, $index) {
|
||||||
if ($fields[$name] == null)
|
if ($fields[$name] == null)
|
||||||
return;
|
return;
|
||||||
if (gettype($fields[$name]) != 'string')
|
if (gettype($fields[$name]) != 'string')
|
||||||
return;
|
return;
|
||||||
if (strlen($fields[$name]) == 0)
|
if (strlen($fields[$name]) == 0)
|
||||||
return;
|
return;
|
||||||
$menu_field = mp_already_in_menu($menu, $fields[$name]);
|
$menu_item = mp_already_in_menu($menu, $fields[$name]);
|
||||||
if ($menu_field != null) {
|
if ($menu_item != null) {
|
||||||
|
// no need to add name if already exist
|
||||||
|
// add to lists of event info (cities, countries, ...)
|
||||||
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) )
|
if (! isset($menu_item->$key_field) )
|
||||||
$menu_field->$key_field = [];
|
$menu_item->$key_field = [];
|
||||||
if (strlen($value) != 0) {
|
if (strlen($value) != 0) {
|
||||||
if (! in_array($value, $menu_field->$key_field) )
|
if (! in_array($value, $menu_item->$key_field) )
|
||||||
array_push($menu_field->$key_field, $value);
|
array_push($menu_item->$key_field, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// add to list of location index
|
||||||
|
if (! in_array($index, $menu_item->indexes) )
|
||||||
|
array_push($menu_item->indexes, $index);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$filter = (object)[];
|
$menu_item = (object)[];
|
||||||
$filter->_name = $fields[$name];
|
$menu_item->_name = $fields[$name];
|
||||||
|
// add lists of event info (cities, countries, ...)
|
||||||
foreach ($fields as $key_field => $value) {
|
foreach ($fields as $key_field => $value) {
|
||||||
if ($key_field == $name)
|
if ($key_field == $name)
|
||||||
continue;
|
continue;
|
||||||
$filter->$key_field = [];
|
$menu_item->$key_field = [];
|
||||||
if (strlen($value) != 0)
|
if (strlen($value) != 0)
|
||||||
array_push($filter->$key_field, $value);
|
array_push($menu_item->$key_field, $value);
|
||||||
}
|
}
|
||||||
array_push($menu, $filter);
|
// add list of location index
|
||||||
|
$menu_item->indexes = [];
|
||||||
|
array_push($menu_item->indexes, $index);
|
||||||
|
|
||||||
|
// and add this item to list of menu
|
||||||
|
array_push($menu, $menu_item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,10 +72,11 @@ function mp_get_filters(&$events) {
|
|||||||
"categories" => $event->categorie,
|
"categories" => $event->categorie,
|
||||||
"mode" => ($event->irl)? "En présentiel" : "En ligne",
|
"mode" => ($event->irl)? "En présentiel" : "En ligne",
|
||||||
);
|
);
|
||||||
|
$index = $event->index;
|
||||||
foreach ($fields as $key => $value) {
|
foreach ($fields as $key => $value) {
|
||||||
if (! isset($filters->$key))
|
if (! isset($filters->$key))
|
||||||
$filters->$key = [];
|
$filters->$key = [];
|
||||||
mp_fill_name($fields, $key, $filters->$key);
|
mp_fill_name($fields, $key, $filters->$key, $index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,23 +90,15 @@ function mp_get_filters(&$events) {
|
|||||||
/*
|
/*
|
||||||
{ }
|
{ }
|
||||||
{ [ ] }
|
{ [ ] }
|
||||||
{ [ { - _name : "" } ] }
|
filters: { - countries : [ { - _name : "" } ] }
|
||||||
{ - countries : [ { - cities : [] }, ... ] }
|
|
||||||
{ [ { - categories: [] } ] }
|
|
||||||
{ [ ] }
|
|
||||||
{ }
|
|
||||||
{ [ ] }
|
|
||||||
{ [ { - _name : "" } ] }
|
|
||||||
filters: { - cities : [ { - countries : [] }, ... ] }
|
|
||||||
{ [ { - categories: [] } ] }
|
|
||||||
{ [ ] }
|
|
||||||
{ }
|
|
||||||
{ [ ] }
|
|
||||||
{ [ { - _name : "" } ] }
|
|
||||||
{ - categories: [ { - countries : [] }, ... ] }
|
|
||||||
{ [ { - cities : [] } ] }
|
{ [ { - cities : [] } ] }
|
||||||
|
{ [ { - categories: [] } ] }
|
||||||
|
{ [ { - indexes : [] }, ... ] }
|
||||||
{ [ ] }
|
{ [ ] }
|
||||||
{ }
|
{ }
|
||||||
|
{ - cities : }
|
||||||
|
{ - categories: }
|
||||||
|
{ }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -110,6 +114,7 @@ filters: { - cities : [ { - countries : [] }, ... ] }
|
|||||||
- nom : "";
|
- nom : "";
|
||||||
- irl : bool;
|
- irl : bool;
|
||||||
- id : x;
|
- id : x;
|
||||||
|
- index : x;
|
||||||
- title : "";
|
- title : "";
|
||||||
- location : {}
|
- location : {}
|
||||||
- street : "";
|
- street : "";
|
||||||
|
|||||||
Reference in New Issue
Block a user