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


PHP vcalendar::getComponent方法代码示例

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


在下文中一共展示了vcalendar::getComponent方法的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: 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

示例4: 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

示例5: add_vcalendar_events_to_db

 /**
  * Process vcalendar instance - add events to database.
  *
  * @param vcalendar $v    Calendar to retrieve data from.
  * @param array     $args Arbitrary arguments map.
  *
  * @throws Ai1ec_Parse_Exception
  *
  * @internal param stdClass $feed           Instance of feed (see Ai1ecIcs plugin).
  * @internal param string   $comment_status WP comment status: 'open' or 'closed'.
  * @internal param int      $do_show_map    Map display status (DB boolean: 0 or 1).
  *
  * @return int Count of events added to database.
  */
 public function add_vcalendar_events_to_db(vcalendar $v, array $args)
 {
     $forced_timezone = null;
     $feed = isset($args['feed']) ? $args['feed'] : null;
     $comment_status = isset($args['comment_status']) ? $args['comment_status'] : 'open';
     $do_show_map = isset($args['do_show_map']) ? $args['do_show_map'] : 0;
     $count = 0;
     $events_in_db = isset($args['events_in_db']) ? $args['events_in_db'] : 0;
     //sort by event date function _cmpfcn of iCalcreator.class.php
     $v->sort();
     // Reverse the sort order, so that RECURRENCE-IDs are listed before the
     // defining recurrence events, and therefore take precedence during
     // caching.
     $v->components = array_reverse($v->components);
     // TODO: select only VEVENT components that occur after, say, 1 month ago.
     // Maybe use $v->selectComponents(), which takes into account recurrence
     // Fetch default timezone in case individual properties don't define it
     $tz = $v->getComponent('vtimezone');
     $local_timezone = $this->_registry->get('date.timezone')->get_default_timezone();
     $timezone = $local_timezone;
     if (!empty($tz)) {
         $timezone = $tz->getProperty('TZID');
     }
     $feed_name = $v->getProperty('X-WR-CALNAME');
     $x_wr_timezone = $v->getProperty('X-WR-TIMEZONE');
     if (isset($x_wr_timezone[1]) && is_array($x_wr_timezone)) {
         $forced_timezone = (string) $x_wr_timezone[1];
         $timezone = $forced_timezone;
     }
     $messages = array();
     if (empty($forced_timezone)) {
         $forced_timezone = $local_timezone;
     }
     $current_timestamp = $this->_registry->get('date.time')->format_to_gmt();
     // initialize empty custom exclusions structure
     $exclusions = array();
     // go over each event
     while ($e = $v->getComponent('vevent')) {
         // Event data array.
         $data = array();
         // =====================
         // = Start & end times =
         // =====================
         $start = $e->getProperty('dtstart', 1, true);
         $end = $e->getProperty('dtend', 1, true);
         // For cases where a "VEVENT" calendar component
         // specifies a "DTSTART" property with a DATE value type but none
         // of "DTEND" nor "DURATION" property, the event duration is taken to
         // be one day.  For cases where a "VEVENT" calendar component
         // specifies a "DTSTART" property with a DATE-TIME value type but no
         // "DTEND" property, the event ends on the same calendar date and
         // time of day specified by the "DTSTART" property.
         if (empty($end)) {
             // #1 if duration is present, assign it to end time
             $end = $e->getProperty('duration', 1, true, true);
             if (empty($end)) {
                 // #2 if only DATE value is set for start, set duration to 1 day
                 if (!isset($start['value']['hour'])) {
                     $end = array('value' => array('year' => $start['value']['year'], 'month' => $start['value']['month'], 'day' => $start['value']['day'] + 1, 'hour' => 0, 'min' => 0, 'sec' => 0));
                     if (isset($start['value']['tz'])) {
                         $end['value']['tz'] = $start['value']['tz'];
                     }
                 } else {
                     // #3 set end date to start time
                     $end = $start;
                 }
             }
         }
         $categories = $e->getProperty("CATEGORIES", false, true);
         $imported_cat = array(Ai1ec_Event_Taxonomy::CATEGORIES => array());
         // If the user chose to preserve taxonomies during import, add categories.
         if ($categories && $feed->keep_tags_categories) {
             $imported_cat = $this->add_categories_and_tags($categories['value'], $imported_cat, false, true);
         }
         $feed_categories = $feed->feed_category;
         if (!empty($feed_categories)) {
             $imported_cat = $this->add_categories_and_tags($feed_categories, $imported_cat, false, false);
         }
         $tags = $e->getProperty("X-TAGS", false, true);
         $imported_tags = array(Ai1ec_Event_Taxonomy::TAGS => array());
         // If the user chose to preserve taxonomies during import, add tags.
         if ($tags && $feed->keep_tags_categories) {
             $imported_tags = $this->add_categories_and_tags($tags[1]['value'], $imported_tags, true, true);
         }
         $feed_tags = $feed->feed_tags;
         if (!empty($feed_tags)) {
//.........这里部分代码省略.........
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:101,代码来源:ics.php

示例6: genTimezone

{
	#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"));
	$description .= "\\n\\n$url";
	$vevent->deleteProperty('description');
开发者ID:palfrey,项目名称:calendars,代码行数:31,代码来源:fbevents.php

示例7: agenda_import_ical

/**
 * Import an iCal file into the database
 * @param   array   Course info
 * @return  boolean True on success, false otherwise
 */
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));
    $ical->parse();
    //we need to recover: summary, description, dtstart, dtend, organizer, attendee, location (=course name),
    // rrule
    $ve = $ical->getComponent(VEVENT);
    //print_r($ve);
    $ttitle = $ve->getProperty('summary');
    //print_r($ttitle);
    $title = api_convert_encoding($ttitle, $charset, 'UTF-8');
    $tdesc = $ve->getProperty('description');
    $desc = api_convert_encoding($tdesc, $charset, 'UTF-8');
    $ts = $ve->getProperty('dtstart');
    $start_date = $ts['year'] . '-' . $ts['month'] . '-' . $ts['day'] . ' ' . $ts['hour'] . ':' . $ts['min'] . ':' . $ts['sec'];
    $ts = $ve->getProperty('dtend');
    $end_date = $ts['year'] . '-' . $ts['month'] . '-' . $ts['day'] . ' ' . $ts['hour'] . ':' . $ts['min'] . ':' . $ts['sec'];
    //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, $end_date, $_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']);
        }
        //TODO: deal with count
        if (!empty($repeat['COUNT'])) {
            $count = $repeat['COUNT'];
            $res = agenda_add_repeat_item($course_info, $id, $freq, $count, $_POST['selectedform']);
        }
    }
    return true;
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:55,代码来源:calendar.lib.php

示例8: add_vcalendar_events_to_db

 /**
  * Process vcalendar instance - add events to database.
  *
  * @param vcalendar $v    Calendar to retrieve data from.
  * @param array     $args Arbitrary arguments map.
  *
  * @throws Ai1ec_Parse_Exception
  *
  * @internal param stdClass $feed           Instance of feed (see Ai1ecIcs plugin).
  * @internal param string   $comment_status WP comment status: 'open' or 'closed'.
  * @internal param int      $do_show_map    Map display status (DB boolean: 0 or 1).
  *
  * @return int Count of events added to database.
  */
 public function add_vcalendar_events_to_db(vcalendar $v, array $args)
 {
     $feed = isset($args['feed']) ? $args['feed'] : null;
     $comment_status = isset($args['comment_status']) ? $args['comment_status'] : 'open';
     $do_show_map = isset($args['do_show_map']) ? $args['do_show_map'] : 0;
     $count = 0;
     $events_in_db = $args['events_in_db'];
     $v->sort();
     // Reverse the sort order, so that RECURRENCE-IDs are listed before the
     // defining recurrence events, and therefore take precedence during
     // caching.
     $v->components = array_reverse($v->components);
     // TODO: select only VEVENT components that occur after, say, 1 month ago.
     // Maybe use $v->selectComponents(), which takes into account recurrence
     // Fetch default timezone in case individual properties don't define it
     $timezone = $v->getProperty('X-WR-TIMEZONE');
     $timezone = (string) $timezone[1];
     // go over each event
     while ($e = $v->getComponent('vevent')) {
         // Event data array.
         $data = array();
         // =====================
         // = Start & end times =
         // =====================
         $start = $e->getProperty('dtstart', 1, true);
         $end = $e->getProperty('dtend', 1, true);
         // For cases where a "VEVENT" calendar component
         // specifies a "DTSTART" property with a DATE value type but none
         // of "DTEND" nor "DURATION" property, the event duration is taken to
         // be one day.  For cases where a "VEVENT" calendar component
         // specifies a "DTSTART" property with a DATE-TIME value type but no
         // "DTEND" property, the event ends on the same calendar date and
         // time of day specified by the "DTSTART" property.
         if (empty($end)) {
             // #1 if duration is present, assign it to end time
             $end = $e->getProperty('duration', 1, true, true);
             if (empty($end)) {
                 // #2 if only DATE value is set for start, set duration to 1 day
                 if (!isset($start['value']['hour'])) {
                     $end = array('value' => array('year' => $start['value']['year'], 'month' => $start['value']['month'], 'day' => $start['value']['day'] + 1, 'hour' => 0, 'min' => 0, 'sec' => 0));
                     if (isset($start['value']['tz'])) {
                         $end['value']['tz'] = $start['value']['tz'];
                     }
                 } else {
                     // #3 set end date to start time
                     $end = $start;
                 }
             }
         }
         $categories = $e->getProperty("CATEGORIES", false, true);
         $imported_cat = array();
         // If the user chose to preserve taxonomies during import, add categories.
         if ($categories && $feed->keep_tags_categories) {
             $imported_cat = $this->_add_categories_and_tags($categories['value'], $imported_cat, false, true);
         }
         $feed_categories = $feed->feed_category;
         if (!empty($feed_categories)) {
             $imported_cat = $this->_add_categories_and_tags($feed_categories, $imported_cat, false, false);
         }
         $tags = $e->getProperty("X-TAGS", false, true);
         $imported_tags = array();
         // If the user chose to preserve taxonomies during import, add tags.
         if ($tags && $feed->keep_tags_categories) {
             $imported_tags = $this->_add_categories_and_tags($tags[1]['value'], $imported_tags, true, true);
         }
         $feed_tags = $feed->feed_tags;
         if (!empty($feed_tags)) {
             $imported_tags = $this->_add_categories_and_tags($feed_tags, $imported_tags, true, true);
         }
         // Event is all-day if no time components are defined
         $allday = $this->_is_timeless($start['value']) && $this->_is_timeless($end['value']);
         // Also check the proprietary MS all-day field.
         $ms_allday = $e->getProperty('X-MICROSOFT-CDO-ALLDAYEVENT');
         if (!empty($ms_allday) && $ms_allday[1] == 'TRUE') {
             $allday = true;
         }
         $start = $this->_time_array_to_datetime($start, $timezone);
         $end = $this->_time_array_to_datetime($end, $timezone);
         if (false === $start || false === $end) {
             throw new Ai1ec_Parse_Exception('Failed to parse one or more dates given timezone "' . var_export($timezone, true) . '"');
             continue;
         }
         // If all-day, and start and end times are equal, then this event has
         // invalid end time (happens sometimes with poorly implemented iCalendar
         // exports, such as in The Event Calendar), so set end time to 1 day
         // after start time.
//.........这里部分代码省略.........
开发者ID:newmight2015,项目名称:psmpsm,代码行数:101,代码来源:ics.php

示例9: 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

示例10: toKalenderEvent

 public static function toKalenderEvent($iCal, $ownerClass = "iCal", $ownerClassID = "-1")
 {
     $VC = new vcalendar();
     $VC->parse($iCal);
     $event = $VC->getComponent("vevent");
     $dayStart = $event->getProperty("DTSTART");
     $dayEnd = $event->getProperty("DTEND");
     $dayStartTS = strtotime(implode("", $dayStart));
     $dayEndTS = strtotime(implode("", $dayEnd));
     $KE = new KalenderEvent($ownerClass, $ownerClassID, Kalender::formatDay($dayStartTS), Kalender::formatTime($dayStartTS), $event->getProperty("SUMMARY"));
     $KE->UID($event->getProperty("UID"));
     $organizer = $event->getProperty("ORGANIZER", 0, true);
     $organizer["value"] = str_replace("MAILTO:", "", $organizer["value"]);
     $ON = $organizer["value"];
     if (isset($organizer["params"]["CN"])) {
         $ON = $organizer["params"]["CN"];
     }
     $OE = $organizer["value"];
     $KE->organizer($ON, $OE);
     if ($dayStart["hour"] . $dayStart["min"] == "" and $dayEnd["hour"] . $dayEnd["min"] == "") {
         $KE->allDay(true);
     } else {
         $KE->endDay(Kalender::formatDay($dayEndTS));
         $KE->endTime(Kalender::formatTime($dayEndTS));
     }
     return $KE;
 }
开发者ID:nemiah,项目名称:trinityDB,代码行数:27,代码来源:iCalUtil.class.php

示例11: vcalendar




<?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"]}";
    $startTime = "{$dtstart["hour"]}:{$dtstart["min"]}:{$dtstart["sec"]}";
    $dtend_array = $comp->getProperty("dtend", 1, TRUE);
    //$dtend_array = $vevent->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";
开发者ID:nathanlon,项目名称:twical,代码行数:28,代码来源:Googleread.php

示例12: vcalendar

 $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');
             $exec = array(', exec time:', $starttime2, microtime(TRUE));
             if (FALSE === ($dtstart = $comp->getProperty('dtstart'))) {
                 $createFileStatus = TRUE;
                 addLogEntry(2, '  FALSE from (first) getProperty(DTSTART), no DTSTART in vevent component' . $exec[0], $exec[1], $exec[2]);
             } else {
                 $fileDtstartDate = sprintf("%04d%02d%02d", $dtstart['year'], $dtstart['month'], $dtstart['day']);
                 addLogEntry(3, "  {$fileDtstartDate} = (first) getProperty(DTSTART)" . $exec[0], $exec[1], $exec[2]);
开发者ID:bobjacobsen,项目名称:EventTools,代码行数:31,代码来源:createTestfile.php

示例13: iCal2csv


//.........这里部分代码省略.........
    }
    $proporder['TYPE'] = 0;
    $proporder['ORDER'] = 1;
    $props = array('TZID', 'LAST-MODIFIED', 'TZURL', 'DTSTART', 'TZOFFSETTO', 'TZOFFSETFROM', 'TZOFFSETTFROM', 'COMMENT', 'RRULE', 'RDATE', 'TZNAME');
    $pix = 2;
    foreach ($props as $prop) {
        if (isset($proporder[$prop])) {
            continue;
        }
        if (isset($conf['skip']) && in_array($prop, $conf['skip'])) {
            if ($log) {
                $log->log("{$iCal2csv_VERSION} {$prop} removed from output", 7);
            }
            continue;
        }
        while (in_array($pix, $proporder)) {
            $pix++;
        }
        $proporder[$prop] = $pix++;
    }
    /* remove unused properties from and add x-props to property order list */
    $maxpropix = 11;
    if ($maxpropix != count($proporder) - 1) {
        $maxpropix = count($proporder) - 1;
    }
    $compsinfo = $calendar->getConfig('compsinfo');
    $potmp = array();
    $potmp[0] = 'TYPE';
    $potmp[1] = 'ORDER';
    foreach ($compsinfo as $cix => $compinfo) {
        if ('vtimezone' != $compinfo['type']) {
            continue;
        }
        $comp = $calendar->getComponent($compinfo['ordno']);
        foreach ($compinfo['props'] as $propName => $propcnt) {
            if (!in_array($propName, $potmp) && isset($proporder[$propName])) {
                $potmp[$proporder[$propName]] = $propName;
            } elseif ('X-PROP' == $propName) {
                while ($xprop = $comp->getProperty()) {
                    if (!in_array($xprop[0], $potmp)) {
                        $maxpropix += 1;
                        $potmp[$maxpropix] = $xprop[0];
                    }
                    // end if
                }
                // end while xprop
            }
            // end X-PROP
        }
        // end $compinfo['props']
        if (isset($compinfo['sub'])) {
            foreach ($compinfo['sub'] as $compinfo2) {
                foreach ($compinfo2['props'] as $propName => $propcnt) {
                    if (!in_array($propName, $potmp) && isset($proporder[$propName])) {
                        $potmp[$proporder[$propName]] = $propName;
                    } elseif ('X-PROP' == $propName) {
                        $scomp = $comp->getComponent($compinfo2['ordno']);
                        while ($xprop = $scomp->getProperty()) {
                            if (!in_array($xprop[0], $potmp)) {
                                $maxpropix += 1;
                                $potmp[$maxpropix] = $xprop[0];
                            }
                            // end if
                        }
                        // end while xprop
                    }
开发者ID:santas156,项目名称:joomleague-2-komplettpaket,代码行数:67,代码来源:iCal2csv.php

示例14: 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

示例15: get_json

 public function get_json()
 {
     $event_json = array();
     $filters = $this->in->exists('filters', 'int') ? $this->in->getArray('filters', 'int') : false;
     $range_start = $this->time->fromformat($this->in->get('start', ''), 'Y-m-d');
     $range_end = $this->time->fromformat($this->in->get('end', ''), 'Y-m-d');
     $filterby = $this->in->get('filterby', 'all');
     // 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);
                         // set the date for the events
                         $allday = isset($enddate['hour']) && isset($startdate['hour']) ? false : true;
                         if ($allday) {
                             $startdate_out = sprintf("%04d", $startdate['year']) . '-' . sprintf("%02d", $startdate['month']) . '-' . sprintf("%02d", $startdate['day']) . ' 00:00';
                             $enddate_out = sprintf("%04d", $enddate['year']) . '-' . sprintf("%02d", $enddate['month']) . '-' . sprintf("%02d", $enddate['day'] - 1) . ' 00:00';
                         } else {
                             $startdate_out = sprintf("%04d", $startdate['year']) . '-' . sprintf("%02d", $startdate['month']) . '-' . sprintf("%02d", $startdate['day']) . ' ' . (isset($startdate['hour']) ? sprintf("%02d", $startdate['hour']) . ':' . sprintf("%02d", $startdate['min']) : '00:00');
                             $enddate_out = sprintf("%04d", $enddate['year']) . '-' . $enddate['month'] . '-' . $enddate['day'] . ' ' . (isset($enddate['hour']) ? $enddate['hour'] . ':' . $enddate['min'] : '00:00');
                         }
                         // build the event colours
                         $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 . ' !important', 'textColor' => $eventcolor_txt . ' !important');
                     }
                 }
             }
         }
     }
     // 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, $range_start, $range_end, false, $filterby));
     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 = $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 ? '<i class="fa fa-lock fa-lg" title="' . $this->user->lang('raidevent_raid_deadl_reach') . '"></i>' : '';
                     // Build the JSON
                     $event_json[] = array('type' => 'raid', 'eventid' => $calid, 'editable' => $this->user->check_auth('a_cal_revent_conf', false) || $this->check_permission($calid) ? true : false, 'title' => $this->in->decode_entity($this->pdh->get('calendar_events', 'name', array($calid))), 'url' => $this->routing->build('calendarevent', $this->pdh->get('calendar_events', 'name', array($calid)), $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, 'flag' => $deadlineflag . $this->pdh->get('calendar_raids_attendees', 'html_status', array($calid, $this->user->data['user_id'])), 'icon' => $eventextension['raid_eventid'] ? $this->pdh->get('event', 'icon', array($eventextension['raid_eventid'], 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 . ' !important', 'textColor' => $eventcolor_txt . ' !important');
                 } else {
                     // check if the event is private
                     if (!$this->pdh->get('calendar_events', 'private_userperm', array($calid))) {
                         continue;
                     }
                     $alldayevents = $this->pdh->get('calendar_events', 'allday', array($calid)) > 0 ? true : false;
                     $event_json[] = array('type' => 'event', 'eventid' => $calid, 'editable' => $this->user->check_auth('a_cal_revent_conf', false) || $this->check_permission($calid) ? true : false, 'url' => $this->routing->build('calendarevent', $this->pdh->get('calendar_events', 'name', array($calid)), $calid) . 'eventdetails', '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, $alldayevents))), 'allDay' => $alldayevents, 'note' => $this->pdh->get('calendar_events', 'notes', array($calid)), 'color' => $eventcolor, 'textColor' => $eventcolor_txt, 'isowner' => $this->pdh->get('calendar_events', 'is_owner', array($calid)), 'isinvited' => $this->pdh->get('calendar_events', 'is_invited', array($calid)), 'joinedevent' => $this->pdh->get('calendar_events', 'joined_invitation', array($calid)), 'author' => $this->pdh->get('calendar_events', 'creator', array($calid)), 'attendees' => $this->pdh->get('calendar_events', 'sharedevent_attendees', array($calid)));
                 }
             }
         }
     }
     // birthday calendar
     if ($this->config->get('calendar_show_birthday') && $this->user->check_auth('u_userlist', false)) {
//.........这里部分代码省略.........
开发者ID:rswiders,项目名称:core,代码行数:101,代码来源:calendar_pageobject.class.php


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