/** * Display all informations about the holidays */ public function index_action() { $this->holidays = array_reverse(SemesterHoliday::getAll()); // Filter data? if ($this->filter === 'current') { $this->holidays = array_filter($this->holidays, function ($holiday) { return $holiday->ende > time(); }); } elseif ($this->filter === 'past') { $this->holidays = array_filter($this->holidays, function ($holiday) { return $holiday->ende <= time(); }); } }
function getAllHolidays() { return SemesterHoliday::getAll(); }
/** * Returns if a given date is a holiday. * * @param int $time Timestamp to check * @param bool $check_vacation_only Defines whether to check only vacation * times or against all holidays * @return mixed false if no holiday was found, an array with the name and * the "col" value of the holiday otherwise */ public static function isHoliday($time, $check_vacation_only = true) { // Check all defined vaciation times foreach (SemesterHoliday::getAll() as $val) { if ($val->beginn <= $time && $val->ende >= $time) { return array('name' => $val->name, 'col' => 3); } } // Check all other holidays if (!$check_vacation_only) { return holiday($time); $holiday_entry = holiday($time); } // Nothing found return false; }