Source for file 10.php
Documentation is available at 10.php
* Description: demonstrates a decorator to provide simple output formatting
* on the month while still allowing the days to be accessed via the decorator
* In practice you _wouldn't_ do this - each decorator comes with a performance
* hit for extra method calls. For this example some simple functions could help
* format the month while the days are accessed via the normal Month object
if ( !@include 'Calendar/Calendar.php' ) {
define ('CALENDAR_ROOT','../../');
require_once CALENDAR_ROOT. 'Month/Weekdays.php';
require_once CALENDAR_ROOT. 'Decorator.php';
// Decorate a Month with methods to improve formatting
* Override the prevMonth method to format the output
// Build the URL for the previous month
return $_SERVER['PHP_SELF']. '?y='. date('Y',$prevStamp).
'&m='. date('n',$prevStamp). '&d='. date('j',$prevStamp);
* Override the thisMonth method to format the output
// A human readable string from this month
return date('F Y',$thisStamp);
* Override the nextMonth method to format the output
// Build the URL for next month
return $_SERVER['PHP_SELF']. '?y='. date('Y',$nextStamp).
'&m='. date('n',$nextStamp). '&d='. date('j',$nextStamp);
if (!isset ($_GET['y'])) $_GET['y'] = date('Y');
if (!isset ($_GET['m'])) $_GET['m'] = date('n');
// Creata a month as usual
// Pass it to the decorator and use the decorator from now on...
$MonthDecorator->build();
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title> A Simple Decorator </title>
<h1>A Simple Decorator</h1>
<caption> <?php echo ( $MonthDecorator->thisMonth() ); ?></caption>
while ( $Day = $MonthDecorator->fetch() ) {
echo ( "<td> </td>" );
echo ( "<td>". $Day->thisDay(). "</td>" );
<td><a href=" <?php echo ($MonthDecorator->prevMonth()); ?>">Prev</a></td>
<td colspan="5"> </td>
<td><a href=" <?php echo ($MonthDecorator->nextMonth()); ?>">Next</a></td>
Documentation generated on Mon, 11 Mar 2019 15:37:47 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|