CardDAV (pre-alpha/unstable)

This commit is contained in:
RainLoop Team 2013-12-23 04:06:48 +04:00
parent 0ec965bccb
commit 599e934b4a
76 changed files with 6984 additions and 1512 deletions

View file

@ -2,7 +2,9 @@
namespace Sabre\VObject\Splitter;
use Sabre\VObject;
use
Sabre\VObject,
Sabre\VObject\Parser\MimeDir;
/**
* Splitter
@ -27,16 +29,25 @@ class VCard implements SplitterInterface {
*/
protected $input;
/**
* Persistent parser
*
* @var MimeDir
*/
protected $parser;
/**
* Constructor
*
* The splitter should receive an readable file stream as it's input.
*
* @param resource $input
* @param int $options Parser options, see the OPTIONS constants.
*/
public function __construct($input) {
public function __construct($input, $options = 0) {
$this->input = $input;
$this->parser = new MimeDir($input, $options);
}
@ -50,23 +61,10 @@ class VCard implements SplitterInterface {
*/
public function getNext() {
$vcard = '';
do {
if (feof($this->input)) {
return false;
}
$line = fgets($this->input);
$vcard .= $line;
} while(strtoupper(substr($line,0,4))!=="END:");
$object = VObject\Reader::read($vcard);
if($object->name !== 'VCARD') {
throw new \InvalidArgumentException("Thats no vCard!", 1);
try {
$object = $this->parser->parse();
} catch (VObject\EofException $e) {
return null;
}
return $object;