Calendar : Documentation
Description :
Calendar is a PHP4 class intended to generates and displays a calendar in valid XHTML 1.1 as stated by the W3C.
It also provides many features such as translations in several languages or a "links on days" system ...
Main features :
- Generates valid XHTML according to the W3C Validator.
- Provides 5 translations "out of the box" : English, German, Spanish, French and Portuguese. Making your owns is easy as pie.
- Lets you choose to show either the current month calendar or the calendar of the month and the year of your choice. Covers about 136 years (limitation due to UNIX timestamp).
- Allows you to specify links on specific days, with the url pattern of your choice, which can be dynamic.
- Lets you choose whether the first day of the calendar must be Monday or Sunday.
- Lets you change the current month with a link system that adapts to your website by checking the variables you passed by url.
Licence :
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation.
Variables :
- $calendar::CFG
- $calendar::buffer
- $calendar::url
- $calendar::LINKS
- $calendar::monday_1st
- $calendar::jour_1er_du_mois
- $calendar::jour_1er_du_mois_chiffre
- $calendar::cases_vides_debut
- $calendar::cases_vides_fin
- $calendar::nombre_jour_du_mois
- $calendar::use_links
- $calendar::allow_change
- $calendar::prev
- $calendar::next
$calendar::CFG
- Type : Array.
- Role : Contains three essential informations : the month, the year and the language choosen.
$calendar::buffer
- Type : Varchar.
- Role : Contains all the generated XHTML
$calendar::url
- Type : String.
- Role : Contains the url pattern, specified by the user.
$calendar::LINKS
- Type : Array.
- Role : Contains the days that have to be linked.
$calendar::monday_1st
- Type : Char.
- Role : Have to be set to 'y', 'yes', 'o', 'oui' or '1' in order to have monday as the first day on the calendar.
$calendar::jour_1er_du_mois
- Type : Varchar.
- Role : Name of the first day of the month
$calendar::jour_1er_du_mois_chiffre
- Type : Int.
- Role : Number of the first day of the month
$calendar::cases_vides_debut
- Type : Int.
- Role : Number of empty cells at the beginning of the calendar.
$calendar::cases_vides_fin
- Type : Int.
- Role : Number of empty cells at the end of the calendar.
$calendar::nombre_jour_du_mois
- Type : Int.
- Role : Number of days during the month.
$calendar::use_links
- Type : Int.
- Role : Set to '1' if function calendar::links() is used ; unset otherwise.
$calendar::allow_change
- Type : Int.
- Role : Set to '0' if you don't want to let the visitors change the month of the calendar. Set to '1' if you want so. Note that default is '1'.
$calendar::prev
- Type : String.
- Role : String used to show where to click to get the previous month. Default is '<'.
$calendar::next
- Type : String.
- Role : String used to show where to click to get the next month. Default is '>'.
Functions :
- calendar::calendar([string, string, char])
- calendar::links(string str, string str)
- calendar::generate()
- calendar::draw()
calendar::calendar([string, string, char])
- Role : Constructor : initialize the class, set most of the settings.
- First parameter : Optionnal : set it to the wanted month (in numbers, DD) ; let it blank or set it to auto if you want the current month.
- Second parameter : Optionnal : set it to the wanted year (in numbers, YYYY) ; let it blank or set it to auto if you want the current year.
-
Third parameter : Optionnal : specify here the expected translation.
Default translations codes : en : English, de : German, es : Spanish, fr : French, pt : Portuguese.
Note that you can make your own by creating a new calendar.xx.php file. Have a look at 5 provided out of the box, it will be easy then to understand how to.
calendar::links(string str, string str)
- Role : Optionnal : Allows you to put links to specified days.
- First parameter : String composed of numbers separated by ':' ; the numbers are expected to be the days you want to link. (ex: '03:16:25:31')
-
Second parameter : Pattern of the links url. You can specify either static pattern or dynamic pattern.
A static pattern consists in a simple string
(ex: 'foo.php')
A dynamic pattern consists in a string with special elements that change according to the setting of the calendar. There are 3 special elements :
{D} : int, number of the day linked in the calendar.
{M} : int, month of the calendar.
{Y} : int, year of the calendar.
This can be very useful to interact with the users, passing variables through the url thanks to these elements.
(ex: 'foo.php?day={D}&month={M}&year={Y}')
calendar::generate()
- Role : Generate the XHTML code.
- No parameter
calendar::draw()
- Role : Display the calendar.
- No parameter
Author :
Rémy Salettes < remysa {at} gmail {dot} com > < http://remsa.free.fr >
Release Date :
February 2005