mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-08 08:57:03 +03:00
CardDAV (pre-alpha/unstable)
This commit is contained in:
parent
0ec965bccb
commit
599e934b4a
76 changed files with 6984 additions and 1512 deletions
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Sabre\VObject\Property\VCard;
|
||||
|
||||
use
|
||||
Sabre\VObject\DateTimeParser;
|
||||
|
||||
/**
|
||||
* Date property
|
||||
*
|
||||
* This object encodes vCard DATE values.
|
||||
*
|
||||
* @copyright Copyright (C) 2007-2013 fruux GmbH. All rights reserved.
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Date extends DateAndOrTime {
|
||||
|
||||
/**
|
||||
* Returns the type of value.
|
||||
*
|
||||
* This corresponds to the VALUE= parameter. Every property also has a
|
||||
* 'default' valueType.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValueType() {
|
||||
|
||||
return "DATE";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
|
||||
namespace Sabre\VObject\Property\VCard;
|
||||
|
||||
use
|
||||
Sabre\VObject\DateTimeParser,
|
||||
Sabre\VObject\Property\Text;
|
||||
|
||||
/**
|
||||
* DateAndOrTime property
|
||||
*
|
||||
* This object encodes DATE-AND-OR-TIME values.
|
||||
*
|
||||
* @copyright Copyright (C) 2007-2013 fruux GmbH. All rights reserved.
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class DateAndOrTime extends Text {
|
||||
|
||||
/**
|
||||
* Field separator
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $delimiter = null;
|
||||
|
||||
/**
|
||||
* Returns the type of value.
|
||||
*
|
||||
* This corresponds to the VALUE= parameter. Every property also has a
|
||||
* 'default' valueType.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValueType() {
|
||||
|
||||
return "DATE-AND-OR-TIME";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value, in the format it should be encoded for json.
|
||||
*
|
||||
* This method must always return an array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getJsonValue() {
|
||||
|
||||
$parts = DateTimeParser::parseVCardDateTime($this->getValue());
|
||||
|
||||
$dateStr = '';
|
||||
|
||||
// Year
|
||||
if (!is_null($parts['year'])) {
|
||||
$dateStr.=$parts['year'];
|
||||
|
||||
if (!is_null($parts['month'])) {
|
||||
// If a year and a month is set, we need to insert a separator
|
||||
// dash.
|
||||
$dateStr.='-';
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (!is_null($parts['month']) || !is_null($parts['date'])) {
|
||||
// Inserting two dashes
|
||||
$dateStr.='--';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Month
|
||||
|
||||
if (!is_null($parts['month'])) {
|
||||
$dateStr.=$parts['month'];
|
||||
|
||||
if (isset($parts['date'])) {
|
||||
// If month and date are set, we need the separator dash.
|
||||
$dateStr.='-';
|
||||
}
|
||||
} else {
|
||||
if (isset($parts['date'])) {
|
||||
// If the month is empty, and a date is set, we need a 'empty
|
||||
// dash'
|
||||
$dateStr.='-';
|
||||
}
|
||||
}
|
||||
|
||||
// Date
|
||||
if (!is_null($parts['date'])) {
|
||||
$dateStr.=$parts['date'];
|
||||
}
|
||||
|
||||
|
||||
// Early exit if we don't have a time string.
|
||||
if (is_null($parts['hour']) && is_null($parts['minute']) && is_null($parts['second'])) {
|
||||
return array($dateStr);
|
||||
}
|
||||
|
||||
$dateStr.='T';
|
||||
|
||||
// Hour
|
||||
if (!is_null($parts['hour'])) {
|
||||
$dateStr.=$parts['hour'];
|
||||
|
||||
if (!is_null($parts['minute'])) {
|
||||
$dateStr.=':';
|
||||
}
|
||||
} else {
|
||||
// We know either minute or second _must_ be set, so we insert a
|
||||
// dash for an empty value.
|
||||
$dateStr.='-';
|
||||
}
|
||||
|
||||
// Minute
|
||||
if (!is_null($parts['minute'])) {
|
||||
$dateStr.=$parts['minute'];
|
||||
|
||||
if (!is_null($parts['second'])) {
|
||||
$dateStr.=':';
|
||||
}
|
||||
} else {
|
||||
if (isset($parts['second'])) {
|
||||
// Dash for empty minute
|
||||
$dateStr.='-';
|
||||
}
|
||||
}
|
||||
|
||||
// Second
|
||||
if (!is_null($parts['second'])) {
|
||||
$dateStr.=$parts['second'];
|
||||
}
|
||||
|
||||
// Timezone
|
||||
if (!is_null($parts['timezone'])) {
|
||||
$dateStr.=$parts['timezone'];
|
||||
}
|
||||
|
||||
return array($dateStr);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Sabre\VObject\Property\VCard;
|
||||
|
||||
use
|
||||
Sabre\VObject\DateTimeParser;
|
||||
|
||||
/**
|
||||
* DateTime property
|
||||
*
|
||||
* This object encodes DATE-TIME values for vCards.
|
||||
*
|
||||
* @copyright Copyright (C) 2007-2013 fruux GmbH. All rights reserved.
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class DateTime extends DateAndOrTime {
|
||||
|
||||
/**
|
||||
* Returns the type of value.
|
||||
*
|
||||
* This corresponds to the VALUE= parameter. Every property also has a
|
||||
* 'default' valueType.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValueType() {
|
||||
|
||||
return "DATE-TIME";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace Sabre\VObject\Property\VCard;
|
||||
|
||||
use
|
||||
Sabre\VObject\Property;
|
||||
|
||||
/**
|
||||
* LanguageTag property
|
||||
*
|
||||
* This object represents LANGUAGE-TAG values as used in vCards.
|
||||
*
|
||||
* @copyright Copyright (C) 2007-2013 fruux GmbH. All rights reserved.
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class LanguageTag extends Property {
|
||||
|
||||
/**
|
||||
* Sets a raw value coming from a mimedir (iCalendar/vCard) file.
|
||||
*
|
||||
* This has been 'unfolded', so only 1 line will be passed. Unescaping is
|
||||
* not yet done, but parameters are not included.
|
||||
*
|
||||
* @param string $val
|
||||
* @return void
|
||||
*/
|
||||
public function setRawMimeDirValue($val) {
|
||||
|
||||
$this->setValue($val);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a raw mime-dir representation of the value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawMimeDirValue() {
|
||||
|
||||
return $this->value;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of value.
|
||||
*
|
||||
* This corresponds to the VALUE= parameter. Every property also has a
|
||||
* 'default' valueType.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValueType() {
|
||||
|
||||
return "LANGUAGE-TAG";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace Sabre\VObject\Property\VCard;
|
||||
|
||||
use
|
||||
Sabre\VObject\DateTimeParser,
|
||||
Sabre\VObject\Property\Text;
|
||||
|
||||
/**
|
||||
* TimeStamp property
|
||||
*
|
||||
* This object encodes TIMESTAMP values.
|
||||
*
|
||||
* @copyright Copyright (C) 2007-2013 fruux GmbH. All rights reserved.
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class TimeStamp extends Text {
|
||||
|
||||
/**
|
||||
* In case this is a multi-value property. This string will be used as a
|
||||
* delimiter.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $delimiter = null;
|
||||
|
||||
/**
|
||||
* Returns the type of value.
|
||||
*
|
||||
* This corresponds to the VALUE= parameter. Every property also has a
|
||||
* 'default' valueType.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValueType() {
|
||||
|
||||
return "TIMESTAMP";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value, in the format it should be encoded for json.
|
||||
*
|
||||
* This method must always return an array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getJsonValue() {
|
||||
|
||||
$parts = DateTimeParser::parseVCardDateTime($this->getValue());
|
||||
|
||||
$dateStr =
|
||||
$parts['year'] . '-' .
|
||||
$parts['month'] . '-' .
|
||||
$parts['date'] . 'T' .
|
||||
$parts['hour'] . ':' .
|
||||
$parts['minute'] . ':' .
|
||||
$parts['second'];
|
||||
|
||||
// Timezone
|
||||
if (!is_null($parts['timezone'])) {
|
||||
$dateStr.=$parts['timezone'];
|
||||
}
|
||||
|
||||
return array($dateStr);
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue