NAME HTML::CalendarMonthDB - Perl Module for Generating Persistant HTML Calendars SYNOPSIS use HTML::CalendarMonthDB; $cal = new HTML::CalendarMonthDB('year'=>2001,'month'=>2, 'dbname'=>'test', 'dbuser'=>'postgres', 'dbpass'=>'', 'dbcalendar'=>'testcal', 'dbclient'=>'testClient'); $cal->width('50%'); # non-persistant $cal->border(10); # non-persistant $cal->header('Text at the top of the Grid'); # non-persistant $cal->bgcolor('pink'); $cal->editdbcalendar('width'=>'50%', 'border'=>10, 'header'=>'Text at the top of the Grid', 'bgcolor'=>'pink'); # persistant, stored in DB. $cal->setcontent(14,"Don't forget to buy flowers"); # non-persistant $cal->addcontent(13,"Guess what's tomorrow?"); # non-persistant $cal->adddbevent('date'=>'14', 'eventname'=>'Don't forget to buy flowers'); # persistant, stored in db $cal->adddbevent('date'=>'13', 'eventname'=>'Guess what's tomorrow?', 'eventdesc'=>'A big surprise is happening tommorrow. Click here to see more!!', 'eventlink'=>'http://www.surprise.com'); # persistant, stored in db print $cal->as_HTML; # print standard 7 column calendar print $cal->as_HTML_list; # print HTML calendar as list DESCRIPTION HTML::CalendarMonthDB is a Perl module for generating, manipulating, and printing a HTML calendar grid for a specified month. It is intended as a faster and easier-to-use alternative to HTML::CalendarMonth. It is based on HTML::CalendarMonthSimple, but can store persistant data into a database, as well as adding features like per-event links, descriptions, and times. This module requires the Date::Calc module, which is available from CPAN. INTERFACE METHODS new(ARGUMENTS) Naturally, new() returns a newly constructed calendar object. Recognized arguments include 'year' and 'month', to specify which month's calendar will be used. If either is omitted, the current value is used. An important note is that the month and the year are NOT the standard C or Perl -- use a month in the range 1-12 and a real year, e.g. 2001. If this is to be a persistant calendar (you wish to store info in a database), there are other arguments: * 'dbname' (name of database to use, required if you wish to use a database) * 'dbuser' (database user, default 'nobody') * 'dbpass' (database user password, default '') * 'dbcalendar' (database calendar name, default '') * 'dbclient' (database calendar client name, default '') * 'dbhost' (database host name, default '') # Examples: # Create a calendar for this month. $cal = new HTML::CalendarMonthSimple(); # not persistant # One for a specific month/year $cal = new HTML::CalendarMonthSimple('month'=>2,'year'=>2000); # not persistant # One for "the current month" in 1997 $cal = new HTML::CalendarMonthSimple('year'=>1997); # not persistant # One for a specific month/year, to use database specified $cal = new HTML::CalendarMonthSimple('month'=>2,'year'=>2000,'dbname'=>'test','dbuser'=>postgres,'dbcalendar'=>'testcal','dbclient'=>'testClient'); deldbevent (EVENTID) Permanently deletes record from database associated with the event id passed in. adddbevent (ARGUMENTS) Add persistant event for date (day) specified within current month and year. The following are arguments: * 'eventname' (name of event) * 'eventdesc' (event description, optional) * 'eventlink' (event link, optional) * 'eventtime' (event time, optional) =head2 addevent(DATE,STRING) getcontent(DATE) These methods are used to control the content of date cells within the calendar grid. The DATE argument may be a numeric date or it may be a string describing a certain occurrence of a weekday, e.g. "3MONDAY" to represent "the third Monday of the month being worked with", or it may be the plural of a weekday name, e.g. "wednesdays" to represent all occurrences of the given weekday. The weekdays are case-insensitive. # Examples: # The cell for the 15th of the month will now say something. $cal->setcontent(15,"An Important Event!"); # Later down the program, we want the content to be boldfaced. $foo = "" . $cal->getcontent(15) . ""; $cal->setcontent(15,$foo); # Or we could get extra spiffy: $cal->setcontent(15,"" . $cal->getcontent(15) . ""); # addcontent() does not clober existing content. # Also, if you setcontent() to '', you've deleted the content. $cal->setcontent(16,''); $cal->addcontent(16,"
Hello World
"); $cal->addcontent(16,"Hello Again
"); print $cal->getcontent(16); # Prints 2 sentences # Padded and decimal numbers may be used, as well: $cal->setcontent(3.14159,'Third of the month'); $cal->addcontent('00003.0000','Still the third'); $cal->getcontent('3'); # Gets the 2 sentences # The second Sunday of May is some holiday or another... $cal->addcontent('2sunday','Some Special Day') if ($cal->month() == 5); # So is the third wednesday of this month $cal->setcontent('3WedNEsDaY','Third Wednesday!'); # What's scheduled for the second Friday? $cal->getcontent('2FRIDAY'); # Every Wednesday and Friday of this month... $cal->addcontent('wednesdays','Every Wednesday!'); $cal->getcontent('Fridays'); as_HTML(ARGUMENTS) as_HTML_list(ARGUMENTS) These methods return a string containing the HTML calendar for the month. as_HTML() returns a standard 7 column table, while as_HTML_list() returns a two-column list format calendar. # Examples: print $cal->as_HTML(); print $cal->as_HTML_list('editurl'=>'editcal.cgi', 'addurl'=>'addcal.cgi'); Two optional arguments may be passed, in order to ease the integration of adminitrative front-ends: 'editurl' (Will add a [edit] link in each day's cell to specified url like so- http://editurl?date=month_day_year&calid=calendarid.) 'addurl' (Will add a [add] link in each day's cell to specified url like so- http://addurl?date=month_day_year&calid=calendarid.) year() month() monthname() These methods simply return the year/month of the calendar. monthname() returns the text name of the month, e.g. "December". getdbcontent() Loads calendar event content from database. getdbcalendar() Loads calendar formatting data from database. editdbcalendar(ARGUMENTS) Edits calendar formatting attributes stored in database. Takes any or all of the following arguments: * 'border' (size of calendar border, integer) * 'width' (width of calendar, should be in pixels or %) * 'bgcolor' (background color of calendar) * 'weekdaycolor' (background color of weekday cells) * 'weekendcolor' (background color of weekend cells) * 'todaycolor' (background color of today's cell) * 'bordercolor' (border color of calendar) * 'weekdaybordercolor' (border color of weekday cells) * 'weekendbordercolor' (border color of weekend cells) * 'todaybordercolor' (border color of today's cell) * 'contentcolor' (color of cell content) * 'weekdaycontentcolor' (color of weekday cell content) * 'weekendcontentcolor' (color of weekend cell content) * 'todaycontentcolor' (color of today's cell content) * 'headercolor' (background color of header cell) * 'weekdayheadercolor' (background color of weekday header cell) * 'weekendheadercolor' (background color of weekend header cell) * 'header' (header text, defaults to 'Month Year' if not specified or '') * 'cellalignment' (alignment of text within cells, defaults to left, other valid values include right, center) editdbevent(ARGUMENTS) Edits specific event attributes in database. Arguments: * 'eventid' (id of specific event, required) * 'eventname' (name of event) * 'eventdesc' (event description) * 'eventlink' (event link) * 'eventtime' (event time) getdbevent(DATE) Takes an argument of the date(day) and returns a hash of event id's and their attributes for the specified day in this form: hash{eventid}{eventattribute} Useful as a function to be used in admin tools. border([INTEGER]) This specifies the value of the border attribute to the tag for each
day's cell. This controls how text will be centered/aligned within the
cells.
Any value can be used, if you think the web browser will find it
interesting. Some useful alignments are: left, right, center, top, and
bottom,
By default, cells are aligned to the left.
header([STRING])
By default, the current month and year are displayed at the top of the
calendar grid. This is called the "header".
The header() method allows you to set the header to whatever you like.
If no new header is specified, the current header is returned.
If the header is set to an empty string, then no header will be printed
at all. (No, you won't be stuck with a big empty cell!)
# Example:
# Set the month/year header to something snazzy.
my($y,$m) = ( $cal->year() , $cal->monthname() );
$cal->header(" |