setDate($day, $month, $year ); $CCalender->printCalender(); class CCalender { var $m_date; function CCalender() { set_time_limit( 1 ); $this->m_date = getdate(); } function setDate( $day, $month, $year ) { if (isset($_GET['month'])){ $day = $_GET['day']; $month = $_GET['month']; $year = $_GET['year']; } if( $day != "" && $month != "" && $year != "" ) { $this->m_date["mday"] = $day; $this->m_date["mon"] = $month; $this->m_date["year"] = $year; return true; } else return false; } function getDateByMonth( $new_month ) { $newdate = mktime (0,0,0, ($this->m_date["mon"] + $new_month), $this->m_date["mday"], $this->m_date["year"] ); return $newdate; } function printCalender() { if( $this->m_date == "" ) return false; else $date = $this->m_date; $monthnames = array(); $monthnames[1] = "Januari"; $monthnames[2] = "Februari"; $monthnames[3] = "Maart"; $monthnames[4] = "April"; $monthnames[5] = "Mei"; $monthnames[6] = "Juni"; $monthnames[7] = "Juli"; $monthnames[8] = "Augustus"; $monthnames[9] = "September"; $monthnames[10] = "Oktober"; $monthnames[11] = "November"; $monthnames[12] = "December"; $week_begin = 2; echo( "" ); $newdate = $this->getDateByMonth( -1 ); echo ""; echo ""; $daysmax = date( "t", mktime( 0, 0, 0, $date["mon"], 1, $date["year"] ) ); for( $iCurrDay = 1; $iCurrDay <= $daysmax; $iCurrDay++ ) { $daynum = date("w", mktime(0, 0, 0, $date["mon"], $iCurrDay, $date["year"])) + 1; if ($iCurrDay == 1) { echo("\n"); echo( ""); for( $iDay = $week_begin; $daynum != $iDay; $iDay++ ) { echo( ""); if( $daynum == 1 && $iDay == 7 ) { echo( $this->getCell( $iCurrDay ) ); break; } if( $iDay > 15 ) break; } if ($daynum == $iDay) echo( $this->getCell( $iCurrDay ) ); } else if ($daynum == $week_begin) { echo ""; echo( $this->getCell( $iCurrDay ) ); } else echo( $this->getCell( $iCurrDay ) ); } $iCurrDay = $iCurrDay - 6; $daynum = date("w", mktime(0, 0, 0, $date["mon"], $iCurrDay, $date["year"])); while( $daynum != $week_begin ) { echo( "\n" ); $iCurrDay++; $daynum = date("w", mktime(0, 0, 0, $date["mon"], $iCurrDay, $date["year"])); } echo( "
<"; echo $monthnames[ $date["mon"] ] . " " . $date["year"]; $newdate = $this->getDateByMonth( +1 ); echo ">
MaDiWo DoVrZa Zo
 
 
"); return true; } function getCell($day) { $dag = date("Y-m-d", mktime(0, 0, 0, date("m", $this->getDateByMonth( 0 ) ), $day, date("Y", $this->getDateByMonth( 0 ) ) ) ); $weekday = date("w", mktime(0, 0, 0, date("m", $this->getDateByMonth( 0 ) ), $day, date("Y", $this->getDateByMonth( 0 ) ) ) ); if( date("Y-m-d") == $dag ){ $style = "vandaag"; } else if( $weekday == 6 || $weekday == 0 ){ $style = "weekend"; } else { $style = "normaal"; } if ($dag == "2009-09-01"){ $style = "apart"; $day = "$dayBegin van het schooljaar"; } $val = " " . $day.""; return $val; } } ?>