本文整理汇总了PHP中vcalendar类的典型用法代码示例。如果您正苦于以下问题:PHP vcalendar类的具体用法?PHP vcalendar怎么用?PHP vcalendar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vcalendar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getICalPeriods
/**
* @return array
*/
private function getICalPeriods()
{
$response = [];
$iCalLink = $this->checkForICalHref();
if ($this->checkAccessToFile($iCalLink)) {
$startArray = array();
$endArray = array();
require_once 'iCalcreator.php';
$v = new \vcalendar();
// initiate new CALENDAR
$config = array("unique_id" => "ukrapts.com", "url" => "{$iCalLink}");
$v->setConfig($config);
$v->parse();
$v->sort();
$i = 0;
while ($comp = $v->getComponent("VEVENT")) {
$dtstart_array = $comp->getProperty("DTSTART", 1, TRUE);
$dtstart = $dtstart_array["value"];
$startDate = "{$dtstart["year"]}-{$dtstart["month"]}-{$dtstart["day"]}";
$dtend_array = $comp->getProperty("dtend", 1, TRUE);
$dtend = $dtend_array["value"];
$endDate = "{$dtend["year"]}-{$dtend["month"]}-{$dtend["day"]}";
if ($endDate >= $this->DBQueries()->currentDate()) {
$startArray[] = $startDate;
$endArray[] = $endDate;
}
$i++;
}
sort($startArray);
sort($endArray);
$response['start'] = $startArray;
$response['end'] = $endArray;
}
return $response;
}
示例2: createVevent
/**
* Creates an event in an iCalendar
*
* @param vcalendar $cal
* @return vevent
*/
public function createVevent($cal)
{
$event = $cal->newComponent('vevent');
$event->setProperty('dtstart', $this->makeDateArray());
// End date must be the day after to make it an all-day event
$endDate = clone $this;
$endDate->addDays(1);
$event->setProperty('dtend', $endDate->makeDateArray());
return $event;
}
示例3: row2array
private static function row2array($row, $timezone, $hostname, $uid, $namespace_id)
{
$v = new vcalendar();
$v->setConfig('unique_id', $hostname);
$v->setProperty('method', 'PUBLISH');
$v->setProperty("x-wr-calname", "AnimexxCal");
$v->setProperty("X-WR-CALDESC", "Animexx Calendar");
$v->setProperty("X-WR-TIMEZONE", $timezone);
if ($row["adjust"]) {
$start = datetime_convert('UTC', date_default_timezone_get(), $row["start"]);
$finish = datetime_convert('UTC', date_default_timezone_get(), $row["finish"]);
} else {
$start = $row["start"];
$finish = $row["finish"];
}
$allday = strpos($start, "00:00:00") !== false && strpos($finish, "00:00:00") !== false;
/*
if ($allday) {
$dat = Datetime::createFromFormat("Y-m-d H:i:s", $finish_tmp);
$dat->sub(new DateInterval("P1D"));
$finish = datetime_convert("UTC", date_default_timezone_get(), $dat->format("Y-m-d H:i:s"));
var_dump($finish);
}
*/
$subject = substr(preg_replace("/\\[[^\\]]*\\]/", "", $row["desc"]), 0, 100);
$description = preg_replace("/\\[[^\\]]*\\]/", "", $row["desc"]);
$vevent = dav_create_vevent(wdcal_mySql2icalTime($row["start"]), wdcal_mySql2icalTime($row["finish"]), false);
$vevent->setLocation(icalendar_sanitize_string($row["location"]));
$vevent->setSummary(icalendar_sanitize_string($subject));
$vevent->setDescription(icalendar_sanitize_string($description));
$v->setComponent($vevent);
$ical = $v->createCalendar();
return array("uid" => $uid, "namespace" => CALDAV_NAMESPACE_FRIENDICA_NATIVE, "namespace_id" => $namespace_id, "date" => $row["edited"], "data_uri" => "friendica-" . $namespace_id . "-" . $row["id"] . "@" . $hostname, "data_subject" => $subject, "data_location" => $row["location"], "data_description" => $description, "data_start" => $start, "data_end" => $finish, "data_allday" => $allday, "data_type" => $row["type"], "ical" => $ical, "ical_size" => strlen($ical), "ical_etag" => md5($ical));
}
示例4: ical
public function ical($params)
{
$this->setView('ical.php');
$official = isset($params['official']);
$group_name = isset($params['group']) ? $params['group'] : null;
$event_model = new Event_Model();
$events = $event_model->getUpcoming($group_name, $official, false);
// Creation of the iCal content
$cache_entry = 'ical-' . (isset($group_name) ? $group_name : '') . '-' . ($official ? 'official' : 'non-official');
$content = Cache::read($cache_entry);
if (!$content) {
require_once APP_DIR . 'classes/class.iCalcreator.php';
$cal = new vcalendar();
$cal->setConfig('unique_id', $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
$cal->setProperty('method', 'PUBLISH');
$cal->setProperty('x-wr-calname', $official ? __('EVENTS_TITLE_OFFICIAL') : __('EVENTS_TITLE_NONOFFICIAL'));
$cal->setProperty('X-WR-CALDESC', '');
$cal->setProperty('X-WR-TIMEZONE', date('e'));
foreach ($events as $event) {
$vevent = new vevent();
$vevent->setProperty('dtstart', array('year' => (int) date('Y', $event['date_start']), 'month' => (int) date('n', $event['date_start']), 'day' => (int) date('j', $event['date_start']), 'hour' => (int) date('G', $event['date_start']), 'min' => (int) date('i', $event['date_start']), 'sec' => (int) date('s', $event['date_start'])));
$vevent->setProperty('dtend', array('year' => (int) date('Y', $event['date_end']), 'month' => (int) date('n', $event['date_end']), 'day' => (int) date('j', $event['date_end']), 'hour' => (int) date('G', $event['date_end']), 'min' => (int) date('i', $event['date_end']), 'sec' => (int) date('s', $event['date_end'])));
$vevent->setProperty('summary', $event['title']);
$vevent->setProperty('description', $event['message']);
$cal->setComponent($vevent);
}
$content = $cal->createCalendar();
Cache::write($cache_entry, $content, 2 * 3600);
}
$this->set('content', $content);
}
示例5: onPreInit
public function onPreInit($param)
{
if (isset($_GET['idtm_termin'])) {
$TerminRecord = TerminRecord::finder()->findByPK($_GET['idtm_termin']);
} else {
echo "Kein Termin";
exit;
}
date_default_timezone_set('Europe/Berlin');
$v = new vcalendar();
// initiate new CALENDAR
$v->setConfig('pliq_hpartner', 'planlogiq.com');
// config with site domain
$e = new vevent();
// initiate a new EVENT
$SDateArray = explode('-', $TerminRecord->ter_startdate);
$EDateArray = explode('-', $TerminRecord->ter_enddate);
$STimeArray = explode(':', $TerminRecord->ter_starttime);
$ETimeArray = explode(':', $TerminRecord->ter_endtime);
$e->setProperty('categories', ActivityRecord::finder()->findByPK($TerminRecord->idtm_activity)->act_name);
// catagorize
$e->setProperty('dtstart', $SDateArray[0], $SDateArray[1], $SDateArray[2], $STimeArray[0], $STimeArray[1], 00);
// 24 dec 2006 19.30
$e->setProperty('dtend', $EDateArray[0], $EDateArray[1], $EDateArray[2], $ETimeArray[0], $ETimeArray[1], 00);
// 24 dec 2006 19.30
//$e->setProperty( 'duration'
// , 0, 0, 3 ); // 3 hours
$e->setProperty('summary', $TerminRecord->ter_betreff);
// describe the event
$e->setProperty('description', $TerminRecord->ter_descr);
// describe the event
$e->setProperty('location', $TerminRecord->ter_ort);
// locate the event
$v->addComponent($e);
// add component to calendar
/* alt. production */
// $v->returnCalendar(); // generate and redirect output to user browser
/* alt. dev. and test */
$str = $v->createCalendar();
// generate and get output in string, for testing?
$this->getResponse()->appendHeader("Content-Type:" . $this->header);
$this->getResponse()->appendHeader("Content-Disposition:inline;filename=" . $this->docName . '.' . $this->ext);
echo $str;
$writer->save('php://output');
exit;
}
示例6: display
function display($tpl = null)
{
$mainframe = JFactory::getApplication();
$option = JRequest::getCmd('option');
$model = $this->getModel();
$results = $model->getResults(JRequest::getVar('p', 0, '', 'int'));
$project = $model->getProject(JRequest::getVar('p', 0, '', 'int'));
$document = JFactory::getDocument();
$v = new vcalendar();
// initiate new CALENDAR
$v->setConfig('project' . $project->id, $mainframe->getCfg('live_site'));
// config with site domain
$v->setProperty('X-WR-CALNAME', $project->name);
// set some X-properties, name, content.. .
$v->setProperty('X-WR-CALDESC', JText::_('COM_TRACKS_Project_calendar'));
$v->setConfig("filename", 'project_' . $project->id . '.ics');
foreach ((array) $results as $result) {
if (!ereg('([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})', $result->start_date, $start_date)) {
continue;
}
$e = new vevent();
// initiate a new EVENT
$e->setProperty('categories', $project->name);
// catagorize
$e->setProperty('dtstart', $start_date[1], $start_date[2], $start_date[3], $start_date[4], $start_date[5], $start_date[6]);
if (ereg('([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})', $result->end_date, $end_date)) {
$e->setProperty('dtend', $end_date[1], $end_date[2], $end_date[3], $end_date[4], $end_date[5], $end_date[6]);
}
$description = array();
$description[] = $result->round_name;
if ($result->winner && $result->winner->last_name) {
$winner = JText::_('COM_TRACKS_Winner') . $result->winner->first_name . ' ' . $result->winner->last_name;
if ($result->winner->team_name) {
$winner .= ' (' . $result->winner->team_name . ')';
}
$description[] = $winner;
}
$description = implode('\\n', $description);
$e->setProperty('description', $description);
// describe the event
$e->setProperty('location', $result->round_name);
// locate the event
$v->addComponent($e);
// add component to calendar
}
/* alt. production */
// $v->returnCalendar(); // generate and redirect output to user browser
/* alt. dev. and test */
$str = $v->createCalendar();
// generate and get output in string, for testing?
// echo $str;return;
$v->returnCalendar();
}
示例7: setEventsFromICal
/**
* The file contents is looked at and events are created here.
* @param string $fileContents
* @return integer The number of events saved.
*/
public function setEventsFromICal($fullDir, $fullFileName, $personId)
{
//start parse of local file
$v = new vcalendar();
// set directory
$v->setConfig('directory', $fullDir);
// set file name
$v->setConfig('filename', $fullFileName);
$v->parse();
$count = 0;
foreach ($v->components as $component => $info) {
# get first vevent
$comp = $v->getComponent("VEVENT");
$summary_array = $comp->getProperty("summary", 1, TRUE);
//echo "Event: ", $summary_array["value"], "\n";
$dtstart_array = $comp->getProperty("dtstart", 1, TRUE);
$dtstart = $dtstart_array["value"];
$startDate = "{$dtstart["year"]}-{$dtstart["month"]}-{$dtstart["day"]}";
$startTime = "{$dtstart["hour"]}:{$dtstart["min"]}:{$dtstart["sec"]}";
$dtend_array = $comp->getProperty("dtend", 1, TRUE);
$dtend = $dtend_array["value"];
$endDate = "{$dtend["year"]}-{$dtend["month"]}-{$dtend["day"]}";
$endTime = "{$dtend["hour"]}:{$dtend["min"]}:{$dtend["sec"]}";
//echo "start: ", $startDate,"T",$startTime, "\n";
//echo "end: ", $endDate,"T",$endTime, "\n";
$location_array = $comp->getProperty("location", 1, TRUE);
//echo "Location: ", $location_array["value"], "\n <br>";
//TODO: Check that this event does not already exist.
$event = new Event();
$event->setPersonId($personId);
$event->setName($summary_array["value"]);
$event->setStartTime($startDate . "T" . $startTime);
$event->setEndTime($endDate . "T" . $endTime);
$event->setLocation($location_array["value"]);
$event->save();
$count++;
}
return $count;
}
示例8: create
function create($name, $description = '', $tz = 'US/Pacific')
{
$v = new vcalendar();
$v->setConfig('unique_id', $name . '.' . 'yourdomain.com');
$v->setProperty('method', 'PUBLISH');
$v->setProperty('x-wr-calname', $name . ' Calendar');
$v->setProperty("X-WR-CALDESC", $description);
$v->setProperty("X-WR-TIMEZONE", $tz);
$this->calendar = $v;
}
示例9: exportar
function exportar($aObj = array(), $directo_a_browser = 1)
{
if (is_array($aObj)) {
$v = new vcalendar();
$v->setConfig('DIRECTORY', sfConfig::get('sf_cache_dir'));
foreach ($aObj as $link_evento) {
if ($link_evento->getEvento()) {
$e = new vevent();
$e->setProperty('DESCRIPTION', '');
$e->setProperty('SUMMARY', $link_evento->getEvento()->getTitulo());
$e->setProperty('class', 'PUBLIC');
$aFechaInicio = getdate(strtotime($link_evento->getEvento()->getFechaInicio()));
$e->setProperty('dtstart', $aFechaInicio['year'], $aFechaInicio['mon'], $aFechaInicio['mday'], $aFechaInicio['hours'], $aFechaInicio['minutes'], 0);
$aFechaFin = getdate(strtotime($link_evento->getEvento()->getFechaFin()));
$e->setProperty('dtend', $aFechaFin['year'], $aFechaFin['mon'], $aFechaFin['mday'], $aFechaFin['hours'], $aFechaFin['minutes'], 0);
$e->setProperty('dtstamp', gmdate('Ymd\\THi00\\Z'));
if ($link_evento->getEvento()->getFrecuencia()) {
$freq = $this->aFreq[$link_evento->getEvento()->getFrecuencia()];
$interval = $link_evento->getEvento()->getFrecuenciaIntervalo();
$aRrule = array();
$aRrule['FREQ'] = $freq;
$aRrule['INTERVAL'] = $interval;
if ($freq == "WEEKLY") {
$aRrule['BYDAY'] = array_chunk(explode(",", $link_evento->getEvento()->getRecurrenciaDiasIcal()), 1);
}
if ($link_evento->getEvento()->getRecurrenciaFin() != "") {
if (is_numeric($link_evento->getEvento()->getRecurrenciaFin())) {
$aRrule['COUNT'] = $link_evento->getEvento()->getRecurrenciaFin();
} else {
$aRrule['UNTIL'] = gmdate('Ymd\\THi00\\Z', strtotime($link_evento->getEvento()->getRecurrenciaFin()));
}
}
$e->setProperty('rrule', $aRrule);
}
$v->addComponent($e);
}
}
if ($directo_a_browser == 1) {
$v->returnCalendar();
} else {
$v->saveCalendar();
return $v->getConfig('filename');
}
} else {
$error = 'No envío un array para la exportación';
throw new Exception($error);
}
}
示例10: generateIcal
/**
* Export an event as iCalendar (ics)
*/
public function generateIcal($eventID)
{
$ical = new \vcalendar();
$ical->setConfig('ical_' . $this->id);
$ical->setProperty('method', 'PUBLISH');
$ical->setProperty("X-WR-TIMEZONE", $GLOBALS['TL_CONFIG']['timeZone']);
$time = time();
// Get event
$objEvent = \CalendarEventsModel::findByPk($eventID);
$vevent = new \vevent();
if ($objEvent->addTime) {
$vevent->setProperty('dtstart', array('year' => date('Y', $objEvent->startTime), 'month' => date('m', $objEvent->startTime), 'day' => date('d', $objEvent->startTime), 'hour' => date('H', $objEvent->startTime), 'min' => date('i', $objEvent->startTime), 'sec' => 0));
$vevent->setProperty('dtend', array('year' => date('Y', $objEvent->endTime), 'month' => date('m', $objEvent->endTime), 'day' => date('d', $objEvent->endTime), 'hour' => date('H', $objEvent->endTime), 'min' => date('i', $objEvent->endTime), 'sec' => 0));
} else {
$vevent->setProperty('dtstart', date('Ymd', $objEvent->startDate), array('VALUE' => 'DATE'));
if (!strlen($objEvent->endDate) || $objEvent->endDate == 0) {
$vevent->setProperty('dtend', date('Ymd', $objEvent->startDate + 24 * 60 * 60), array('VALUE' => 'DATE'));
} else {
$vevent->setProperty('dtend', date('Ymd', $objEvent->endDate + 24 * 60 * 60), array('VALUE' => 'DATE'));
}
}
$vevent->setProperty('summary', $objEvent->title, ENT_QUOTES, 'UTF-8');
$vevent->setProperty('description', strip_tags($objEvent->details ? $objEvent->details : $objEvent->teaser));
if ($objEvent->recurring) {
$count = 0;
$arrRepeat = deserialize($objEvent->repeatEach);
$arg = $arrRepeat['value'];
$unit = $arrRepeat['unit'];
if ($arg == 1) {
$unit = substr($unit, 0, -1);
}
$strtotime = '+ ' . $arg . ' ' . $unit;
$newstart = strtotime($strtotime, $objEvent->startTime);
$newend = strtotime($strtotime, $objEvent->endTime);
$freq = 'YEARLY';
switch ($arrRepeat['unit']) {
case 'days':
$freq = 'DAILY';
break;
case 'weeks':
$freq = 'WEEKLY';
break;
case 'months':
$freq = 'MONTHLY';
break;
case 'years':
$freq = 'YEARLY';
break;
}
$rrule = array('FREQ' => $freq);
if ($objEvent->recurrences > 0) {
$rrule['count'] = $objEvent->recurrences;
}
if ($arg > 1) {
$rrule['INTERVAL'] = $arg;
}
$vevent->setProperty('rrule', $rrule);
}
/*
* begin module event_recurrences handling
*/
if ($objEvent->repeatExecptions) {
$arrSkipDates = deserialize($objEvent->repeatExecptions);
foreach ($arrSkipDates as $skipDate) {
$exTStamp = strtotime($skipDate);
$exdate = array(array(date('Y', $exTStamp), date('m', $exTStamp), date('d', $exTStamp), date('H', $objEvent->startTime), date('i', $objEvent->startTime), date('s', $objEvent->startTime)));
$vevent->setProperty('exdate', $exdate);
}
}
/*
* end module event_recurrences handling
*/
$ical->setComponent($vevent);
$ical->setConfig("FILENAME", urlencode($objEvent->title) . ".ics");
$ical->returnCalendar();
}
示例11: _insert_event_in_calendar
/**
* Convert an event from a feed into a new Ai1ec_Event object and add it to
* the calendar.
*
* @param Ai1ec_Event $event Event object.
* @param vcalendar $calendar Calendar object.
* @param bool $export States whether events are created for export.
* @param array $params Additional parameters for export.
*
* @return void
*/
protected function _insert_event_in_calendar(Ai1ec_Event $event, vcalendar $calendar, $export = false, array $params = array())
{
$tz = $this->_registry->get('date.timezone')->get_default_timezone();
$e =& $calendar->newComponent('vevent');
$uid = '';
if ($event->get('ical_uid')) {
$uid = addcslashes($event->get('ical_uid'), "\\;,\n");
} else {
$uid = $event->get_uid();
$event->set('ical_uid', $uid);
$event->save(true);
}
$e->setProperty('uid', $this->_sanitize_value($uid));
$e->setProperty('url', get_permalink($event->get('post_id')));
// =========================
// = Summary & description =
// =========================
$e->setProperty('summary', $this->_sanitize_value(html_entity_decode(apply_filters('the_title', $event->get('post')->post_title), ENT_QUOTES, 'UTF-8')));
$content = apply_filters('the_content', $event->get('post')->post_content);
$content = str_replace(']]>', ']]>', $content);
$content = html_entity_decode($content, ENT_QUOTES, 'UTF-8');
// Prepend featured image if available.
$size = null;
$avatar = $this->_registry->get('view.event.avatar');
if ($img_url = $avatar->get_post_thumbnail_url($event, $size)) {
$content = '<div class="ai1ec-event-avatar alignleft timely"><img src="' . esc_attr($img_url) . '" width="' . $size[0] . '" height="' . $size[1] . '" /></div>' . $content;
}
if (isset($params['no_html']) && $params['no_html']) {
$e->setProperty('description', $this->_sanitize_value(strip_tags(strip_shortcodes($content))));
if (!empty($content)) {
$html_content = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">\\n' . '<HTML>\\n<HEAD>\\n<TITLE></TITLE>\\n</HEAD>\\n<BODY>' . $content . '</BODY></HTML>';
$e->setProperty('X-ALT-DESC', $this->_sanitize_value($html_content), array('FMTTYPE' => 'text/html'));
unset($html_content);
}
} else {
$e->setProperty('description', $this->_sanitize_value($content));
}
$revision = (int) current(array_keys(wp_get_post_revisions($event->get('post_id'))));
$e->setProperty('sequence', $revision);
// =====================
// = Start & end times =
// =====================
$dtstartstring = '';
$dtstart = $dtend = array();
if ($event->is_allday()) {
$dtstart['VALUE'] = $dtend['VALUE'] = 'DATE';
// For exporting all day events, don't set a timezone
if ($tz && !$export) {
$dtstart['TZID'] = $dtend['TZID'] = $tz;
}
// For exportin' all day events, only set the date not the time
if ($export) {
$e->setProperty('dtstart', $this->_sanitize_value($event->get('start')->format('Ymd')), $dtstart);
$e->setProperty('dtend', $this->_sanitize_value($event->get('end')->format('Ymd')), $dtend);
} else {
$e->setProperty('dtstart', $this->_sanitize_value($event->get('start')->format("Ymd\\T")), $dtstart);
$e->setProperty('dtend', $this->_sanitize_value($event->get('end')->format("Ymd\\T")), $dtend);
}
} else {
if ($tz) {
$dtstart['TZID'] = $dtend['TZID'] = $tz;
}
// This is used later.
$dtstartstring = $event->get('start')->format("Ymd\\THis");
$e->setProperty('dtstart', $this->_sanitize_value($dtstartstring), $dtstart);
$e->setProperty('dtend', $this->_sanitize_value($event->get('end')->format("Ymd\\THis")), $dtend);
}
// ========================
// = Latitude & longitude =
// ========================
if (floatval($event->get('latitude')) || floatval($event->get('longitude'))) {
$e->setProperty('geo', $event->get('latitude'), $event->get('longitude'));
}
// ===================
// = Venue & address =
// ===================
if ($event->get('venue') || $event->get('address')) {
$location = array($event->get('venue'), $event->get('address'));
$location = array_filter($location);
$location = implode(' @ ', $location);
$e->setProperty('location', $this->_sanitize_value($location));
}
$categories = array();
$language = get_bloginfo('language');
foreach ($this->_taxonomy_model->get_post_categories($event->get('post_id')) as $cat) {
$categories[] = $cat->name;
}
$e->setProperty('categories', implode(',', $categories), array("LANGUAGE" => $language));
$tags = array();
//.........这里部分代码省略.........
示例12: array
$e->setProperty('categories', 'PERSONAL');
$e->setProperty('categories', 'SPECIAL OCCASION');
$e->setProperty('rrule', array('FREQ' => 'YEARLY'));
echo nl2br($v->createCalendar());
// generate and get output in string, for testing?
echo "<br />\n\n";
/*
* BEGIN:VTODO
* UID:19970901T130000Z-123404@host.com
* DTSTAMP:19970901T1300Z
* DTSTART:19970415T133000Z
* DUE:19970416T045959Z
* SUMMARY:1996 Income Tax Preparation
* CLASS:CONFIDENTIAL
* CATEGORIES:FAMILY,FINANCE
* PRIORITY:1
* STATUS:NEEDS-ACTION
* END:VTODO
*/
$c = new vcalendar(array('unique_id' => 'kigkonsult.se'));
$t =& $c->newComponent('vtodo');
$t->setProperty('dtstart', '19970415T133000 GMT');
$t->setProperty('due', '19970416T045959 GMT');
$t->setProperty('summary', '1996 Income Tax Preparation');
$t->setProperty('class', 'CONFIDENTIAL');
$t->setProperty('categories', 'FAMILY');
$t->setProperty('categories', 'FINANCE');
$t->setProperty('priority', 1);
$t->setProperty('status', 'NEEDS-ACTION');
echo nl2br($v->createCalendar());
// generate and get output in string, for testing?
示例13: _get_events_url
function _get_events_url(&$events, $url, $date)
{
$v = new vcalendar();
$v->setConfig('unique_id', 'barchat');
$v->setProperty('method', 'PUBLISH');
$v->setProperty("x-wr-calname", "Calendar Sample");
$v->setProperty("X-WR-CALDESC", "Calendar Description");
$v->setProperty("X-WR-TIMEZONE", "America/New_York");
$v->setConfig('url', $url);
try {
$v->parse();
} catch (exception $e) {
}
$v->sort();
$m = $date->format('n');
$d = $date->format('j');
$y = $date->format('Y');
$eventArray = $v->selectComponents($y, $m, 1, $y, $m, 31);
foreach ((array) $eventArray as $yearkey => $yeararray) {
foreach ((array) $yeararray as $monthkey => $montharray) {
foreach ((array) $montharray as $daykey => $dayarray) {
foreach ((array) $dayarray as $eventnumber => $event) {
//echo "{$y}-{$m}-{$daykey} [{$eventnumber}]: ";
$time = $event->dtstart['value'];
$tz = $event->dtstart['params']['TZID'] == '' ? 'America/New_York' : $event->dtstart['params']['TZID'];
if ($time['tz'] == 'Z') {
$tz = 'GMT';
}
if (isset($event->dtstart['params']['VALUE']) && $event->dtstart['params']['VALUE'] == 'DATE') {
$allday = new DateTime("{$time['year']}-{$time['month']}-{$time['day']}", new DateTimeZone($tz));
$allday->setTimezone(new DateTimeZone('America/New_York'));
$d = sprintf('%04d-%02d-%02d', $y, $m, $daykey);
if (!is_array($events[$d])) {
$events[$d] = array();
}
$alldayint = intval($allday->format('U'));
while (isset($events[$d][$alldayint])) {
$alldayint++;
}
$events[$d][$alldayint] = '<span class="calendartime">All Day</span> ' . trim($event->summary['value']);
//var_dump(date('r', $allday) . ' = ' . $allday);
//var_dump($event->summary['value']);
} else {
if (isset($event->xprop['X-CURRENT-DTSTART'])) {
$dt = new DateTime($event->xprop['X-CURRENT-DTSTART']['value'], new DateTimeZone($tz));
} else {
$dt = new DateTime("{$time['year']}-{$time['month']}-{$time['day']} {$time['hour']}:{$time['min']}:{$time['sec']}", new DateTimeZone($tz));
}
$dt->setTimezone(new DateTimeZone('America/New_York'));
if (isset($event->xprop['X-CURRENT-DTEND'])) {
$dte = new DateTime($event->xprop['X-CURRENT-DTEND']['value'], new DateTimeZone($tz));
} else {
$timee = $event->dtstart['value'];
$dte = new DateTime("{$timee['year']}-{$timee['month']}-{$timee['day']} {$timee['hour']}:{$timee['min']}:{$timee['sec']}", new DateTimeZone($tz));
}
$dte->setTimezone(new DateTimeZone('America/New_York'));
if (!is_array($events[$d])) {
$events[$d] = array();
}
$d = sprintf('%04d-%02d-%02d', $y, $m, $daykey);
$daytime = $dt->format('U');
while (isset($events[$d][$daytime])) {
$daytime++;
}
if ($dt->format('g:ia') != $dte->format('g:ia')) {
$events[$d][$daytime] = '<span class="calendartime">' . $dt->format('g:ia') . ' - ' . $dte->format('g:ia') . '</span> ' . trim($event->summary['value']);
} else {
$events[$d][$daytime] = '<span class="calendartime">' . $dt->format('g:ia') . '</span> ' . trim($event->summary['value']);
}
//var_dump($event->dtstart);
//var_dump($event->summary['value']);
//var_dump($dt->format('r'));
//var_dump($event);
}
}
}
}
}
}
示例14: generateIcal
/**
* Generate ical file content
*
* @param $who user ID
* @param $who_group group ID
* @param $limititemtype itemtype only display this itemtype (default '')
*
* @return icalendar string
**/
static function generateIcal($who, $who_group, $limititemtype = '')
{
global $CFG_GLPI;
if ($who === 0 && $who_group === 0) {
return false;
}
include_once GLPI_ROOT . "/lib/icalcreator/iCalcreator.class.php";
$v = new vcalendar();
if (!empty($CFG_GLPI["version"])) {
$v->setConfig('unique_id', "GLPI-Planning-" . trim($CFG_GLPI["version"]));
} else {
$v->setConfig('unique_id', "GLPI-Planning-UnknownVersion");
}
$tz = date_default_timezone_get();
$v->setConfig('TZID', $tz);
$v->setProperty("method", "PUBLISH");
$v->setProperty("version", "2.0");
$v->setProperty("X-WR-TIMEZONE", $tz);
$xprops = array("X-LIC-LOCATION" => $tz);
iCalUtilityFunctions::createTimezone($v, $tz, $xprops);
$v->setProperty("x-wr-calname", "GLPI-" . $who . "-" . $who_group);
$v->setProperty("calscale", "GREGORIAN");
$interv = array();
$begin = time() - MONTH_TIMESTAMP * 12;
$end = time() + MONTH_TIMESTAMP * 12;
$begin = date("Y-m-d H:i:s", $begin);
$end = date("Y-m-d H:i:s", $end);
$params = array('who' => $who, 'who_group' => $who_group, 'begin' => $begin, 'end' => $end);
$interv = array();
if (empty($limititemtype)) {
foreach ($CFG_GLPI['planning_types'] as $itemtype) {
$interv = array_merge($interv, $itemtype::populatePlanning($params));
}
} else {
$interv = $limititemtype::populatePlanning($params);
}
if (count($interv) > 0) {
foreach ($interv as $key => $val) {
$vevent = new vevent();
//initiate EVENT
if (isset($val['itemtype'])) {
if (isset($val[getForeignKeyFieldForItemType($val['itemtype'])])) {
$vevent->setProperty("uid", $val['itemtype'] . "#" . $val[getForeignKeyFieldForItemType($val['itemtype'])]);
} else {
$vevent->setProperty("uid", "Other#" . $key);
}
} else {
$vevent->setProperty("uid", "Other#" . $key);
}
$vevent->setProperty("dstamp", $val["begin"]);
$vevent->setProperty("dtstart", $val["begin"]);
$vevent->setProperty("dtend", $val["end"]);
if (isset($val["tickets_id"])) {
$vevent->setProperty("summary", sprintf(__('Ticket #%1$s %2$s'), $val["tickets_id"], $val["name"]));
} else {
if (isset($val["name"])) {
$vevent->setProperty("summary", $val["name"]);
}
}
if (isset($val["content"])) {
$text = $val["content"];
// be sure to replace nl by \r\n
$text = preg_replace("/<br( [^>]*)?" . ">/i", "\r\n", $text);
$text = Html::clean($text);
$vevent->setProperty("description", $text);
} else {
if (isset($val["name"])) {
$text = $val["name"];
// be sure to replace nl by \r\n
$text = preg_replace("/<br( [^>]*)?" . ">/i", "\r\n", $text);
$text = Html::clean($text);
$vevent->setProperty("description", $text);
}
}
if (isset($val["url"])) {
$vevent->setProperty("url", $val["url"]);
}
$v->setComponent($vevent);
}
}
$v->sort();
// $v->parse();
return $v->returnCalendar();
}
示例15: display
function display($tpl = null)
{
// Get a reference of the page instance in joomla
$document = JFactory::getDocument();
$model = $this->getModel();
$project =& $model->getProject();
$config = $model->getTemplateConfig($this->getName());
if (isset($project)) {
$this->assignRef('project', $project);
$this->assignRef('overallconfig', $model->getOverallConfig());
$this->assignRef('config', $this->overallconfig);
$this->assignRef('teams', $model->getTeamsIndexedByPtid());
$this->assignRef('matches', $model->getMatches($config));
}
// load a class that handles ical formats.
require_once JLG_PATH_SITE . DS . 'helpers' . DS . 'iCalcreator.class.php';
// create a new calendar instance
$v = new vcalendar();
foreach ($this->matches as $match) {
$hometeam = $this->teams[$match->projectteam1_id];
$home = sprintf('%s', $hometeam->name);
$guestteam = $this->teams[$match->projectteam2_id];
$guest = sprintf('%s', $guestteam->name);
$summary = $project->name . ': ' . $home . ' - ' . $guest;
// check if match gots a date, if not it will not be included
// in ical
if (!strstr($match->match_date, "0000-00-00")) {
$syear = JHTML::date($match->match_date, "%Y");
$sday = JHTML::date($match->match_date, "%d");
$smonth = JHTML::date($match->match_date, "%m");
$shour = JHTML::date($match->match_date, "%H");
$smin = JHTML::date($match->match_date, "%M");
//$start = JHTML::date($match->match_date, "%Y-%m-%d %H:%M:%S" );
$start = strftime("%Y-%m-%d %H:%M:%S", strtotime($match->match_date));
$start_oldphpversion = array('year' => $syear, 'month' => $smonth, 'day' => $sday, 'hour' => $shour, 'min' => $smin, 'sec' => 0);
$time_to_ellapse = $project->halftime * ($project->game_parts - 1) + $project->game_regular_time;
$endtime = JoomleagueHelper::getTimestamp($match->match_date) + $time_to_ellapse * 60;
$year = JHTML::date($endtime, "%Y");
$day = JHTML::date($endtime, "%d");
$month = JHTML::date($endtime, "%m");
$hour = JHTML::date($endtime, "%H");
$min = JHTML::date($endtime, "%M");
//$end = JHTML::date($endtime, "%Y-%m-%d %H:%M:%S" );
$end = strftime("%Y-%m-%d %H:%M:%S", $endtime);
$end_oldphpversion = array('year' => $year, 'month' => $month, 'day' => $day, 'hour' => $hour, 'min' => $min, 'sec' => 0);
// check if exist a playground in match or team or club
if ($match->playground_id != "") {
$stringlocation = $match->playground_address . ", " . $match->playground_zipcode . " " . $match->playground_city;
$stringname = $match->playground_name;
} else {
if ($match->team_playground_id != "") {
$stringlocation = $match->team_playground_address . ", " . $match->team_playground_zipcode . " " . $match->team_playground_city;
$stringname = $match->team_playground_name;
} elseif ($match->club_playground_id != "") {
$stringlocation = $match->club_playground_address . ", " . $match->club_playground_zipcode . " " . $match->club_playground_city;
$stringname = $match->club_playground_name;
}
}
$location = $stringlocation;
//if someone want to insert more in description here is the place
$description = $stringname;
// create an event and insert it in calendar
$vevent = new vevent();
$vevent->setProperty("dtstart", $start, array("TZID" => $project->timezone));
$vevent->setProperty("dtend", $end, array("TZID" => $project->timezone));
$vevent->setProperty('LOCATION', $location);
$vevent->setProperty('summary', $summary);
$vevent->setProperty('description', $description);
$v->setComponent($vevent);
}
}
$v->returnCalendar();
// exit before display
// parent::display( $tpl );
}