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


PHP Horde_Icalendar::getComponent方法代码示例

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


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

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

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

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

示例6: toHash

 protected function toHash($vcard, $map = array())
 {
     $driver = new Turba_Driver();
     foreach ($map as $field => $config) {
         $driver->map[$field] = $config;
     }
     $ical = new Horde_Icalendar();
     $ical->parsevCalendar($vcard);
     return $driver->toHash($ical->getComponent(0));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:10,代码来源:ImportTest.php

示例7: replace

 /**
  * Replaces the contact identified by UID with the content represented in
  * the specified contentType.
  *
  * @param string $uid            Idenfity the contact to replace.
  * @param mixed  $content        The content of the contact.
  * @param string $contentType    What format is the data in? Currently
  *                               supports array, text/directory,
  *                               text/vcard, text/x-vcard and activesync.
  * @param string|array $sources  The source(s) where the contact will be
  *                               replaced.
  *
  * @return boolean  Success or failure.
  * @throws Turba_Exception
  */
 public function replace($uid, $content, $contentType, $sources = null)
 {
     if (empty($uid)) {
         throw new Turba_Exception(_("Invalid contact unique ID"));
     }
     $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver');
     foreach ($this->_getSources($sources) as $source) {
         $sdriver = $driver->create($source);
         // Check permissions.
         if (!$sdriver->hasPermission(Horde_Perms::EDIT)) {
             continue;
         }
         $result = $sdriver->search(array('__uid' => $uid));
         if (!count($result)) {
             continue;
         } elseif (count($result) > 1) {
             throw new Turba_Exception(sprintf(_("Multiple contacts found with same unique ID %s."), $uid));
         }
         $object = $result->objects[0];
         switch ($contentType) {
             case 'activesync':
                 $content = $sdriver->fromASContact($content);
                 foreach ($content as $attribute => $value) {
                     if ($attribute != '__key') {
                         $object->setValue($attribute, $value);
                     }
                 }
                 return $object->store();
             case 'array':
                 break;
             case 'text/x-vcard':
             case 'text/vcard':
             case 'text/directory':
                 $iCal = new Horde_Icalendar();
                 if (!$iCal->parsevCalendar($content)) {
                     throw new Turba_Exception(_("There was an error importing the iCalendar data."));
                 }
                 switch ($iCal->getComponentCount()) {
                     case 0:
                         throw new Turba_Exception(_("No vCard data was found."));
                     case 1:
                         $content = $sdriver->toHash($iCal->getComponent(0));
                         break;
                     default:
                         throw new Turba_Exception(_("Only one vcard supported."));
                 }
                 break;
             default:
                 throw new Turba_Exception(sprintf(_("Unsupported Content-Type: %s"), $contentType));
         }
         foreach ($content as $attribute => $value) {
             if ($attribute != '__key') {
                 $object->setValue($attribute, $value);
             }
         }
         return $object->store();
     }
     throw new Turba_Exception(sprintf(_("Object %s not found."), $uid));
 }
开发者ID:Gomez,项目名称:horde,代码行数:74,代码来源:Api.php

示例8: testTimezone

    public function testTimezone()
    {
        $date = new Horde_Date(array('year' => 2010, 'month' => 1, 'mday' => 1, 'hour' => 1, 'min' => 0, 'sec' => 0), 'UTC');
        $ical = new Horde_Icalendar();
        $event = Horde_Icalendar::newComponent('vevent', $ical);
        $event->setAttribute('UID', 'uid');
        $event->setAttribute('DTSTAMP', $date);
        $event->setAttribute('DTSTART', $date);
        $ical->addComponent($event);
        $this->assertEquals('BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//The Horde Project//Horde iCalendar Library//EN
BEGIN:VEVENT
UID:uid
DTSTAMP:20100101T010000Z
DTSTART:20100101T010000Z
END:VEVENT
END:VCALENDAR
', $ical->exportVCalendar());
        $ical = new Horde_Icalendar();
        $event = Horde_Icalendar::newComponent('vevent', $ical);
        $event->setAttribute('UID', 'uid');
        $event->setAttribute('DTSTAMP', $date);
        $date->setTimezone('Europe/Berlin');
        $event->setAttribute('DTSTART', $date, array('TZID' => 'Europe/Berlin'));
        $ical->addComponent($event);
        $this->assertEquals('BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//The Horde Project//Horde iCalendar Library//EN
BEGIN:VEVENT
UID:uid
DTSTAMP:20100101T010000Z
DTSTART;TZID=Europe/Berlin:20100101T020000
END:VEVENT
END:VCALENDAR
', $ical->exportVCalendar());
        $ical = new Horde_Icalendar();
        $tz = $ical->parsevCalendar('BEGIN:VCALENDAR
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:19800406T010000
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU;UNTIL=19800406T00000Z
TZNAME:CEST
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:19800928T010000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=9;UNTIL=19950923T23000Z
TZNAME:CE-T
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:19810329T010000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
TZNAME:CEST
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:19961027T010000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZNAME:CE-T
END:STANDARD
END:VTIMEZONE
END:VCALENDAR
');
        $tz = $ical->getComponent(0);
        $ical = new Horde_Icalendar();
        $ical->addComponent($tz);
        $event = Horde_Icalendar::newComponent('vevent', $ical);
        $event->setAttribute('UID', 'uid');
        $event->setAttribute('DTSTAMP', $date);
        $date->setTimezone('Europe/Berlin');
        $event->setAttribute('DTSTART', $date, array('TZID' => 'Europe/Berlin'));
        $ical->addComponent($event);
        $ical->addComponent($tz);
        $event = Horde_Icalendar::newComponent('vevent', $ical);
        $event->setAttribute('UID', 'uid2');
        $event->setAttribute('DTSTAMP', $date);
        $date->setTimezone('Europe/Berlin');
        $start = clone $date;
        $start->mday++;
        $event->setAttribute('DTSTART', $start, array('TZID' => 'Europe/Berlin'));
        $ical->addComponent($event);
        $this->assertEquals('BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//The Horde Project//Horde iCalendar Library//EN
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:19800406T010000
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU;UNTIL=19800406T00000Z
TZNAME:CEST
//.........这里部分代码省略.........
开发者ID:jubinpatel,项目名称:horde,代码行数:101,代码来源:ExportTest.php

示例9: testTimezone

 public function testTimezone()
 {
     $date = new Horde_Date(array('year' => 2010, 'month' => 1, 'mday' => 1, 'hour' => 1, 'min' => 0, 'sec' => 0), 'UTC');
     $ical = new Horde_Icalendar();
     $event = Horde_Icalendar::newComponent('vevent', $ical);
     $event->setAttribute('UID', 'uid');
     $event->setAttribute('DTSTAMP', $date);
     $event->setAttribute('DTSTART', $date);
     $ical->addComponent($event);
     $this->assertStringEqualsFile(__DIR__ . '/fixtures/timezone1.ics', $ical->exportVCalendar());
     $ical = new Horde_Icalendar();
     $event = Horde_Icalendar::newComponent('vevent', $ical);
     $event->setAttribute('UID', 'uid');
     $event->setAttribute('DTSTAMP', $date);
     $date->setTimezone('Europe/Berlin');
     $event->setAttribute('DTSTART', $date, array('TZID' => 'Europe/Berlin'));
     $ical->addComponent($event);
     $this->assertStringEqualsFile(__DIR__ . '/fixtures/timezone2.ics', $ical->exportVCalendar());
     $ical = new Horde_Icalendar();
     $tz = $ical->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/timezone3.ics'));
     $tz = $ical->getComponent(0);
     $ical = new Horde_Icalendar();
     $ical->addComponent($tz);
     $event = Horde_Icalendar::newComponent('vevent', $ical);
     $event->setAttribute('UID', 'uid');
     $event->setAttribute('DTSTAMP', $date);
     $date->setTimezone('Europe/Berlin');
     $event->setAttribute('DTSTART', $date, array('TZID' => 'Europe/Berlin'));
     $ical->addComponent($event);
     $ical->addComponent($tz);
     $event = Horde_Icalendar::newComponent('vevent', $ical);
     $event->setAttribute('UID', 'uid2');
     $event->setAttribute('DTSTAMP', $date);
     $date->setTimezone('Europe/Berlin');
     $start = clone $date;
     $start->mday++;
     $event->setAttribute('DTSTART', $start, array('TZID' => 'Europe/Berlin'));
     $ical->addComponent($event);
     $this->assertStringEqualsFile(__DIR__ . '/fixtures/timezone4.ics', $ical->exportVCalendar());
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:40,代码来源:ExportTest.php

示例10: testBug7423

 public function testBug7423()
 {
     $ical = new Horde_Icalendar();
     $ical->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/bug7423.ics'));
     $this->assertEquals(array('SUMMARY' => 'birthday'), $ical->getComponent(0)->toHash(true));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:6,代码来源:ParseTest.php


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