entries[] = $entry; } function getEntry() { $entry = each($this->entries); if ($entry) { return $entry['value']; } else { reset($this->entries); return false; } } } class MonthPayload_Decorator extends Calendar_Decorator { //Calendar engine var $cE; var $tableHelper; var $year; var $month; var $firstDay = false; function build($events=array()) { require_once CALENDAR_ROOT . 'Day.php'; require_once CALENDAR_ROOT . 'Table/Helper.php'; $this->tableHelper = & new Calendar_Table_Helper($this, $this->firstDay); $this->cE = & $this->getEngine(); $this->year = $this->thisYear(); $this->month = $this->thisMonth(); $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month); for ($i=1; $i<=$daysInMonth; $i++) { $Day = new Calendar_Day(2000,1,1); // Create Day with dummy values $Day->setTimeStamp($this->cE->dateToStamp($this->year, $this->month, $i)); $this->children[$i] = new DiaryEvent($Day); } if (count($events) > 0) { $this->setSelection($events); } Calendar_Month_Weekdays::buildEmptyDaysBefore(); Calendar_Month_Weekdays::shiftDays(); Calendar_Month_Weekdays::buildEmptyDaysAfter(); Calendar_Month_Weekdays::setWeekMarkers(); return true; } function setSelection($events) { $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month); for ($i=1; $i<=$daysInMonth; $i++) { $stamp1 = $this->cE->dateToStamp($this->year, $this->month, $i); $stamp2 = $this->cE->dateToStamp($this->year, $this->month, $i+1); foreach ($events as $event) { if (($stamp1 >= $event['start'] && $stamp1 < $event['end']) || ($stamp2 >= $event['start'] && $stamp2 < $event['end']) || ($stamp1 <= $event['start'] && $stamp2 > $event['end']) ) { $this->children[$i]->addEntry($event); $this->children[$i]->setSelected(); } } } } function fetch() { $child = each($this->children); if ($child) { return $child['value']; } else { reset($this->children); return false; } } } // Calendar instance used to get the dates in the preferred format: // you can switch Calendar Engine and the example still works $cal = new Calendar; $events = array(); //add some events $events[] = array( 'start' => $cal->cE->dateToStamp(2004, 6, 1, 10), 'end' => $cal->cE->dateToStamp(2004, 6, 1, 12), 'desc' => 'Important meeting' ); $events[] = array( 'start' => $cal->cE->dateToStamp(2004, 6, 1, 21), 'end' => $cal->cE->dateToStamp(2004, 6, 1, 23, 59), 'desc' => 'Dinner with the boss' ); $events[] = array( 'start' => $cal->cE->dateToStamp(2004, 6, 5), 'end' => $cal->cE->dateToStamp(2004, 6, 10, 23, 59), 'desc' => 'Holidays!' ); $Month = & new Calendar_Month_Weekdays(2004, 6); $MonthDecorator = new MonthPayload_Decorator($Month); $MonthDecorator->build($events); ?>
Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday |
---|---|---|---|---|---|---|
';
echo ' '.$Day->thisDay().' ';
if ($Day->isEmpty()) {
echo ' ';
} else {
echo '
| ';
if ($Day->isLast()) {
echo "