本文整理汇总了PHP中Horde_Icalendar::parseVCalendar方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Icalendar::parseVCalendar方法的具体用法?PHP Horde_Icalendar::parseVCalendar怎么用?PHP Horde_Icalendar::parseVCalendar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Icalendar
的用法示例。
在下文中一共展示了Horde_Icalendar::parseVCalendar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exit
*/
require_once 'Horde/Cli.php';
require_once 'Horde/Icalendar.php';
// This only works on the command line.
if (!Horde_Cli::runningFromCLI()) {
exit("Must be run from the command line\n");
}
// Load the CLI environment - make sure there's no time limit, init
// some variables, etc.
$cli = Horde_Cli::init();
if (empty($argv[1])) {
$cli->fatal('No file specified on the command line.');
}
$input_file = $argv[1];
if (!file_exists($input_file)) {
$cli->fatal($input_file . ' does not exist.');
}
if (!is_readable($input_file)) {
$cli->fatal($input_file . ' is not readable.');
}
$cli->writeln($cli->blue('Parsing ' . $input_file . ' ...'));
$data = file_get_contents($input_file);
$ical = new Horde_Icalendar();
if (!$ical->parseVCalendar($data)) {
$cli->fatal('iCalendar parsing failed.');
}
$cli->writeln($cli->green('Parsing successful, found ' . $ical->getComponentCount() . ' component(s).'));
$components = $ical->getComponents();
foreach ($components as $component) {
var_dump($component->toHash(true));
}
示例2: testEscapes
public function testEscapes()
{
$ical = new Horde_Icalendar();
$event1 = Horde_Icalendar::newComponent('vevent', $ical);
$event2 = Horde_Icalendar::newComponent('vevent', $ical);
$event1->setAttribute('UID', '20041120-8550-innerjoin-org');
$event1->setAttribute('DTSTART', array('year' => 2005, 'month' => 5, 'mday' => 3), array('VALUE' => 'DATE'));
$event1->setAttribute('DTSTAMP', array('year' => 2004, 'month' => 11, 'mday' => 20), array('VALUE' => 'DATE'));
$event1->setAttribute('SUMMARY', 'Escaped Comma in Description Field');
$event1->setAttribute('DESCRIPTION', 'There is a comma (escaped with a baskslash) in this sentence and some important words after it, see anything here?');
$event1->setAttribute('CATEGORIES', null, array(), true, array('Foo'));
$event2->setAttribute('UID', '20041120-8549-innerjoin-org');
$event2->setAttribute('DTSTART', array('year' => 2005, 'month' => 5, 'mday' => 4), array('VALUE' => 'DATE'));
$event2->setAttribute('DTSTAMP', array('year' => 2004, 'month' => 11, 'mday' => 20), array('VALUE' => 'DATE'));
$event2->setAttribute('SUMMARY', 'Dash (rather than Comma) in the Description Field');
$event2->setAttribute('DESCRIPTION', 'There are important words after this dash - see anything here or have the words gone?');
$event2->setAttribute('CATEGORIES', null, array(), true, array('Foo', 'Foo,Bar', 'Bar'));
$ical->addComponent($event1);
$ical->addComponent($event2);
$this->assertStringEqualsFile(__DIR__ . '/fixtures/escapes2.ics', $ical->exportVCalendar());
$readIcal = new Horde_Icalendar();
$readIcal->parseVCalendar($ical->exportVCalendar());
$this->assertEquals(array('There is a comma (escaped with a baskslash) in this sentence and some important words after it, see anything here?'), $readIcal->getComponent(0)->getAttributeValues('DESCRIPTION'));
$this->assertEquals(array('There are important words after this dash - see anything here or have the words gone?'), $readIcal->getComponent(1)->getAttributeValues('DESCRIPTION'));
}