phpmailer-php5/extras/EasyPeasyICS.php
public function render($output = true)
    {
        //Add header
        $ics = 'BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
X-WR-CALNAME:' . $this->calendarName . '
PRODID:-//hacksw/handcal//NONSGML v1.0//EN';

        //Add events
        foreach ($this->events as $event) {
            $ics .= '
BEGIN:VEVENT
UID:' . $event['uid'] . '
DTSTAMP:' . gmdate('Ymd') . 'T' . gmdate('His') . 'Z
DTSTART:' . $event['start'] . '
DTEND:' . $event['end'] . '
SUMMARY:' . str_replace("\n", "\\n", $event['summary']) . '
DESCRIPTION:' . str_replace("\n", "\\n", $event['description']) . '
URL;VALUE=URI:' . $event['url'] . '
END:VEVENT';
        }

        //Add footer
        $ics .= '
END:VCALENDAR';

        if ($output) {
            //Output
            $filename = $this->calendarName;
            //Filename needs quoting if it contains spaces
            if (strpos($filename, ' ') !== false) {
                $filename = '"'.$filename.'"';
            }
            header('Content-type: text/calendar; charset=utf-8');
            header('Content-Disposition: inline; filename=' . $filename . '.ics');
            echo $ics;
        }
        return $ics;
    }
public function render($output = true)
    {
        //Add header
        $ics = 'BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
X-WR-CALNAME:' . $this->calendarName . '
PRODID:-//hacksw/handcal//NONSGML v1.0//EN';

        //Add events
        foreach ($this->events as $event) {
            $ics .= '
BEGIN:VEVENT
UID:' . $event['uid'] . '
DTSTAMP:' . gmdate('Ymd') . 'T' . gmdate('His') . 'Z
DTSTART:' . $event['start'] . '
DTEND:' . $event['end'] . '
SUMMARY:' . str_replace("\n", "\\n", $event['summary']) . '
DESCRIPTION:' . str_replace("\n", "\\n", $event['description']) . '
URL;VALUE=URI:' . $event['url'] . '
END:VEVENT';
        }

        //Add footer
        $ics .= '
END:VCALENDAR';

        if ($output) {
            //Output
            $filename = $this->calendarName;
            //Filename needs quoting if it contains spaces
            if (strpos($filename, ' ') !== false) {
                $filename = '"'.$filename.'"';
            }
            header('Content-type: text/calendar; charset=utf-8');
            header('Content-Disposition: inline; filename=' . $filename . '.ics');
            echo $ics;
        }
        return $ics;
    }
public function render ( $ output = true ) { //Add header $ ics = 'BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
X-WR-CALNAME:' . $ this -> calendarName . '
PRODID:-//hacksw/handcal//NONSGML v1.0//EN' ; //Add events foreach ( $ this -> events as $ event ) { $ ics .= '
BEGIN:VEVENT
UID:' . $ event [ 'uid' ] . '
DTSTAMP:' . gmdate ( 'Ymd' ) . 'T' . gmdate ( 'His' ) . 'Z
DTSTART:' . $ event [ 'start' ] . '
DTEND:' . $ event [ 'end' ] . '
SUMMARY:' . str_replace ( "\n" , "\\n" , $ event [ 'summary' ] ) . '
DESCRIPTION:' . str_replace ( "\n" , "\\n" , $ event [ 'description' ] ) . '
URL;VALUE=URI:' . $ event [ 'url' ] . '
END:VEVENT' ; } //Add footer $ ics .= '
END:VCALENDAR' ; if ( $ output ) { //Output $ filename = $ this -> calendarName ; //Filename needs quoting if it contains spaces if ( strpos ( $ filename , ' ' ) !== false ) { $ filename = '"' . $ filename . '"' ; } header ( 'Content-type: text/calendar; charset=utf-8' ) ; header ( 'Content-Disposition: inline; filename=' . $ filename . '.ics' ) ; echo $ ics ; } return $ ics ; }
Render and optionally output a vcal string.
@param bool $output Whether to output the calendar data directly (the default).
@return string The complete rendered vlal
Render and optionally output a vcal string .