Ejemplo n.º 1
0
 /**
  * Parses a vCard or iCalendar object, and returns the top component.
  *
  * The options argument is a bitfield. Pass any of the OPTIONS constant to
  * alter the parsers' behaviour.
  *
  * You can either supply a string, or a readable stream for input.
  *
  * @param string|resource $data
  * @param int $options
  * @param string $charset
  * @return Document
  */
 static function read($data, $options = 0, $charset = 'UTF-8')
 {
     $parser = new Parser\MimeDir();
     $parser->setCharset($charset);
     $result = $parser->parse($data, $options);
     return $result;
 }
 /**
  * Parses a vCard or iCalendar object, and returns the top component.
  *
  * The options argument is a bitfield. Pass any of the OPTIONS constant to
  * alter the parsers' behaviour.
  *
  * You can either supply a string, or a readable stream for input.
  *
  * @param string|resource $data
  * @param int $options
  * @return Document
  */
 static function read($data, $options = 0)
 {
     $parser = new Parser\MimeDir();
     $result = $parser->parse($data, $options);
     return $result;
 }
Ejemplo n.º 3
0
    help();
    die;
}
if ($posArgs[0] !== '-') {
    $input = fopen($posArgs[0], 'r');
} else {
    $input = STDIN;
}
if (isset($posArgs[1]) && $posArgs[1] !== '-') {
    $output = fopen($posArgs[1], 'w');
} else {
    $output = STDOUT;
}
$parser = new Parser\MimeDir($input);
try {
    while ($vObj = $parser->parse()) {
        switch ($vObj->name) {
            case 'VCALENDAR':
                fwrite(STDERR, "iCalendar: " . (string) $vObj->VERSION . "\n");
                break;
            case 'VCARD':
                fwrite(STDERR, "vCard: " . (string) $vObj->VERSION . "\n");
                break;
            default:
                fwrite(STDERR, "This was an unknown object, but it did parse. It's likely that validation will give you unexpected results.\n");
                break;
        }
        $options = 0;
        if ($repair) {
            $options |= Node::REPAIR;
        }