本文整理汇总了PHP中Sabre\Xml\Writer::writeElement方法的典型用法代码示例。如果您正苦于以下问题:PHP Writer::writeElement方法的具体用法?PHP Writer::writeElement怎么用?PHP Writer::writeElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sabre\Xml\Writer
的用法示例。
在下文中一共展示了Writer::writeElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmlSerialize
/**
* The xmlSerialize metod is called during xml writing.
*
* Use the $writer argument to write its own xml serialization.
*
* An important note: do _not_ create a parent element. Any element
* implementing XmlSerializble should only ever write what's considered
* its 'inner xml'.
*
* The parent of the current element is responsible for writing a
* containing element.
*
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
*
* @param Writer $writer
* @return void
*/
function xmlSerialize(Writer $writer)
{
if ($this->canBeShared) {
$writer->writeElement('{' . Plugin::NS_CALENDARSERVER . '}can-be-shared');
}
if ($this->canBePublished) {
$writer->writeElement('{' . Plugin::NS_CALENDARSERVER . '}can-be-published');
}
}
示例2: xmlSerialize
/**
* The serialize method is called during xml writing.
*
* It should use the $writer argument to encode this object into XML.
*
* Important note: it is not needed to create the parent element. The
* parent element is already created, and we only have to worry about
* attributes, child elements and text (if any).
*
* Important note 2: If you are writing any new elements, you are also
* responsible for closing them.
*
* @param Writer $writer
* @return void
*/
function xmlSerialize(Writer $writer)
{
foreach ($this->getResponses() as $response) {
$writer->writeElement('{DAV:}response', $response);
}
if ($syncToken = $this->getSyncToken()) {
$writer->writeElement('{DAV:}sync-token', $syncToken);
}
}
示例3: xmlSerialize
/**
* The xmlSerialize metod is called during xml writing.
*
* Use the $writer argument to write its own xml serialization.
*
* An important note: do _not_ create a parent element. Any element
* implementing XmlSerializble should only ever write what's considered
* its 'inner xml'.
*
* The parent of the current element is responsible for writing a
* containing element.
*
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
*
* @param Writer $writer
* @return void
*/
function xmlSerialize(Writer $writer)
{
switch ($this->value) {
case self::TRANSPARENT:
$writer->writeElement('{' . Plugin::NS_CALDAV . '}transparent');
break;
case self::OPAQUE:
$writer->writeElement('{' . Plugin::NS_CALDAV . '}opaque');
break;
}
}
示例4: xmlSerialize
/**
* The xmlSerialize metod is called during xml writing.
*
* Use the $writer argument to write its own xml serialization.
*
* An important note: do _not_ create a parent element. Any element
* implementing XmlSerializble should only ever write what's considered
* its 'inner xml'.
*
* The parent of the current element is responsible for writing a
* containing element.
*
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
*
* @param Writer $writer
* @return void
*/
function xmlSerialize(Writer $writer)
{
$collations = ['i;ascii-casemap', 'i;octet', 'i;unicode-casemap'];
foreach ($collations as $collation) {
$writer->writeElement('{' . Plugin::NS_CALDAV . '}supported-collation', $collation);
}
}
示例5: xmlSerializeValue
/**
* This method serializes only the value of a property. This is used to
* create xCard or xCal documents.
*
* @param Xml\Writer $writer XML writer.
*
* @return void
*/
protected function xmlSerializeValue(Xml\Writer $writer)
{
// xCard is the only XML and JSON format that has the same date and time
// format than vCard.
$valueType = strtolower($this->getValueType());
$writer->writeElement($valueType, $this->getValue());
}
示例6: xmlSerialize
/**
* The xmlSerialize metod is called during xml writing.
*
* Use the $writer argument to write its own xml serialization.
*
* An important note: do _not_ create a parent element. Any element
* implementing XmlSerializble should only ever write what's considered
* its 'inner xml'.
*
* The parent of the current element is responsible for writing a
* containing element.
*
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
*
* @param Writer $writer
* @return void
*/
function xmlSerialize(Writer $writer)
{
foreach ($this->privileges as $privName) {
$writer->startElement('{DAV:}privilege');
$writer->writeElement($privName);
$writer->endElement();
}
}
示例7: xmlSerialize
/**
* The xmlSerialize metod is called during xml writing.
*
* Use the $writer argument to write its own xml serialization.
*
* An important note: do _not_ create a parent element. Any element
* implementing XmlSerializble should only ever write what's considered
* its 'inner xml'.
*
* The parent of the current element is responsible for writing a
* containing element.
*
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
*
* @param Writer $writer
* @return void
*/
function xmlSerialize(Writer $writer)
{
$cs = '{' . Plugin::NS_CALENDARSERVER . '}';
foreach ($this->sharees as $sharee) {
if ($sharee->access === \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER) {
$writer->startElement($cs . 'organizer');
} else {
$writer->startElement($cs . 'user');
switch ($sharee->inviteStatus) {
case DAV\Sharing\Plugin::INVITE_ACCEPTED:
$writer->writeElement($cs . 'invite-accepted');
break;
case DAV\Sharing\Plugin::INVITE_DECLINED:
$writer->writeElement($cs . 'invite-declined');
break;
case DAV\Sharing\Plugin::INVITE_NORESPONSE:
$writer->writeElement($cs . 'invite-noresponse');
break;
case DAV\Sharing\Plugin::INVITE_INVALID:
$writer->writeElement($cs . 'invite-invalid');
break;
}
$writer->startElement($cs . 'access');
switch ($sharee->access) {
case DAV\Sharing\Plugin::ACCESS_READWRITE:
$writer->writeElement($cs . 'read-write');
break;
case DAV\Sharing\Plugin::ACCESS_READ:
$writer->writeElement($cs . 'read');
break;
}
$writer->endElement();
// access
}
$href = new \Sabre\DAV\Xml\Property\Href($sharee->href);
$href->xmlSerialize($writer);
if (isset($sharee->properties['{DAV:}displayname'])) {
$writer->writeElement($cs . 'common-name', $sharee->properties['{DAV:}displayname']);
}
if ($sharee->comment) {
$writer->writeElement($cs . 'summary', $sharee->comment);
}
$writer->endElement();
// organizer or user
}
}
示例8: xmlSerialize
/**
* The xmlSerialize method is called during xml writing.
*
* Use the $writer argument to write its own xml serialization.
*
* An important note: do _not_ create a parent element. Any element
* implementing XmlSerializble should only ever write what's considered
* its 'inner xml'.
*
* The parent of the current element is responsible for writing a
* containing element.
*
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
*
* @param Writer $writer
* @return void
*/
function xmlSerialize(Writer $writer)
{
switch ($this->value) {
case SharingPlugin::ACCESS_NOTSHARED:
$writer->writeElement('{DAV:}not-shared');
break;
case SharingPlugin::ACCESS_SHAREDOWNER:
$writer->writeElement('{DAV:}shared-owner');
break;
case SharingPlugin::ACCESS_READ:
$writer->writeElement('{DAV:}read');
break;
case SharingPlugin::ACCESS_READWRITE:
$writer->writeElement('{DAV:}read-write');
break;
case SharingPlugin::ACCESS_NOACCESS:
$writer->writeElement('{DAV:}no-access');
break;
}
}
示例9: xmlSerialize
/**
* The serialize method is called during xml writing.
*
* It should use the $writer argument to encode this object into XML.
*
* Important note: it is not needed to create the parent element. The
* parent element is already created, and we only have to worry about
* attributes, child elements and text (if any).
*
* Important note 2: If you are writing any new elements, you are also
* responsible for closing them.
*
* @param Writer $writer
* @return void
*/
function xmlSerialize(Writer $writer)
{
foreach ($this->locks as $lock) {
$writer->startElement('{DAV:}activelock');
$writer->startElement('{DAV:}lockscope');
if ($lock->scope === LockInfo::SHARED) {
$writer->writeElement('{DAV:}shared');
} else {
$writer->writeElement('{DAV:}exclusive');
}
$writer->endElement();
// {DAV:}lockscope
$writer->startElement('{DAV:}locktype');
$writer->writeElement('{DAV:}write');
$writer->endElement();
// {DAV:}locktype
if (!self::$hideLockRoot) {
$writer->startElement('{DAV:}lockroot');
$writer->writeElement('{DAV:}href', $writer->contextUri . $lock->uri);
$writer->endElement();
// {DAV:}lockroot
}
$writer->writeElement('{DAV:}depth', $lock->depth == DAV\Server::DEPTH_INFINITY ? 'infinity' : $lock->depth);
$writer->writeElement('{DAV:}timeout', 'Second-' . $lock->timeout);
$writer->startElement('{DAV:}locktoken');
$writer->writeElement('{DAV:}href', 'opaquelocktoken:' . $lock->token);
$writer->endElement();
// {DAV:}locktoken
$writer->writeElement('{DAV:}owner', new XmlFragment($lock->owner));
$writer->endElement();
// {DAV:}activelock
}
}
示例10: xmlSerializeValue
/**
* This method serializes only the value of a property. This is used to
* create xCard or xCal documents.
*
* @param Xml\Writer $writer XML writer.
*
* @return void
*/
protected function xmlSerializeValue(Xml\Writer $writer)
{
$values = $this->getParts();
$map = function ($items) use($values, $writer) {
foreach ($items as $i => $item) {
$writer->writeElement($item, !empty($values[$i]) ? $values[$i] : null);
}
};
switch ($this->name) {
// Special-casing the REQUEST-STATUS property.
//
// See:
// http://tools.ietf.org/html/rfc6321#section-3.4.1.3
case 'REQUEST-STATUS':
$writer->writeElement('code', $values[0]);
$writer->writeElement('description', $values[1]);
if (isset($values[2])) {
$writer->writeElement('data', $values[2]);
}
break;
case 'N':
$map(['surname', 'given', 'additional', 'prefix', 'suffix']);
break;
case 'GENDER':
$map(['sex', 'text']);
break;
case 'ADR':
$map(['pobox', 'ext', 'street', 'locality', 'region', 'code', 'country']);
break;
case 'CLIENTPIDMAP':
$map(['sourceid', 'uri']);
break;
default:
parent::xmlSerializeValue($writer);
}
}
示例11: xmlSerialize
/**
* The xmlSerialize metod is called during xml writing.
*
* Use the $writer argument to write its own xml serialization.
*
* An important note: do _not_ create a parent element. Any element
* implementing XmlSerializble should only ever write what's considered
* its 'inner xml'.
*
* The parent of the current element is responsible for writing a
* containing element.
*
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
*
* @param Writer $writer
* @return void
*/
function xmlSerialize(Writer $writer)
{
foreach (['i;ascii-casemap', 'i;octet', 'i;unicode-casemap'] as $coll) {
$writer->writeElement('{urn:ietf:params:xml:ns:carddav}supported-collation', $coll);
}
}
示例12: xmlSerialize
/**
* The xmlSerialize metod is called during xml writing.
*
* Use the $writer argument to write its own xml serialization.
*
* An important note: do _not_ create a parent element. Any element
* implementing XmlSerializble should only ever write what's considered
* its 'inner xml'.
*
* The parent of the current element is responsible for writing a
* containing element.
*
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
*
* @param Writer $writer
* @return void
*/
function xmlSerialize(Writer $writer)
{
foreach ($this->tags as $tag) {
$writer->startElement(self::NS_OWNCLOUD . ':tag');
$writer->writeElement($tag);
$writer->endElement();
}
}
示例13: xmlSerialize
/**
* The xmlSerialize metod is called during xml writing.
*
* Use the $writer argument to write its own xml serialization.
*
* An important note: do _not_ create a parent element. Any element
* implementing XmlSerializble should only ever write what's considered
* its 'inner xml'.
*
* The parent of the current element is responsible for writing a
* containing element.
*
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
*
* @param Writer $writer
* @return void
*/
function xmlSerialize(Writer $writer)
{
switch ($this->type) {
case self::UNAUTHENTICATED:
$writer->writeElement('{DAV:}unauthenticated');
break;
case self::AUTHENTICATED:
$writer->writeElement('{DAV:}authenticated');
break;
case self::HREF:
parent::xmlSerialize($writer);
break;
case self::ALL:
$writer->writeElement('{DAV:}all');
break;
}
}
示例14: repeatingElements
/**
* This serializer helps you serialize xml structures that look like
* this:
*
* <collection>
* <item>...</item>
* <item>...</item>
* <item>...</item>
* </collection>
*
* In that previous example, this serializer just serializes the item element,
* and this could be called like this:
*
* repeatingElements($writer, $items, '{}item');
*
* @param Writer $writer
* @param array $items A list of items sabre/xml can serialize.
* @param string $childElementName Element name in clark-notation
* @return void
*/
function repeatingElements(Writer $writer, array $items, $childElementName)
{
foreach ($items as $item) {
$writer->writeElement($childElementName, $item);
}
}
示例15: xmlSerializeValue
/**
* This method serializes only the value of a property. This is used to
* create xCard or xCal documents.
*
* @param Xml\Writer $writer XML writer.
*
* @return void
*/
protected function xmlSerializeValue(Xml\Writer $writer)
{
$writer->startElement(strtolower($this->getValueType()));
$value = $this->getJsonValue();
$writer->writeElement('start', $value[0][0]);
if ($value[0][1][0] === 'P') {
$writer->writeElement('duration', $value[0][1]);
} else {
$writer->writeElement('end', $value[0][1]);
}
$writer->endElement();
}