NAME

Gantry::Plugins::Calendar - Calendar

SYNOPSIS

use Gantry::Plugins::Calendar;

or

use Gantry qw/... Calendar/;

DESCRIPTION

If you have a date field on a web form, which the user must supply, you can use this module to help them. When you've got it set up, your form will have a link sitting next to the date's text entry box. If the user clicks the link, a calendar pops up. It allows for navigation by time period. Each date is just linked text. When the user presses one of the links, that date is entered into the text field as if they had typed it.

To make this happen do the following.

  1. Add Calendar to the list in the use statement for Gantry in your application's base module. For example:

    use Gantry qw/... Calendar/;
  2. In your module's _form method, add the following to the form hash:

    javascript => $site->calendar_month_js( 'your_form_name' );

    where your_form_name must match the name entry in the hash.

  3. Add the following to the hash for your date fields:

    date_select => 'User Label',

    User Label will be the link text, so make it something like 'Select' or 'Choose Date'.

That's all.

HOW IT WORKS

The three steps above are simple, but they conceal quite a bit of careful Perl and Javascript code. This section explains what is actually happening behind the scenes.

When you use the Calendar template, methods are exported into the site object. The important ones are calendar_month_js and do_calendar_month. The global handler will call do_calendar_month for you.

calendar_month_js creates two Javascript functions:

datepopup(form_name)

makes the calendar window popup.

SetDate(field_name, date)

sets the date when the user clicks on a date in the popup window.

You must pass the name of the form to calendar_month_js, otherwise its Javascript won't be able to tell the name to the popup window, which will then be unable to set any dates on your form.

do_calendar_month is the method called by the handler when the window pops up. It generates the calendar and manages user interaction with it. It relies on the internal _calendar_month to make the actual output. When the user clicks on a date, its Javascript first calls SetDate with the field name and the date value and then closes the popup window.

FUNCTIONS

The other functions are not directly useful to normal callers but here is a complete list.

Methods called by global handler

do_calendar_month( $site, ... )

This is the only do_* method we currently use.

do_calendar_week( $site ... )

Might not work, not tested. Meant to display weeks with time slots.

do_calendar_year( $site ... )

Might not work, not tested. Meant to display a whole year at a time.

Functions used internatlly

@month = _calendar_month( $r, $root, $month, $year, $select, \&function, @param )

This function creates a month in html for display. $r is the apache request object. $root is the uri root of the calendar, this is used for paging. $month and $year are the month and year to show. $select should be a boolean value, true if the month select is to be shown, false otherwise. \&function is a function referenc for the day. @params are any params that need to be passed to \&function

@week = _calendar_week( $r, $root, $day, $month, $year, \&function, @param )

This function creates a week in html for display. $r is the apache request object. $root is the uri root of the week, this is used for paging. $day, $month, and $year are the day, month, and year of the Wednesday of the week. \&function should be a function reference for the day function. @param is for the parameters for the day function that will be passed through.

@year = _calendar_year( $r, $root, $year, \&function, @param )

This function creates a year in html for display. $r is the apache request object. $root is the uri root of the year, this is used for paging. $year is the year to show. \&function is the day function to be used. @param are any other params to pass into the day function. This function uses the cal_month function to create it's month.

@day = \&function( $year, $month, $day, @params)

This is the "day function" it is not defined in this module at all. It needs to be defined by the user. The function should take the year, month, and day to show. It should also accept the @params that would be passed into the cal_* params.

SEE ALSO

Gantry(3)

LIMITATIONS and BUGS

Only do_calendary_month has been tested, the other do_* methods are unlikely to work.

AUTHOR

Tim Keefer <tkeefer@gmail.com> Phil Crow <philcrow2000@yahoo.com> Nicholas Studt <nstudt@angrydwarf.org>

COPYRIGHT and LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 458:

'=item' outside of any '=over'