mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 23:17:02 +03:00
CardDAV (pre-alpha/unstable)
This commit is contained in:
parent
0ec965bccb
commit
599e934b4a
76 changed files with 6984 additions and 1512 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue