cvs: pear /Calendar/docs/examples 24.php index.html
| From: | Harry Fuecks | Date: | Tue, 17 Aug 2004 09:10:56 +0000 |
| Subject: | cvs: pear /Calendar/docs/examples 24.php index.html | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-22998@lists.php.net to get a copy of this message | ||
hfuecks Tue Aug 17 05:10:56 2004 EDT
Added files:
/pear/Calendar/docs/examples 24.php
Modified files:
/pear/Calendar/docs/examples index.html
Log:
Adding example of Weekday and Wrapper decorators combined
http://cvs.php.net/diff.php/pear/Calendar/docs/examples/index.html?r1=1.5&r2=1.6&ty=u
Index: pear/Calendar/docs/examples/index.html
diff -u pear/Calendar/docs/examples/index.html:1.5 pear/Calendar/docs/examples/index.html:1.6
--- pear/Calendar/docs/examples/index.html:1.5 Mon Aug 16 09:15:48 2004
+++ pear/Calendar/docs/examples/index.html Tue Aug 17 05:10:53 2004
@@ -19,7 +19,7 @@
<body>
<h1>PEAR::Calendar Examples</h1>
-<p>$Id: index.html,v 1.5 2004/08/16 13:15:48 hfuecks Exp $</p>
+<p>$Id: index.html,v 1.6 2004/08/17 09:10:53 hfuecks Exp $</p>
<ul>
<li><a href="1.php">1.php</a> [<a
href="1.phps">src</a>] - shows basic usage, passing all the way down from
<code>Calendar_Year</code> to <code>Calendar_Second</code> - more of a quick
test it's working</li>
<li><a href="2.php">2.php</a> [<a
href="2.phps">src</a>] - shows how to build a tabular month using
<code>Calendar_Month_Weeks</code>, <code>Calendar_Week</code>,
<code>Calendar_Day</code> as well as selecting some dates.</li>
@@ -36,14 +36,15 @@
<li><a href="13.php">13.php</a> [<a
href="13.phps">src</a>] - same as 1.php but using
<code>Calendar_Engine_PearDate</code>, (see <a href="http://pear.php.net/Date">PEAR::Date</a>).</li>
<li><a href="14.php">14.php</a> [<a
href="14.phps">src</a>] - same as 3.php but using
<code>Calendar_Engine_PearDate</code></li>
<li><a href="15.php">15.php</a> [<a
href="15.phps">src</a>] - paging through weeks </li>
-<li><a href="16.php">16.php</a> [<a
href="16.phps">src</a>] - demonstrates using the Uri decorator.
<i>Note</i> you should prefer <code>Calendar_Util_Uri</code> (see below) in
most cases, for performance </li>
-<li><a href="17.php">17.php</a> [<a
href="17.phps">src</a>] - demonstrates using the Textual decorator</li>
-<li><a href="18.php">18.php</a> [<a
href="18.phps">src</a>] - demonstrates using the Wrapper decorator</li>
-<li><a href="19.php">19.php</a> [<a
href="19.phps">src</a>] - demonstrates using the Weekday decorator</li>
+<li><a href="16.php">16.php</a> [<a
href="16.phps">src</a>] - example of
<code>Calendar_Decorator_Uri</code>. <i>Note</i> you should prefer
<code>Calendar_Util_Uri</code> (see below) in most cases, for performance </li>
+<li><a href="17.php">17.php</a> [<a
href="17.phps">src</a>] - example of
<code>Calendar_Decorator_Textual</code>. <i>Note</i> you should prefer
<code>Calendar_Util_Textual</code> (see below) in most cases, for performance</li>
+<li><a href="18.php">18.php</a> [<a
href="18.phps">src</a>] - example of
<code>Calendar_Decorator_Wrapper</code>.</li>
+<li><a href="19.php">19.php</a> [<a
href="19.phps">src</a>] - example of
<code>Calendar_Decorator_Weekday</code>.</li>
<li><a href="20.php">20.php</a> [<a
href="20.phps">src</a>] - shows how to attach a "payload" spanning
multiple days, with more than one entry per day</li>
<li><a href="21.php">21.php</a> [<a
href="21.phps">src</a>] - same as 12.php but using
<code>Calendar_Month_Weeks</code> instead of
<code>Calendar_Month_Weekdays</code> to allow the week in the year or week in the month
to be displayed.</li>
<li><a href="22.php">22.php</a> [<a
href="22.phps">src</a>] - demonstrates use of
<code>Calendar_Util_Uri</code>.</li>
-<li><a href="22.php">23.php</a> [<a
href="23.phps">src</a>] - demonstrates use of
<code>Calendar_Util_Textual</code>.</li>
+<li><a href="23.php">23.php</a> [<a
href="23.phps">src</a>] - demonstrates use of
<code>Calendar_Util_Textual</code>.</li>
+<li><a href="24.php">24.php</a> [<a
href="24.phps">src</a>] - <code>Calendar_Decorator_Weekday</code>
combined with <code>Calendar_Decorator_Wrapper</code> to decorate days in the
month.</li>
</ul>
</body>
</html>
http://cvs.php.net/co.php/pear/Calendar/docs/examples/24.php?r=1.1&p=1
Index: pear/Calendar/docs/examples/24.php
+++ pear/Calendar/docs/examples/24.php
<?php
/**
* Description: shows the Weekday decorator combined with the Wrapper decorator
* plus the Uri and Textual utilities
*/
if ( !@include 'Calendar/Calendar.php' ) {
define('CALENDAR_ROOT','../../');
}
require_once CALENDAR_ROOT.'Month'.DIRECTORY_SEPARATOR.'Weekdays.php';
require_once CALENDAR_ROOT.'Decorator'.DIRECTORY_SEPARATOR.'Wrapper.php';
require_once CALENDAR_ROOT.'Decorator'.DIRECTORY_SEPARATOR.'Weekday.php';
require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Uri.php';
require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Textual.php';
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
if (!isset($_GET['m'])) $_GET['m'] = date('m');
// Build a month
$Month = & new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
// Build the days in the month
$Month->build();
// Decorate it with the Wrapper
$WrappedMonth = & new Calendar_Decorator_Wrapper($Month);
// Set up the Uri util, specifying required fragments (see $_GET vars above)
$Uri = & new Calendar_Util_Uri('y','m');
// Get the names of the days of the week
$weekDayNames = Calendar_Util_Textual::weekdayNames('short');
// Move Sunday to the end of the list
$weekDayNames[] = array_shift($weekDayNames);
// Find out who's on call for this day of the week
function whoIsOnCall($dayOfWeek) {
switch ( $dayOfWeek ) {
case 0:
case 4:
return 'John';
break;
case 1:
case 3:
return 'Bill';
break;
case 2:
return 'Mary';
break;
// No one on call at weekends
case 5:
case 6:
return false;
break;
}
}
?>
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> On Call List </title>
<style text="text/css">
body {
font-family: verdana;
font-size: 11px;
}
h2, p {
text-align: center;
}
table {
border-collapse: collapse; font-size: inherit;
}
caption {
font-family: verdana;
font-size: 14pt;
padding-bottom: 4pt;
}
th {
text-align: center;
background-color: #e7e3e7;
padding: 5pt;
line-height: 150%;
border: 1px solid #ccc;
}
td {
text-align: left;
vertical-align: top;
border: 1px solid #b5bece; padding: 3px;
}
td.calCellEmpty { background-color: #f3f3f7;}
.calWeekNum { text-align: center;
width: 50px;
border: ;
}
#prev {
float: left;
font-size: 70%;
}
#next {
float: right;
font-size: 70%;
}
</style>
</head>
<body>
<h2>On Call List</h2>
<p>Shows the Wrapper and Weekday decorators in use. The "on call" person is assigned
by day of the week in this example.</p>
<table class="calendar" width="98%" cellspacing="0"
cellpadding="0">
<caption>
<div id="next">
<a href="?<?php echo $Uri->next($Month,'month');
?>">>></a>
</div>
<div id="prev">
<a href="?<?php echo $Uri->prev($Month,'month');
?>"><<</a>
</div>
<?php echo strftime('%B %Y',$Month->getTimestamp()); ?>
</caption>
<tr>
<th class="calWeekNum">Week #</th>
<?php
foreach ( $weekDayNames as $weekDayName ) {
?>
<th><?php echo $weekDayName; ?></th>
<?php
}
?>
</tr>
<?php
$weekNum = 1;
// Pull out the days, immediately wrapping them in a Weekday decorator
while ( $Weekday = & $WrappedMonth->fetch('Calendar_Decorator_Weekday') ) {
if ($Weekday->isFirst()) { echo "<tr>\n";
echo "<td class='calWeekNum'>$weekNum</td>\n"; }
if ( $Weekday->isEmpty() ) {
echo "<td class='calCellEmpty'> </td>\n";
} else {
echo "<td>";
if ( false !== ( $onCall = whoIsOnCall($Weekday->thisWeekDay()) ) ) {
echo "On Call: $onCall";
} else {
echo " ";
}
echo "</td>\n";
}
if ($Weekday->isLast()) { echo "</tr>\n";
$weekNum++; }
}
?>
</table>
</body>
</html>