\"Privious\"/ __YEAR_AND_DAY__ \"next\"/ "; private $bottom; function __construct() { $this->url = parent::$root.'/navigate/show_day.php'; $this->calendar = $calendar; $this->range = array(); } protected function parseDate() { if ($this->year && $this->day >= 0) { $day = $this->day; if ($day < 0 || $day > 365) { $day = date('z'); $year = date('Y'); } else $year = $this->year; } else { $day = date('z'); $year = date('Y'); } $now = mktime(0, 0, 0, 1, 1, $year); $this->year_and_day = "$year day ".(date('z', strtotime("+$day days", $now))+1); $this->privious = $day - 1; $this->p_year = $year; if ($this->privious < 0) { $this->p_year -= 1; $this->privious = date('z', mktime(0, 0, 0, 12, 31, $this->p_year)); } $this->next = $day + 1; $this->n_year = $year; if ($this->next > date('z', mktime(0, 0, 0, 12, 31, $this->year))) { $this->next = 0; $this->n_year += 1; } $this->year = $year; $this->day = $day; } protected function getHead() { $this->parseDate(); $head = str_replace('__URL__', $this->url, $this->top); $head = str_replace('__P_YEAR__', $this->p_year, $head); $head = str_replace('__PRIVIOUS__', $this->privious, $head); $head = str_replace('__WEB_ROOT__', parent::$root, $head); $head = str_replace('__YEAR_AND_DAY__', $this->year_and_day, $head); $head = str_replace('__N_YEAR__', $this->n_year, $head); $head = str_replace('__NEXT__', $this->next, $head); $this->bottom = $head; return $this->applyLegend() . $head; } private function getCell($events, $day, $progress, $excluded = FALSE) { $cell = ''; //$etags = array(); if ($events) { $now = mktime(0, 0, 0, 1, 1, $this->year); $ts = strtotime("+$day days +$progress hours", $now); $ical_start = CaldavRessource::timestamp2ICal($ts, TRUE); $ts = strtotime("+$day days +".($progress+1)." hours", $now); $ical_end = CaldavRessource::timestamp2ICal($ts, TRUE); $dateFormat = new dateFormat(); foreach ($events as $etag =>$infos) { foreach ($infos['dates'] as $time) { CaldavRessource::fix_allday_event($time['start'],$time['end']); $time['start'] = $dateFormat->UTC2Client($time['start']); $time['end'] = $dateFormat->UTC2Client($time['end']); if ($excluded) { $ts = strtotime( "+$day days +".parent::$start_hour." hours", $now); $parent_start = CaldavRessource::timestamp2ICal($ts, TRUE); $end = (parent::$end_hour == 24) ? 23 : parent::$end_hour; $ts = strtotime( "+$day days +".$end." hours", $now); $parent_end = CaldavRessource::timestamp2ICal($ts, TRUE); $time_start = (strrchr($time['start'], 'Z')) ? trim($time['start'], "Z") : $time['start']; $time_end = (strrchr($time['end'], 'Z')) ? trim($time['end'], "Z") : $time['end']; $parts = explode("T", $time_end); if (substr($parts[1], 0, 2) == "00") { $parts[1] = "24" . substr($parts[1], 2, 4); $time_end = $parts[0] . "T" . $parts[1]; } //print substr($time_end, 0, 2)."b[$parent_start : $parent_end] [$time_start : $time_end]" . CaldavRessource::cmptime( // $parent_end, $time_end) ."
"; /*if ((CaldavRessource::cmptime( $parent_start, $time_start) > 0 && CaldavRessource::cmpdate($parent_start, $time_start) == 0) || (CaldavRessource::cmptime( $parent_end, $time_end) < 0 && CaldavRessource::cmpdate($parent_end, $time_end) == 0)) {*/ if ((CaldavRessource::cmptime( $parent_start, $time_start) > 0 && CaldavRessource::cmpdate($parent_start, $time_end) == 0) || (CaldavRessource::cmptime( $parent_end, $time_end) < 0 && CaldavRessource::cmpdate($parent_end, $time_start) == 0)) { if (! in_array($etag, $this->etags)) { array_push($this->etags, $etag); $cell = $this->makeEvent($cell, $etag, $infos); //print "$cell
"; } } //print "a[$parent_start : $parent_end] [$time_start : $time_end] parent_start:time_start" . CaldavRessource::cmptime( // $parent_start, $time_start) ."
"; //print "a[$parent_start : $parent_end] [$time_start : $time_end] parent_end:time_end" . CaldavRessource::cmptime( // $parent_end, $time_end) ."
"; } else { //print "$ical_start:$ical_end:{$time['start']}:{$time['end']}
"; $s_cmp = CaldavRessource::datecmp($ical_start, $time['start']); $e_cmp = CaldavRessource::datecmp($ical_start, $time['end']); if ($s_cmp >= 0 && $e_cmp < 0) { // if (! in_array($etag, $this->etags)) { $cell = $this->makeEvent($cell, $etag, $infos); //print "$cell"; // } } } } } } return ($cell == '') ? ' ' : $cell; } public function getView($year = NULL, $day = NULL) { $this->year = $year; $this->day = $day; $calendar = $this->getHead(); $calendar .= '
'; $calendar .= str_replace('__DAY__', $this->dateFromDayInYear( $this->year, $this->day, $head), $this->getViewHead('day')); $now = mktime(0, 0, 0, 1, 1, $this->year); $this->range['start'] = strtotime("+".($this->day - 1)." days", $now); $this->range['end'] = strtotime("+".$this->day." days", $now); $events = $this->getEvents($this->range); $calendar .= "Excluded\n"; $cell = $this->getCell($events, $this->day, 0, TRUE); if ($this->day == date('z')) { $calendar .= "$cell\n"; } else $calendar .= "$cell\n"; $calendar .= ''; for ($i = parent::$start_hour; $i < parent::$end_hour; $i++) { $s_time = ($i < 10) ? "0$i" : $i; $e_time = ($i < 9) ? '0'.($i + 1) : ($i + 1); $calendar .= "$s_time - $e_time\n"; $cell = $this->getCell($events, $this->day, $i); if ($this->day == date('z')) { $calendar .= "$cell\n"; } else $calendar .= "$cell\n"; $calendar .= ''; } $calendar .= ''; $calendar .= '
'; $calendar .= $this->bottom; return $calendar; } }