year = $year; } else { $this->year = gmstrftime("%Y", gmmktime()); } if ( $year != '' ) { $this->month = $month; } else { $this->month = gmstrftime("%m", gmmktime()); } } function __destruct() { } function _get_last_dom($year,$month) { return gmstrftime("%d",gmmktime(0,0,0,$month+1,0,$year)); } function _get_first_dow($year,$month) { $fdow = gmstrftime('%w',gmmktime (0,0,0,$month,1,$year)); if ( $fdow == 0 ) { $fdow = 7; } return $fdow; } function _get_month_name($month) { return gmstrftime("%B",gmmktime(0,0,0,$month,1,$this->year)); } function _render_month($year,$month) { $mon = $this->_get_month_name($month); $days = $this->_get_last_dom($year,$month); $fdow = $this->_get_first_dow($year,$month); $result = ''."\n"; $result .= ' '."\n"; $result .= ' '."\n"; $day = 1; while ( $day <= $days ) { $result .= " "; for ( $i=1; $i<8; $i++) { if ( ( ( $day == 1 ) && ( $fdow == $i ) ) || ( ( $day > 1 ) && ( $day <= $days ) ) ) { if ( $this->get_appt($year,$month,$day) != '' ) { $result .= ''; } else { $result .= ''; } $day++; } else { $result .= ''; } } $result .= "\n"; } $result .= "
'.$mon.' '.$year.'
MTWTFSS
'.$day.''.$day.' 
\n"; return($result); } function _render_year($year) { $month = 1; $result = "\n"; for ( $c=1; $c<5; $c++ ) { $result .= "\n"; for ( $r=1; $r<4; $r++ ) { $result .= "\n"; } $result .= "\n"; } $result .= "
\n"; $result .= $this->_render_month($year,$month); $month++; $result .= "
\n"; return($result); } function get_appt($year,$month,$day) { return( $this->appt[ gmmktime(0,0,0,$month,$day,$year) ] ); } function set_appt($year,$month,$day,$url) { $this->appt[ gmmktime(0,0,0,$month,$day,$year) ] = $url; return(true); } function render($year='',$month='') { if ( $year != '' && $year >= 0 && $year <= 9999 && $month == '' ) { return($this->_render_year($year)); } elseif ( $year != '' && $year >= 0 && $year <= 9999 && $month != '' && $month >= 1 && $month <= 12 ) { return($this->_render_month($year,$month)); } else { return($this->_render_year($this->year)); } } } ?>