mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 16:37:02 +03:00
Idea to solve https://github.com/sabre-io/vobject/issues/589
This commit is contained in:
parent
02623ab827
commit
497193750b
4 changed files with 98 additions and 0 deletions
|
|
@ -136,6 +136,8 @@ class VCard extends VObject\Document
|
||||||
'HOBBY' => VObject\Property\FlatText::class,
|
'HOBBY' => VObject\Property\FlatText::class,
|
||||||
'INTEREST' => VObject\Property\FlatText::class,
|
'INTEREST' => VObject\Property\FlatText::class,
|
||||||
'ORG-DIRECTORY' => VObject\Property\FlatText::class,
|
'ORG-DIRECTORY' => VObject\Property\FlatText::class,
|
||||||
|
|
||||||
|
'X-CRYPTO' => VObject\Property\XCrypto::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,10 @@ class Json extends Parser
|
||||||
unset($parameters['group']);
|
unset($parameters['group']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('X-CRYPTO' === $propertyName) {
|
||||||
|
$propertyType = 'X-CRYPTO';
|
||||||
|
}
|
||||||
|
|
||||||
$prop = $this->root->createProperty($propertyName, null, $parameters, $valueType);
|
$prop = $this->root->createProperty($propertyName, null, $parameters, $valueType);
|
||||||
$prop->setJsonValue($value);
|
$prop->setJsonValue($value);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,27 @@ class XML extends Parser
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'xcard:x-crypto':
|
||||||
|
foreach ($xmlProperty['value'] as $i => $xmlPropertyChild) {
|
||||||
|
if (is_array($xmlPropertyChild)) {
|
||||||
|
$propertyParameterValues = [];
|
||||||
|
foreach ($xmlPropertyChild['value'] as $xmlParameter) {
|
||||||
|
if (is_array($xmlParameter['value'])) {
|
||||||
|
foreach ($xmlParameter['value'] as $xmlParameterValues) {
|
||||||
|
$propertyParameterValues[] = $xmlParameterValues['value'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$propertyParameterValues[] = $xmlParameter['value'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$propertyParameters[static::getTagName($xmlPropertyChild['name'])]
|
||||||
|
= implode(',', $propertyParameterValues);
|
||||||
|
}
|
||||||
|
array_splice($xmlProperty['value'], $i, 1);
|
||||||
|
}
|
||||||
|
$propertyType = 'X-CRYPTO';
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$propertyType = static::getTagName($xmlProperty['value'][0]['name']);
|
$propertyType = static::getTagName($xmlProperty['value'][0]['name']);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Sabre\VObject\Property;
|
||||||
|
|
||||||
|
use Sabre\VObject\Property;
|
||||||
|
//use Sabre\VObject\Property\Text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XCrypto property.
|
||||||
|
*
|
||||||
|
* This object encodes X-CRYPTO values, as defined in KDE KAddressBook
|
||||||
|
*
|
||||||
|
* @copyright Copyright (C) SnappyMail (https://snappymail.eu/)
|
||||||
|
* @author DJMaze (https://snappymail.eu/)
|
||||||
|
* @license http://sabre.io/license/ Modified BSD License
|
||||||
|
*/
|
||||||
|
class XCrypto extends Property
|
||||||
|
//class XCrypto extends Text
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns the type of value.
|
||||||
|
*
|
||||||
|
* This corresponds to the VALUE= parameter. Every property also has a
|
||||||
|
* 'default' valueType.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getValueType()
|
||||||
|
{
|
||||||
|
return 'X-CRYPTO';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
public function setRawMimeDirValue($val)
|
||||||
|
{
|
||||||
|
error_log("setRawMimeDirValue({$val})");
|
||||||
|
// $this->setValue(MimeDir::unescapeValue($val, $this->delimiter));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a raw mime-dir representation of the value.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRawMimeDirValue()
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
foreach ($this->parameters as $parameter) {
|
||||||
|
$result[] = strtolower($parameter->name) . '=' . $parameter->getValue();
|
||||||
|
}
|
||||||
|
return implode(',', $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function xmlSerialize(\Sabre\Xml\Writer $writer): void
|
||||||
|
{
|
||||||
|
$writer->startElement(strtolower($this->name));
|
||||||
|
foreach ($this->parameters as $parameter) {
|
||||||
|
$writer->startElement(strtolower($parameter->name));
|
||||||
|
$writer->write($parameter);
|
||||||
|
$writer->endElement();
|
||||||
|
}
|
||||||
|
$writer->endElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue