entry = $entry; } function getEntry() { return $this->entry; } } // Create a day to view the hours for $Day = & new Calendar_Day(2003,10,24); // A sample query to get the data for today (NOT ACTUALLY USED HERE) $sql = " SELECT * FROM diary WHERE eventtime >= '".$Day->thisDay(TRUE)."' AND eventtime < '".$Day->nextDay(TRUE)."';"; // An array simulating data from a database $result = array ( array('eventtime'=>mktime(9,0,0,10,24,2003),'entry'=>'Meeting with sales team'), array('eventtime'=>mktime(11,0,0,10,24,2003),'entry'=>'Conference call with Widget Inc.'), array('eventtime'=>mktime(15,0,0,10,24,2003),'entry'=>'Presentation to board of directors') ); // An array to place selected hours in $selection = array(); // Loop through the "database result" foreach ( $result as $row ) { $Hour = new Calendar_Hour(2000,1,1,1); // Create Hour with dummy values $Hour->setTimeStamp($row['eventtime']); // Set the real time with setTimeStamp // Create the decorator, passing it the Hour $DiaryEvent = new DiaryEvent($Hour); // Attach the payload $DiaryEvent->setEntry($row['entry']); // Add the decorator to the selection $selection[] = $DiaryEvent; } // Build the hours in that day, passing the selection $Day->build($selection); ?>
Time | Entry | |
---|---|---|
$hour:$minute | \n" ); // If the hour is selected, call the decorator method... if ( $Hour->isSelected() ) { echo ( "".$Hour->getEntry()." | \n" ); } else { echo ( "\n" ); } echo ( " |
The query to fetch this data, with help from PEAR::Calendar, might be;