当前位置: 首页>>代码示例>>PHP>>正文


PHP vcalendar::parse方法代码示例

本文整理汇总了PHP中vcalendar::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP vcalendar::parse方法的具体用法?PHP vcalendar::parse怎么用?PHP vcalendar::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vcalendar的用法示例。


在下文中一共展示了vcalendar::parse方法的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;
 }
开发者ID:eidicon,项目名称:SyncNow,代码行数:38,代码来源:SyncICalToDB.php

示例2: 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;
 }
开发者ID:nathanlon,项目名称:twical,代码行数:44,代码来源:EventTable.class.php

示例3: get_json

 public function get_json()
 {
     $event_json = array();
     $filters = $this->in->exists('filters', 'int') ? $this->in->getArray('filters', 'int') : false;
     // parse the feeds
     $feeds = $this->pdh->get('calendars', 'idlist', array('feed', $filters));
     if (is_array($feeds) && count($feeds) > 0) {
         foreach ($feeds as $feed) {
             $feedurl = $this->pdh->get('calendars', 'feed', array($feed));
             if (isValidURL($feedurl)) {
                 require_once $this->root_path . 'libraries/icalcreator/iCalcreator.class.php';
                 $vcalendar = new vcalendar(array('url' => $feedurl));
                 if (TRUE === $vcalendar->parse()) {
                     $vcalendar->sort();
                     while ($comp = $vcalendar->getComponent('vevent')) {
                         $startdate = $comp->getProperty('dtstart', 1);
                         $enddate = $comp->getProperty('dtend', 1);
                         $startdate_out = $startdate['year'] . '-' . $startdate['month'] . '-' . $startdate['day'] . ' ' . (isset($startdate['hour']) ? $startdate['hour'] . ':' . $startdate['min'] : '00:00');
                         $enddate_out = $enddate['year'] . '-' . $enddate['month'] . '-' . $enddate['day'] . ' ' . (isset($enddate['hour']) ? $enddate['hour'] . ':' . $enddate['min'] : '00:00');
                         $allday = isset($enddate['hour']) && isset($startdate['hour']) ? false : true;
                         $eventcolor = $this->pdh->get('calendars', 'color', $feed);
                         $eventcolor_txt = get_brightness($eventcolor) > 130 ? 'black' : 'white';
                         $event_json[] = array('eventid' => $calid, 'title' => $comp->getProperty('summary', 1), 'start' => $startdate_out, 'end' => $enddate_out, 'allDay' => $allday, 'note' => $comp->getProperty('description', 1), 'color' => '#' . $eventcolor, 'textColor' => $eventcolor_txt);
                     }
                 }
             }
         }
     }
     // add the calendar events to the json feed
     $calendars = $this->pdh->get('calendars', 'idlist', array('nofeed', $filters));
     $caleventids = $this->pdh->get('calendar_events', 'id_list', array(false, $this->in->get('start', 0), $this->in->get('end', 0)));
     if (is_array($caleventids) && count($caleventids) > 0) {
         foreach ($caleventids as $calid) {
             $eventextension = $this->pdh->get('calendar_events', 'extension', array($calid));
             $raidmode = $eventextension['calendarmode'];
             $eventcolor = $this->pdh->get('calendars', 'color', $this->pdh->get('calendar_events', 'calendar_id', array($calid)));
             $eventcolor_txt = get_brightness($eventcolor) > 130 ? 'black' : 'white';
             if (in_array($this->pdh->get('calendar_events', 'calendar_id', array($calid)), $calendars)) {
                 if ($raidmode == 'raid') {
                     // fetch the attendees
                     $attendees_raw = $this->pdh->get('calendar_raids_attendees', 'attendees', array($calid));
                     $attendees = array();
                     if (is_array($attendees_raw)) {
                         foreach ($attendees_raw as $attendeeid => $attendeerow) {
                             $attendees[$attendeerow['signup_status']][$attendeeid] = $attendeerow;
                         }
                     }
                     // Build the guest array
                     $guests = array();
                     if (registry::register('config')->get('calendar_raid_guests') == 1) {
                         $guestarray = registry::register('plus_datahandler')->get('calendar_raids_guests', 'members', array($calid));
                         if (is_array($guestarray)) {
                             foreach ($guestarray as $guest_row) {
                                 $guests[] = $guest_row['name'];
                             }
                         }
                     }
                     // fetch per raid data
                     $raidcal_status = unserialize($this->config->get('calendar_raid_status'));
                     $rstatusdata = '';
                     if (is_array($raidcal_status)) {
                         foreach ($raidcal_status as $raidcalstat_id) {
                             if ($raidcalstat_id != 4) {
                                 $actcount = isset($attendees[$raidcalstat_id]) ? count($attendees[$raidcalstat_id]) : 0;
                                 if ($raidcalstat_id == 0) {
                                     $actcount += is_array($guests) ? count($guests) : 0;
                                 }
                                 $rstatusdata .= '<div class="raid_status' . $raidcalstat_id . '">' . $this->user->lang(array('raidevent_raid_status', $raidcalstat_id)) . ': ' . $actcount . '</div>';
                             }
                         }
                     }
                     $rstatusdata .= '<div class="raid_status_total">' . $this->user->lang('raidevent_raid_required') . ': ' . (isset($eventextension) ? $eventextension['attendee_count'] : 0) . '</div>';
                     $deadlinedate = $this->pdh->get('calendar_events', 'time_start', array($calid)) - $eventextension['deadlinedate'] * 3600;
                     $deadline = $deadlinedate > $this->time->time || $this->config->get('calendar_raid_allowstatuschange') == '1' && $this->pdh->get('calendar_raids_attendees', 'status', array($calid, $this->user->id)) > 0 && $this->pdh->get('calendar_raids_attendees', 'status', array($calid, $this->user->id)) != 4 && $this->pdh->get('calendar_events', 'time_end', array($calid)) > $this->time->time ? false : true;
                     $deadlineflag = $deadline ? '<img src="' . $this->root_path . 'images/calendar/clock_s.png" alt="Deadline" title="' . $this->user->lang('raidevent_raid_deadl_reach') . '" />' : '';
                     // Build the JSON
                     $event_json[] = array('title' => $this->in->decode_entity($this->pdh->get('calendar_events', 'name', array($calid))), 'start' => $this->time->date('Y-m-d H:i', $this->pdh->get('calendar_events', 'time_start', array($calid))), 'end' => $this->time->date('Y-m-d H:i', $this->pdh->get('calendar_events', 'time_end', array($calid))), 'closed' => $this->pdh->get('calendar_events', 'raidstatus', array($calid)) == 1 ? true : false, 'editable' => true, 'eventid' => $calid, 'flag' => $deadlineflag . $this->pdh->get('calendar_raids_attendees', 'html_status', array($calid, $this->user->data['user_id'])), 'url' => 'calendar/viewcalraid.php' . $this->SID . '&eventid=' . $calid, 'icon' => $eventextension['raid_eventid'] ? $this->pdh->get('event', 'icon', array($eventextension['raid_eventid'], true, true)) : '', 'note' => $this->pdh->get('calendar_events', 'notes', array($calid)), 'raidleader' => $eventextension['raidleader'] > 0 ? implode(', ', $this->pdh->aget('member', 'name', 0, array($eventextension['raidleader']))) : '', 'rstatusdata' => $rstatusdata, 'color' => '#' . $eventcolor, 'textColor' => $eventcolor_txt);
                 } else {
                     $event_json[] = array('eventid' => $calid, 'title' => $this->pdh->get('calendar_events', 'name', array($calid)), 'start' => $this->time->date('Y-m-d H:i', $this->pdh->get('calendar_events', 'time_start', array($calid))), 'end' => $this->time->date('Y-m-d H:i', $this->pdh->get('calendar_events', 'time_end', array($calid))), 'allDay' => $this->pdh->get('calendar_events', 'allday', array($calid)) > 0 ? true : false, 'note' => $this->pdh->get('calendar_events', 'notes', array($calid)), 'color' => '#' . $eventcolor, 'textColor' => $eventcolor_txt);
                 }
             }
         }
     }
     // Output the array as JSON
     echo json_encode($event_json);
     exit;
 }
开发者ID:ubick,项目名称:lorekeepers.org,代码行数:87,代码来源:calendar.php

示例4: filemtime

$self_age = filemtime($_SERVER['SCRIPT_FILENAME']);
$self_age_fm = strftime("%Y%M%DT%H%M%SZ", $self_age);

$fname = "facebook-$uid-$key.ics";
$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];
开发者ID:palfrey,项目名称:calendars,代码行数:30,代码来源:fbevents.php

示例5: vcalendar

 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

require_once( 'iCalcreator.class.php' );
$v = new vcalendar(); // create a new calendar instance
$v->parse($argv[1]);

echo "<?\n\$_tz = array(";
foreach ($v->components as $tz)
{
	if (!is_a($tz, "vtimezone"))
		continue;
	$location = $tz->getProperty("X-LIC-LOCATION");
	$name = trim($location[1]);
	if ($name == "")
	{
		$location = $tz->getProperty("TZID");
		$name = trim($location);
	}
	$junk = array();
	echo "\"$name\" => \"".urlencode($tz->createComponent($junk))."\",\n";
开发者ID:palfrey,项目名称:calendars,代码行数:31,代码来源:genTz.php

示例6: iCal2xls

 /**
  * function iCal2xls
  *
  * Convert iCal file to xls format and send file to browser (default) or save xls file to disk
  * Definition iCal  : rcf2445, http://kigkonsult.se/downloads/index.php#rfc
  * Using iCalcreator: http://kigkonsult.se/downloads/index.php#iCalcreator
  * Based on PEAR Spreadsheet_Excel_Writer-0.9.1 (and OLE-1.0.0RC1)
  * to be installed as
  * pear install channel://pear.php.net/OLE-1.0.0RC1
  * pear install channel://pear.php.net/Spreadsheet_Excel_Writer-0.9.1
  *
  * @author Kjell-Inge Gustafsson <ical@kigkonsult.se>
  * @since  3.0 - 2011-12-21
  * @param  object $calendar opt. iCalcreator calendar instance
  * @return bool   returns FALSE when error
  */
 public function iCal2xls($calendar = FALSE)
 {
     $timeexec = array('start' => microtime(TRUE));
     if ($this->log) {
         $this->log->log(' ********** START **********', PEAR_LOG_NOTICE);
     }
     /** check input/output directory and filename */
     $inputdirFile = $outputdirFile = '';
     $inputFileParts = $outputFileParts = array();
     $remoteInput = $remoteOutput = FALSE;
     if ($calendar) {
         $inputdirFile = $calendar->getConfig('DIRFILE');
         $inputFileParts = pathinfo($inputdirFile);
         $inputFileParts['dirname'] = realpath($inputFileParts['dirname']);
         if ($this->log) {
             $this->log->log('fileParts:' . var_export($inputFileParts, TRUE), PEAR_LOG_DEBUG);
         }
     } elseif (FALSE === $this->_fixIO('input', 'ics', $inputdirFile, $inputFileParts, $remoteInput)) {
         if ($this->log) {
             $this->log->log(number_format(microtime(TRUE) - $timeexec['start'], 5) . ' sec', PEAR_LOG_ERR);
             $this->log->log("ERROR 2, invalid input ({$inputdirFile})", PEAR_LOG_ERR);
             $this->log->flush();
         }
         return FALSE;
     }
     if (FALSE === $this->_fixIO('output', FALSE, $outputdirFile, $outputFileParts, $remoteOutput)) {
         if (FALSE === $this->setConfig('outputfilename', $inputFileParts['filename'] . '.xls')) {
             if ($this->log) {
                 $this->log->log(number_format(microtime(TRUE) - $timeexec['start'], 5) . ' sec', PEAR_LOG_ERR);
                 $this->log->log('ERROR 3, invalid output (' . $inputFileParts['filename'] . '.csv)', PEAR_LOG_ERR);
                 $this->log->flush();
             }
             return FALSE;
         }
         $outputdirFile = $this->getConfig('outputdirectory') . DIRECTORY_SEPARATOR . $inputFileParts['filename'] . '.xls';
         $outputFileParts = pathinfo($outputdirFile);
         if ($this->log) {
             $this->log->log("output set to '{$outputdirFile}'", PEAR_LOG_INFO);
         }
     }
     if ($this->log) {
         $this->log->log("INPUT..FILE:{$inputdirFile}", PEAR_LOG_NOTICE);
         $this->log->log("OUTPUT.FILE:{$outputdirFile}", PEAR_LOG_NOTICE);
     }
     $save = $this->getConfig('save');
     if ($calendar) {
         $calnl = $calendar->getConfig('nl');
     } else {
         /** iCalcreator set config, read and parse input iCal file */
         $calendar = new vcalendar();
         if (FALSE !== ($unique_id = $this->getConfig('unique_id'))) {
             $calendar->setConfig('unique_id', $unique_id);
         }
         $calnl = $calendar->getConfig('nl');
         if ($remoteInput) {
             if (FALSE === $calendar->setConfig('url', $inputdirFile)) {
                 if ($this->log) {
                     $this->log->log("ERROR 3 INPUT FILE:'{$inputdirFile}' iCalcreator: invalid url", 3);
                 }
                 return FALSE;
             }
         } else {
             if (FALSE === $calendar->setConfig('directory', $inputFileParts['dirname'])) {
                 if ($this->log) {
                     $this->log->log("ERROR 4 INPUT FILE:'{$inputdirFile}' iCalcreator: invalid directory: '" . $inputFileParts['dirname'] . "'", 3);
                     $this->log->flush();
                 }
                 return FALSE;
             }
             if (FALSE === $calendar->setConfig('filename', $inputFileParts['basename'])) {
                 if ($this->log) {
                     $this->log->log("ERROR 5 INPUT FILE:'{$inputdirFile}' iCalcreator: invalid filename: '" . $inputFileParts['basename'] . "'", 3);
                     $this->log->flush();
                 }
                 return FALSE;
             }
         }
         if (FALSE === $calendar->parse()) {
             if ($this->log) {
                 $this->log->log("ERROR 6 INPUT FILE:'{$inputdirFile}' iCalcreator parse error", 3);
                 $this->log->flush();
             }
             return FALSE;
         }
//.........这里部分代码省略.........
开发者ID:andyUA,项目名称:kabmin-new,代码行数:101,代码来源:iCalcnv.class.php

示例7: import_ics_data

 public function import_ics_data($calendar_id)
 {
     // -------------------------------------
     //	Get some basic info to use later
     // -------------------------------------
     $cbasics = $this->data->calendar_basics();
     $cbasics = $cbasics[$calendar_id];
     $urls = $cbasics['ics_url'];
     if ($urls == '') {
         return FALSE;
     }
     $tz_offset = $cbasics['tz_offset'] != '' ? $cbasics['tz_offset'] : '0000';
     /*
     
     		This shouldn't be happening because DST is only something that
     		would need to be applied when generating the users current local time.
     		If an event were at 7pm EST or EDT, it would still be at 7pm either way.
     		I hate DST.
     
     		if ($tz_offset != '0000' AND ee()->config->item('daylight_savings') == 'y')
     		{
     			$tz_offset += 100;
     		}
     */
     $channel_id = $this->data->channel_is_events_channel();
     $author_id = $cbasics['author_id'];
     // -------------------------------------
     //	Prepare the URLs
     // -------------------------------------
     if (!is_array($urls)) {
         $urls = explode("\n", $urls);
     }
     foreach ($urls as $k => $url) {
         $urls[$k] = trim($url);
     }
     // -------------------------------------
     //	Load iCalCreator
     // -------------------------------------
     if (!class_exists('vcalendar')) {
         require_once CALENDAR_PATH_ASSETS . 'icalcreator/iCalcreator.class.php';
     }
     // -------------------------------------
     //	Load Calendar_datetime
     // -------------------------------------
     if (!class_exists('Calendar_datetime')) {
         require_once CALENDAR_PATH . 'calendar.datetime' . EXT;
     }
     $CDT = new Calendar_datetime();
     $CDT_end = new Calendar_datetime();
     // -------------------------------------
     //	Load Publish
     // -------------------------------------
     if (APP_VER < 2.0) {
         //need to set DSP if not present
         if (!isset($GLOBALS['DSP']) or !is_object($GLOBALS['DSP'])) {
             if (!class_exists('Display')) {
                 require_once PATH_CP . 'cp.display' . EXT;
             }
             $GLOBALS['DSP'] = new Display();
         }
         if (!class_exists('Publish')) {
             require_once PATH_CP . 'cp.publish' . EXT;
         }
         $PB = new Publish();
         $PB->assign_cat_parent = ee()->config->item('auto_assign_cat_parents') == 'n' ? FALSE : TRUE;
     } else {
         ee()->load->library('api');
         ee()->api->instantiate(array('channel_entries', 'channel_categories', 'channel_fields'));
         ee()->api_channel_entries->assign_cat_parent = ee()->config->item('auto_assign_cat_parents') == 'n' ? FALSE : TRUE;
     }
     // -------------------------------------
     //	Tell our extensions that we're running the icalendar import
     // -------------------------------------
     $this->cache['ical'] = TRUE;
     // -------------------------------------
     //	Get already-imported events
     // -------------------------------------
     $imported = $this->data->get_imported_events($calendar_id);
     // -------------------------------------
     //	Don't let EXT drop us early
     // -------------------------------------
     ee()->extensions->in_progress = '';
     // -------------------------------------
     //	Cycle through the URLs
     // -------------------------------------
     foreach ($urls as $url) {
         $ICAL = new vcalendar();
         $ICAL->parse($this->fetch_url($url));
         // -------------------------------------
         //	Iterate among the events
         // -------------------------------------
         while ($event = $ICAL->getComponent('vevent')) {
             // -------------------------------------
             //	Times
             // -------------------------------------
             $hour = isset($event->dtstart['value']['hour']) ? $event->dtstart['value']['hour'] : 00;
             $minute = isset($event->dtstart['value']['min']) ? $event->dtstart['value']['min'] : 00;
             $end_hour = isset($event->dtend['value']['hour']) ? $event->dtend['value']['hour'] : $hour;
             $end_minute = isset($event->dtend['value']['min']) ? $event->dtend['value']['min'] : $minute;
             // -------------------------------------
//.........这里部分代码省略.........
开发者ID:thomasvandoren,项目名称:teentix-site,代码行数:101,代码来源:act.calendar.php

示例8: parse_ics_feed

 /**
  * Gets and parses an iCalendar feed into an array of `Ai1ec_Event' objects
  *
  * @param object $feed Row from the ai1ec_event_feeds table
  *
  * @return int Number of events imported
  */
 public function parse_ics_feed(&$feed, $content = false)
 {
     global $ai1ec_events_helper;
     $count = 0;
     $comment_status = 'open';
     if (isset($feed->comments_enabled) && $feed->comments_enabled < 1) {
         $comment_status = 'closed';
     }
     $do_show_map = 0;
     if (isset($feed->map_display_enabled) && $feed->map_display_enabled > 0) {
         $do_show_map = 1;
     }
     // set unique id, required if any component UID is missing
     $config = array('unique_id' => 'ai1ec');
     // create new instance
     $v = new vcalendar(array('unique_id' => $feed->feed_url, 'url' => $feed->feed_url));
     // actual parse of the feed
     if ($v->parse($content)) {
         $count = $this->add_vcalendar_events_to_db($v, $feed, $comment_status, $do_show_map);
     }
     return $count;
 }
开发者ID:briancompton,项目名称:knightsplaza,代码行数:29,代码来源:class-ai1ec-importer-helper.php

示例9: updateItem

 /**
  * @param string $uri
  * @param array $start
  * @param array $end
  * @param string $subject
  * @param bool $allday
  * @param string $description
  * @param string $location
  * @param null $color
  * @param string $timezone
  * @param bool $notification
  * @param null $notification_type
  * @param null $notification_value
  * @throws Sabre_DAV_Exception_NotFound
  * @throws Sabre_DAV_Exception_Conflict
  */
 public function updateItem($uri, $start, $end, $subject = "", $allday = false, $description = "", $location = "", $color = null, $timezone = "", $notification = true, $notification_type = null, $notification_value = null)
 {
     $a = get_app();
     $usr_id = IntVal($this->calendarDb->uid);
     $old = q("SELECT * FROM %s%sjqcalendar WHERE `uid` = %d AND `namespace` = %d AND `namespace_id` = %d AND `ical_uri` = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $usr_id, $this->getNamespace(), $this->namespace_id, dbesc($uri));
     if (count($old) == 0) {
         throw new Sabre_DAV_Exception_NotFound("Not Found 1");
     }
     $old_obj = new DBClass_friendica_jqcalendar($old[0]);
     $calendarBackend = new Sabre_CalDAV_Backend_Std();
     $obj = $calendarBackend->getCalendarObject($this->getNamespace() . "-" . $this->namespace_id, $old_obj->ical_uri);
     if (!$obj) {
         throw new Sabre_DAV_Exception_NotFound("Not Found 2");
     }
     $v = new vcalendar();
     $v->setConfig('unique_id', $a->get_hostname());
     $v->setMethod('PUBLISH');
     $v->setProperty("x-wr-calname", "AnimexxCal");
     $v->setProperty("X-WR-CALDESC", "Animexx Calendar");
     $v->setProperty("X-WR-TIMEZONE", $a->timezone);
     $obj["calendardata"] = icalendar_sanitize_string($obj["calendardata"]);
     $v->parse($obj["calendardata"]);
     /** @var $vevent vevent */
     $vevent = $v->getComponent('vevent');
     if (trim($vevent->getProperty('uid')) . ".ics" != $old_obj->ical_uri) {
         throw new Sabre_DAV_Exception_Conflict("URI != URI: " . $old_obj->ical_uri . " vs. " . trim($vevent->getProperty("uid")));
     }
     if ($end["year"] < $start["year"] || $end["year"] == $start["year"] && $end["month"] < $start["month"] || $end["year"] == $start["year"] && $end["month"] == $start["month"] && $end["day"] < $start["day"] || $end["year"] == $start["year"] && $end["month"] == $start["month"] && $end["day"] == $start["day"] && $end["hour"] < $start["hour"] || $end["year"] == $start["year"] && $end["month"] == $start["month"] && $end["day"] == $start["day"] && $end["hour"] == $start["hour"] && $end["minute"] < $start["minute"] || $end["year"] == $start["year"] && $end["month"] == $start["month"] && $end["day"] == $start["day"] && $end["hour"] == $start["hour"] && $end["minute"] == $start["minute"] && $end["second"] < $start["second"]) {
         $end = $start;
         if ($end["hour"] < 23) {
             $end["hour"]++;
         }
     }
     // DTEND muss <= DTSTART
     if ($start["hour"] == 0 && $start["minute"] == 0 && $end["hour"] == 23 && $end["minute"] == 59) {
         $allday = true;
     }
     if ($allday) {
         $vevent->setDtstart($start["year"], $start["month"], $start["day"], FALSE, FALSE, FALSE, FALSE, array("VALUE" => "DATE"));
         $end = mktime(0, 0, 0, $end["month"], $end["day"], $end["year"]) + 3600 * 24;
         // If a DST change occurs on the current day
         $end += date("Z", $end - 3600 * 24) - date("Z", $end);
         $vevent->setDtend(date("Y", $end), date("m", $end), date("d", $end), FALSE, FALSE, FALSE, FALSE, array("VALUE" => "DATE"));
     } else {
         $vevent->setDtstart($start["year"], $start["month"], $start["day"], $start["hour"], $start["minute"], $start["second"], FALSE, array("VALUE" => "DATE-TIME"));
         $vevent->setDtend($end["year"], $end["month"], $end["day"], $end["hour"], $end["minute"], $end["second"], FALSE, array("VALUE" => "DATE-TIME"));
     }
     if ($subject != "") {
         $vevent->setProperty('LOCATION', $location);
         $vevent->setProperty('summary', $subject);
         $vevent->setProperty('description', $description);
     }
     if (!is_null($color) && $color >= 0) {
         $vevent->setProperty("X-ANIMEXX-COLOR", $color);
     }
     if (!$notification || $notification_type != null) {
         $vevent->deleteComponent("VALARM");
         if ($notification) {
             $valarm = new valarm();
             $valarm->setTrigger($notification_type == "year" ? $notification_value : 0, $notification_type == "month" ? $notification_value : 0, $notification_type == "day" ? $notification_value : 0, $notification_type == "week" ? $notification_value : 0, $notification_type == "hour" ? $notification_value : 0, $notification_type == "minute" ? $notification_value : 0, $notification_type == "minute" ? $notification_value : 0, true, $notification_value > 0);
             $valarm->setProperty("ACTION", "DISPLAY");
             $valarm->setProperty("DESCRIPTION", $subject);
             $vevent->setComponent($valarm);
         }
     }
     $v->deleteComponent("vevent");
     $v->setComponent($vevent, trim($vevent->getProperty("uid")));
     $ical = $v->createCalendar();
     $calendarBackend->updateCalendarObject($this->getNamespace() . "-" . $this->namespace_id, $old_obj->ical_uri, $ical);
 }
开发者ID:robhell,项目名称:friendica-addons,代码行数:86,代码来源:wdcal_cal_source_private.inc.php

示例10: import_from_string

 /**
  * Tries to import data treating it either as csv or as ics.
  *
  * @param string $data
  * @return int the number of imported objetcs
  */
 private function import_from_string($data)
 {
     $ics = $this->_registry->get('import-export.ics');
     $id = __('textarea_import', AI1EC_PLUGIN_NAME) . '-' . date('Y-m-d-H:i:s');
     $feed = $this->create_feed_instance($id);
     $comments = isset($_POST['ai1ec_file_upload_comments_enabled']) ? 'open' : 'closed';
     $show_map = isset($_POST['ai1ec_file_upload_map_display_enabled']) ? 1 : 0;
     $ical_cnv = new iCalcnv();
     $ical_cnv->setConfig(array('outputobj' => true, 'string_to_parse' => $data));
     $v = $ical_cnv->csv2iCal();
     $count = $ics->add_vcalendar_events_to_db($v, array('feed' => $feed, 'comment_status' => $comments, 'do_show_map' => $show_map));
     if (0 === $count['count']) {
         // create new instance
         $v = new vcalendar();
         $v->parse($data);
         $count = $ics->add_vcalendar_events_to_db($v, array('feed' => $feed, 'comment_status' => $comments, 'do_show_map' => $show_map));
     }
     return $count['count'];
 }
开发者ID:brianotoole,项目名称:tbttt,代码行数:25,代码来源:csv.php

示例11: addLogEntry

    }
}
/* check if testfile is to be recreated (after 24h) */
$createFileStatus = FALSE;
if (TRUE === ($createFileStatus = !is_file($dirFile))) {
    addLogEntry(3, "  '{$dirFile}' file is missing");
} else {
    $calendar = new vcalendar();
    $calendar->setConfig('unique_id', UNIQUE);
    if (!$calendar->setConfig('directory', CALDIR)) {
        addLogEntry(1, '  ERROR (1) when setting directory \'' . CALDIR . '\', check directory/file permissions!!');
    } elseif (!$calendar->setConfig('filename', TESTFILE)) {
        addLogEntry(1, "  ERROR (2) when setting directory/file '{$dirFile}', check directory/file permissions!!");
    } else {
        $starttime2 = microtime(TRUE);
        $createFileStatus = !$calendar->parse();
        $exec = array(', Parse exec time:', $starttime2, microtime(TRUE));
        if (FALSE !== $createFileStatus) {
            addLogEntry(2, '  FALSE from calendar->parse, i.e. file missing or empty' . $exec[0], $exec[1], $exec[2]);
        } else {
            addLogEntry(3, '  TRUE from calendar->parse' . $exec[0], $exec[1], $exec[2]);
            $starttime2 = microtime(TRUE);
            $comp = $calendar->getComponent('vevent', 1);
            $exec = array(', exec time:', $starttime2, microtime(TRUE));
            if (FALSE === $comp) {
                $createFileStatus = TRUE;
                addLogEntry(2, '  FALSE from calendar->getComponent, no vevent in file' . $exec[0], $exec[1], $exec[2]);
            } else {
                addLogEntry(3, '  TRUE from calendar->getComponent' . $exec[0], $exec[1], $exec[2]);
                $starttime2 = microtime(TRUE);
                $dtstart = $comp->getProperty('dtstart');
开发者ID:bobjacobsen,项目名称:EventTools,代码行数:31,代码来源:createTestfile.php

示例12: iCal2csv

/**
 * function iCal2csv
 *
 * Convert iCal file to csv format and send file to browser (default) or save csv file to disk
 * Definition iCal  : rcf2445, http://localhost/work/kigkonsult.se/downloads/index.php#rfc2445
 * Definition csv   : http://en.wikipedia.org/wiki/Comma-separated_values
 * Using iCalcreator: http://localhost/work/kigkonsult.se/downloads/index.php#iCalcreator
 * ical directory/file read/write error OR iCalcreator parse error will be directed to error_log/log
 *
 * @author Kjell-Inge Gustafsson <ical@kigkonsult.se>
 * @since 2.0 - 2009-03-27
 * @param string $filename      file to convert (incl. opt. directory)
 * @param array  $conf          opt, default FALSE(=array('del'=>'"','sep'=>',', 'nl'=>'\n'), delimiter, separator and newline characters
 *                              escape sequences will be expanded, '\n' will be used as "\n" etc.
 *                              also map iCal property names to user friendly names, ex. 'DTSTART' => 'startdate'
 *                              also order output columns, ex. 2 => 'DTSTART' (2=first order column, 3 next etc)
 *                              also properties to skip, ex. 'skip' => array( 'CREATED', 'PRIORITY' );
 * @param bool   $save          opt, default FALSE, TRUE=save to disk
 * @param string $diskfilename  opt, filename for file to save or else taken from $filename + 'csv' extension
 * @param object $log           opt, default FALSE (error_log), writes log to file using PEAR LOG or eClog class
 * @return bool                 returns FALSE when error
 */
function iCal2csv($filename, $conf = FALSE, $save = FALSE, $diskfilename = FALSE, $log = FALSE)
{
    if ($log) {
        $timeexec = array('start' => microtime(TRUE));
    }
    $iCal2csv_VERSION = 'iCal2csv 2.0';
    if (!function_exists('fileCheckRead')) {
        require_once 'fileCheck.php';
    }
    if (!class_exists('vcalendar', FALSE)) {
        require_once 'iCalcreator.class.php';
    }
    if ($log) {
        $log->log("{$iCal2csv_VERSION} input={$filename}, conf=" . var_export($conf, TRUE) . ", save={$save}, diskfilename={$diskfilename}", 7);
    }
    $remoteInput = 'http://' == strtolower(substr($filename, 0, 7)) || 'webcal://' == strtolower(substr($filename, 0, 9)) ? TRUE : FALSE;
    // field DELimiter && field SEParator && NewLine character(-s) etc.
    if (!$conf) {
        $conf = array();
    }
    if (!isset($conf['del'])) {
        $conf['del'] = '"';
    }
    if (!isset($conf['sep'])) {
        $conf['sep'] = ',';
    }
    if (!isset($conf['nl'])) {
        $conf['nl'] = "\n";
    }
    foreach ($conf as $key => $value) {
        if ('skip' == $key) {
            foreach ($value as $six => $skipp) {
                $conf['skip'][$six] = strtoupper($skipp);
            }
        } elseif ('2' <= $key && '99' > $key) {
            $conf[$key] = strtoupper($value);
            if ($log) {
                $log->log("{$iCal2csv_VERSION} column {$key} contains " . strtoupper($value), 7);
            }
        } elseif (in_array($key, array('del', 'sep', 'nl'))) {
            $conf[$key] = "{$value}";
        } else {
            $conf[strtoupper($key)] = $value;
            if ($log) {
                $log->log("{$iCal2csv_VERSION} " . strtoupper($key) . " mapped to {$value}", 7);
            }
        }
    }
    /* create path and filename */
    if ($remoteInput) {
        $inputFileParts = parse_url($filename);
        $inputFileParts = array_merge($inputFileParts, pathinfo($inputFileParts['path']));
        if (!$diskfilename) {
            $diskfilename = $inputFileParts['filename'] . '.csv';
        }
    } else {
        if (FALSE === ($filename = fileCheckRead($filename, $log))) {
            if ($log) {
                $log->log("{$iCal2csv_VERSION} (" . number_format(microtime(TRUE) - $timeexec['start'], 5) . ')');
                $log->flush();
            }
            return FALSE;
        }
        $inputFileParts = pathinfo($filename);
        if (!$diskfilename) {
            $diskfilename = $inputFileParts['dirname'] . DIRECTORY_SEPARATOR . $inputFileParts['filename'] . '.csv';
        }
    }
    $outputFileParts = pathinfo($diskfilename);
    if ($save) {
        if (FALSE === ($diskfilename = fileCheckWrite($outputFileParts['dirname'] . DIRECTORY_SEPARATOR . $outputFileParts['basename'], $log))) {
            if ($log) {
                $log->log("{$iCal2csv_VERSION} (" . number_format(microtime(TRUE) - $timeexec['start'], 5) . ')');
                $log->flush();
            }
            return FALSE;
        }
    }
//.........这里部分代码省略.........
开发者ID:santas156,项目名称:joomleague-2-komplettpaket,代码行数:101,代码来源:iCal2csv.php

示例13: agenda_import_ical

/**
 * Import an iCal file into the database
 * @param   array   Course info
 * @return  boolean True on success, false otherwise
 * @deprecated
 */
function agenda_import_ical($course_info, $file)
{
    require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
    $charset = api_get_system_encoding();
    $filepath = api_get_path(SYS_ARCHIVE_PATH) . $file['name'];
    if (!@move_uploaded_file($file['tmp_name'], $filepath)) {
        error_log('Problem moving uploaded file: ' . $file['error'] . ' in ' . __FILE__ . ' line ' . __LINE__);
        return false;
    }
    require_once api_get_path(LIBRARY_PATH) . 'icalcreator/iCalcreator.class.php';
    $ical = new vcalendar();
    $ical->setConfig('directory', dirname($filepath));
    $ical->setConfig('filename', basename($filepath));
    $return = $ical->parse();
    //we need to recover: summary, description, dtstart, dtend, organizer, attendee, location (=course name),
    /*
              $ve = $ical->getComponent(VEVENT);
    
              $ttitle	= $ve->getProperty('summary');
              $title	= api_convert_encoding($ttitle,$charset,'UTF-8');
    
              $tdesc	= $ve->getProperty('description');
              $desc	= api_convert_encoding($tdesc,$charset,'UTF-8');
    
              $start_date	= $ve->getProperty('dtstart');
              $start_date_string = $start_date['year'].'-'.$start_date['month'].'-'.$start_date['day'].' '.$start_date['hour'].':'.$start_date['min'].':'.$start_date['sec'];
    
    
              $ts 	 = $ve->getProperty('dtend');
              if ($ts) {
              $end_date_string = $ts['year'].'-'.$ts['month'].'-'.$ts['day'].' '.$ts['hour'].':'.$ts['min'].':'.$ts['sec'];
              } else {
              //Check duration if dtend does not exist
              $duration 	  = $ve->getProperty('duration');
              if ($duration) {
              $duration = $ve->getProperty('duration');
              $duration_string = $duration['year'].'-'.$duration['month'].'-'.$duration['day'].' '.$duration['hour'].':'.$duration['min'].':'.$duration['sec'];
              $start_date_tms = mktime(intval($start_date['hour']), intval($start_date['min']), intval($start_date['sec']), intval($start_date['month']), intval($start_date['day']), intval($start_date['year']));
              //$start_date_tms = mktime(($start_date['hour']), ($start_date['min']), ($start_date['sec']), ($start_date['month']), ($start_date['day']), ($start_date['year']));
              //echo date('d-m-Y - h:i:s', $start_date_tms);
    
              $end_date_string = mktime(intval($start_date['hour']) +$duration['hour'], intval($start_date['min']) + $duration['min'], intval($start_date['sec']) + $duration['sec'], intval($start_date['month']) + $duration['month'], intval($start_date['day'])+$duration['day'], intval($start_date['year']) + $duration['year']);
              $end_date_string = date('Y-m-d H:i:s', $end_date_string);
              //echo date('d-m-Y - h:i:s', $end_date_string);
              }
              }
    
    
              //echo $start_date.' - '.$end_date;
              $organizer	 = $ve->getProperty('organizer');
              $attendee 	 = $ve->getProperty('attendee');
              $course_name = $ve->getProperty('location');
              //insert the event in our database
              $id = agenda_add_item($course_info,$title,$desc,$start_date_string,$end_date_string,$_POST['selectedform']);
    
    
              $repeat = $ve->getProperty('rrule');
              if(is_array($repeat) && !empty($repeat['FREQ'])) {
              $trans = array('DAILY'=>'daily','WEEKLY'=>'weekly','MONTHLY'=>'monthlyByDate','YEARLY'=>'yearly');
              $freq = $trans[$repeat['FREQ']];
              $interval = $repeat['INTERVAL'];
              if(isset($repeat['UNTIL']) && is_array($repeat['UNTIL'])) {
              $until = mktime(23,59,59,$repeat['UNTIL']['month'],$repeat['UNTIL']['day'],$repeat['UNTIL']['year']);
              $res = agenda_add_repeat_item($course_info,$id,$freq,$until,$_POST['selectedform']);
              } */
    $eventcount = 0;
    $message = array();
    $agenda_obj = new Agenda();
    while (true) {
        //we need to recover: summary, description, dtstart, dtend, organizer, attendee, location (=course name)
        $ve = $ical->getComponent('VEVENT', $eventcount);
        if (!$ve) {
            break;
        }
        $ttitle = $ve->getProperty('summary');
        $title = api_convert_encoding($ttitle, $charset, 'UTF-8');
        $tdesc = $ve->getProperty('description');
        $desc = api_convert_encoding($tdesc, $charset, 'UTF-8');
        $start_date = $ve->getProperty('dtstart', false, true);
        if (isset($start_date['params']['VALUE'])) {
            $start_date_value = $start_date['value'];
            if ($start_date['params']['VALUE'] == 'DATE') {
                $start_date_string = $start_date_value['year'] . '-' . $start_date_value['month'] . '-' . $start_date_value['day'] . '';
            } else {
                $start_date_string = $start_date_value['year'] . '-' . $start_date_value['month'] . '-' . $start_date_value['day'] . ' ' . $start_date_value['hour'] . ':' . $start_date_value['min'] . ':' . $start_date_value['sec'];
            }
        } else {
            continue;
        }
        $ts = $ve->getProperty('dtend');
        if ($ts) {
            $end_date = $ve->getProperty('dtend', false, true);
            if (isset($end_date['params']['VALUE'])) {
                $end_date_value = $end_date['value'];
//.........这里部分代码省略.........
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:101,代码来源:agenda.inc.php

示例14: array

#!/usr/bin/php
<?php 
require 'vendor/autoload.php';
require_once 'configs.php';
$scopes = array('https://www.googleapis.com/auth/calendar');
// iCal データ取得
$client = new GuzzleHttp\Client();
$clientRes = $client->get($aipoIcalUrl, ['auth' => [$aipoUser, $aipoPasswd]]);
if ($clientRes->getStatusCode() != 200) {
    echo 'Authorization Required' . "\n";
    exit(1);
}
$icalContents = $clientRes->getBody();
$ical = new vcalendar();
$icalRes = $ical->parse($icalContents);
$aipoEvents = array();
if ($icalRes == true) {
    foreach ($ical->components as $key => $event) {
        $summary = $event->getProperty('summary');
        if (!$summary) {
            continue;
        }
        $dtstamp = $event->getProperty('dtstamp');
        $dtstart = $event->getProperty('dtstart', 0, true);
        $dtend = $event->getProperty('dtend', 0, true);
        $uid = $event->getProperty('uid');
        preg_match('/^([0-9A-Za-z]+)-([0-9]+)\\@(.+?)$/', $uid, $matches);
        $aipoId = $matches[2];
        $start = new Google_Service_Calendar_EventDateTime();
        if (!empty($dtstart['params']) && $dtstart['params']['VALUE'] == 'DATE') {
            $start->setDate($dtstart['value']['year'] . '-' . sprintf('%02d', $dtstart['value']['month']) . '-' . sprintf('%02d', $dtstart['value']['day']));
开发者ID:kksn2501,项目名称:aipo_to_gcal,代码行数:31,代码来源:upload.php

示例15: vcalendar

 /**
  * Parses an iCalendar resource
  */
 function parse_icalendar($data)
 {
     $vcalendar = new vcalendar($this->config);
     $vcalendar->parse($data);
     return $vcalendar;
 }
开发者ID:julien2512,项目名称:agendav,代码行数:9,代码来源:Icshelper.php


注:本文中的vcalendar::parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。