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


PHP vcalendar::selectComponents方法代码示例

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


在下文中一共展示了vcalendar::selectComponents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: vcalendar

 function _get_events_url(&$events, $url, $date)
 {
     $v = new vcalendar();
     $v->setConfig('unique_id', 'barchat');
     $v->setProperty('method', 'PUBLISH');
     $v->setProperty("x-wr-calname", "Calendar Sample");
     $v->setProperty("X-WR-CALDESC", "Calendar Description");
     $v->setProperty("X-WR-TIMEZONE", "America/New_York");
     $v->setConfig('url', $url);
     try {
         $v->parse();
     } catch (exception $e) {
     }
     $v->sort();
     $m = $date->format('n');
     $d = $date->format('j');
     $y = $date->format('Y');
     $eventArray = $v->selectComponents($y, $m, 1, $y, $m, 31);
     foreach ((array) $eventArray as $yearkey => $yeararray) {
         foreach ((array) $yeararray as $monthkey => $montharray) {
             foreach ((array) $montharray as $daykey => $dayarray) {
                 foreach ((array) $dayarray as $eventnumber => $event) {
                     //echo "{$y}-{$m}-{$daykey} [{$eventnumber}]: ";
                     $time = $event->dtstart['value'];
                     $tz = $event->dtstart['params']['TZID'] == '' ? 'America/New_York' : $event->dtstart['params']['TZID'];
                     if ($time['tz'] == 'Z') {
                         $tz = 'GMT';
                     }
                     if (isset($event->dtstart['params']['VALUE']) && $event->dtstart['params']['VALUE'] == 'DATE') {
                         $allday = new DateTime("{$time['year']}-{$time['month']}-{$time['day']}", new DateTimeZone($tz));
                         $allday->setTimezone(new DateTimeZone('America/New_York'));
                         $d = sprintf('%04d-%02d-%02d', $y, $m, $daykey);
                         if (!is_array($events[$d])) {
                             $events[$d] = array();
                         }
                         $alldayint = intval($allday->format('U'));
                         while (isset($events[$d][$alldayint])) {
                             $alldayint++;
                         }
                         $events[$d][$alldayint] = '<span class="calendartime">All Day</span> ' . trim($event->summary['value']);
                         //var_dump(date('r', $allday) . ' = ' . $allday);
                         //var_dump($event->summary['value']);
                     } else {
                         if (isset($event->xprop['X-CURRENT-DTSTART'])) {
                             $dt = new DateTime($event->xprop['X-CURRENT-DTSTART']['value'], new DateTimeZone($tz));
                         } else {
                             $dt = new DateTime("{$time['year']}-{$time['month']}-{$time['day']} {$time['hour']}:{$time['min']}:{$time['sec']}", new DateTimeZone($tz));
                         }
                         $dt->setTimezone(new DateTimeZone('America/New_York'));
                         if (isset($event->xprop['X-CURRENT-DTEND'])) {
                             $dte = new DateTime($event->xprop['X-CURRENT-DTEND']['value'], new DateTimeZone($tz));
                         } else {
                             $timee = $event->dtstart['value'];
                             $dte = new DateTime("{$timee['year']}-{$timee['month']}-{$timee['day']} {$timee['hour']}:{$timee['min']}:{$timee['sec']}", new DateTimeZone($tz));
                         }
                         $dte->setTimezone(new DateTimeZone('America/New_York'));
                         if (!is_array($events[$d])) {
                             $events[$d] = array();
                         }
                         $d = sprintf('%04d-%02d-%02d', $y, $m, $daykey);
                         $daytime = $dt->format('U');
                         while (isset($events[$d][$daytime])) {
                             $daytime++;
                         }
                         if ($dt->format('g:ia') != $dte->format('g:ia')) {
                             $events[$d][$daytime] = '<span class="calendartime">' . $dt->format('g:ia') . ' - ' . $dte->format('g:ia') . '</span> ' . trim($event->summary['value']);
                         } else {
                             $events[$d][$daytime] = '<span class="calendartime">' . $dt->format('g:ia') . '</span> ' . trim($event->summary['value']);
                         }
                         //var_dump($event->dtstart);
                         //var_dump($event->summary['value']);
                         //var_dump($dt->format('r'));
                         //var_dump($event);
                     }
                 }
             }
         }
     }
 }
开发者ID:amitchouhan004,项目名称:barchat,代码行数:79,代码来源:calendar.php

示例2: renderCalDavEntry_data

/**
 * @param DBClass_friendica_calendars $calendar
 * @param DBClass_friendica_calendarobjects $calendarobject
 */
function renderCalDavEntry_data(&$calendar, &$calendarobject)
{
    $a = get_app();
    $v = new vcalendar();
    $v->setConfig('unique_id', $a->get_hostname());
    $v->parse($calendarobject->calendardata);
    $v->sort();
    $eventArray = $v->selectComponents(2009, 1, 1, date("Y") + 2, 12, 30);
    $start_min = $end_max = "";
    $allday = $summary = $vevent = $rrule = $color = $start = $end = null;
    $location = $description = "";
    foreach ($eventArray as $yearArray) {
        foreach ($yearArray as $monthArray) {
            foreach ($monthArray as $day => $dailyEventsArray) {
                foreach ($dailyEventsArray as $vevent) {
                    /** @var $vevent vevent  */
                    $start = "";
                    $rrule = "NULL";
                    $allday = 0;
                    $dtstart = $vevent->getProperty('X-CURRENT-DTSTART');
                    if (is_array($dtstart)) {
                        $start = "'" . $dtstart[1] . "'";
                        if (strpos($dtstart[1], ":") === false) {
                            $allday = 1;
                        }
                    } else {
                        $dtstart = $vevent->getProperty('dtstart');
                        if (isset($dtstart["day"]) && $dtstart["day"] == $day) {
                            // Mehrtägige Events nur einmal rein
                            if (isset($dtstart["hour"])) {
                                $start = "'" . $dtstart["year"] . "-" . $dtstart["month"] . "-" . $dtstart["day"] . " " . $dtstart["hour"] . ":" . $dtstart["minute"] . ":" . $dtstart["secont"] . "'";
                            } else {
                                $start = "'" . $dtstart["year"] . "-" . $dtstart["month"] . "-" . $dtstart["day"] . " 00:00:00'";
                                $allday = 1;
                            }
                        }
                    }
                    $dtend = $vevent->getProperty('X-CURRENT-DTEND');
                    if (is_array($dtend)) {
                        $end = "'" . $dtend[1] . "'";
                        if (strpos($dtend[1], ":") === false) {
                            $allday = 1;
                        }
                    } else {
                        $dtend = $vevent->getProperty('dtend');
                        if (isset($dtend["hour"])) {
                            $end = "'" . $dtend["year"] . "-" . $dtend["month"] . "-" . $dtend["day"] . " " . $dtend["hour"] . ":" . $dtend["minute"] . ":" . $dtend["second"] . "'";
                        } else {
                            $end = "'" . $dtend["year"] . "-" . $dtend["month"] . "-" . $dtend["day"] . " 00:00:00' - INTERVAL 1 SECOND";
                            $allday = 1;
                        }
                    }
                    $summary = $vevent->getProperty('summary');
                    $description = $vevent->getProperty('description');
                    $location = $vevent->getProperty('location');
                    $rrule_prob = $vevent->getProperty('rrule');
                    if ($rrule_prob != null) {
                        $rrule = $vevent->createRrule();
                        $rrule = "'" . dbesc($rrule) . "'";
                    }
                    $color_ = $vevent->getProperty("X-ANIMEXX-COLOR");
                    $color = is_array($color_) ? $color_[1] : "NULL";
                    if ($start_min == "" || preg_replace("/[^0-9]/", "", $start) < preg_replace("/[^0-9]/", "", $start_min)) {
                        $start_min = $start;
                    }
                    if ($end_max == "" || preg_replace("/[^0-9]/", "", $end) > preg_replace("/[^0-9]/", "", $start_min)) {
                        $end_max = $end;
                    }
                }
            }
        }
    }
    if ($start_min != "") {
        if ($allday && mb_strlen($end_max) == 12) {
            $x = explode("-", str_replace("'", "", $end_max));
            $time = mktime(0, 0, 0, IntVal($x[1]), IntVal($x[2]), IntVal($x[0]));
            $end_max = date("'Y-m-d H:i:s'", $time - 1);
        }
        q("INSERT INTO %s%sjqcalendar (`uid`, `namespace`, `namespace_id`, `ical_uri`, `Subject`, `Location`, `Description`, `StartTime`, `EndTime`, `IsAllDayEvent`, `RecurringRule`, `Color`)\n\t\t\tVALUES (%d, %d, %d, '%s', '%s', '%s', '%s', %s, %s, %d, '%s', '%s')", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($calendar->uid), IntVal($calendarobject->namespace), IntVal($calendarobject->namespace_id), dbesc($calendarobject->uri), dbesc($summary), dbesc($location), dbesc(str_replace("\\n", "\n", $description)), $start_min, $end_max, IntVal($allday), dbesc($rrule), dbesc($color));
        foreach ($vevent->components as $comp) {
            /** @var $comp calendarComponent */
            $trigger = $comp->getProperty("TRIGGER");
            $sql_field = $trigger["relatedStart"] ? $start : $end;
            $sql_op = $trigger["before"] ? "DATE_SUB" : "DATE_ADD";
            $num = "";
            $rel_type = "";
            $rel_value = 0;
            if (isset($trigger["second"])) {
                $num = IntVal($trigger["second"]) . " SECOND";
                $rel_type = "second";
                $rel_value = IntVal($trigger["second"]);
            }
            if (isset($trigger["minute"])) {
                $num = IntVal($trigger["minute"]) . " MINUTE";
                $rel_type = "minute";
                $rel_value = IntVal($trigger["minute"]);
//.........这里部分代码省略.........
开发者ID:robhell,项目名称:friendica-addons,代码行数:101,代码来源:calendar.fnk.php


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