day = $day; $this->month = $month; $this->year = $year; $this->h = $h; $this->area = $area; $this->room = $room; $this->dmy = $dmy; } function getCalendarLink($month, $year) { return ""; } #Liens vers une une date donnée. function getDateLink($day, $month, $year) { global $vocab; if ($this->dmy=='day') return "area; if ($this->dmy!='day') return "area; } #Calcule le nombre de jours dans un mois en tenant compte des années bissextiles. function getDaysInMonth($month, $year) { if ($month < 1 || $month > 12) return 0; $days = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); $d = $days[$month - 1]; if ($month == 2) { #Vérification de l'année bissextile. if ($year%4 == 0) { if ($year%100 == 0) { if ($year%400 == 0) $d = 29; } else $d = 29; } } return $d; } function getFirstDays() { global $weekstarts; $basetime = mktime(12,0,0,6,11+$weekstarts,2000); for ($i = 0, $s = ""; $i < 7; $i++) { $show = $basetime + ($i * 24 * 60 * 60); $fl = strftime('%a',$show); $s .= "$fl\n"; } return $s; } function getHTML() { global $weekstarts; global $vocab; // Calcul de la date courante $date_today = mktime(12, 0, 0, $this->month, $this->day, $this->year); // Calcul du numéro de semaine courante $week_today = strftime("%W",$date_today); if (!isset($weekstarts)) $weekstarts = 0; $s = ""; $daysInMonth = $this->getDaysInMonth($this->month, $this->year); // Calcul de la date au 1er du mois de la date courante $date = mktime(12, 0, 0, $this->month, 1, $this->year); $first = (strftime("%w",$date) + 7 - $weekstarts) % 7; $monthName = strftime("%B",$date); $prevMonth = $this->getCalendarLink($this->month - 1 > 0 ? $this->month - 1 : 12, $this->month - 1 > 0 ? $this->year : $this->year - 1); $nextMonth = $this->getCalendarLink($this->month + 1 <= 12 ? $this->month + 1 : 1, $this->month + 1 <= 12 ? $this->year : $this->year + 1); $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= $this->getFirstDays(); $s .= "\n"; $d = 1 - $first; $temp = 1; $numweek=1; while ($d <= $daysInMonth) { if (($week_today == $week) and ($this->h) and (($this->dmy=='week_all') or ($this->dmy=='week') )) $bg_lign = "span class=\"week\""; else $bg_lign = ''; $s .= "\n"; for ($i = 0; $i < 7; $i++) { $s .= "\n"; $d++; } $s .= "\n"; } $s .= "
"; #Permet de récupérer le numéro de la 1ere semaine affichée par le mini calendier. $week = number_format(strftime("%W",$date),0); if (($this->dmy!='day') and ($this->dmy!='week_all') and ($this->dmy!='month_all')) $s .= "year&month=$this->month&day=1&area=$this->area&room=$this->room\">$monthName $this->year"; else $s .= "year&month=$this->month&day=1&area=$this->area\">$monthName $this->year"; $s .= "
"; #Affichage du numéro de la semaine en cours à droite du calendrier et génère un lien sur la semaine voulue. if (($this->dmy!='day') and ($this->dmy!='week_all') and ($this->dmy!='month_all')) $s .="year&month=$this->month&day=$temp&area=$this->area&room=$this->room\">s".$week.""; else $s .="year&month=$this->month&day=$temp&area=$this->area\">s".$week.""; $temp=$temp+7; while (!checkdate($this->month, $temp, $this->year)) $temp--; #Ancien affichage, affichait le numéro de la semaine dans le mois. $numweek++; #Nouveau affichage, affiche le numéro de la semaine dans l'année.Incrémentation de ce numéro à chaque nouvelle semaine. $week++; $s .= ""; if ($d > 0 && $d <= $daysInMonth) { $link = $this->getDateLink($d, $this->month, $this->year); if ($link == "") $s .= $d; #Permet de colorer la date affichée sur la page elseif (($d == $this->day) and ($this->h)) $s .= $link.">$d"; else $s .= $link.">$d"; } else $s .= " "; $s .= "
\n"; return $s; } } $lastmonth = mktime(0, 0, 0, $month-1, 1, $year); $thismonth = mktime(0, 0, 0, $month, $day, $year); $nextmonth = mktime(0, 0, 0, $month+1, 1, $year); echo "";$cal = new Calendar(date("d",$lastmonth), date("m",$lastmonth), date("Y",$lastmonth), 0, $area, $room, $dmy); echo $cal->getHTML(); echo ""; echo "";$cal = new Calendar(date("d",$thismonth), date("m",$thismonth), date("Y",$thismonth), 1, $area, $room, $dmy); echo $cal->getHTML(); echo ""; echo "";$cal = new Calendar(date("d",$nextmonth), date("m",$nextmonth), date("Y",$nextmonth), 0, $area, $room, $dmy); echo $cal->getHTML(); echo ""; }?>