diff --git a/model/Upcoming.php b/model/Upcoming.php index d7375744..0fa6e3f3 100644 --- a/model/Upcoming.php +++ b/model/Upcoming.php @@ -15,4 +15,21 @@ public function getNextEvents() return array(); } } + + /* + Try to find the next upcoming event, which does not match current event. + */ + public function getNextEvent($currentEvent = "") + { + $nextEvents = getNextEvents(); + foreach($nextEvents as $event) { + similar_text($event["name"], $currentEvent, $percentMatch); + + if($percentMatch < 50) { + return $event; + } + } + + return @$nextEvents[0]; + } } diff --git a/view/closed.php b/view/closed.php index 3346aadd..31b0a84a 100644 --- a/view/closed.php +++ b/view/closed.php @@ -7,6 +7,6 @@ 'page' => 'closed', 'title' => 'See you soon … somewhere else!', - 'next' => @$events[0], + 'next' => $upcoming->getNextEvent($conference->getTitle()), 'events' => $events, ));