PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of JN   Easy PHP Event Calendar   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Easy PHP Event Calendar
Display a calendar with events
Author: By
Last change:
Date: 14 years ago
Size: 3,119 bytes
 

Contents

Class file image Download
<?php

/**

EasyPhpEventCalendar Class version 1.0.0

Copyright (c) 2009 JF Nutbroek <jfnutbroek@gmail.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.

*/

//Create HTML page
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
echo
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
echo
"<head><title>Example of EasyPhpEventCalendar Class</title>\n";
echo
"</head><body bgcolor=\"#CCCCCC\">\n";

// Include the Class - Paths are relative to the file that included the class
include_once('../easyphpeventcalendar.class.php');

// Initialize the Class
$calendar = new easyphpeventcalendar;

// Configure the Calendar
// Provide the path to the class background images
// Paths are 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('20091225','<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 ...

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

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

?>