/** * 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'); } }
/** * 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); } }
/** * 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; } }
/** * 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); } }
/** * 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()); }
/** * 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(); } }
/** * 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 } }
/** * 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; } }
/** * 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 } }
/** * 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); } }
/** * 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); } }
/** * 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(); } }
/** * 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; } }
/** * 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); } }
/** * 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(); }
/** * Serializes a property * * This is a recursive function. * * @param Writer $writer * @param array $privilege * @return void */ private function serializePriv(Writer $writer, $privName, $privilege) { $writer->startElement('{DAV:}supported-privilege'); $writer->startElement('{DAV:}privilege'); $writer->writeElement($privName); $writer->endElement(); // privilege if (!empty($privilege['abstract'])) { $writer->writeElement('{DAV:}abstract'); } if (!empty($privilege['description'])) { $writer->writeElement('{DAV:}description', $privilege['description']); } if (isset($privilege['aggregates'])) { foreach ($privilege['aggregates'] as $subPrivName => $subPrivilege) { $this->serializePriv($writer, $subPrivName, $subPrivilege); } } $writer->endElement(); // supported-privilege }
/** * 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) { $valueType = strtolower($this->getValueType()); foreach ($this->getJsonValue() as $value) { $writer->writeElement($valueType, $value); } }
/** * 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->getValue() as $val) { $writer->startElement('{DAV:}supported-report'); $writer->startElement('{DAV:}report'); $writer->writeElement($val); $writer->endElement(); $writer->endElement(); } }
function xmlSerialize(Writer $writer) { foreach ($this->groups as $group) { $writer->writeElement('{' . self::NS_OWNCLOUD . '}group', $group); } }
/** * 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) { if ($status = $this->getHTTPStatus()) { $writer->writeElement('{DAV:}status', 'HTTP/1.1 ' . $status . ' ' . \Sabre\HTTP\Response::$statusCodes[$status]); } $writer->writeElement('{DAV:}href', $writer->contextUri . \Sabre\HTTP\encodePath($this->getHref())); $empty = true; foreach ($this->getResponseProperties() as $status => $properties) { // Skipping empty lists if (!$properties || !ctype_digit($status) && !is_int($status)) { continue; } $empty = false; $writer->startElement('{DAV:}propstat'); $writer->writeElement('{DAV:}prop', $properties); $writer->writeElement('{DAV:}status', 'HTTP/1.1 ' . $status . ' ' . \Sabre\HTTP\Response::$statusCodes[$status]); $writer->endElement(); // {DAV:}propstat } if ($empty) { /* * The WebDAV spec _requires_ at least one DAV:propstat to appear for * every DAV:response. In some circumstances however, there are no * properties to encode. * * In those cases we MUST specify at least one DAV:propstat anyway, with * no properties. */ $writer->writeElement('{DAV:}propstat', ['{DAV:}prop' => [], '{DAV:}status' => 'HTTP/1.1 418 ' . \Sabre\HTTP\Response::$statusCodes[418]]); } }
/** * 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->emails as $email) { $writer->writeElement('{http://calendarserver.org/ns/}email-address', $email); } }
/** * 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) { $valueType = strtolower($this->getValueType()); $parts = DateTimeParser::parseVCardDateAndOrTime($this->getValue()); $value = ''; // $d = defined $d = function ($part) use($parts) { return !is_null($parts[$part]); }; // $r = read $r = function ($part) use($parts) { return $parts[$part]; }; // From the Relax NG Schema. // // # 4.3.1 // value-date = element date { // xsd:string { pattern = "\d{8}|\d{4}-\d\d|--\d\d(\d\d)?|---\d\d" } // } if (($d('year') || $d('month') || $d('date')) && (!$d('hour') && !$d('minute') && !$d('second') && !$d('timezone'))) { if ($d('year') && $d('month') && $d('date')) { $value .= $r('year') . $r('month') . $r('date'); } elseif ($d('year') && $d('month') && !$d('date')) { $value .= $r('year') . '-' . $r('month'); } elseif (!$d('year') && $d('month')) { $value .= '--' . $r('month') . $r('date'); } elseif (!$d('year') && !$d('month') && $d('date')) { $value .= '---' . $r('date'); } // # 4.3.2 // value-time = element time { // xsd:string { pattern = "(\d\d(\d\d(\d\d)?)?|-\d\d(\d\d?)|--\d\d)" // ~ "(Z|[+\-]\d\d(\d\d)?)?" } // } } elseif (!$d('year') && !$d('month') && !$d('date') && ($d('hour') || $d('minute') || $d('second'))) { if ($d('hour')) { $value .= $r('hour') . $r('minute') . $r('second'); } elseif ($d('minute')) { $value .= '-' . $r('minute') . $r('second'); } elseif ($d('second')) { $value .= '--' . $r('second'); } $value .= $r('timezone'); // # 4.3.3 // value-date-time = element date-time { // xsd:string { pattern = "(\d{8}|--\d{4}|---\d\d)T\d\d(\d\d(\d\d)?)?" // ~ "(Z|[+\-]\d\d(\d\d)?)?" } // } } elseif ($d('date') && $d('hour')) { if ($d('year') && $d('month') && $d('date')) { $value .= $r('year') . $r('month') . $r('date'); } elseif (!$d('year') && $d('month') && $d('date')) { $value .= '--' . $r('month') . $r('date'); } elseif (!$d('year') && !$d('month') && $d('date')) { $value .= '---' . $r('date'); } $value .= 'T' . $r('hour') . $r('minute') . $r('second') . $r('timezone'); } $writer->writeElement($valueType, $value); }
/** * This method serializes the entire notification, as it is used in the * response body. * * @param Writer $writer * @return void */ function xmlSerializeFull(Writer $writer) { $cs = '{' . Plugin::NS_CALENDARSERVER . '}'; switch ($this->type) { case self::TYPE_LOW: $type = 'low'; break; case self::TYPE_MEDIUM: $type = 'medium'; break; default: case self::TYPE_HIGH: $type = 'high'; break; } $writer->startElement($cs . 'systemstatus'); $writer->writeAttribute('type', $type); if ($this->description) { $writer->writeElement($cs . 'description', $this->description); } if ($this->href) { $writer->writeElement('{DAV:}href', $this->href); } $writer->endElement(); // systemstatus }
/** * 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(Xml\Writer $writer) { foreach ($this->value as $val) { $writer->writeElement($val); } }
/** * This method serializes the entire notification, as it is used in the * response body. * * @param Writer $writer * @return void */ function xmlSerializeFull(Writer $writer) { $cs = '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}'; $this->dtStamp->setTimezone(new \DateTimezone('GMT')); $writer->writeElement($cs . 'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); $writer->startElement($cs . 'invite-notification'); $writer->writeElement($cs . 'uid', $this->id); $writer->writeElement('{DAV:}href', $this->href); switch ($this->type) { case SharingPlugin::STATUS_ACCEPTED: $writer->writeElement($cs . 'invite-accepted'); break; case SharingPlugin::STATUS_DECLINED: $writer->writeElement($cs . 'invite-declined'); break; case SharingPlugin::STATUS_DELETED: $writer->writeElement($cs . 'invite-deleted'); break; case SharingPlugin::STATUS_NORESPONSE: $writer->writeElement($cs . 'invite-noresponse'); break; } $writer->writeElement($cs . 'hosturl', ['{DAV:}href' => $writer->contextUri . $this->hostUrl]); if ($this->summary) { $writer->writeElement($cs . 'summary', $this->summary); } $writer->startElement($cs . 'access'); if ($this->readOnly) { $writer->writeElement($cs . 'read'); } else { $writer->writeElement($cs . 'read-write'); } $writer->endElement(); // access $writer->startElement($cs . 'organizer'); // If the organizer contains a 'mailto:' part, it means it should be // treated as absolute. if (strtolower(substr($this->organizer, 0, 7)) === 'mailto:') { $writer->writeElement('{DAV:}href', $this->organizer); } else { $writer->writeElement('{DAV:}href', $writer->contextUri . $this->organizer); } if ($this->commonName) { $writer->writeElement($cs . 'common-name', $this->commonName); } if ($this->firstName) { $writer->writeElement($cs . 'first-name', $this->firstName); } if ($this->lastName) { $writer->writeElement($cs . 'last-name', $this->lastName); } $writer->endElement(); // organizer if ($this->commonName) { $writer->writeElement($cs . 'organizer-cn', $this->commonName); } if ($this->firstName) { $writer->writeElement($cs . 'organizer-first', $this->firstName); } if ($this->lastName) { $writer->writeElement($cs . 'organizer-last', $this->lastName); } if ($this->supportedComponents) { $writer->writeElement('{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set', $this->supportedComponents); } $writer->endElement(); // invite-notification }
/** * This method serializes the entire notification, as it is used in the * response body. * * @param Writer $writer * @return void */ function xmlSerializeFull(Writer $writer) { $cs = '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}'; $this->dtStamp->setTimezone(new \DateTimezone('GMT')); $writer->writeElement($cs . 'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); $writer->startElement($cs . 'invite-reply'); $writer->writeElement($cs . 'uid', $this->id); $writer->writeElement($cs . 'in-reply-to', $this->inReplyTo); $writer->writeElement('{DAV:}href', $this->href); switch ($this->type) { case SharingPlugin::STATUS_ACCEPTED: $writer->writeElement($cs . 'invite-accepted'); break; case SharingPlugin::STATUS_DECLINED: $writer->writeElement($cs . 'invite-declined'); break; } $writer->writeElement($cs . 'hosturl', ['{DAV:}href' => $writer->contextUri . $this->hostUrl]); if ($this->summary) { $writer->writeElement($cs . 'summary', $this->summary); } $writer->endElement(); // invite-reply }
/** * 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_OWNCLOUD . '}'; if (!is_null($this->organizer)) { $writer->startElement($cs . 'organizer'); $writer->writeElement('{DAV:}href', $this->organizer['href']); if (isset($this->organizer['commonName']) && $this->organizer['commonName']) { $writer->writeElement($cs . 'common-name', $this->organizer['commonName']); } if (isset($this->organizer['firstName']) && $this->organizer['firstName']) { $writer->writeElement($cs . 'first-name', $this->organizer['firstName']); } if (isset($this->organizer['lastName']) && $this->organizer['lastName']) { $writer->writeElement($cs . 'last-name', $this->organizer['lastName']); } $writer->endElement(); // organizer } foreach ($this->users as $user) { $writer->startElement($cs . 'user'); $writer->writeElement('{DAV:}href', $user['href']); if (isset($user['commonName']) && $user['commonName']) { $writer->writeElement($cs . 'common-name', $user['commonName']); } $writer->writeElement($cs . 'invite-accepted'); $writer->startElement($cs . 'access'); if ($user['readOnly']) { $writer->writeElement($cs . 'read'); } else { $writer->writeElement($cs . 'read-write'); } $writer->endElement(); // access if (isset($user['summary']) && $user['summary']) { $writer->writeElement($cs . 'summary', $user['summary']); } $writer->endElement(); //user } }
/** * 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) { // Special-casing the GEO property. // // See: // http://tools.ietf.org/html/rfc6321#section-3.4.1.2 if ($this->name === 'GEO') { $value = array_map('floatval', $this->getParts()); $writer->writeElement('latitude', $value[0]); $writer->writeElement('longitude', $value[1]); } else { parent::xmlSerializeValue($writer); } }
/** * 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->getHrefs() as $href) { if ($this->autoPrefix) { $href = $writer->contextUri . \Sabre\HTTP\encodePath($href); } $writer->writeElement('{DAV:}href', $href); } }
/** * 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) { if ($status = $this->getHTTPStatus()) { $writer->writeElement('{DAV:}status', 'HTTP/1.1 ' . $status . ' ' . \Sabre\HTTP\Response::$statusCodes[$status]); } $writer->writeElement('{DAV:}href', $writer->contextUri . \Sabre\HTTP\encodePath($this->getHref())); foreach ($this->getResponseProperties() as $status => $properties) { // Skipping empty lists if (!$properties || !ctype_digit($status) && !is_int($status)) { continue; } $writer->startElement('{DAV:}propstat'); $writer->writeElement('{DAV:}prop', $properties); $writer->writeElement('{DAV:}status', 'HTTP/1.1 ' . $status . ' ' . \Sabre\HTTP\Response::$statusCodes[$status]); $writer->endElement(); // {DAV:}propstat } }