EasyPhpCalendar

The simple & easy Calendar utility

★  easyphpeventcalendar.zip  ★  eventmanager.zip  

The EasyPhpEventCalendar class allows you to display a clean, easy to integrate, easy to use and easy to navigate event calendar for your website. It will display single day and multiple day events up to 12 months in the future. The event itself can be styled and formatted as you wish by providing the appropriate HTML markup. The event calendar is cross-browser compatible.


The EasyPhpEventCalendar PHP script is XHTML 1.0 strict compliant!

Getting started

  1. Download the class, unzip it and upload it to your webserver
  2. Open the example.php page

The most simple script would be

<?php
include_once('easyphpeventcalendar.class.php');
$calendar = new easyphpeventcalendar;
$calendar -> Gfxurl     = 'gfx';
$calendar -> Events[] = array('20111225','Christmasday 2011');
$calendar -> Events[] = array('2011122820111231','New years vacation 2011');
$calendar -> CreateEventCalendar();
?>

This would create the event calendar with one event on December the 25th 2011 and an event period from December the 28th to 31st. You can add as many events as you would like. You can use full html markup to enhance the appearance of the events. You can add events manually as shown above, read events from files as shown in the example below or read them from a database. How you manage your events is up to you, the class is designed to display them only.

<?php
$eventslocation = getcwd() . '/events'; 
if ($dir = opendir($eventslocation)) {
    while ($file = readdir($dir)) {
        if (strtolower(substr($file, -3)) == 'txt') {
            if ($fp = fopen("$eventslocation/" . $file, 'r+')) {
                $text = fread($fp, filesize("$eventslocation/" . $file));
                fclose($fp);
		if (strlen($file) == 20)
			$calendar -> Events[] = array(substr($file, 0, 16), $text);
		else
			$calendar -> Events[] = array(substr($file, 0, 8), $text);
            }  
        }
    }
}
?>

The above example expects a text file for each event to be located in a directory called ‘events’. The filenames of the events are in the format: ‘YYYYMMDD.txt’ for a single day event and ‘YYYYMMDDYYYYMMDD.txt’ for an event spanning multiple days.

As an extra you can download the Eventmanager below, just unzip this in your ‘events’ directory and change the login password at the top of the eventmanager.php script. With this eventmanager you can easiliy manage your events in simple textfiles.


API reference

Initialize the class:

include_once('easyphpeventcalendar.class.php');
$calendar = new easyphpeventcalendar;

Options:

$calendar -> Gfxurl      = (string)      // Path to the class gfx directory
$calendar -> Days        = (array)       // Days of the week in other langauge
                                            [0]: (string) Sunday
                                            [1]: (string) Monday
                                            [2]: (string) Tuesday
                                            [3]: (string) Wednesday
                                            [4]: (string) Thursday
                                            [5]: (string) Friday
                                            [6]: (string) Saturday
$calendar -> Months      = (array)      // Months of the year in other language
                                            [0]: (string) January
                                            [1]: (string) February
                                            [2]: (string) March
                                            [3]: (string) April
                                            [4]: (string) May
                                            [5]: (string) June
                                            [6]: (string) July
                                            [7]: (string) August
                                            [8]: (string) September
                                            [9]: (string) October
                                            [10]: (string) November
                                            [11]: (string) December

$calendar -> Hide        = (boolean)    // Hide the days from previous or next months from display. In normal mode these days are 'greyed out'
$calendar -> Events[]    = (array)     // Add new single day or multiple day events
                                            []: (array) [0] (string) Date of event in format YYYYMMDD
                                            [1] (string) Single day event html
                                            []: (array) [0] (string) Date of event in format YYYYMMDDYYYYMMDD
                                            [1] (string) Multiple day event html

★  easyphpeventcalendar.zip  ★  eventmanager.zip