A decorator would be an ideal way to make that
feature available. Several decorators are offered for reference and use, including
Calendar_Decorator, Calendar_Decorator_Uri, Calendar_Decorator_Textual, and
Calendar_Decorator_Wrapper. In the interest of covering only the most commonly
used features, Calendar??™s decorator internals aren??™t discussed here; consider
examining the decorators installed with Calendar for ideas regarding how to go
about creating your own.
All four classes are subclasses of Calendar, meaning all of the Calendar class??™s methods
are available to each subclass. For a complete summary of the methods for this superclass
and the four subclasses, see http://pear.php.net/package/Calendar.
CHAPTER 1 2 ?– D ATE AND T IME 343
Creating a Monthly Calendar
These days, grid-based monthly calendars seem to be one of the most commonly
desired Web site features, particularly given the popularity of time-based content such
as blogs. Yet creating one from scratch can be deceivingly difficult. Thankfully, Calendar
handles all of the tedium for you, offering the ability to create a grid calendar with just
a few lines of code. For example, suppose you want to create a calendar as shown in
Figure 12-1.
The code for creating this calendar is surprisingly simple and is presented in
Listing 12-1. An explanation of key lines follows the code, referring to their line
numbers for convenience.
Pages:
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420