<?php
/**
* tiCalFile 3.0
*
* copyright (c) 2011-2012 Kjell-Inge Gustafsson kigkonsult
* kigkonsult.se/tiCalFile/index.php
* kigkonsult.se/contact/index.php
* updated 20120527
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Config create test iCal files with events. Configurable, start date, number of events etc.
*
**/
/*************************************************************/
/** include iCalcreator, if not included elsewhere, required */
require_once './iCalcreator.class.php';
/*************************************************************/
/** include tiCalFile class */
require_once './tiCalFile.class.php';
/*************************************************************/
/** LOG CONFIGURATION ****************************************/
/*************************************************************/
/** include eClog, or comment if no logging */
require_once './eClog.class.php';
/** include PEAR LOG, or comment if no logging */
// require_once 'Log.php';
/** set FALSE (no log) or logfile (incl. path) and priority */
//$logFile = FALSE; // no logging
$logFile = dirname(__FILE__).DIRECTORY_SEPARATOR;
// logFile .= $logFile.date('Ymd').'.log'; // daily log file name
// $logFile .= $logFile.date('YW').'.log'; // weekly log file name
$logFile .= 'tiCalFile.log'; // fixed log file name
$config = array();
$config['timeFormat'] = '%Y-%m-%d %T'; // strftime format, PEAR Log/eClog default
// $config['timeFormat'] = 'Y-m-d H:i:s.u'; // date format, eClog only (u=microseconds)
// $config['timeFormat'] = 'H:i:s'; // date format, eClog only
// $config['liro'] = '1 3 2 4'; // eClog only, Log Item Row Order, (time, priority, ident, msg )
/** priority levels, check PEAR LOG or eClog.class.php, 7=debug, 6=info, 5=notice, 4=warn, 3=error, 2=crit, 1=alarm, 0=emerg */
$logLevel = 7;
/** fire up log (or not) */
$tiCalFileLog = FALSE;
if( FALSE !== $logFile ) {
/** using PEAR log class */
if( class_exists( 'Log' ))
$tiCalFileLog = Log::factory( 'file', $logFile, tiCalFile::version, $config, $logLevel );
// $tiCalFileLog = & Log::singleton( 'file', $logFile, tiCalFile::version, $config, $logLevel );
/** using eClog class */
elseif( class_exists( 'eClog' ))
// $tiCalFileLog = new eClog( 'file', $logFile, tiCalFile::version, $config, $logLevel );
$tiCalFileLog = eClog::singleton( 'file', $logFile, tiCalFile::version, $config, $logLevel );
}
// if( FALSE !== $tiCalFileLog ) { $tiCalFileLog->log( "log started !!! ($logFile)", 7 ); $tiCalFileLog->flush(); } // test ###
/*************************************************************/
/** tiCalFile CONFIGURATION **********************************/
/*************************************************************/
/** General config *******************************************/
/** create instance */
$tiCalFile = new tiCalFile( $tiCalFileLog );
// $tiCalFile = tiCalFile::singleton( $tiCalFileLog );
/** Environment config ***************************************/
/** folder for test files, default 'calendars', MUST exist */
$tiCalFile->setConfig( 'CALDIR' , 'calendars' );
/** names of calendar files to check and (re-)create, default 'testFile.ics' */
$tiCalFile->setConfig( 'FILENAMES' , array( 'testFile.ics' )); // , 'testFile2.ics' ));
/** folder (MUST exist) and name for lock file, default 'calendars' and 'tiCalFile.lck' */
$tiCalFile->setConfig( 'LOCKDIR' , $tiCalFile->getConfig( 'CALDIR' ));
$tiCalFile->setConfig( 'LOCKFILE' , 'tiCalFile.lck' );
/** Calendar config ******************************************/
/** replace with you site unique id */
$tiCalFile->setConfig( 'UNIQUE' , 'kigkonsult.se' );
/** optional calendar x-properties, default 50 (0=none, 100=100%), 'lorem ipsum.. .' */
$tiCalFile->setConfig( 'X_PROP1STCALOCCURRENCE' , 50 );
$tiCalFile->setConfig( 'X_PROP2NDCALOCCURRENCE' , 50 );
/** Some (MS.. .) calendar software required (x-)properties **/
/** METHOD, default PUBLISH */
$tiCalFile->setConfig( 'METHOD' , 'PUBLISH' );
/** X-WR-TIMEZONE, default date_default_timezone_get (if not empty/UTC) */
/** replace with you local timezone (FALSE=none) */
/** if set, also creates one timezone and two standard/daylight components */
$tiCalFile->setConfig( 'X-WR-TIMEZONE' , 'Europe/Stockholm' );
/** Event config *********************************************/
/** calendar startdate, default now */
$tiCalFile->setConfig( 'THISDATE' , date( 'YmdHis' )); // now
//$tiCalFile->setConfig( 'THISDATE' = date( 'YmdHis', mktime( 0, 0, 0, 12, 27, 2011 ))); // new year test
/** when to recreate calendar files, default after 1 hour, 0=always */
$tiCalFile->setConfig( 'CALAGE' , 1 );
/** how many days to create events for, default 10 days */
$tiCalFile->setConfig( 'DAYCNT' , 10 );
/** how many events every day, default 5 */
$tiCalFile->setConfig( 'EVENTCNT' , 5 );
/** General event Property config ****************************/
/** event start time (hour) period, randomly selected within period, default 7-18 */
$tiCalFile->setConfig( 'EVENTSTART' , 7 );
$tiCalFile->setConfig( 'EVENTEND' , 18 );
/** duration in hours for events, randomly selected within period, default 1-36 */
$tiCalFile->setConfig( 'EVENTDURMIN' , 1 );
$tiCalFile->setConfig( 'EVENTDURMAX' , 36 );
/** set LANGUAGE parameter whenever (!) possible, FALSE=no language parameter (default) */
$tiCalFile->setConfig( 'LANGUAGE' , 'EN' );
/** set ALTREP parameter whenever (!) possible, FALSE=no altrep parameter (default) */
$tiCalFile->setConfig( 'ALTREP' , 'http://kigkonsult.se/docs/doc.txt' );
/** set 'X-param' parameter whenever (!) possible, FALSE=no X-param parameter (default) */
$tiCalFile->setConfig( 'X-PARAM' , 'X-VALUE' );
/** set TZID parameter whenever (!) possible, FALSE=no TZID parameter */
$tiCalFile->setConfig( 'TZID' , $tiCalFile->getConfig( 'X-WR-TIMEZONE' ));
/** Specific event Property config ***************************/
/** property occurence, default 50 (0=none, 100=100%) */
/** always one DTSTART property in every event */
/** percent AllDayEvent/DTEND/DURATION occurence, mutually exclusive, checked in order */
$tiCalFile->setConfig( 'ALLDAYEVENTOCCURRENCE' , 20 ); // DTSTART (Ymd)
$tiCalFile->setConfig( 'DTENDOCCURRENCE' , 50 ); // DTSTART (YmdHis) + DTEND (YmdHis)
$tiCalFile->setConfig( 'DURATIONDOCCURRENCE' , 50 ); // DTSTART (YmdHis) + DURATION (H)
/** always one SUMMARY property in every event, 'lorem ipsum.. .' */
/** always one DESCRIPTION property in every event, 'lorem ipsum.. .' */
/** always one Categories, selects 1 of 10 categories */
/** percent 2nd property Categories, 3rd occurence (3rd appended to 2nd) */
$tiCalFile->setConfig( 'CATEGORIES2NDOCCURRENCE' , 50 );
$tiCalFile->setConfig( 'CATEGORIES3RDOCCURRENCE' , 50 );
/** always one property Resources, selects 1 of 10 resources */
/** percent 2nd property Resources, 3rd occurence (3rd appended to 2nd) */
$tiCalFile->setConfig( 'RESOURCES2NDOCCURRENCE' , 50 );
$tiCalFile->setConfig( 'RESOURCES3RDOCCURRENCE' , 50 );
/** percent ATTACH occurence (attach text document URI) */
$tiCalFile->setConfig( 'ATTACHOCCURRENCE' , 50 );
/** percent (1st and/or 2nd) Attendee occurence, from a mixture of common names */
$tiCalFile->setConfig( 'ATTENDEE1STOCCURRENCE' , 50 );
$tiCalFile->setConfig( 'ATTENDEE2NDOCCURRENCE' , 50 );
/** percent (1st and/or 2nd) Comment occurence, 'lorem ipsum.. .' */
$tiCalFile->setConfig( 'COMMENT1STOCCURRENCE' , 50 );
$tiCalFile->setConfig( 'COMMENT2NDOCCURRENCE' , 50 );
/** percent CONTACT occurence, from a mixture of common names */
$tiCalFile->setConfig( 'CONTACTOCCURRENCE' , 50 );
/** percent CREATED occurence, two days before event start date */
$tiCalFile->setConfig( 'CREATEDOCCURRENCE' , 50 );
/** percent EXDATE occurence (excludes DTSTART date, only if RDATE or RRULE, below, is set) */
$tiCalFile->setConfig( 'EXDATEOCCURRENCE' , 50 );
/** percent GEO occurence, random.. . */
$tiCalFile->setConfig( 'GEOOCCURRENCE' , 50 );
/** percent LAST-MODIFIED occurence, one day before event start date */
$tiCalFile->setConfig( 'LAST_MODIFIEDOCCURRENCE' , 50 );
/** percent LOCATION occurencem fake location */
$tiCalFile->setConfig( 'LOCATIONOCCURRENCE' , 50 );
/** percent ORGANIZER occurence, from a mixture of common names */
$tiCalFile->setConfig( 'ORGANIZEROCCURRENCE' , 50 );
/** percent PRIORITY occurence, 1-9 */
$tiCalFile->setConfig( 'PRIORITY' , 50 );
/** percent RDATE occurence, one week after event start date */
$tiCalFile->setConfig( 'RDATEOCCURRENCE' , 50 );
/** percent RELATED-TO occurence (points to any previously created event */
$tiCalFile->setConfig( 'RELATED_TOOCCURRENCE' , 5 );
/** percent RRULE occurence, Weekly/monthly until 30-70 days from start date*/
$tiCalFile->setConfig( 'RRULEOCCURRENCE' , 50 );
/** percent STATUS occurence, from a fix value set */
$tiCalFile->setConfig( 'STATUSOCCURRENCE' , 50 );
/** percent TRANSP occurence, from a fix value set */
$tiCalFile->setConfig( 'TRANSPOCCURRENCE' , 50 );
/** percent URL occurence, a fix value */
$tiCalFile->setConfig( 'URLOCCURRENCE' , 50 );
/** percent (1st and/or 2nd) X-prop occurence, 'lorem ipsum.. .' */
$tiCalFile->setConfig( 'X_PROP1STOCCURRENCE' , 50 );
$tiCalFile->setConfig( 'X_PROP2NDOCCURRENCE' , 50 );
/** Event Alarm config ***************************************/
/** percent AUDIO ALARM occurence; ACTION ('AUDIO'), ATTACH (URI), DURATION (1H), REPEAT (=2), TRIGGER */
/** and when (hours before start) to trigger an audio alarm, default 1 */
$tiCalFile->setConfig( 'AUDIOALARMOCCURRENCE' , 50 );
$tiCalFile->setConfig( 'AUDIOALARMTRIGGER' , 1 );
/** percent DISPLAY ALARM occurence; ACTION ('DISPLAY'), DESCRIPTION, TRIGGER */
/** and when (hours before start) to trigger a display alarm, default 4 */
$tiCalFile->setConfig( 'DISPLAYALARMOCCURRENCE' , 50 );
$tiCalFile->setConfig( 'DISPLAYALARMTRIGGER' , 4 );
/** percent EMAIL ALARM occurence; ACTION ('EMAIL'), DESCRIPTION, SUMMARY, ATTENDEE (2x), TRIGGER */
/** and when (hours before start) to trigger an email alarm, default 24 */
$tiCalFile->setConfig( 'EMAILALARMOCCURRENCE' , 50 );
$tiCalFile->setConfig( 'EMAILALARMTRIGGER' , 24 );
/** execute tiCalFile ****************************************/
$tiCalFile->createTestFiles();
/** wipe out tiCalFile instance ******************************/
$tiCalFile->__destruct();
unset( $tiCalFile );
?>