program - order sessions by month
This commit is contained in:
parent
3694b55357
commit
28c6f3d5c7
6 changed files with 111 additions and 14 deletions
|
|
@ -1,5 +1,30 @@
|
|||
<?php
|
||||
|
||||
function sortByMonth($sessions) {
|
||||
$months = array(
|
||||
'janvier', 'février', 'mars', 'avril', 'mai', 'juin',
|
||||
'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'
|
||||
);
|
||||
|
||||
$orderedSessions = array();
|
||||
|
||||
foreach ($months as $month) {
|
||||
$orderedSessions[$month] = array();
|
||||
}
|
||||
|
||||
foreach ($sessions as $item) {
|
||||
$month = date('F', strtotime($item['date']));
|
||||
$month = str_replace(
|
||||
array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'),
|
||||
$months,
|
||||
$month
|
||||
);
|
||||
$orderedSessions[$month][] = $item;
|
||||
}
|
||||
|
||||
return $orderedSessions;
|
||||
}
|
||||
|
||||
return function($page) {
|
||||
$currentSeason = $page->children()->first();
|
||||
$today = date('Ymd');
|
||||
|
|
@ -7,12 +32,16 @@ return function($page) {
|
|||
$previousEvents = new Pages();
|
||||
$nextEvents = new Pages();
|
||||
|
||||
$currentSeasonSessions = [];
|
||||
|
||||
foreach ($currentSeason->children() as $event) {
|
||||
$sessions = $event->isMapadoEvent() == 'true' ? $event->remoteSessions() : $event->sessions();
|
||||
|
||||
$isStillShowing = false;
|
||||
|
||||
foreach ($sessions->toStructure() as $session) {
|
||||
$currentSeasonSessions[] = $session->toArray();
|
||||
|
||||
$sessionDate = str_replace('-', '', $session->date()->toDate('YMMdd'));
|
||||
|
||||
if ($sessionDate >= $today) {
|
||||
|
|
@ -25,11 +54,12 @@ return function($page) {
|
|||
$nextEvents->add($event);
|
||||
} else {
|
||||
$previousEvents->add($event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'previousEvents' => $previousEvents,
|
||||
'nextEvents' => $nextEvents
|
||||
'nextEvents' => $nextEvents,
|
||||
'currentSeasonSessions' => sortByMonth($currentSeasonSessions)
|
||||
];
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue