本文整理汇总了PHP中vcalendar::addComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP vcalendar::addComponent方法的具体用法?PHP vcalendar::addComponent怎么用?PHP vcalendar::addComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcalendar
的用法示例。
在下文中一共展示了vcalendar::addComponent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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);
}
}
示例3: 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;
}
示例4: vcalendar
echo "Use browser function to show source!<br />\n<br />\n";
$v = new vcalendar();
// initiate new CALENDAR
$e = new vevent();
// initiate a new EVENT
$e->setProperty('categories', 'FAMILY');
// catagorize
$e->setProperty('dtstart', 2006, 12, 24, 19, 30, 00);
// 24 dec 2006 19.30
$e->setProperty('duration', 0, 0, 3);
// 3 hours
$e->setProperty('description', 'x-mas evening - diner');
// describe the event
$e->setProperty('location', 'Home');
// 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;
echo "<br />\n\n";
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
$v = new vcalendar();
// initiate new CALENDAR
$v->setConfig('unique_id', 'testdomain.com');
// config with site domain
$v->setProperty('X-WR-CALNAME', 'Sample calendar');
// set some X-properties, name, content.. .
示例5: vcalendar
}
} else {
$calendar = new vcalendar();
$calsql = $data->select_query("calendar_items", "WHERE allowed = 1 AND trash=0");
while ($temp = $data->fetch_array($calsql)) {
$groups = unserialize($temp['groups']);
if (is_array($groups)) {
$allowed = in_group($groups);
} else {
$allowed = true;
}
if ($allowed) {
$e = new vevent();
$e->setProperty('categories', $config['troopname'] . " Calendar");
$date = getdate($temp['startdate']);
$e->setProperty('dtstart', $date['year'], $date['mon'], $date['mday'], $date['hours'], $date['minutes'], 00);
$date = getdate($temp['enddate']);
$e->setProperty('dtend', $date['year'], $date['mon'], $date['mday'], $date['hours'], $date['minutes'], 00);
$e->setProperty('summary', censor($temp['summary']));
$e->setProperty('description', $temp['detail'] != NULL ? truncate(strip_tags(censor($temp['detail']))) : "No details");
$calendar->addComponent($e);
}
}
header('Content-type: text/calendar');
header('Content-Disposition: attachment; filename="calendar.ics"');
echo $calendar->createCalendar();
exit;
}
$tpl->assign("show_detail", $show_detail);
$pagename = "Calender";
$dbpage = true;
示例6: filemtime
$age = filemtime($fname);
if (!$age || time()-$age > 60*60)
{
#http://www.fbcalendar.com/cal/707610112/9b857cca655089425da6d912-707610112/events/ics/attending,unsure,not_replied/
$data = file_get_contents("http://www.fbcalendar.com/cal/$uid/$key-$uid/events/ics/attending,unsure,not_replied/");
if ($data == "")
die("Can't read from Facebook!\n");
file_put_contents($fname, $data);
}
$v->parse($fname);
$tz = genTimezone ($timezone);
$tzid = $tz->getProperty("TZID");
$out->addComponent($tz);
while( $vevent = $v->getComponent( 'vevent' )) {
$url = $vevent->getProperty('URL');
preg_match("/eid%3D(\d+)/", $url, $matches);
if (count($matches) != 2)
{
print_r($matches);
die("Wrong number of matches!");
}
$url = "http://www.facebook.com/event.php?eid=".$matches[1];
$vevent->setProperty("URL", $url);
$description = $vevent->getProperty( 'description' );
#$description = urlencode($description);
$description = substr($description,0,strrpos($description, "\\n"));
示例7: cs_event_calendar
function cs_event_calendar($post_id = '')
{
if (!isset($post_id) && $post_id == '') {
global $post;
$post_id = $post->ID;
}
$cal_post = get_post($post_id);
if ($cal_post) {
$event_from_date = get_post_meta($post_id, "cs_event_from_date", true);
$cs_event_to_date = get_post_meta($post_id, "cs_event_to_date", true);
$cs_event_meta = get_post_meta($post_id, "cs_event_meta", true);
if ($cs_event_meta != "") {
$cs_event_meta = new SimpleXMLElement($cs_event_meta);
if ($cs_event_meta->event_address != '') {
$address_map = get_the_title("{$cs_event_meta->event_address}");
} else {
$address_map = '';
}
}
$cs_event_loc = get_post_meta($cs_event_meta->event_address, "cs_event_loc_meta", true);
if ($cs_event_loc != "") {
$cs_xmlObject = new SimpleXMLElement($cs_event_loc);
$loc_address = $cs_xmlObject->loc_address;
$event_loc_lat = $cs_xmlObject->event_loc_lat;
$event_loc_long = $cs_xmlObject->event_loc_long;
$event_loc_zoom = $cs_xmlObject->event_loc_zoom;
$loc_city = $cs_xmlObject->loc_city;
$loc_postcode = $cs_xmlObject->loc_postcode;
$loc_country = $cs_xmlObject->loc_country;
$location = $loc_address . ', ' . $loc_city . ', ' . $loc_postcode . ', ' . $loc_country;
} else {
$loc_address = '';
$event_loc_lat = '';
$event_loc_long = '';
$event_loc_zoom = '';
$loc_city = '';
$loc_postcode = '';
$loc_country = '';
$location = '';
}
$start_year = date('Y', strtotime($event_from_date));
$start_month = date('m', strtotime($event_from_date));
$start_day = date('d', strtotime($event_from_date));
$end_year = date('Y', strtotime($cs_event_to_date));
$end_month = date('m', strtotime($cs_event_to_date));
$end_day = date('d', strtotime($cs_event_to_date));
if ($cs_event_meta->event_all_day != "on") {
$start_time = calender_time($cs_event_meta->event_start_time);
$end_time = calender_time($cs_event_meta->event_end_time);
} else {
$start_time = $end_time = '';
}
if ($start_time != '' && $start_time != ':') {
$event_start_time = explode(":", $start_time);
}
if ($end_time != '' && $end_time != ':') {
$event_end_time = explode(":", $end_time);
}
$post_title = get_the_title($post_id);
$cs_vcalendar = new vcalendar();
$cs_vevent = new vevent();
$site_info = get_bloginfo('name') . 'Events';
$cs_vevent->setProperty('categories', $site_info);
if (isset($event_start_time)) {
@$cs_vevent->setProperty('dtstart', @$start_year, @$start_month, @$start_day, @$event_start_time[0], @$event_start_time[1], 00);
} else {
$cs_vevent->setProperty('dtstart', $start_year, $start_month, $start_day);
}
// YY MM dd hh mm ss
if (isset($event_end_time)) {
@$cs_vevent->setProperty('dtend', $end_year, $end_month, $end_day, $event_end_time[0], $event_end_time[1], 00);
} else {
$cs_vevent->setProperty('dtend', $end_year, $end_month, $end_day);
}
// YY MM dd hh mm ss
$cs_vevent->setProperty('description', strip_tags($cal_post->post_excerpt));
if (isset($location)) {
$cs_vevent->setProperty('location', $location);
}
$cs_vevent->setProperty('summary', $post_title);
$cs_vcalendar->addComponent($cs_vevent);
$templateurl = get_template_directory_uri() . '/cache/';
//makeDir(get_bloginfo('template_directory').'/cache/');
$home = home_url();
$dir = str_replace($home, '', $templateurl);
$dir = str_replace('/wp-content/', 'wp-content/', $dir);
$directory_url = get_template_directory_uri();
$directorypath = explode('/', $directory_url);
$themefolderName = $directorypath[count($directorypath) - 1];
$cs_vcalendar->setConfig('directory', ABSPATH . 'wp-content/themes/' . $themefolderName . '/cache');
$cs_vcalendar->setConfig('filename', 'event-' . $post_id . '.ics');
$cs_vcalendar->saveCalendar();
////OUT LOOK & iCAL URL//
$output_calendar_url['ical'] = $templateurl . 'event-' . $post_id . '.ics';
////GOOGLE URL//
$google_url = "http://www.google.com/calendar/event?action=TEMPLATE";
$google_url .= "&text=" . urlencode($post_title);
if (isset($event_start_time) && isset($event_end_time)) {
$google_url .= "&dates=" . @$start_year . @$start_month . @$start_day . "T" . str_replace('.', '', @$event_start_time[0]) . str_replace('.', '', @$event_start_time[1]) . "00/" . @$end_year . @$end_month . @$end_day . "T" . str_replace('.', '', @$event_end_time[0]) . str_replace('.', '', @$event_end_time[1]) . "00";
} else {
//.........这里部分代码省略.........
示例8: render_icalendar
/**
* Render iCal data
*
* @param string $name iCalendar name
* @param array $objects
* @param boolean $include_project_name
* @return void
*/
function render_icalendar($name, $objects, $include_project_name = false)
{
require_once ANGIE_PATH . '/classes/icalendar/iCalCreator.class.php';
$calendar = new vcalendar();
//$calendar->setProperty('VERSION', '1.0');
$calendar->setProperty('X-WR-CALNAME', $name);
$calendar->setProperty('METHOD', 'PUBLISH');
$projects = array();
foreach ($objects as $object) {
$summary = $object->getName();
if ($include_project_name) {
$project_id = $object->getProjectId();
if (isset($projects[$project_id])) {
$summary .= ' | ' . $projects[$project_id]->getName();
} else {
$project = $object->getProject();
if (instance_of($project, 'Project')) {
$projects[$project_id] = $project;
$summary .= ' | ' . $projects[$project_id]->getName();
}
// if
}
// if
}
// if
switch (strtolower($object->getType())) {
case 'milestone':
$start_on = $object->getStartOn();
$due_on = $object->getDueOn();
$due_on->advance(24 * 60 * 60, true);
// One day shift because iCal and Windows Calendar don't include last day
$start_on_year = $start_on->getYear();
$start_on_month = $start_on->getMonth() < 10 ? '0' . $start_on->getMonth() : $start_on->getMonth();
$start_on_day = $start_on->getDay() < 10 ? '0' . $start_on->getDay() : $start_on->getDay();
$due_on_year = $due_on->getYear();
$due_on_month = $due_on->getMonth() < 10 ? '0' . $due_on->getMonth() : $due_on->getMonth();
$due_on_day = $due_on->getDay() < 10 ? '0' . $due_on->getDay() : $due_on->getDay();
$event = new vevent();
$event->setProperty('dtstart', array($start_on_year, $start_on_month, $start_on_day), array('VALUE' => 'DATE'));
$event->setProperty('dtend', array($due_on_year, $due_on_month, $due_on_day), array('VALUE' => 'DATE'));
$event->setProperty('dtstamp', date('Ymd'));
$event->setProperty('summary', $summary);
if ($object->getBody()) {
$event->setProperty('description', html_to_text($object->getFormattedBody()) . "\n\n" . lang('Details: ') . $object->getViewUrl());
} else {
$event->setProperty('description', lang('Details') . ': ' . $object->getViewUrl());
}
// if
switch ($object->getPriority()) {
case PRIORITY_HIGHEST:
$event->setProperty('priority', 1);
break;
case PRIORITY_HIGH:
$event->setProperty('priority', 3);
break;
case PRIORITY_LOW:
$event->setProperty('priority', 7);
break;
case PRIORITY_LOWEST:
$event->setProperty('priority', 9);
break;
case PRIORITY_ONGOING:
$event->setProperty('priority', 11);
break;
case PRIORITY_HOLD:
$event->setProperty('priority', 13);
break;
default:
$event->setProperty('priority', 5);
}
// switch
$calendar->addComponent($event);
break;
case 'ticket':
case 'task':
$start_on = $object->getCreatedOn();
$due_on = $object->getDueOn();
$todo = new vtodo();
$todo->setProperty('summary', $summary);
$todo->setProperty('description', $object->getName() . "\n\n" . lang('Details') . ': ' . $object->getViewUrl());
switch ($object->getPriority()) {
case PRIORITY_HIGHEST:
$todo->setProperty('priority', 1);
break;
case PRIORITY_HIGH:
$todo->setProperty('priority', 3);
break;
case PRIORITY_LOW:
$todo->setProperty('priority', 7);
break;
case PRIORITY_LOWEST:
$todo->setProperty('priority', 9);
//.........这里部分代码省略.........
示例9: vcalendar
/* new vcalendar with name of the timezone, name of the calendar */
$v = new vcalendar();
$v->setProperty("method", "PUBLISH");
$v->setProperty('X-WR-TIMEZONE', 'Europe/Berlin');
$v->setProperty("x-wr-calname", "Filmstarts Deutschland");
$v->setProperty("calscale", "GREGORIAN");
//$v->setConfig( "filename", "filmstarts_de.ics" );
/* define timezone */
$timezone = new vtimezone();
$timezone->setProperty("Tzid", "Europe/Berlin");
/*
$timezonedaylight = new vtimezone( "daylight" );
$timezonedaylight->setProperty( "tzoffsetfrom", "+0100" );
$timezonedaylight->setProperty('dtstart', 2006, 8, 11, 7, 30, 1);
$timezonedaylight->setProperty( "tzname", "GMT+02:00" );
$timezonedaylight->setProperty( "tzoffsetto", "+0200" );
$timezonedaylight->setProperty( "rrule", array("freq" => "YEARLY", "bymonth" => 3, "byday" => array( array(-1, "DAY" => "SU" ))) );
*/
$timezonestandard = new vtimezone("standard");
$timezonestandard->setProperty("tzoffsetfrom", "+0200");
$timezonestandard->setProperty('dtstart', 2006, 8, 11, 7, 30, 1);
$timezonestandard->setProperty("tzname", "GMT+01:00");
$timezonestandard->setProperty("tzoffsetto", "+0100");
$timezonestandard->setProperty("rrule", array("freq" => "YEARLY", "bymonth" => 10, "byday" => array(array(-1, "DAY" => "SU"))));
//$timezone->addSubComponent( $timezonedaylight );
$timezone->addSubComponent($timezonestandard);
$v->addComponent($timezone);
unset($timezone);
unset($timezonestandard);
require_once 'curl.php';
$v->returnCalendar();