本文整理汇总了PHP中vcalendar::setConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP vcalendar::setConfig方法的具体用法?PHP vcalendar::setConfig怎么用?PHP vcalendar::setConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcalendar
的用法示例。
在下文中一共展示了vcalendar::setConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: 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;
}
示例4: 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));
}
示例5: 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;
}
示例6: 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;
}
示例7: 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);
}
}
示例8: 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;
}
示例9: renderCalDavEntry_data
/**
* @param DBClass_friendica_calendars $calendar
* @param DBClass_friendica_calendarobjects $calendarobject
*/
function renderCalDavEntry_data(&$calendar, &$calendarobject)
{
$a = get_app();
$v = new vcalendar();
$v->setConfig('unique_id', $a->get_hostname());
$v->parse($calendarobject->calendardata);
$v->sort();
$eventArray = $v->selectComponents(2009, 1, 1, date("Y") + 2, 12, 30);
$start_min = $end_max = "";
$allday = $summary = $vevent = $rrule = $color = $start = $end = null;
$location = $description = "";
foreach ($eventArray as $yearArray) {
foreach ($yearArray as $monthArray) {
foreach ($monthArray as $day => $dailyEventsArray) {
foreach ($dailyEventsArray as $vevent) {
/** @var $vevent vevent */
$start = "";
$rrule = "NULL";
$allday = 0;
$dtstart = $vevent->getProperty('X-CURRENT-DTSTART');
if (is_array($dtstart)) {
$start = "'" . $dtstart[1] . "'";
if (strpos($dtstart[1], ":") === false) {
$allday = 1;
}
} else {
$dtstart = $vevent->getProperty('dtstart');
if (isset($dtstart["day"]) && $dtstart["day"] == $day) {
// Mehrtägige Events nur einmal rein
if (isset($dtstart["hour"])) {
$start = "'" . $dtstart["year"] . "-" . $dtstart["month"] . "-" . $dtstart["day"] . " " . $dtstart["hour"] . ":" . $dtstart["minute"] . ":" . $dtstart["secont"] . "'";
} else {
$start = "'" . $dtstart["year"] . "-" . $dtstart["month"] . "-" . $dtstart["day"] . " 00:00:00'";
$allday = 1;
}
}
}
$dtend = $vevent->getProperty('X-CURRENT-DTEND');
if (is_array($dtend)) {
$end = "'" . $dtend[1] . "'";
if (strpos($dtend[1], ":") === false) {
$allday = 1;
}
} else {
$dtend = $vevent->getProperty('dtend');
if (isset($dtend["hour"])) {
$end = "'" . $dtend["year"] . "-" . $dtend["month"] . "-" . $dtend["day"] . " " . $dtend["hour"] . ":" . $dtend["minute"] . ":" . $dtend["second"] . "'";
} else {
$end = "'" . $dtend["year"] . "-" . $dtend["month"] . "-" . $dtend["day"] . " 00:00:00' - INTERVAL 1 SECOND";
$allday = 1;
}
}
$summary = $vevent->getProperty('summary');
$description = $vevent->getProperty('description');
$location = $vevent->getProperty('location');
$rrule_prob = $vevent->getProperty('rrule');
if ($rrule_prob != null) {
$rrule = $vevent->createRrule();
$rrule = "'" . dbesc($rrule) . "'";
}
$color_ = $vevent->getProperty("X-ANIMEXX-COLOR");
$color = is_array($color_) ? $color_[1] : "NULL";
if ($start_min == "" || preg_replace("/[^0-9]/", "", $start) < preg_replace("/[^0-9]/", "", $start_min)) {
$start_min = $start;
}
if ($end_max == "" || preg_replace("/[^0-9]/", "", $end) > preg_replace("/[^0-9]/", "", $start_min)) {
$end_max = $end;
}
}
}
}
}
if ($start_min != "") {
if ($allday && mb_strlen($end_max) == 12) {
$x = explode("-", str_replace("'", "", $end_max));
$time = mktime(0, 0, 0, IntVal($x[1]), IntVal($x[2]), IntVal($x[0]));
$end_max = date("'Y-m-d H:i:s'", $time - 1);
}
q("INSERT INTO %s%sjqcalendar (`uid`, `namespace`, `namespace_id`, `ical_uri`, `Subject`, `Location`, `Description`, `StartTime`, `EndTime`, `IsAllDayEvent`, `RecurringRule`, `Color`)\n\t\t\tVALUES (%d, %d, %d, '%s', '%s', '%s', '%s', %s, %s, %d, '%s', '%s')", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($calendar->uid), IntVal($calendarobject->namespace), IntVal($calendarobject->namespace_id), dbesc($calendarobject->uri), dbesc($summary), dbesc($location), dbesc(str_replace("\\n", "\n", $description)), $start_min, $end_max, IntVal($allday), dbesc($rrule), dbesc($color));
foreach ($vevent->components as $comp) {
/** @var $comp calendarComponent */
$trigger = $comp->getProperty("TRIGGER");
$sql_field = $trigger["relatedStart"] ? $start : $end;
$sql_op = $trigger["before"] ? "DATE_SUB" : "DATE_ADD";
$num = "";
$rel_type = "";
$rel_value = 0;
if (isset($trigger["second"])) {
$num = IntVal($trigger["second"]) . " SECOND";
$rel_type = "second";
$rel_value = IntVal($trigger["second"]);
}
if (isset($trigger["minute"])) {
$num = IntVal($trigger["minute"]) . " MINUTE";
$rel_type = "minute";
$rel_value = IntVal($trigger["minute"]);
//.........这里部分代码省略.........
示例10: vcalendar
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>jhgjghjg</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="John Lunn">
<!-- Date: 2010-05-08 -->
</head>
<body>
<?php
ini_set('display_errors', 1);
require_once 'iCalcreator.class.php';
$v = new vcalendar();
/* start parse of local file */
$v->setConfig('directory', 'uploads');
// set directory
$v->setConfig('filename', 'basic.ics');
// set file name
$v->parse();
foreach ($v->components as $component => $info) {
# get first vevent
$comp = $v->getComponent("VEVENT");
//print_r($comp);
$summary_array = $comp->getProperty("summary", 1, TRUE);
//$summary_array = $vevent->getProperty("summary", 1, TRUE);
echo "Event: ", $summary_array["value"], "\n";
$dtstart_array = $comp->getProperty("dtstart", 1, TRUE);
//$dtstart_array = $vevent->getProperty("dtstart", 1, TRUE);
$dtstart = $dtstart_array["value"];
$startDate = "{$dtstart["year"]}-{$dtstart["month"]}-{$dtstart["day"]}";
示例11: vcalendar
<?php
/**
* Create a ical for the upcoming recordings
*
* @license GPL
*
* @package MythWeb
* @subpackage TV
*
**/
$calendar = new vcalendar();
$calendar->setConfig($_SERVER['SERVER_SIGNATURE'], $_SERVER['HTTP_HOST']);
$calendar->setProperty('method', 'PUBLISH');
foreach ($all_shows as $show) {
$event = new vevent();
$event->setProperty('dtstart', array('year' => date('Y', $show->starttime), 'month' => date('m', $show->starttime), 'day' => date('d', $show->starttime), 'hour' => date('H', $show->starttime), 'min' => date('i', $show->starttime), 'sec' => date('s', $show->starttime)));
$event->setProperty('dtend', array('year' => date('Y', $show->endtime), 'month' => date('m', $show->endtime), 'day' => date('d', $show->endtime), 'hour' => date('H', $show->endtime), 'min' => date('i', $show->endtime), 'sec' => date('s', $show->endtime)));
$event->setProperty('summary', $show->title . ($show->subtitle ? ' - ' . $show->subtitle : ''));
$event->setProperty('description', $show->description . "\n\n" . preg_replace('/([A-Z]+)/', ' $1', $show->recstatus));
$event->setProperty('location', $show->channel->callsign);
$calendar->setComponent($event);
}
$calendar->returnCalendar();
示例12: 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();
}
示例13: vcalendar
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
*
* @return icalendar string
**/
static function generateIcal($who, $who_group)
{
global $CFG_GLPI, $LANG;
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");
}
$v->setConfig('filename', "glpi.ics");
$v->setProperty("method", "PUBLISH");
$v->setProperty("version", "2.0");
$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);
// ---------------Tracking
$interv = TicketPlanning::populatePlanning(array('who' => $who, 'who_group' => $who_group, 'begin' => $begin, 'end' => $end));
// ---------------Reminder
$data = Reminder::populatePlanning(array('who' => $who, 'who_group' => $who_group, 'begin' => $begin, 'end' => $end));
$interv = array_merge($interv, $data);
// ---------------Plugin
$data = doHookFunction("planning_populate", array("begin" => $begin, "end" => $end, "who" => $who, "who_group" => $who_group));
if (isset($data["items"]) && count($data["items"])) {
$interv = array_merge($data["items"], $interv);
}
if (count($interv) > 0) {
foreach ($interv as $key => $val) {
$vevent = new vevent();
//initiate EVENT
if (isset($val["tickettasks_id"])) {
$vevent->setProperty("uid", "Job#" . $val["tickettasks_id"]);
} else {
if (isset($val["reminders_id"])) {
$vevent->setProperty("uid", "Event#" . $val["reminders_id"]);
} else {
if (isset($val['planningID'])) {
// Specify the ID (for plugins)
$vevent->setProperty("uid", "Plugin#" . $val['planningID']);
} else {
$vevent->setProperty("uid", "Plugin#" . $key);
}
}
}
$vevent->setProperty("dstamp", $val["begin"]);
$vevent->setProperty("dtstart", $val["begin"]);
$vevent->setProperty("dtend", $val["end"]);
if (isset($val["tickets_id"])) {
$vevent->setProperty("summary", $LANG['planning'][8] . " # " . $val["tickets_id"] . " " . $LANG['document'][14] . " # " . $val["device"]);
} else {
if (isset($val["name"])) {
$vevent->setProperty("summary", $val["name"]);
}
}
if (isset($val["content"])) {
$vevent->setProperty("description", html_clean($val["content"]));
} else {
if (isset($val["name"])) {
$vevent->setProperty("description", $val["name"]);
}
}
if (isset($val["tickets_id"])) {
$vevent->setProperty("url", $CFG_GLPI["url_base"] . "/index.php?redirect=tracking_" . $val["tickets_id"]);
}
$v->setComponent($vevent);
}
}
$v->sort();
//$v->parse();
return $v->returnCalendar();
}
示例15: array
$myOut = registry::register('file_handler')->FileLink('rss/' . $data['url'], 'eqdkp', 'relative');
}
}
break;
// generate an ical feed
// generate an ical feed
case 'icalfeed':
// the permissions for the single modules
$permissions = array('calendar' => 'po_calendarevent');
$modulename = registry::register('input')->get('module', '');
// check for permission
$userid = registry::fetch('user')->getUserIDfromExchangeKey(registry::register('input')->get('key', ''));
if (isset($permissions[$modulename]) && registry::fetch('user')->check_auth($permissions[$modulename], false, $userid)) {
require $eqdkp_root_path . 'libraries/icalcreator/iCalcreator.class.php';
$v = new vcalendar();
$v->setConfig('unique_id', registry::register('config')->get('server_name'));
$v->setProperty('x-wr-calname', sprintf(registry::fetch('user')->lang('icalfeed_name'), registry::register('config')->get('guildtag')));
$v->setProperty('X-WR-CALDESC', registry::fetch('user')->lang('icalfeed_description'));
// set the timezone - required by some clients
$timezone = registry::register('config')->get('timezone');
$v->setProperty("X-WR-TIMEZONE", $timezone);
iCalUtilityFunctions::createTimezone($v, $timezone, array("X-LIC-LOCATION" => $timezone));
switch ($modulename) {
case 'calendar':
$eventtypes = registry::register('input')->get('type', 'raids');
switch ($eventtypes) {
case 'raids':
$eventsfilter = true;
break;
case 'all':
$eventsfilter = false;