diff options
author | MaZderMind | 2016-08-02 22:23:00 +0200 |
---|---|---|
committer | MaZderMind | 2016-08-02 22:23:00 +0200 |
commit | 37f786bf233b901eebf5c0f11fafc19addf752ed (patch) | |
tree | a39b42549fc410e630e6b24da8697bd644d3da36 | |
parent | 632c77889a0c3d7e3c5cf5d4d974f2b866c857e7 (diff) |
sort rooms according to roomfilter
-rw-r--r-- | model/Schedule.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/model/Schedule.php b/model/Schedule.php index 96ac28e..cc1db55 100644 --- a/model/Schedule.php +++ b/model/Schedule.php @@ -208,6 +208,31 @@ class Schedule extends ModelBase } } + + if($this->has('SCHEDULE.ROOMFILTER')) + { + // sort by roomfilter + $roomfilter = $this->get('SCHEDULE.ROOMFILTER'); + + // map roomfilter-rooms to room-slugs + $roomfilter = array_map(function($e) use ($mapping) { + if(isset($mapping[$e])) + return $mapping[$e]; + + return $e; + }, $roomfilter); + + // sort according to roomtilter ordering + uksort($program, function($a, $b) use ($roomfilter) { + return array_search($a, $roomfilter) - array_search($b, $roomfilter); + }); + } + else + { + // sort by key + ksort($program); + } + return $program; } |