Location: PHPKode > scripts > EasyPhpEventCalendar Class > easyphpeventcalendar/example.php
<?php

/**

EasyPhpEventCalendar Class version 1.0.2

Copyright (c) 2009-2011 JF Nutbroek <hide@address.com>
For more information visit http://wwww.mywebmymail.com

Permission to use, copy, modify, and/or distribute this software for any
purpose without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

*/

// Include the Class
include_once('inc/easyphpeventcalendar.class.php');

// Initialize the Class
$calendar = new easyphpeventcalendar;

// Path to the background images - use full URL if required
$calendar -> Gfxurl = 'gfx';

// Optional: Hide the days from the previous month and next month in the display
$calendar -> Hide = false;

// Optional: Override the English language by providing the days and months in another language
// $calendar -> Days   = array('Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag');
// $calendar -> Months = array('Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December');

// Adding Events
// Format single day   : $calendar -> Events[] = array('YYYYMMDD','Event as text with optional html markup')
// Format multiple days: $calendar -> Events[] = array('YYYYMMDDYYYYMMDD','Event period as text with optional html markup')

// Method 1: Add events manually in PHP code
$calendar -> Events[] = array(date('Y'). '1225','<b>Christmasday</b><br /><br />Merry X-mas!!');
$calendar -> Events[] = array(date('Y'). '0601','<div style="text-align: center;padding: 50px 10px;"><b>1st of June!!</b></div>');
// An example for an event period spanning multiple days
$calendar -> Events[] = array(date('Y'). '0401' . date('Y'). '0405','<div style="text-align: center;padding: 50px 10px;"><b>This demonstrates<br />an event of 5 days</b></div>');
$calendar -> Events[] = array(date('Y'). '1231' . (date('Y')+1). '0101','<div style="text-align: center;padding: 50px 10px;"><b>2 day New Years Party!!</div>');

// Method 2: Add events from textfiles
// Provide the path/location to your directory with events stored in textfiles with filenames 'YYYYMMDD.txt' or 'YYYYMMDDYYYYMMDD.txt'
$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);
            }  
        }
    }
}

// Method 3: Add events from a database
// Place your custom code here ...

// Create HTML page
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n";
echo "<head><title>EasyPhpEventcalendar Example</title>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />\n";

// Insert Event Calendar CSS Styles a
// Note if you use a CMS try to integrate this in your CSS template
$calendar -> CreateEventCalendarCSS();

// Insert the JavaScript 
// Note if you use a CMS try to integrate this in your JS codebase
echo "<script type=\"text/javascript\" src=\"inc/eventcalendar.js\"></script>";
echo "</head><body>\n";

// Print the Event Calendar
// You can position it anywhere on a page using a <div>
$calendar -> CreateEventCalendar();

// Close the HTML Page
echo "</body></html>\n";

?>
Return current item: EasyPhpEventCalendar Class