本文整理汇总了PHP中vcalendar::newComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP vcalendar::newComponent方法的具体用法?PHP vcalendar::newComponent怎么用?PHP vcalendar::newComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcalendar
的用法示例。
在下文中一共展示了vcalendar::newComponent方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: nl2br
$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?
示例3: vcalendar
/**
* Export to the specified format
* @param array $input - ATutor dates to be exported
* @param int $mode - Mode of operation of export [ 0 | 1 ]
* * mode 0 - returns the exported dates as a string
* * mode 1 - returns the name of the file that has the exported dates
* @param string $format - Export Format DEFAULT 'ical'
* @return string
* @author Anurup Raveendran
*
*/
function cal_export($input = null, $mode, $format = 'ical')
{
$cal = "";
//output
$user = "";
if ($input == null) {
$time_zone = "";
} else {
$time_zone = $input['timezone'];
}
global $db;
require_once 'iCalcreator.class.php';
require_once 'html_parser.inc.php';
$v = new vcalendar(array('unique_id' => 'Inclusive Design Insitute'));
//create an instance of the ical obj
// ADD EXTRA DETAILS
if (isset($_SESSION['member_id'])) {
// GET USER DETAILS
$m_id = $_SESSION['member_id'];
// GET TIME ZONE
// CHECK USER TABLE FOR PREF_TIMEZONE
$sql = "SELECT first_name,last_name,preferences FROM " . TABLE_PREFIX . "members WHERE member_id='" . $m_id . "'";
$result = mysql_query($sql, $db) or die(mysql_error());
$row = mysql_fetch_assoc($result);
$user = $row['first_name'] . ' ' . $row['last_name'];
if ($time_zone == "") {
$prefs = unserialize($row['preferences']);
$time_zone_offset = $prefs['PREF_TIMEZONE'];
if ($time_zone_offset == "") {
// CHECK CONFIG TABLE SET BY ADMIN
$sql = "SELECT value \n\t\t\t\t\tFROM " . TABLE_PREFIX . "config\n\t\t\t\t\tWHERE name='pref_defaults'";
$result = mysql_query($sql, $db) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
//pref_defaults is set
$row = mysql_fetch_row($result);
$prefs = unserialize($row[0]);
$time_zone_offset = $prefs['PREF_TIMEZONE'];
}
}
if ($time_zone_offset != "") {
$sql = "SELECT time_zone \n\t\t\t\t\t\tFROM " . TABLE_PREFIX . "calendar_timezone_offset \n\t\t\t\t\t\tWHERE offset='" . $time_zone_offset . "'";
$result = mysql_query($sql, $db) or die(mysql_error());
$row = mysql_fetch_row($result);
$time_zone = $row[0];
} else {
// GET TIMEZONE FROM SERVER
$version = phpversion();
$version = str_replace('Current PHP version: ', '', $version);
$version = explode('.', $version);
if ($version[0] > 4) {
$time_zone = date_default_timezone_get();
} else {
// get from ini file
$time_zone = ini_get('date.timezone');
}
$sql = "SELECT offset \n\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "calendar_timezone_offset \n\t\t\t\t\t\t\tWHERE time_zone='" . $time_zone . "'";
$result = mysql_query($sql, $db) or die(mysql_error());
$row = mysql_fetch_row($result);
$time_zone_offset = $row[0];
}
} else {
$sql = "SELECT offset \n\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "calendar_timezone_offset \n\t\t\t\t\t\t\tWHERE time_zone='" . $time_zone . "'";
$result = mysql_query($sql, $db) or die(mysql_error());
$row = mysql_fetch_row($result);
$time_zone_offset = $row[0];
}
}
/** HEADER **/
$v->setProperty('X-WR-CALNAME', $user);
$v->setProperty('X-WR-CALDESC', 'ATutor Dates');
$v->setProperty('X-WR-TIMEZONE', $time_zone);
// set the ical timezone component
$e =& $v->newComponent('vtimezone');
$e->setProperty('TZID', $time_zone);
$e->setProperty('X-LIC-LOCATION', $time_zone);
$t =& $e->newComponent('standard');
$t->setProperty('tzoffsetfrom', $this->get_tz_offset($time_zone_offset));
$t->setProperty('tzoffsetto', $this->get_tz_offset($time_zone_offset));
$t->setProperty('dtstart', 1970, 1, 1, 0, 0, 00);
/** HEADER **/
// NOW LOAD THE EVENTS
global $moduleFactory;
$coursesmod = $moduleFactory->getModule("_core/courses");
$assignmentsmod = $moduleFactory->getModule("_standard/assignments");
$testsmod = $moduleFactory->getModule("_standard/tests");
// GET ALL THE COURSES THE USER IS ENROLLED IN
$sql = "SELECT course_id\n \tFROM " . TABLE_PREFIX . "course_enrollment \n \tWHERE member_id = '" . $_SESSION['member_id'] . "'";
$course_result = mysql_query($sql, $db) or die(mysql_error());
while ($row = mysql_fetch_row($course_result)) {
//.........这里部分代码省略.........
示例4: _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();
//.........这里部分代码省略.........
示例5: Event
//echo "<br />";
$iduser = $_SESSION['do_User']->iduser;
//echo $user;
//$time = time();
//$key = "$iduser"."$time";
$e_set_api = new Event("do_User->eventGenerateAPIKey");
$e_set_api->addParam("goto", $_SERVER['PHP_SELF']);
if ($_SESSION['do_User']->api_key != '') {
$apikey = $_SESSION['do_User']->api_key;
$c->setConfig(array("directory" => "Calevents", "filename" => "{$iduser}.ics"));
$vivek->getAllTaskByuser($iduser);
while ($vivek->fetch()) {
$stdt = explode('-', $vivek->getData("due_date_dateformat"));
$startdate = "{$stdt['0']}" . "{$stdt['1']}" . "{$stdt['2']}";
$enddate = $startdate;
$e =& $c->newComponent('vevent');
//$e->setProperty( 'dtstart', $startdate );
//$e->setProperty( 'dtend', $enddate );
$e->setProperty("dtstart", "{$startdate}", array("VALUE" => "DATE"));
$e->setProperty('description', $vivek->getData("task_description"));
$e->setProperty('summary', $vivek->getData("task_description"));
$e->setProperty('class', 'PUBLIC');
}
$c->createCalendar();
$str = $c->saveCalendar();
$tt = $_SERVER["SERVER_NAME"];
$path = "http://" . "{$tt}" . "/" . "Calevents/" . "{$iduser}.ics";
$ff = "Calevents/{$iduser}.ics";
system("chmod 0777 {$ff}");
echo _('Your iCal URL is : ' . $path . ' ');
} else {
示例6: addcslashes
/**
* 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
*
* @return void
*/
function insert_event_in_calendar(Ai1ec_Event $event, vcalendar &$calendar, $export = false)
{
global $ai1ec_events_helper;
$tz = Ai1ec_Meta::get_option('timezone_string');
$e =& $calendar->newComponent('vevent');
$uid = '';
if ($event->ical_uid) {
$uid = addcslashes($event->ical_uid, "\\;,\n");
} else {
$uid = sprintf($this->get_uid_format(), $event->post->ID);
}
$e->setProperty('uid', $this->_sanitize_value($uid));
$e->setProperty('url', get_permalink($event->post_id));
// =========================
// = Summary & description =
// =========================
$e->setProperty('summary', $this->_sanitize_value(html_entity_decode(apply_filters('the_title', $event->post->post_title), ENT_QUOTES, 'UTF-8')));
$content = apply_filters('the_content', $event->post->post_content);
$content = str_replace(']]>', ']]>', $content);
$content = html_entity_decode($content, ENT_QUOTES, 'UTF-8');
// Prepend featured image if available.
$size = null;
if ($img_url = $event->get_post_thumbnail_url($size)) {
$content = '<div class="ai1ec-event-avatar alignleft timely"><img src="' . esc_attr($img_url) . '" width="' . $size[0] . '" height="' . $size[1] . '" /></div>' . $content;
}
$e->setProperty('description', $this->_sanitize_value($content));
// =====================
// = Start & end times =
// =====================
$dtstartstring = '';
$dtstart = $dtend = array();
if ($event->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(gmdate("Ymd", $ai1ec_events_helper->gmt_to_local($event->start))), $dtstart);
$e->setProperty('dtend', $this->_sanitize_value(gmdate("Ymd", $ai1ec_events_helper->gmt_to_local($event->end))), $dtend);
} else {
$e->setProperty('dtstart', $this->_sanitize_value(gmdate("Ymd\\T", $ai1ec_events_helper->gmt_to_local($event->start))), $dtstart);
$e->setProperty('dtend', $this->_sanitize_value(gmdate("Ymd\\T", $ai1ec_events_helper->gmt_to_local($event->end))), $dtend);
}
} else {
if ($tz) {
$dtstart["TZID"] = $dtend["TZID"] = $tz;
}
// This is used later.
$dtstartstring = gmdate("Ymd\\THis", $ai1ec_events_helper->gmt_to_local($event->start));
$e->setProperty('dtstart', $this->_sanitize_value($dtstartstring), $dtstart);
$e->setProperty('dtend', $this->_sanitize_value(gmdate("Ymd\\THis", $ai1ec_events_helper->gmt_to_local($event->end))), $dtend);
}
// ========================
// = Latitude & longitude =
// ========================
if (floatval($event->latitude) || floatval($event->longitude)) {
$e->setProperty('geo', $event->latitude, $event->longitude);
}
// ===================
// = Venue & address =
// ===================
if ($event->venue || $event->address) {
$location = array($event->venue, $event->address);
$location = array_filter($location);
$location = implode(' @ ', $location);
$e->setProperty('location', $this->_sanitize_value($location));
}
$categories = array();
$language = get_bloginfo('language');
foreach (wp_get_post_terms($event->post_id, 'events_categories') as $cat) {
$categories[] = $cat->name;
}
$e->setProperty('categories', implode(',', $categories), array("LANGUAGE" => $language));
$tags = array();
foreach (wp_get_post_terms($event->post_id, 'events_tags') as $tag) {
$tags[] = $tag->name;
}
if (!empty($tags)) {
$e->setProperty('X-TAGS', implode(',', $tags), array("LANGUAGE" => $language));
}
// ==================
// = Cost & tickets =
// ==================
if ($event->cost) {
$e->setProperty('X-COST', $this->_sanitize_value($event->cost));
}
if ($event->ticket_url) {
$e->setProperty('X-TICKETS-URL', $this->_sanitize_value($event->ticket_url));
//.........这里部分代码省略.........
示例7: array
function test_add_date()
{
$tests = array('2011-01-20' => array('params' => array('VALUE' => 'DATE'), 'value' => array('year' => '2011', 'month' => '01', 'day' => '20')), '2011-01-20 17:30:15' => array('params' => '', 'value' => array('year' => '2011', 'month' => '01', 'day' => '20', 'hour' => '17', 'min' => '30', 'sec' => '15')));
$calendar = new vcalendar(array('unique_id' => 'test'));
$event =& $calendar->newComponent('vevent');
foreach ($tests as $test => $expected) {
$this->formatter->add_date($event, 'dtstart', $test);
$this->assertEqual($event->dtstart, $expected);
}
}
示例8: getIcal
public function getIcal($studio = null) {
error_reporting(0);
sfProjectConfiguration::getActive()->loadHelpers(array("Number","Url","Date"));
require_once sfConfig::get('sf_lib_dir').'/vendor/icalcreator/iCalcreator.class.php';
error_reporting(E_ALL ^ E_NOTICE);
$config = array( "unique_id" => "downtownswing.rockstep.ch" );
$v = new vcalendar( $config );
$v->setProperty( "method",
"PUBLISH" );
$v->setProperty( "X-WR-CALNAME",
"Downtownswing Kurse" );
$v->setProperty( "X-WR-CALDESC",
"" );
//$vcalendar->setProperty( "X-WR-RELCALID", $uuid );
$v->setProperty( "X-WR-TIMEZONE",
"Europe/Zurich" );
// TODO
// - filter für kommende, publizierte artikel (model)
// - verarbeitung von gecancelten events
// - event uuid in db speichern und hier einsetzen (model, on publish, für updates + cancels)
$lessons = Doctrine_Core::getTable('dsLesson')
->createQuery('a')
->execute();
// todo
// join dance, teachers, ..
foreach( $lessons as $lesson ) {
$e = & $v->newComponent( 'vevent' );
$e->setUid( $lesson->getIcalUID() );
$e->setSequence( $lesson->getIcalSequence() );
$e->setProperty( 'categories'
, $lesson->getDance() );
// $e->setProperty( 'dtstart', '2012-01-06 20:00:00' );
$e->setProperty( 'dtstart',
$lesson->getDateTimeObject('date')->format('Y'), // date("Y", $lesson->getDate()), // date("Y", $lesson->getDateTimeObject('date')->format('Y') ),
$lesson->getDateTimeObject('date')->format('m'), // date("m", $lesson->getDate()), //date("m", $lesson->getDateTimeObject('date')->format('m') ),
$lesson->getDateTimeObject('date')->format('d'), // date("d", $lesson->getDate()), //date("d", $lesson->getDateTimeObject('date')->format('d') ),
date('H', strtotime($lesson->getTime())),
date('i', strtotime($lesson->getTime())),
00);
$e->setProperty( 'duration',
array( "min" => $lesson->getDuration() ));
// summary
$summary = $lesson->getName() ;
$e->setProperty( "summary", strip_tags($summary));
// description
$description = $lesson->getClass()->getDance().", ".
$lesson->getClass()->getTrack()->getType()."\r\n".
$lesson->getClass()."\r\n".
$lesson->getTeachersAsString();
$e->setProperty( 'description',
$description );
// location
/*
$e->setProperty( 'location',
strip_tags($lesson->getStudio()) );
*/
/*
$request = sfContext::getInstance()->getRequest();
$url = 'http'.($request->isSecure() ? 's' : '').'://'. $request->getHost();
$url .= url_for('event_show',$event);
$e->setProperty( "url",
strip_tags($url ));
*/
/*
$e->setProperty( "contact", strip_tags($concert->getContact() ));
//$e->setProperty( "organizer", strip_tags($concert->getContact() ));
//$e->setProperty( "geo", 11.23456, -23.45678 );
*/
$e->setProperty( 'last-modified' ,
$this->datestring2icalArr( $lesson->getCreatedAt() ));
/*
if($lesson->getUpdatedAt())
$e->setProperty( 'last-modified' ,
$this->datestring2icalArr( $event->getUpdatedAt() ));
else
$e->setProperty( 'last-modified' ,
$this->datestring2icalArr( $event->getCreatedAt() ));
}
*/
//.........这里部分代码省略.........
示例9: foreach
$v->setProperty("method", "PUBLISH");
// required of some calendar software
$v->setProperty("x-wr-calname", $tables[0]['stuname'] . "的课表 " . $tables[0]['year'] . '-' . $tables[0]['term']);
// required of some calendar software
$v->setProperty("X-WR-CALDESC", "");
// required of some calendar software
$v->setProperty("X-WR-TIMEZONE", "Asia/Shanghai");
// required of some calendar software
foreach ($t1 as $o) {
$odata = array('name' => $o->name, 'credit' => $o->credit, 'tutor' => $o->tutor, 'schedule' => $o->schedule);
if (count($o->schedule)) {
foreach ($o->schedule as $os) {
$startTimeTrans = array([], ['8', '00'], ['8', '50'], ['9', '50'], ['10', '40'], ['11', '30'], ['13', '20'], ['14', '10'], ['15', '10'], ['16', '00'], ['16', '50'], ['18', '30'], ['19', '20'], ['20', '10']);
$endTimeTrans = array([], ['8', '45'], ['9', '35'], ['10', '35'], ['11', '25'], ['12', '15'], ['14', '05'], ['14', '55'], ['15', '55'], ['16', '45'], ['17', '35'], ['19', '15'], ['20', '05'], ['20', '55']);
$dateArr = $school->getSchoolCalendar2Date($tables[0]['year'], $tables[0]['term'], $os->week[0], $os->day);
$vevent = $v->newComponent("vevent");
// create an event calendar component
$vevent->setProperty("dtstart", array("year" => $dateArr[0], "month" => $dateArr[1], "day" => $dateArr[2], "hour" => $startTimeTrans[$os->startTime][0], "min" => $startTimeTrans[$os->startTime][1], "sec" => 0));
$vevent->setProperty("dtend", array("year" => $dateArr[0], "month" => $dateArr[1], "day" => $dateArr[2], "hour" => $endTimeTrans[$os->startTime][0], "min" => $endTimeTrans[$os->startTime + $os->durationTime - 1][1], "sec" => 0));
$vevent->setProperty("LOCATION", $os->location);
// property name - case independent
$vevent->setProperty("summary", $o->name);
$vevent->setProperty("description", $o->tutor);
if (count($os->week) > 1) {
// Set recurrence rule
$endWeek = $os->week[count($os->week) - 1];
$iWeek = $os->week[0];
$weekdayTrans = array('', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU');
$vevent->setProperty("RRULE", array("FREQ" => "WEEKLY", "COUNT" => $endWeek - $iWeek + 1, "INTERVAL" => 1, "WKST" => $weekdayTrans[$os->day]));
for (; $iWeek < $endWeek; $iWeek++) {
if (!in_array($iWeek, $os->week)) {
示例10: foreach
}
if (isset($_GET["debug"])) {
echo "<pre>";
foreach ($listeEvt as $evt) {
echo $evt;
}
echo "</pre>";
} else {
// sortie au format iCalendar
$sourcesEnteteICal = array();
foreach (array_keys($listeSourcesAAnalyser) as $src) {
array_push($sourcesEnteteICal, $SOURCES[$src]["nomSite"]);
}
$vcal = new vcalendar(array("unique_id" => "[" . implode(',', $sourcesEnteteICal) . "]"));
foreach ($listeEvt as $evmt) {
$event =& $vcal->newComponent("vevent");
// si la date de fin n'est pas positionnée
if ($evmt->dateFin == 0) {
// on déclare l'évènement comme un évènement à la journée
$event->setProperty("dtstart", array("timestamp" => $evmt->dateDebut, "tz" => "Europe/Paris"), array("VALUE" => "DATE"));
} else {
// on déclare l'évènement entre deux dates
$event->setProperty("dtstart", array("timestamp" => $evmt->dateDebut, "tz" => "Europe/Paris"), array("VALUE" => "DATE-TIME"));
$event->setProperty("dtend", array("timestamp" => $evmt->dateFin, "tz" => "Europe/Paris"), array("VALUE" => "DATE-TIME"));
}
$event->setProperty("summary", '[' . $evmt->lieu . '] ' . $evmt->description);
$event->setProperty("description", $evmt->description . '\\n' . $evmt->lien);
$event->setProperty("location", $evmt->lieu);
}
echo $vcal->createCalendar();
}
示例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('ai1ec_the_content', apply_filters('the_content', $event->get('post')->post_content));
$post_meta_values = get_post_meta($event->get('post_id'), '', false);
$cost_type = null;
if ($post_meta_values) {
foreach ($post_meta_values as $key => $value) {
if ('_ai1ec_cost_type' === $key) {
$cost_type = $value[0];
}
if (isset($params['xml']) && $params['xml'] && false !== preg_match('/^x\\-meta\\-/i', $key)) {
$e->setProperty($key, $this->_sanitize_value($value));
}
}
}
if (false === ai1ec_is_blank($cost_type)) {
$e->setProperty('X-COST-TYPE', $this->_sanitize_value($cost_type));
}
$url = '';
$api = $this->_registry->get('model.api.api-ticketing');
$api_event_id = $api->get_api_event_id($event->get('post_id'));
if ($api_event_id) {
//getting all necessary informations that will be necessary on imported ticket events
$e->setProperty('X-API-EVENT-ID', $api_event_id);
$e->setProperty('X-API-URL', $api->get_api_event_url($event->get('post_id')));
$e->setProperty('X-CHECKOUT-URL', $api->get_api_event_checkout_url($event->get('post_id')));
$e->setProperty('X-API-EVENT-CURRENCY', $api->get_api_event_currency($event->get('post_id')));
} else {
if ($event->get('ticket_url')) {
$url = $event->get('ticket_url');
}
}
//Adding Ticket URL to the Description field
if (false === ai1ec_is_blank($url)) {
$content = $this->_remove_ticket_url($content);
$content = $content . '<p>' . __('Tickets: ', AI1EC_PLUGIN_NAME) . '<a class="ai1ec-ticket-url-exported" href="' . $url . '">' . $url . '</a>.</p>';
}
$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');
$matches = $avatar->get_image_from_content($content);
// if no img is already present - add thumbnail
if (empty($matches)) {
$post_id = get_post_thumbnail_id($event->get('post_id'));
$images = null;
$added = null;
foreach (array('thumbnail', 'medium', 'large', 'full') as $_size) {
$attributes = wp_get_attachment_image_src($post_id, $_size);
if (false !== $attributes) {
$key_str = sprintf('%d_%d', $attributes[1], $attributes[2]);
if (null === $added || false === isset($added[$key_str])) {
$added[$key_str] = true;
array_unshift($attributes, $_size);
$images[] = implode(';', $attributes);
}
}
}
if (null !== $images) {
$e->setProperty('X-WP-IMAGES-URL', $this->_sanitize_value(implode(',', $images)));
}
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);
}
//.........这里部分代码省略.........
示例12: save
public function save(Doctrine_Connection $conn = null)
{
if ($this->isNew() || !$this->getIcalUID()) # && !$this->getIcalUID()
{
require_once sfConfig::get('sf_lib_dir').'/vendor/icalcreator/iCalcreator.class.php';
$config = array( "unique_id" => "downtownswing.rockstep.ch" );
$v = new vcalendar( $config );
$e = & $v->newComponent( 'vevent' );
$e->createUid();
#var_dump( $e->uid );
$this->setIcalUID($e->uid['value']);
#$now = $this->getCreatedAt() ? $this->getDateTimeObject('created_at')->format('U') : time();
#$this->setExpiresAt(date('Y-m-d H:i:s', $now + 86400 * 30));
} else {
$this->setIcalSequence( $this->getIcalSequence()+1 );
}
return parent::save($conn);
}
示例13: setCourseEvent
function setCourseEvent(Course $course, vcalendar $ical, array $info)
{
$startTime = semInfo($info['year'], $info['sem']);
$lessons = $course->lessons;
//add lessons
foreach ($lessons as $lesson) {
$lessonEvent =& $ical->newComponent('vevent');
//set summary(name)
$lessonEvent->setProperty('summary', $lesson->summary);
//set start and end time.
//start
$start = fewDaysNextOrBefore($startTime, '+' . ($lesson->time->wkDay - 1) . ' days');
$shour = $lesson->time->startTime / 100;
$smin = $lesson->time->startTime % 100;
$start['hour'] = $shour;
$start['min'] = $smin;
$start['sec'] = 0;
$lessonEvent->setProperty('dtstart', $start);
//end
$end = fewDaysNextOrBefore($startTime, '+' . ($lesson->time->wkDay - 1) . ' days');
$ehour = $lesson->time->endTime / 100;
$emin = intval($lesson->time->endTime) % 100;
$end['hour'] = $ehour;
$end['min'] = $emin;
$end['sec'] = 0;
$lessonEvent->setProperty('dtend', $end);
//set location
$lessonEvent->setProperty('LOCATION', $lesson->venue);
//set description
$lessonEvent->setProperty('description', $lesson->description);
//set week repeat
if (!$lesson->wkRepeatValid) {
continue;
}
$endTime = fewDaysNextOrBefore($startTime, '+14 weeks');
$rule = array('FREQ' => 'WEEKLY', 'UNTIL' => $endTime['year'] . '/' . $endTime['month'] . '/' . $endTime['day']);
$lessonEvent->setProperty("rrule", $rule);
$exdate = array('year' => $start['year'], 'month' => $start['month'], 'day' => $start['day']);
$recess = fewDaysNextOrBefore($exdate, '+7 weeks');
$recess['hour'] = $shour;
$recess['min'] = $smin;
$recess['sec'] = 0;
$wk = $lesson->time->wkRepeat;
$exdates = array();
array_push($exdates, $recess);
for ($i = 0; $i < 13; $i++) {
if ($i < 7) {
$j = $i;
} else {
$j = $i + 1;
}
if (!$wk[$i]) {
$w = fewDaysNextOrBefore($exdate, '+' . $j . ' weeks');
$w['hour'] = $shour;
$w['min'] = $smin;
$w['sec'] = 0;
array_push($exdates, $w);
}
}
$lessonEvent->setProperty('exdate', $exdates, array('TZID' => $info['tz']));
}
//add examtime
$examtime = $course->examTime;
if ($examtime == null) {
return;
}
$start = array('year' => $examtime->year, 'month' => $examtime->month, 'day' => $examtime->day, 'hour' => $examtime->startTime / 100, 'min' => $examtime->startTime % 100, 'sec' => 0);
$end = array('year' => $examtime->year, 'month' => $examtime->month, 'day' => $examtime->day, 'hour' => $examtime->endTime / 100, 'min' => $examtime->endTime % 100, 'sec' => 0);
$exam =& $ical->newComponent('vevent');
$exam->setProperty('dtstart', $start);
$exam->setProperty('dtend', $end);
$exam->setProperty('summary', $course->code . ' EXAM!');
$exam->setProperty('description', $course->code . ', ' . $course->name . ', ' . $course->au);
return;
}