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


PHP Horde_Icalendar::parsevCalendar方法代码示例

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


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

示例1: testGeo

 public function testGeo()
 {
     $ical = new Horde_Icalendar();
     $ical->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/geo1.vcf'));
     $this->assertEquals(array('latitude' => -17.87, 'longitude' => 37.24), $ical->getComponent(0)->getAttribute('GEO'));
     $ical->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/geo2.vcf'));
     $this->assertEquals(array('latitude' => 37.386013, 'longitude' => -122.082932), $ical->getComponent(0)->getAttribute('GEO'));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:8,代码来源:AttributeTest.php

示例2: _getFixture

 private function _getFixture($element)
 {
     $iCal = new Horde_Icalendar();
     $iCal->parsevCalendar(file_get_contents(__DIR__ . '/../fixtures/allday.ics'));
     $components = $iCal->getComponents();
     return $components[$element];
 }
开发者ID:horde,项目名称:horde,代码行数:7,代码来源:AllDayTest.php

示例3: _handle

 /**
  * Variables required in form input:
  *   - imple_submit: vcard action. Contains import and source properties
  *   - mime_id
  *   - muid
  *
  * @return boolean  True on success.
  */
 protected function _handle(Horde_Variables $vars)
 {
     global $registry, $injector, $notification;
     $iCal = new Horde_Icalendar();
     try {
         $contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices_Mailbox($vars));
         if (!($mime_part = $contents->getMimePart($vars->mime_id))) {
             throw new IMP_Exception(_("Cannot retrieve vCard data from message."));
         } elseif (!$iCal->parsevCalendar($mime_part->getContents(), 'VCALENDAR', $mime_part->getCharset())) {
             throw new IMP_Exception(_("Error reading the contact data."));
         }
         $components = $iCal->getComponents();
     } catch (Exception $e) {
         $notification->push($e, 'horde.error');
     }
     $import = !empty($vars->imple_submit->import) ? $vars->imple_submit->import : false;
     $source = !empty($vars->imple_submit->source) ? $vars->imple_submit->source : false;
     if ($import && $source && $registry->hasMethod('contacts/import')) {
         $count = 0;
         foreach ($components as $c) {
             if ($c->getType() == 'vcard') {
                 try {
                     $registry->call('contacts/import', array($c, null, $source));
                     ++$count;
                 } catch (Horde_Exception $e) {
                     $notification->push(Horde_Core_Translation::t("There was an error importing the contact data:") . ' ' . $e->getMessage(), 'horde.error');
                 }
             }
         }
         $notification->push(sprintf(Horde_Core_Translation::ngettext("%d contact was successfully added to your address book.", "%d contacts were successfully added to your address book.", $count), $count), 'horde.success');
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:40,代码来源:VcardImport.php

示例4: array

 /**
  * Yet another problem: Outlook seems to remove the organizer from
  * the iCal when forwarding -- we put the original sender back in
  * as organizer.
  *
  * @param string        $icaltext  The ical message.
  * @param MIME_Headers  $from      The message sender.
  */
 function _addOrganizer(&$icaltxt, $from)
 {
     global $conf;
     if (isset($conf['kolab']['filter']['email_domain'])) {
         $email_domain = $conf['kolab']['filter']['email_domain'];
     } else {
         $email_domain = 'localhost';
     }
     $iCal = new Horde_Icalendar();
     $iCal->parsevCalendar($icaltxt);
     $vevent =& $iCal->findComponent('VEVENT');
     if ($vevent) {
         $organizer = $vevent->getAttribute('ORGANIZER', true);
         if (is_a($organizer, 'PEAR_Error')) {
             $adrs = imap_rfc822_parse_adrlist($from, $email_domain);
             if (count($adrs) > 0) {
                 $org_email = 'mailto:' . $adrs[0]->mailbox . '@' . $adrs[0]->host;
                 $org_name = $adrs[0]->personal;
                 if ($org_name) {
                     $vevent->setAttribute('ORGANIZER', $org_email, array('CN' => $org_name), false);
                 } else {
                     $vevent->setAttribute('ORGANIZER', $org_email, array(), false);
                 }
                 Horde::log(sprintf("Adding missing organizer '%s <%s>' to iCal.", $org_name, $org_email), 'DEBUG');
                 $icaltxt = $iCal->exportvCalendar();
             }
         }
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:37,代码来源:Outlook.php

示例5: _renderInline

 /**
  * Return the rendered inline version of the Horde_Mime_Part object.
  *
  * @return array  See parent::render().
  */
 protected function _renderInline()
 {
     $GLOBALS['page_output']->growler = true;
     $data = $this->_mimepart->getContents();
     $mime_id = $this->_mimepart->getMimeId();
     // Parse the iCal file.
     $vCal = new Horde_Icalendar();
     if (!$vCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
         $status = new IMP_Mime_Status(_("The calendar data is invalid"));
         $status->action(IMP_Mime_Status::ERROR);
         return array($mime_id => array('data' => '', 'status' => $status, 'type' => 'text/html; charset=UTF-8'));
     }
     // Check if we got vcard data with the wrong vcalendar mime type.
     $imp_contents = $this->getConfigParam('imp_contents');
     $c = $vCal->getComponentClasses();
     if (count($c) == 1 && !empty($c['horde_icalendar_vcard'])) {
         return $imp_contents->renderMIMEPart($mime_id, IMP_Contents::RENDER_INLINE, array('type' => 'text/x-vcard'));
     }
     $imple = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_ItipRequest', array('mime_id' => $mime_id, 'muid' => strval($imp_contents->getIndicesOb())));
     // Get the method type.
     try {
         $method = $vCal->getAttribute('METHOD');
     } catch (Horde_Icalendar_Exception $e) {
         $method = '';
     }
     $out = array();
     $components = $vCal->getComponents();
     foreach ($components as $key => $component) {
         switch ($component->getType()) {
             case 'vEvent':
                 try {
                     if ($component->getAttribute('RECURRENCE-ID')) {
                         break;
                     }
                 } catch (Horde_ICalendar_Exception $e) {
                 }
                 $out[] = $this->_vEvent($component, $key, $method, $components);
                 break;
             case 'vTodo':
                 $out[] = $this->_vTodo($component, $key, $method);
                 break;
             case 'vTimeZone':
                 // Ignore them.
                 break;
             case 'vFreebusy':
                 $out[] = $this->_vFreebusy($component, $key, $method);
                 break;
                 // @todo: handle stray vcards here as well.
             // @todo: handle stray vcards here as well.
             default:
                 $out[] = sprintf(_("Unhandled component of type: %s"), $component->getType());
                 break;
         }
     }
     $view = $this->_getViewOb();
     $view->formid = $imple->getDomId();
     $view->out = implode('', $out);
     return array($mime_id => array('data' => $view->render('base'), 'type' => 'text/html; charset=UTF-8'));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:64,代码来源:Itip.php

示例6: testIgnoringMultipleAttributeValues

 public function testIgnoringMultipleAttributeValues()
 {
     $ical = new Horde_Icalendar();
     $ical->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/multiple-summary.ics'));
     $result = $ical->getComponent(0)->getAttributeSingle('SUMMARY');
     $this->assertInternalType('string', $result);
     $this->assertEquals('Summary 1', $result);
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:8,代码来源:AttributeTest.php

示例7: _getFixture

 private function _getFixture($name, $item = 0)
 {
     $iCal = new Horde_Icalendar();
     $iCal->parsevCalendar(file_get_contents(__DIR__ . '/../fixtures/' . $name));
     $components = $iCal->getComponents();
     $event = new Kronolith_Event_Sql(new Kronolith_Stub_Driver());
     $event->fromiCalendar($components[$item]);
     return $event;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:9,代码来源:FromIcalendarTest.php

示例8: testFiles

 public function testFiles()
 {
     $test_files = glob(__DIR__ . '/fixtures/charset*.ics');
     foreach ($test_files as $file) {
         $ical = new Horde_Icalendar();
         $ical->parsevCalendar(file_get_contents($file));
         $this->assertEquals('möchen', $ical->getComponent(0)->getAttribute('SUMMARY'));
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:9,代码来源:CharsetTest.php

示例9: testBug14132

 public function testBug14132()
 {
     $ical = new Horde_Icalendar();
     $ical->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/bug14132.ics'));
     $params = $ical->getComponent(1)->getAttribute('DTSTART', true);
     $tz = $params[0]['TZID'];
     $start = $ical->getComponent(1)->getAttribute('DTSTART');
     $dtstart = new Horde_Date($start, $tz);
     $this->assertEquals((string) $dtstart, '2015-10-09 03:00:00');
 }
开发者ID:kossamums,项目名称:horde,代码行数:10,代码来源:ParseTest.php

示例10: testFile

 /**
  * @dataProvider timezones
  */
 public function testFile($file)
 {
     $result = '';
     $ical = new Horde_Icalendar();
     $ical->parsevCalendar(file_get_contents($file));
     foreach ($ical->getComponents() as $component) {
         if ($component->getType() != 'vEvent') {
             continue;
         }
         $date = $component->getAttribute('DTSTART');
         if (is_array($date)) {
             continue;
         }
         $result .= str_replace("\r", '', $component->getAttribute('SUMMARY')) . "\n";
         $d = new Horde_Date($date);
         $result .= $d->format('H:i') . "\n";
     }
     $this->assertStringEqualsFile(__DIR__ . '/fixtures/vTimezone/' . basename($file, 'ics') . 'txt', $result, 'Failed parsing file ' . basename($file));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:22,代码来源:TimezonesTest.php

示例11: parsevCalendar

 /**
  * Parses a string containing vFreebusy data.
  *
  * @param string $data     The data to parse.
  * @param $type TODO
  * @param $charset TODO
  */
 public function parsevCalendar($data, $type = null, $charset = null)
 {
     parent::parsevCalendar($data, 'VFREEBUSY', $charset);
     // Do something with all the busy periods.
     foreach ($this->_attributes as $key => $attribute) {
         if ($attribute['name'] != 'FREEBUSY') {
             continue;
         }
         foreach ($attribute['values'] as $value) {
             $params = isset($attribute['params']) ? $attribute['params'] : array();
             if (isset($value['duration'])) {
                 $this->addBusyPeriod('BUSY', $value['start'], null, $value['duration'], $params);
             } else {
                 $this->addBusyPeriod('BUSY', $value['start'], $value['end'], null, $params);
             }
         }
         unset($this->_attributes[$key]);
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:26,代码来源:Vfreebusy.php

示例12: get

 /**
  * Retrieve Free/Busy data for the specified resource.
  *
  * @param string $resource Fetch the Free/Busy data for this resource.
  *
  * @return Horde_Icalendar_Vfreebusy The Free/Busy data.
  */
 public function get($resource)
 {
     global $conf;
     $url = self::getUrl($resource);
     Horde::log(sprintf('Freebusy URL for resource %s is %s', $resource, $url), 'DEBUG');
     list($user, $domain) = explode('@', $resource);
     if (empty($domain)) {
         $domain = $conf['kolab']['filter']['email_domain'];
     }
     /**
      * This section matches Kronolith_Freebusy and should be merged with it
      * again in a single Horde_Freebusy module.
      */
     $options = array('method' => 'GET', 'timeout' => 5, 'allowRedirects' => true);
     if (!empty($conf['http']['proxy']['proxy_host'])) {
         $options = array_merge($options, $conf['http']['proxy']);
     }
     $http = new HTTP_Request($url, $options);
     $http->setBasicAuth($conf['kolab']['filter']['calendar_id'] . '@' . $domain, $conf['kolab']['filter']['calendar_pass']);
     @$http->sendRequest();
     if ($http->getResponseCode() != 200) {
         throw new Horde_Kolab_Resource_Exception(sprintf('Unable to retrieve free/busy information for %s', $resource), Horde_Kolab_Resource_Exception::NO_FREEBUSY);
     }
     $vfb_text = $http->getResponseBody();
     // Detect the charset of the iCalendar data.
     $contentType = $http->getResponseHeader('Content-Type');
     if ($contentType && strpos($contentType, ';') !== false) {
         list(, $charset, ) = explode(';', $contentType);
         $vfb_text = Horde_String::convertCharset($vfb_text, trim(str_replace('charset=', '', $charset)), 'UTF-8');
     }
     $iCal = new Horde_Icalendar();
     $iCal->parsevCalendar($vfb_text, 'VCALENDAR');
     $vfb =& $iCal->findComponent('VFREEBUSY');
     if ($vfb === false) {
         throw new Horde_Kolab_Resource_Exception(sprintf('Invalid or no free/busy information available for %s', $resource), Horde_Kolab_Resource_Exception::NO_FREEBUSY);
     }
     $vfb->simplify();
     return $vfb;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:46,代码来源:Kolab.php

示例13: testRead

 public function testRead()
 {
     $ical = new Horde_Icalendar();
     $ical->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/vfreebusy1.ics'));
     // Get the vFreeBusy component
     $vfb = $ical->getComponent(0);
     // Dump the type
     $this->assertEquals('vFreebusy', $vfb->getType());
     // Dump the vfreebusy component again (the duration should be
     // converted to start/end
     $this->assertStringEqualsFile(__DIR__ . '/fixtures/vfreebusy2.ics', $vfb->exportvCalendar());
     // Dump organizer name
     $this->assertEquals('GunnarWrobel', $vfb->getName());
     // Dump organizer mail
     $this->assertEquals('wrobel@demo2.pardus.de', $vfb->getEmail());
     // Dump busy periods
     $this->assertEquals(array(1164258000 => 1164261600, 1164268800 => 1164276000), $vfb->getBusyPeriods());
     // Decode the summary information
     $extra = $vfb->getExtraParams();
     $this->assertEquals('testtermin', base64_decode($extra[1164258000]['X-SUMMARY']));
     // Dump the free periods in between the two given time stamps
     $this->assertEquals(array(1164261600 => 1164268800), $vfb->getFreePeriods(1164261500, 1164268900));
     // Dump start of the free/busy information
     $this->assertEquals(1164236400, $vfb->getStart());
     // Dump end of the free/busy information
     $this->assertEquals(1169420400, $vfb->getEnd());
     // Free periods don't get added
     $vfb->addBusyPeriod('FREE', 1164261600, 1164268800);
     $this->assertEquals(array(1164258000 => 1164261600, 1164268800 => 1164276000), $vfb->getBusyPeriods());
     // Add a busy period with start/end (11:00 / 12:00)
     $vfb->addBusyPeriod('BUSY', 1164279600, 1164283200);
     // Add a busy period with start/duration (14:00 / 2h)
     $vfb->addBusyPeriod('BUSY', 1164290400, null, 7200, array('X-SUMMARY' => 'dGVzdA=='));
     // Dump busy periods
     $this->assertEquals(array(1164258000 => 1164261600, 1164268800 => 1164276000, 1164279600 => 1164283200, 1164290400 => 1164297600), $vfb->getBusyPeriods());
     // Dump the extra parameters
     $this->assertEquals(array(1164258000 => array('X-UID' => 'MmZlNWU3NDRmMGFjNjZkNjRjZjFkZmFmYTE4NGFiZTQ=', 'X-SUMMARY' => 'dGVzdHRlcm1pbg=='), 1164268800 => array(), 1164279600 => array(), 1164290400 => array('X-SUMMARY' => 'dGVzdA==')), $vfb->getExtraParams());
     return $vfb;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:39,代码来源:FreeBusyTest.php

示例14: search

 /**
  * @throws Kronolith_Exception
  */
 public function search($email, $private_only = false)
 {
     $server = $GLOBALS['injector']->getInstance('Horde_Kolab_Session')->getFreebusyServer();
     if (empty($server)) {
         throw new Horde_Exception_NotFound();
     }
     $http = $GLOBALS['injector']->getInstance('Horde_Core_Factory_HttpClient')->create(array('request.username' => $GLOBALS['registry']->getAuth(), 'request.password' => $GLOBALS['registry']->getAuthCredential('password')));
     try {
         $response = $http->get(sprintf('%s/%s.xfb', $server, $email));
     } catch (Horde_Http_Exception $e) {
         throw new Horde_Exception_NotFound();
     }
     if ($response->code != 200) {
         throw new Horde_Exception_NotFound();
     }
     $vfb_text = $response->getBody();
     $iCal = new Horde_Icalendar();
     $iCal->parsevCalendar($vfb_text);
     $vfb = $iCal->findComponent('VFREEBUSY');
     if ($vfb === false) {
         throw new Horde_Exception_NotFound();
     }
     return $vfb;
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:27,代码来源:Kolab.php

示例15: _renderInline

 /**
  * Return the full rendered version of the Horde_Mime_Part object.
  *
  * URL parameters used by this function:
  *   - c: (integer) The VCARD component that contains an image.
  *   - p: (integer) The index of image inside the component to display.
  *
  * @return array  See parent::render().
  * @throws Horde_Exception
  */
 protected function _renderInline()
 {
     $vars = $GLOBALS['injector']->getInstance('Horde_Variables');
     if (!isset($vars->p)) {
         $imp_contents = $this->getConfigParam('imp_contents');
         $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_VcardImport', array('mime_id' => $this->_mimepart->getMimeId(), 'muid' => strval($imp_contents->getIndicesOb())));
         $this->_imageUrl = $this->getConfigParam('imp_contents')->urlView($this->_mimepart, 'download_render', array('params' => array('mode' => IMP_Contents::RENDER_INLINE)));
         return parent::_renderInline();
     }
     /* Send the requested photo. */
     $data = $this->_mimepart->getContents();
     $ical = new Horde_Icalendar();
     if (!$ical->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
         // TODO: Error reporting
         return array();
     }
     $components = $ical->getComponents();
     if (!isset($components[$vars->c])) {
         // TODO: Error reporting
         return array();
     }
     $name = $components[$vars->c]->getAttributeDefault('FN', false);
     if ($name === false) {
         $name = $components[$vars->c]->printableName();
     }
     if (empty($name)) {
         $name = preg_replace('/\\..*?$/', '', $this->_mimepart->getName());
     }
     $photos = $components[$vars->c]->getAllAttributes('PHOTO');
     if (!isset($photos[$vars->p])) {
         // TODO: Error reporting
         return array();
     }
     $type = 'image/' . Horde_String::lower($photos[$vars->p]['params']['TYPE']);
     return array($this->_mimepart->getMimeId() => array('data' => base64_decode($photos[$vars->p]['value']), 'name' => $name . '.' . Horde_Mime_Magic::mimeToExt($type), 'type' => $type));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:46,代码来源:Vcard.php


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