ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
EasyPeasyICS Class Reference
+ Collaboration diagram for EasyPeasyICS:

Public Member Functions

 __construct ($calendarName="")
 Constructor. More...
 
 addEvent ($start, $end, $summary='', $description='', $url='', $uid='')
 Add an event to this calendar. More...
 
 getEvents ()
 
 clearEvents ()
 Clear all events. More...
 
 getName ()
 Get the name of the calendar. More...
 
 setName ($name)
 Set the name of the calendar. More...
 
 render ($output=true)
 Render and optionally output a vcal string. More...
 

Protected Attributes

 $calendarName
 
 $events = array()
 

Detailed Description

Definition at line 20 of file EasyPeasyICS.php.

Constructor & Destructor Documentation

◆ __construct()

EasyPeasyICS::__construct (   $calendarName = "")

Constructor.

Parameters
string$calendarName

Definition at line 37 of file EasyPeasyICS.php.

References $calendarName.

38  {
39  $this->calendarName = $calendarName;
40  }

Member Function Documentation

◆ addEvent()

EasyPeasyICS::addEvent (   $start,
  $end,
  $summary = '',
  $description = '',
  $url = '',
  $uid = '' 
)

Add an event to this calendar.

Parameters
string$startThe start date and time as a unix timestamp
string$endThe end date and time as a unix timestamp
string$summaryA summary or title for the event
string$descriptionA description of the event
string$urlA URL for the event
string$uidA unique identifier for the event - generated automatically if not provided
Returns
array An array of event details, including any generated UID

Definition at line 52 of file EasyPeasyICS.php.

References $url.

53  {
54  if (empty($uid)) {
55  $uid = md5(uniqid(mt_rand(), true)) . '@EasyPeasyICS';
56  }
57  $event = array(
58  'start' => gmdate('Ymd', $start) . 'T' . gmdate('His', $start) . 'Z',
59  'end' => gmdate('Ymd', $end) . 'T' . gmdate('His', $end) . 'Z',
60  'summary' => $summary,
61  'description' => $description,
62  'url' => $url,
63  'uid' => $uid
64  );
65  $this->events[] = $event;
66  return $event;
67  }
$url
Definition: shib_logout.php:72

◆ clearEvents()

EasyPeasyICS::clearEvents ( )

Clear all events.

Definition at line 80 of file EasyPeasyICS.php.

81  {
82  $this->events = array();
83  }

◆ getEvents()

EasyPeasyICS::getEvents ( )
Returns
array Get the array of events.

Definition at line 72 of file EasyPeasyICS.php.

References $events.

73  {
74  return $this->events;
75  }

◆ getName()

EasyPeasyICS::getName ( )

Get the name of the calendar.

Returns
string

Definition at line 89 of file EasyPeasyICS.php.

References $calendarName.

90  {
91  return $this->calendarName;
92  }

◆ render()

EasyPeasyICS::render (   $output = true)

Render and optionally output a vcal string.

Parameters
bool$outputWhether to output the calendar data directly (the default).
Returns
string The complete rendered vlal

Definition at line 108 of file EasyPeasyICS.php.

References $calendarName, and $filename.

109  {
110  //Add header
111  $ics = 'BEGIN:VCALENDAR
112 METHOD:PUBLISH
113 VERSION:2.0
114 X-WR-CALNAME:' . $this->calendarName . '
115 PRODID:-//hacksw/handcal//NONSGML v1.0//EN';
116 
117  //Add events
118  foreach ($this->events as $event) {
119  $ics .= '
120 BEGIN:VEVENT
121 UID:' . $event['uid'] . '
122 DTSTAMP:' . gmdate('Ymd') . 'T' . gmdate('His') . 'Z
123 DTSTART:' . $event['start'] . '
124 DTEND:' . $event['end'] . '
125 SUMMARY:' . str_replace("\n", "\\n", $event['summary']) . '
126 DESCRIPTION:' . str_replace("\n", "\\n", $event['description']) . '
127 URL;VALUE=URI:' . $event['url'] . '
128 END:VEVENT';
129  }
130 
131  //Add footer
132  $ics .= '
133 END:VCALENDAR';
134 
135  if ($output) {
136  //Output
138  //Filename needs quoting if it contains spaces
139  if (strpos($filename, ' ') !== false) {
140  $filename = '"'.$filename.'"';
141  }
142  header('Content-type: text/calendar; charset=utf-8');
143  header('Content-Disposition: inline; filename=' . $filename . '.ics');
144  echo $ics;
145  }
146  return $ics;
147  }
$filename
Definition: buildRTE.php:89

◆ setName()

EasyPeasyICS::setName (   $name)

Set the name of the calendar.

Parameters
$name

Definition at line 98 of file EasyPeasyICS.php.

99  {
100  $this->calendarName = $name;
101  }

Field Documentation

◆ $calendarName

EasyPeasyICS::$calendarName
protected

Definition at line 26 of file EasyPeasyICS.php.

Referenced by __construct(), getName(), and render().

◆ $events

EasyPeasyICS::$events = array()
protected

Definition at line 31 of file EasyPeasyICS.php.

Referenced by getEvents().


The documentation for this class was generated from the following file: