Source for file 11.php
Documentation is available at 11.php
* Description: demonstrates a decorator used to "attach a payload" to a selection
* to make it available when iterating over calendar children
if ( !@include 'Calendar/Calendar.php' ) {
define ('CALENDAR_ROOT','../../');
require_once CALENDAR_ROOT. 'Day.php';
require_once CALENDAR_ROOT. 'Hour.php';
require_once CALENDAR_ROOT. 'Decorator.php';
// Decorator to "attach" functionality to selected hours
// Create a day to view the hours for
// A sample query to get the data for today (NOT ACTUALLY USED HERE)
eventtime >= '". $Day->thisDay(TRUE ). "'
eventtime < '". $Day->nextDay(TRUE ). "';";
// An array simulating data from a database
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
// 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
// Add the decorator to the selection
$selection[] = $DiaryEvent;
// Build the hours in that day, passing the selection
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title> Passing a Selection Payload with a Decorator </title>
<h1>Passing a Selection "Payload" using a Decorator</h1>
<caption><b>Your Schedule for <?php echo ( date('D nS F Y',$Day->thisDay(TRUE )) ); ?></b></caption>
while ( $Hour = & $Day->fetch() ) {
if ( $hour >= 8 && $hour <= 18 ) {
echo ( " <td>$hour:$minute</td>\n" );
// If the hour is selected, call the decorator method...
echo ( "<td bgcolor=\"silver\">". $Hour->getEntry(). "</td>\n" );
echo ( "<td> </td>\n" );
<p>The query to fetch this data, with help from PEAR::Calendar, might be;</p>
Documentation generated on Mon, 11 Mar 2019 15:37:47 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|