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

/**

EasyPhpEventCalendar Class version 1.0.1 

Copyright (c) 2009 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 with 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 - Path is relative to the file that included the class
include_once('../easyphpeventcalendar.class.php');

// Initialize the Class
$calendar = new easyphpeventcalendar;

// Configure the Calendar
// Path to the background images. Path is relative to the file that included the class
$calendar -> Gfxurl     = '../gfx';

// 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');

// Method 1: Add events manually 
// Format: $calendar -> Events[] = array('YYYYMMDD','Event as text with optional html markup')
$calendar -> Events[] = array(date('Y'). '1225','<b>Christmasday</b><br /><br />Merry X-mas!!');
$calendar -> Events[] = array(date('Y'). '0801','<div style="text-align: center;padding: 50px 10px;"><b>1st of August!!</b></div>');

// Method 2: Add events from textfiles
// Provide the path/location to your directory with events stored in textfiles with filenames 'YYYYMMDD.txt'
$eventslocation='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);
                $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 and JavaScript
$calendar -> CreateEventCalendarCSS();
echo "<script type=\"text/javascript\" src=\"../inc/eventcalendar.js\"></script>";

echo "</head><body>\n";

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

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

?>
Return current item: EasyPhpEventCalendar Class