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


PHP vcalendar::saveCalendar方法代码示例

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


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

示例1: exportar

 function exportar($aObj = array(), $directo_a_browser = 1)
 {
     if (is_array($aObj)) {
         $v = new vcalendar();
         $v->setConfig('DIRECTORY', sfConfig::get('sf_cache_dir'));
         foreach ($aObj as $link_evento) {
             if ($link_evento->getEvento()) {
                 $e = new vevent();
                 $e->setProperty('DESCRIPTION', '');
                 $e->setProperty('SUMMARY', $link_evento->getEvento()->getTitulo());
                 $e->setProperty('class', 'PUBLIC');
                 $aFechaInicio = getdate(strtotime($link_evento->getEvento()->getFechaInicio()));
                 $e->setProperty('dtstart', $aFechaInicio['year'], $aFechaInicio['mon'], $aFechaInicio['mday'], $aFechaInicio['hours'], $aFechaInicio['minutes'], 0);
                 $aFechaFin = getdate(strtotime($link_evento->getEvento()->getFechaFin()));
                 $e->setProperty('dtend', $aFechaFin['year'], $aFechaFin['mon'], $aFechaFin['mday'], $aFechaFin['hours'], $aFechaFin['minutes'], 0);
                 $e->setProperty('dtstamp', gmdate('Ymd\\THi00\\Z'));
                 if ($link_evento->getEvento()->getFrecuencia()) {
                     $freq = $this->aFreq[$link_evento->getEvento()->getFrecuencia()];
                     $interval = $link_evento->getEvento()->getFrecuenciaIntervalo();
                     $aRrule = array();
                     $aRrule['FREQ'] = $freq;
                     $aRrule['INTERVAL'] = $interval;
                     if ($freq == "WEEKLY") {
                         $aRrule['BYDAY'] = array_chunk(explode(",", $link_evento->getEvento()->getRecurrenciaDiasIcal()), 1);
                     }
                     if ($link_evento->getEvento()->getRecurrenciaFin() != "") {
                         if (is_numeric($link_evento->getEvento()->getRecurrenciaFin())) {
                             $aRrule['COUNT'] = $link_evento->getEvento()->getRecurrenciaFin();
                         } else {
                             $aRrule['UNTIL'] = gmdate('Ymd\\THi00\\Z', strtotime($link_evento->getEvento()->getRecurrenciaFin()));
                         }
                     }
                     $e->setProperty('rrule', $aRrule);
                 }
                 $v->addComponent($e);
             }
         }
         if ($directo_a_browser == 1) {
             $v->returnCalendar();
         } else {
             $v->saveCalendar();
             return $v->getConfig('filename');
         }
     } else {
         $error = 'No envío un array para la exportación';
         throw new Exception($error);
     }
 }
开发者ID:mediasadc,项目名称:alba,代码行数:48,代码来源:miExportadorIcal.class.php

示例2: csv2iCal


//.........这里部分代码省略.........
                         }
                         if ('X-' == substr($propName, 0, 2) || in_array($propName, array('CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'LOCATION', 'RESOURCES', 'SUMMARY'))) {
                             $val = str_replace(',', '\\,', $val);
                             if (FALSE !== ($pos = strpos($del . $val, ':'))) {
                                 while (FALSE !== ($pos2 = strpos($val, ';', $pos + 1))) {
                                     $val = substr($val, 0, $pos2) . '\\;' . substr($val, $pos2 + 1);
                                     if ($this->log) {
                                         $this->log->log("pos={$pos} pos2={$pos2} val='{$val}'", PEAR_LOG_DEBUG);
                                     }
                                     $pos = $pos2 + 1;
                                 }
                             }
                         }
                         if (FALSE === $actcomp->parse("{$propName}{$del}{$val}")) {
                             if ($this->log) {
                                 $this->log->log("ERROR 13, INPUT FILE:'{$inputdirFile}' iCalcreator: parse error: '{$propName}{$del}{$val}'", PEAR_LOG_ERR);
                             }
                         } elseif ($this->log) {
                             $this->log->log("iCalcreator->parse( '{$propName}{$del}{$val}' )", PEAR_LOG_DEBUG);
                         }
                     }
                     // end foreach( $value as $val
                 }
                 // end if( isset( $rows[$row][$col]
             }
             // end foreach( $proporder
         }
         // end for( $row = $actrow;
         if ($comp && $subcomp) {
             $comp->setComponent($subcomp);
         }
         if ($comp) {
             $calendar->setComponent($comp);
         }
     }
     $save = $this->getConfig('save');
     if ($this->log) {
         $timeexec['exit'] = microtime(TRUE);
         $msg = "INPUT '{$inputdirFile}'";
         $msg .= ' fileOk:' . number_format($timeexec['fileOk'] - $timeexec['start'], 5);
         $msg .= ' infoOk:' . number_format($timeexec['infoOk'] - $timeexec['fileOk'], 5);
         $msg .= ' zoneOk:' . number_format($timeexec['zoneOk'] - $timeexec['infoOk'], 5);
         $msg .= ' compOk:' . number_format($timeexec['exit'] - $timeexec['zoneOk'], 5);
         $msg .= ' total:' . number_format($timeexec['exit'] - $timeexec['start'], 5) . ' sec';
         $this->log->log($msg, PEAR_LOG_DEBUG);
         $msg = "'{$inputdirFile}' (" . $cntprops . ' components) start:' . date('H:i:s', $timeexec['start']);
         $msg .= ' total:' . number_format($timeexec['exit'] - $timeexec['start'], 5) . ' sec';
         if ($save) {
             $msg .= " -> '{$outputdirFile}'";
         }
         $this->log->log($msg, PEAR_LOG_NOTICE);
     }
     /** return calendar, save or send the file */
     if ($this->getConfig('outputobj')) {
         if ($this->log) {
             $this->log->log("INPUT FILE:'{$inputdirFile}' returning iCalcreator vcalendar instance", PEAR_LOG_NOTICE);
             $this->log->flush();
         }
         return $calendar;
         exit;
     }
     $d = $calendar->getConfig('directory');
     $f = $calendar->getConfig('filename');
     $df = $d . DIRECTORY_SEPARATOR . $f;
     if ($save) {
         if (FALSE !== $calendar->saveCalendar()) {
             if ($this->log) {
                 $this->log->log("INPUT FILE:'{$inputdirFile}' saved '{$df}'", PEAR_LOG_NOTICE);
                 $this->log->flush();
             }
             return TRUE;
         } else {
             // ??
             if ($this->log) {
                 $this->log->log("ERROR 16, INPUT FILE:'{$inputdirFile}' can't write to output file : '{$df}'", PEAR_LOG_ERR);
                 $this->log->flush();
             }
             return FALSE;
         }
     } else {
         if ($this->log) {
             $this->log->log("INPUT FILE:'{$inputdirFile}' returning : '{$f}'", PEAR_LOG_NOTICE);
             $this->log->flush();
         }
         $output = $calendar->createCalendar();
         $filesize = strlen($output);
         if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
             $output = gzencode($output, 9);
             $filesize = strlen($output);
             header('Content-Encoding: gzip');
             header('Vary: *');
         }
         header('Content-Type: text/calendar; charset=utf-8');
         header("Content-Disposition: attachment; filename='{$f}'");
         header('Cache-Control: max-age=10');
         header('Content-Length: ' . $filesize);
         echo $output;
     }
     return TRUE;
 }
开发者ID:andyUA,项目名称:kabmin-new,代码行数:101,代码来源:iCalcnv.class.php

示例3: while

    $c->setConfig(array("directory" => "Calevents", "filename" => "{$iduser}.ics"));
    $vivek->getAllTaskByuser($iduser);
    while ($vivek->fetch()) {
        $stdt = explode('-', $vivek->getData("due_date_dateformat"));
        $startdate = "{$stdt['0']}" . "{$stdt['1']}" . "{$stdt['2']}";
        $enddate = $startdate;
        $e =& $c->newComponent('vevent');
        //$e->setProperty( 'dtstart', $startdate );
        //$e->setProperty( 'dtend', $enddate );
        $e->setProperty("dtstart", "{$startdate}", array("VALUE" => "DATE"));
        $e->setProperty('description', $vivek->getData("task_description"));
        $e->setProperty('summary', $vivek->getData("task_description"));
        $e->setProperty('class', 'PUBLIC');
    }
    $c->createCalendar();
    $str = $c->saveCalendar();
    $tt = $_SERVER["SERVER_NAME"];
    $path = "http://" . "{$tt}" . "/" . "Calevents/" . "{$iduser}.ics";
    $ff = "Calevents/{$iduser}.ics";
    system("chmod 0777 {$ff}");
    echo _('Your iCal URL is : ' . $path . ' ');
} else {
    echo _('You do not yet have an API key. ');
    echo _('Please generate one ');
    echo $e_set_api->getLink('here');
    echo '<div class="spacerblock_20"></div>';
}
?>
</div>
        <div class="solidline"></div>
    </td></tr></table>
开发者ID:jacquesbagui,项目名称:ofuz,代码行数:31,代码来源:ical_test1.php

示例4: vevent

// 3 hours
$e->setProperty('description', 'x-mas evening - diner');
// describe the event
$e->setProperty('location', 'Jeffikus');
// locate the event
$v->addComponent($e);
// add component to calendar
/* alt. production */
// $v->returnCalendar();                       // generate and redirect output to user browser
/* alt. dev. and test */
/*$str = $v->createCalendar();                   // generate and get output in string, for testing?
echo $str;
echo "<br />\n\n";*/
$v->setConfig('directory', '');
$v->setConfig('filename', 'calendar.ics');
$v->saveCalendar();
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
/*$v = new vcalendar();                          // initiate new CALENDAR
$v->setConfig( 'unique_id'
             , 'testdomain.com' );             // config with site domain
$v->setProperty( 'X-WR-CALNAME'
               , 'Sample calendar' );          // set some X-properties, name, content.. .
$v->setProperty( 'X-WR-CALDESC'
               , 'Description of the calendar' );
$v->setProperty( 'X-WR-TIMEZONE'
               , 'Europe/Stockholm' );

$e = new vevent();                             // initiate EVENT
$e->setProperty( 'categories'
               , 'FAMILY' );                   // catagorize
$e->setProperty( 'dtstart'
开发者ID:rasyidmujahid,项目名称:scalar-web,代码行数:31,代码来源:samples.php

示例5: cs_event_calendar

function cs_event_calendar($post_id = '')
{
    if (!isset($post_id) && $post_id == '') {
        global $post;
        $post_id = $post->ID;
    }
    $cal_post = get_post($post_id);
    if ($cal_post) {
        $event_from_date = get_post_meta($post_id, "cs_event_from_date", true);
        $cs_event_to_date = get_post_meta($post_id, "cs_event_to_date", true);
        $cs_event_meta = get_post_meta($post_id, "cs_event_meta", true);
        if ($cs_event_meta != "") {
            $cs_event_meta = new SimpleXMLElement($cs_event_meta);
            if ($cs_event_meta->event_address != '') {
                $address_map = get_the_title("{$cs_event_meta->event_address}");
            } else {
                $address_map = '';
            }
        }
        $cs_event_loc = get_post_meta($cs_event_meta->event_address, "cs_event_loc_meta", true);
        if ($cs_event_loc != "") {
            $cs_xmlObject = new SimpleXMLElement($cs_event_loc);
            $loc_address = $cs_xmlObject->loc_address;
            $event_loc_lat = $cs_xmlObject->event_loc_lat;
            $event_loc_long = $cs_xmlObject->event_loc_long;
            $event_loc_zoom = $cs_xmlObject->event_loc_zoom;
            $loc_city = $cs_xmlObject->loc_city;
            $loc_postcode = $cs_xmlObject->loc_postcode;
            $loc_country = $cs_xmlObject->loc_country;
            $location = $loc_address . ', ' . $loc_city . ', ' . $loc_postcode . ', ' . $loc_country;
        } else {
            $loc_address = '';
            $event_loc_lat = '';
            $event_loc_long = '';
            $event_loc_zoom = '';
            $loc_city = '';
            $loc_postcode = '';
            $loc_country = '';
            $location = '';
        }
        $start_year = date('Y', strtotime($event_from_date));
        $start_month = date('m', strtotime($event_from_date));
        $start_day = date('d', strtotime($event_from_date));
        $end_year = date('Y', strtotime($cs_event_to_date));
        $end_month = date('m', strtotime($cs_event_to_date));
        $end_day = date('d', strtotime($cs_event_to_date));
        if ($cs_event_meta->event_all_day != "on") {
            $start_time = calender_time($cs_event_meta->event_start_time);
            $end_time = calender_time($cs_event_meta->event_end_time);
        } else {
            $start_time = $end_time = '';
        }
        if ($start_time != '' && $start_time != ':') {
            $event_start_time = explode(":", $start_time);
        }
        if ($end_time != '' && $end_time != ':') {
            $event_end_time = explode(":", $end_time);
        }
        $post_title = get_the_title($post_id);
        $cs_vcalendar = new vcalendar();
        $cs_vevent = new vevent();
        $site_info = get_bloginfo('name') . 'Events';
        $cs_vevent->setProperty('categories', $site_info);
        if (isset($event_start_time)) {
            @$cs_vevent->setProperty('dtstart', @$start_year, @$start_month, @$start_day, @$event_start_time[0], @$event_start_time[1], 00);
        } else {
            $cs_vevent->setProperty('dtstart', $start_year, $start_month, $start_day);
        }
        // YY MM dd hh mm ss
        if (isset($event_end_time)) {
            @$cs_vevent->setProperty('dtend', $end_year, $end_month, $end_day, $event_end_time[0], $event_end_time[1], 00);
        } else {
            $cs_vevent->setProperty('dtend', $end_year, $end_month, $end_day);
        }
        // YY MM dd hh mm ss
        $cs_vevent->setProperty('description', strip_tags($cal_post->post_excerpt));
        if (isset($location)) {
            $cs_vevent->setProperty('location', $location);
        }
        $cs_vevent->setProperty('summary', $post_title);
        $cs_vcalendar->addComponent($cs_vevent);
        $templateurl = get_template_directory_uri() . '/cache/';
        //makeDir(get_bloginfo('template_directory').'/cache/');
        $home = home_url();
        $dir = str_replace($home, '', $templateurl);
        $dir = str_replace('/wp-content/', 'wp-content/', $dir);
        $directory_url = get_template_directory_uri();
        $directorypath = explode('/', $directory_url);
        $themefolderName = $directorypath[count($directorypath) - 1];
        $cs_vcalendar->setConfig('directory', ABSPATH . 'wp-content/themes/' . $themefolderName . '/cache');
        $cs_vcalendar->setConfig('filename', 'event-' . $post_id . '.ics');
        $cs_vcalendar->saveCalendar();
        ////OUT LOOK & iCAL URL//
        $output_calendar_url['ical'] = $templateurl . 'event-' . $post_id . '.ics';
        ////GOOGLE URL//
        $google_url = "http://www.google.com/calendar/event?action=TEMPLATE";
        $google_url .= "&text=" . urlencode($post_title);
        if (isset($event_start_time) && isset($event_end_time)) {
            $google_url .= "&dates=" . @$start_year . @$start_month . @$start_day . "T" . str_replace('.', '', @$event_start_time[0]) . str_replace('.', '', @$event_start_time[1]) . "00/" . @$end_year . @$end_month . @$end_day . "T" . str_replace('.', '', @$event_end_time[0]) . str_replace('.', '', @$event_end_time[1]) . "00";
        } else {
//.........这里部分代码省略.........
开发者ID:rasyidmujahid,项目名称:scalar-web,代码行数:101,代码来源:functions.php

示例6: createTestFile

function createTestFile()
{
    $dirFile = CALDIR . DIRECTORY_SEPARATOR . TESTFILE;
    $calendar = new vcalendar();
    $calendar->setConfig('unique_id', UNIQUE);
    if (!$calendar->setConfig('directory', CALDIR)) {
        addLogEntry(1, '  ERROR (11) when setting directory \'' . CALDIR . '\', check directory/file permissions!!');
        return FALSE;
    } elseif (!$calendar->setConfig('filename', TESTFILE)) {
        addLogEntry(1, "  ERROR (12) when setting directory/file '{$dirFile}', check directory/file permissions!!");
        return FALSE;
    }
    $calendar->setProperty('METHOD', METHOD);
    $calendar->setProperty('X-WR-CALNAME', CALNAME);
    $calendar->setProperty('X-WR-CALDESC', CALDESC);
    $calendar->setProperty('X-WR-TIMEZONE', TIMEZONE);
    $date = mktime(0, 0, 0, (int) substr(THISDATE, 4, 2), (int) substr(THISDATE, 6, 2), (int) substr(THISDATE, 0, 4));
    $stopDate = $date + 7 * 24 * 3600;
    $eventCount = 1;
    // random priority, 1 to 9. HIGH (1-4), MEDIUM (5), LOW (6-9)
    // reversed prio; HIGH: weight 1, MEDIUM weight 4, LOW: weight 8
    $prioArr = array();
    for ($r = 1; $r <= 9; $r++) {
        $weight = 5 < $r ? 1 : 5 > $r ? 8 : 4;
        for ($r1 = 1; $r1 <= $weight; $r1++) {
            $prioArr[] = $r;
        }
    }
    mt_srand();
    shuffle($prioArr);
    // array to randomly select a summary from
    $summaries = array('Duis ac dui sit amet ante auctor euismod.', 'Suspendisse_pellentesque_velit_in_tortor.', 'Mauris vulputate.', 'Nulla sapien pede, dapibus sed.', 'Maecenas tristique, pede_id_sollicitudin_posuere, enim nibh mollis odio.', 'Lorem ipsum dolor sit amet, consectetuerAdipiscingElit.');
    while ($date <= $stopDate) {
        $dayCount = 1;
        while ($dayCount < 4) {
            $event = new vevent();
            $eventdate = $date + mt_rand(7, 18) * 3600;
            // random start hour, 7 to 18
            $event->setProperty('DTSTART', array('timestamp' => $eventdate));
            // random duration, 1-4 hours or 2 days
            if (9 > mt_rand(1, 9)) {
                $event->setProperty('DURATION', 0, 0, mt_rand(1, 4));
            } else {
                $event->setProperty('DURATION', 0, 2);
            }
            // 2 days duration
            $event->setProperty('SUMMARY', "Event #{$eventCount}. " . $summaries[mt_rand(0, 5)]);
            $event->setProperty('CATEGORIES', "Category #{$eventCount}");
            $event->setProperty('LOCATION', "Location #{$eventCount}");
            $event->setProperty('RESOURCES', "Resource #{$eventCount}");
            $event->setProperty('ORGANIZER', "chair.{$eventCount}@" . UNIQUE);
            $event->setProperty('CONTACT', "contact.{$eventCount}@" . UNIQUE);
            $event->setProperty('DESCRIPTION', 'Lorem ipsum dolor sit amet, ' . 'consectetuer adipiscing elit. ' . 'Mauris vulputate. Suspendisse ' . 'pellentesque velit in tortor. ' . 'Nulla sapien pede, dapibus sed.');
            // random priority, 1 to 9. HIGH (1-4), MEDIUM (5), LOW (6-9)
            $event->setProperty('PRIORITY', $prioArr[mt_rand(0, count($prioArr) - 1)]);
            // two attendees every event
            $event->setProperty('ATTENDEE', 'attendee.' . $eventCount . '.1@' . UNIQUE);
            $event->setProperty('ATTENDEE', 'attendee.' . $eventCount . '.2@' . UNIQUE);
            // two comments every event
            $event->setProperty('COMMENT', 'Duis ac dui sit amet ante auctor euismod. Sed vulputate.');
            $event->setProperty('COMMENT', 'Maecenas tristique, pede id sollicitudin posuere, enim nibh mollis odio.');
            $event->setProperty('CREATED', array('timestamp' => $eventdate - 2 * 24 * 3600));
            // fake two days before event startdate
            $event->setProperty('LAST-MODIFIED', array('timestamp' => $eventdate - 23 * 3600));
            // fake 25 hours before event startdate
            if (5 > $eventCount) {
                $event->setProperty('RRULE', array('FREQ' => 'DAILY', 'COUNT' => 4, 'INTERVAL' => 3));
                $event->setProperty('EXRULE', array('FREQ' => 'DAILY', 'COUNT' => 2, 'INTERVAL' => 6));
            }
            $event->setProperty('URL', 'http://www.kigkonsult.se/tinycal/index.php');
            if (FALSE === $calendar->setComponent($event)) {
                error_log('setComponent error');
            }
            $eventCount++;
            $dayCount++;
        }
        $date += 24 * 3600;
    }
    $calendar->sort();
    if (FALSE === $calendar->saveCalendar()) {
        addLogEntry(1, "  ERROR (13) saving calendar file '{$dirFile}'");
    }
}
开发者ID:bobjacobsen,项目名称:EventTools,代码行数:83,代码来源:createTestfile.php


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