<?php
/**
* tiCalFile 3.2
*
* copyright (c) 2011-2013 Kjell-Inge Gustafsson kigkonsult
* kigkonsult.se/tiCalFile/index.php
* kigkonsult.se/contact/index.php
* updated 20121109
*
* 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 vevents/vtodos/vjournals and/or vfreebusys.
* 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 .= 'tiCalFile.log'; // fixed log file name
//$logFile .= 'tiCalFile.'.date('Ymd').'.log'; // daily log file name
//$logFile .= $logFile.date('YW').'.log'; // weekly log file name
//$logFile .= 'tiCalFile.log'; // fixed log file name
/** priority levels, 7=LOG_DEBUG, 6=LOG_INFO, 5=LOG_NOTICE, 4=LOG_WARN, 3=LOG_ERR, 2=LOG_CRIT, 1=LOG_ALARM, 0=LOG_EMERG */
$logLevel = LOG_DEBUG;
/** 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, array(), $logLevel );
// $tiCalFileLog = & Log::singleton( 'file', $logFile, tiCalFile::version, array(), $logLevel );
/** using eClog class */
elseif( class_exists( 'eClog' ))
// $tiCalFileLog = new eClog( 'file', $logFile, tiCalFile::version, array(), $logLevel );
$tiCalFileLog = eClog::singleton( 'file', $logFile, tiCalFile::version, array(), $logLevel );
}
/*************************************************************/
/** tiCalFile CONFIGURATION **********************************/
/*************************************************************/
/** General config *******************************************/
$tiCalFileConfig = array();
/** Environment config ***************************************/
/** folder for test files, default 'calendars', MUST exist */
$tiCalFileConfig['CALDIR'] = 'calendars';
/** names of calendar files to check and (re-)create, default 'testFile.ics', dbls removed */
$tiCalFileConfig['FILENAMES'] = array( 0 => 'testFile.ics'
, 1 => 'testtodoFile.ics'
, 2 => 'testjournalFile.ics'
, 3 => 'testfreebusyFile.ics'
, 4 => 'testa.ics'
, 5 => 'testa.ics'
, 6 => 'testmixedFile.ics' );
// 0 => 'testFile.ics' );
/** folder (MUST exist) and name for lock file, default 'calendars' and 'tiCalFile.lck' */
$tiCalFileConfig['LOCKDIR'] = $tiCalFileConfig['CALDIR'];
$tiCalFileConfig['LOCKFILE'] = 'tiCalFile.lck';
/** Calendar config ******************************************/
/** select component types (first array index corresponds to index in 'FILENAMES' above) */
/** only 'vevent'/'vtodo'/'vjournal'/'vfreebusy' (default 'vevent'), file dbls concatenated */
/** component proportions, will be recalculated to percent */
$tiCalFileConfig['COMPTYPES'] = array( 0 => array( 'vevent' => 50 )
, 1 => array( 'vtodo' => 200 )
, 2 => array( 'vjournal' => 100 )
, 3 => array( 'vfreebusy' => 100 )
, 4 => array( 'vdummy1' => 234, 'vdummy2' => 234 )
, 5 => array( 'vfreebusy' => 100 )
, 6 => array( 'vevent' => 20, 'vtodo' => 20, 'vjournal' => 20, 'vfreebusy' => 20 ));
// , 0 => array( 'vevent' => 75, 'vtodo' => 25 ));
/** replace with you site unique id */
$tiCalFileConfig['UNIQUE'] = 'kigkonsult.se';
/** optional calendar x-properties, default 50 (0=none, 100=100%), 'lorem ipsum.. .' */
$tiCalFileConfig['X_PROP1STCALOCCURRENCE'] = 50;
$tiCalFileConfig['X_PROP2NDCALOCCURRENCE'] = 50;
/** Some (MS.. .) calendar software required (x-)properties **/
/** METHOD, default PUBLISH */
$tiCalFileConfig['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 */
$tiCalFileConfig['X-WR-TIMEZONE'] = 'Europe/Stockholm';
/** calendar startdate, default now */
$tiCalFileConfig['THISDATE'] = date( 'YmdHis' ); // now
//$tiCalFileConfig['THISDATE'] = date( 'YmdHis', mktime( 0, 0, 0, 12, 27, 2012 ))); // new year test
/** when to recreate calendar files, default after 1 hour, 0=always */
$tiCalFileConfig['CALAGE'] = 1;
/** how many days to create events for, default 10 days */
$tiCalFileConfig['DAYCNT'] = 10;
/** how many components every day, default 5 */
$tiCalFileConfig['COMPCNT'] = 5;
/** General component Property config ************************/
/** start time (hour) period, randomly selected within period, default 7-18 */
$tiCalFileConfig['COMPSTART'] = 7;
$tiCalFileConfig['COMPEND'] = 18;
/** duration in hours, randomly selected within period, default 1-36 */
$tiCalFileConfig['COMPDURMIN'] = 1;
$tiCalFileConfig['COMPDURMAX'] = 36;
/** set LANGUAGE parameter whenever (!) possible, FALSE=no language parameter (default) */
$tiCalFileConfig['LANGUAGE'] = 'EN';
/** set ALTREP parameter whenever (!) possible, FALSE=no altrep parameter (default) */
$tiCalFileConfig['ALTREP'] = 'http://kigkonsult.se/docs/doc.txt';
/** set 'X-param' parameter whenever (!) possible, FALSE=no X-param parameter (default) */
$tiCalFileConfig['X-PARAM'] = 'X-VALUE';
/** set TZID parameter whenever (!) possible, FALSE=no TZID parameter */
$tiCalFileConfig['TZID'] = $tiCalFileConfig['X-WR-TIMEZONE'];
/** Specific Property config *********************************/
/** property occurence, default 50 (0=none, 100=100%) */
/** For property component occurrence, visit http://kigkonsult.se/iCalcreator/docs/using.html */
/** always one DTSTART property in every component */
/** percent AllDayEvent (only events)/DTEND(DUE)/DURATION occurence */
/** mutually exclusive, checked in order */
$tiCalFileConfig['ALLDAYEVENTOCCURRENCE'] = 20; // DTSTART (Ymd), vevent/vtodo only!
$tiCalFileConfig['DTENDOCCURRENCE'] = 50; // DTSTART (YmdHis) + DTEND (YmdHis)
$tiCalFileConfig['DURATIONDOCCURRENCE'] = 50; // DTSTART (YmdHis) + DURATION (H)
/** one SUMMARY property (none in freebusy), 'lorem ipsum.. .' */
/** one DESCRIPTION property (two in journal, none in freebusy), 'lorem ipsum.. .' */
/** one Categories (none in freebusy), selects 1 of 10 categories */
/** percent 2nd property Categories, 3rd occurence (3rd appended to 2nd) */
$tiCalFileConfig['CATEGORIES2NDOCCURRENCE'] = 50;
$tiCalFileConfig['CATEGORIES3RDOCCURRENCE'] = 50;
/** one property Resources (vevent/vtodo only), selects 1 of 10 resources */
/** percent 2nd property Resources, 3rd occurence (3rd appended to 2nd) */
$tiCalFileConfig['RESOURCES2NDOCCURRENCE'] = 50;
$tiCalFileConfig['RESOURCES3RDOCCURRENCE'] = 50;
/** percent ATTACH occurence (attach a text document URI) */
$tiCalFileConfig['ATTACHOCCURRENCE'] = 50;
/** percent (1st and/or 2nd) Attendee occurence, from a mixture of common names */
$tiCalFileConfig['ATTENDEE1STOCCURRENCE'] = 50;
$tiCalFileConfig['ATTENDEE2NDOCCURRENCE'] = 50;
/** percent CLASS occurence, from a fix value set */
$tiCalFileConfig['CLASSOCCURRENCE'] = 50;
/** percent (1st and/or 2nd) Comment occurence, 'lorem ipsum.. .' */
$tiCalFileConfig['COMMENT1STOCCURRENCE'] = 50;
$tiCalFileConfig['COMMENT2NDOCCURRENCE'] = 50;
/** percent COMPLETED occurence, three days after start date */
$tiCalFileConfig['COMPLETEDOCCURRENCE'] = 50;
/** percent CONTACT occurence, from a mixture of common names */
$tiCalFileConfig['CONTACTOCCURRENCE'] = 50;
/** percent CREATED occurence, two days before start date */
$tiCalFileConfig['CREATEDOCCURRENCE'] = 50;
/** percent EXDATE occurence (excludes DTSTART date, only if RDATE or RRULE, below, is set) */
$tiCalFileConfig['EXDATEOCCURRENCE'] = 50;
/** percent FREEBUSY occurence (if FREEBUSY appears, ORGANIZER appears) */
$tiCalFileConfig['FREEBUSYOCCURRENCE'] = 50;
/** percent GEO occurence, random.. . */
$tiCalFileConfig['GEOOCCURRENCE'] = 50;
/** percent LAST-MODIFIED occurence, one day before start date */
$tiCalFileConfig['LAST_MODIFIEDOCCURRENCE'] = 50;
/** percent LOCATION occurence, fake location */
$tiCalFileConfig['LOCATIONOCCURRENCE'] = 50;
/** percent ORGANIZER occurence, from a mixture of common names */
$tiCalFileConfig['ORGANIZEROCCURRENCE'] = 50;
/** percent PERCENT-COMPLETE occurence, 1-99 (%) */
$tiCalFileConfig['PERCENT_COMPLETEOCCURRENCE'] = 50;
/** percent PRIORITY occurence, 1-9 */
$tiCalFileConfig['PRIORITYOCCURRENCE'] = 50;
/** percent RDATE occurence, one week after start date */
$tiCalFileConfig['RDATEOCCURRENCE'] = 50;
/** percent RELATED-TO occurence (points to any previously created component) */
$tiCalFileConfig['RELATED_TOOCCURRENCE'] = 5;
/** percent REQUEST-STATUS occurence */
$tiCalFileConfig['REQUEST_STATUSOCCURRENCE'] = 50;
/** percent RRULE occurence, Weekly/monthly until 30-70 days from start date*/
$tiCalFileConfig['RRULEOCCURRENCE'] = 50;
/** percent SEQUENCE and RECURRENCE-ID occurence, prevents EXDATE/RDATE/RRULE */
$tiCalFileConfig['SEQUENCEOCCURRENCE'] = 0;
/** percent STATUS occurence, from a fix value set */
$tiCalFileConfig['STATUSOCCURRENCE'] = 50;
/** percent TRANSP occurence, from a fix value set */
$tiCalFileConfig['TRANSPOCCURRENCE'] = 50;
/** percent URL occurence, a fix value */
$tiCalFileConfig['URLOCCURRENCE'] = 50;
/** percent (1st and/or 2nd) X-prop occurence, 'lorem ipsum.. .' */
$tiCalFileConfig['X_PROP1STOCCURRENCE'] = 50;
$tiCalFileConfig['X_PROP2NDOCCURRENCE'] = 50;
/** vevent/vtodo 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 */
$tiCalFileConfig['AUDIOALARMOCCURRENCE'] = 50;
$tiCalFileConfig['AUDIOALARMTRIGGER'] = 1;
/** percent DISPLAY ALARM occurence; ACTION ('DISPLAY'), DESCRIPTION, TRIGGER */
/** and when (hours before start) to trigger a display alarm, default 4 */
$tiCalFileConfig['DISPLAYALARMOCCURRENCE'] = 50;
$tiCalFileConfig['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 */
$tiCalFileConfig['EMAILALARMOCCURRENCE'] = 50;
$tiCalFileConfig['EMAILALARMTRIGGER'] = 24;
/** create instance ******************************************/
$tiCalFile = new tiCalFile( $tiCalFileLog, $tiCalFileConfig );
// $tiCalFile = tiCalFile::singleton( $tiCalFileLog, $tiCalFileConfig );
/** execute tiCalFile ****************************************/
$tiCalFile->createTestFiles();
/** wipe out tiCalFile instance and flush log ****************/
$tiCalFile->__destruct();
unset( $tiCalFile );
if( $tiCalFileLog )
$tiCalFileLog->flush();
?>