/** * 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 } }
/** * @param $items * @return string */ public function generateXML($items) { $this->writer->openMemory(); $this->writer->startElement('properties'); foreach ($items['data'] as $data) { $property = new Property(); $property->propertyId = $data['property-id']; $property->dateListed = $data['date-listed']; $property->setPropertyType($data['property-type']); $property->setListingType($data['listing-type']); $property->link = $data['link']; $property->postalCode = $data['postal-code']; $property->city = $data['city']; $property->rooms = $data['rooms']; $property->bedrooms = $data['bedrooms']; $property->bathrooms = $data['bathrooms']; $property->propertySize = $data['property-size']; $property->landSize = $data['land-size']; $property->price = $data['price']; $property->images = $data['images']; $property->title = $data['title']; $property->description = $data['description']; $property->languages = $data['languages']; $this->writer->write(['property' => $property]); } $this->writer->endElement(); return $this->writer->outputMemory(); }
/** * 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) { $writer->startElement('{' . Plugin::NS_CALDAV . '}calendar-data'); $writer->writeAttributes(['content-type' => 'text/calendar', 'version' => '2.0']); $writer->endElement(); // calendar-data $writer->startElement('{' . Plugin::NS_CALDAV . '}calendar-data'); $writer->writeAttributes(['content-type' => 'application/calendar+json']); $writer->endElement(); // calendar-data }
/** * 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->properties as $propertyName => $propertyValue) { if (is_null($propertyValue)) { $writer->startElement("{DAV:}remove"); $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); $writer->endElement(); } else { $writer->startElement("{DAV:}set"); $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); $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) { foreach ($this->privileges as $privName) { $writer->startElement('{DAV:}privilege'); $writer->writeElement($privName); $writer->endElement(); } }
/** * Serializes a xCal or xCard object. * * @param Component $component * * @return string */ static function writeXml(Component $component) { $writer = new Xml\Writer(); $writer->openMemory(); $writer->setIndent(true); $writer->startDocument('1.0', 'utf-8'); if ($component instanceof Component\VCalendar) { $writer->startElement('icalendar'); $writer->writeAttribute('xmlns', Parser\Xml::XCAL_NAMESPACE); } else { $writer->startElement('vcards'); $writer->writeAttribute('xmlns', Parser\Xml::XCARD_NAMESPACE); } $component->xmlSerialize($writer); $writer->endElement(); return $writer->outputMemory(); }
/** * 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-method'); $writer->writeAttribute('name', $val); $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) { foreach ($this->components as $component) { $writer->startElement('{' . Plugin::NS_CALDAV . '}comp'); $writer->writeAttributes(['name' => $component]); $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 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->supportedData as $supported) { $writer->startElement('{' . Plugin::NS_CARDDAV . '}address-data-type'); $writer->writeAttributes(['content-type' => $supported['contentType'], 'version' => $supported['version']]); $writer->endElement(); // address-data-type } }
private function writeDataFields(array $fields, Writer $writer) { array_map(function (DataField $field) use($writer) { $writer->startElement(static::nameElement('datafield')); $writer->writeAttributes(['tag' => $field->getTag(), 'ind1' => $field->getIndicator1(), 'ind2' => $field->getIndicator2()]); $this->writeSubFields($field->getSubFields(), $writer); $writer->endElement(); }, $fields); }
/** * @param string $url * @param \VirCom\ePUAP2\Requests\Logout $request * @param \Sabre\Xml\Writer $xmlWriter */ public function __construct(Requests\Logout $request, Xml\Writer $xmlWriter) { $xmlWriter->openMemory(); $xmlWriter->setIndent(true); $xmlWriter->startDocument(); $xmlWriter->startElement('samlp:LogoutRequest'); $xmlWriter->writeAttribute('xmlns:samlp', 'urn:oasis:names:tc:SAML:2.0:protocol'); $xmlWriter->writeAttribute('xmlns:saml', 'urn:oasis:names:tc:SAML:2.0:assertion'); $xmlWriter->writeAttribute('ID', microtime(true)); $xmlWriter->writeAttribute('IssueInstant', (new \DateTime())->format('Y-m-d\\TH:i:s\\Z')); $xmlWriter->writeAttribute('Version', '2.0'); $xmlWriter->startElement('saml:Issuer'); $xmlWriter->write($request->getApplicationId()); $xmlWriter->endElement(); $xmlWriter->startElement('samlp:NameID'); $xmlWriter->write($request->getUsername()); $xmlWriter->endElement(); $xmlWriter->endElement(); $this->parsedMessage = $xmlWriter->outputMemory(); }
/** * @param \VirCom\ePUAP2\Requests\Login $request * @param \Sabre\Xml\Writer $xmlWriter */ public function __construct(Requests\Login $request, Xml\Writer $xmlWriter) { $xmlWriter->openMemory(); $xmlWriter->setIndent(true); $xmlWriter->startDocument(); $xmlWriter->startElement('samlp:AuthnRequest'); $xmlWriter->writeAttribute('xmlns:samlp', 'urn:oasis:names:tc:SAML:2.0:protocol'); $xmlWriter->writeAttribute('ID', microtime(true)); $xmlWriter->writeAttribute('IssueInstant', (new \DateTime())->format('Y-m-d\\TH:i:s\\Z')); $xmlWriter->writeAttribute('Version', '2.0'); $xmlWriter->writeAttribute('Destination', $request->getUrl()); $xmlWriter->writeAttribute('IsPassive', 'false'); $xmlWriter->writeAttribute('AssertionConsumerServiceURL', $request->getResponseUrl()); $xmlWriter->startElement('saml:Issuer'); $xmlWriter->writeAttribute('xmlns:saml', 'urn:oasis:names:tc:SAML:2.0:assertion'); $xmlWriter->write($request->getApplicationId()); $xmlWriter->endElement(); $xmlWriter->endElement(); $this->parsedMessage = $xmlWriter->outputMemory(); }
/** * 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) { $reader = new Reader(); // Wrapping the xml in a container, so root-less values can still be // parsed. $xml = <<<XML <?xml version="1.0"?> <xml-fragment xmlns="http://sabre.io/ns">{$this->getXml()}</xml-fragment> XML; $reader->xml($xml); $elementNamespace = null; while ($reader->read()) { if ($reader->depth < 1) { // Skipping the root node. continue; } switch ($reader->nodeType) { case Reader::ELEMENT: $writer->startElement($reader->getClark()); $empty = $reader->isEmptyElement; while ($reader->moveToNextAttribute()) { switch ($reader->namespaceURI) { case '': $writer->writeAttribute($reader->localName, $reader->value); break; case 'http://www.w3.org/2000/xmlns/': // Skip namespace declarations break; default: $writer->writeAttribute($reader->getClark(), $reader->value); break; } } if ($empty) { $writer->endElement(); } break; case Reader::CDATA: case Reader::TEXT: $writer->text($reader->value); break; case Reader::END_ELEMENT: $writer->endElement(); break; } } }
/** * @dataProvider dataProvider */ function testSerializers($notification, $expected1, $expected2) { $this->assertEquals('foo', $notification->getId()); $this->assertEquals('"1"', $notification->getETag()); $writer = new Writer(); $writer->namespaceMap = ['http://calendarserver.org/ns/' => 'cs']; $writer->openMemory(); $writer->startDocument('1.0', 'UTF-8'); $writer->startElement('{http://calendarserver.org/ns/}root'); $writer->write($notification); $writer->endElement(); $this->assertXmlStringEqualsXmlString($expected1, $writer->outputMemory()); $writer = new Writer(); $writer->namespaceMap = ['http://calendarserver.org/ns/' => 'cs', 'DAV:' => 'd']; $writer->openMemory(); $writer->startDocument('1.0', 'UTF-8'); $writer->startElement('{http://calendarserver.org/ns/}root'); $notification->xmlSerializeFull($writer); $writer->endElement(); $this->assertXmlStringEqualsXmlString($expected2, $writer->outputMemory()); }
/** * @dataProvider dataProvider */ function testSerializers($notification, $expected) { $notification = new InviteReply($notification); $this->assertEquals('foo', $notification->getId()); $this->assertEquals('"1"', $notification->getETag()); $simpleExpected = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:invite-reply/></cs:root>'; $writer = new Writer(); $writer->namespaceMap = ['http://calendarserver.org/ns/' => 'cs']; $writer->openMemory(); $writer->startDocument('1.0', 'UTF-8'); $writer->startElement('{http://calendarserver.org/ns/}root'); $writer->write($notification); $writer->endElement(); $this->assertEquals($simpleExpected, $writer->outputMemory()); $writer = new Writer(); $writer->contextUri = '/'; $writer->namespaceMap = ['http://calendarserver.org/ns/' => 'cs', 'DAV:' => 'd']; $writer->openMemory(); $writer->startDocument('1.0', 'UTF-8'); $writer->startElement('{http://calendarserver.org/ns/}root'); $notification->xmlSerializeFull($writer); $writer->endElement(); $this->assertXmlStringEqualsXmlString($expected, $writer->outputMemory()); }
function writeFull($input) { $writer = new Writer(); $writer->contextUri = '/'; $writer->namespaceMap = $this->namespaceMap; $writer->openMemory(); $writer->startElement('{http://calendarserver.org/ns/}root'); $input->xmlSerializeFull($writer); $writer->endElement(); return $writer->outputMemory(); }
/** * 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) { $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 } }
/** * 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 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 }
/** * 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(); } }
/** * This method serializes the data into XML. This is used to create xCard or * xCal documents. * * @param Xml\Writer $writer XML writer. * * @return void */ function xmlSerialize(Xml\Writer $writer) { $components = []; $properties = []; foreach ($this->children as $childGroup) { foreach ($childGroup as $child) { if ($child instanceof self) { $components[] = $child; } else { $properties[] = $child; } } } $writer->startElement(strtolower($this->name)); if (!empty($properties)) { $writer->startElement('properties'); foreach ($properties as $property) { $property->xmlSerialize($writer); } $writer->endElement(); } if (!empty($components)) { $writer->startElement('components'); foreach ($components as $component) { $component->xmlSerialize($writer); } $writer->endElement(); } $writer->endElement(); }
/** * 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 }
/** * This method serializes the data into XML. This is used to create xCard or * xCal documents. * * @param Xml\Writer $writer XML writer. * * @return void */ function xmlSerialize(Xml\Writer $writer) { $parameters = []; foreach ($this->parameters as $parameter) { if ($parameter->name === 'VALUE') { continue; } $parameters[] = $parameter; } $writer->startElement(strtolower($this->name)); if (!empty($parameters)) { $writer->startElement('parameters'); foreach ($parameters as $parameter) { $writer->startElement(strtolower($parameter->name)); $writer->write($parameter); $writer->endElement(); } $writer->endElement(); } $this->xmlSerializeValue($writer); $writer->endElement(); }
/** * 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(); }
/** * 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 } }
/** * 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 }
/** * This method serializes the data into XML. This is used to create xCard or * xCal documents. * * @param Xml\Writer $writer XML writer. * * @return void */ function xmlSerialize(Xml\Writer $writer) { $propertiesByGroup = []; foreach ($this->children() as $property) { $group = $property->group; if (!isset($propertiesByGroup[$group])) { $propertiesByGroup[$group] = []; } $propertiesByGroup[$group][] = $property; } $writer->startElement(strtolower($this->name)); foreach ($propertiesByGroup as $group => $properties) { if (!empty($group)) { $writer->startElement('group'); $writer->writeAttribute('name', strtolower($group)); } foreach ($properties as $property) { switch ($property->name) { case 'VERSION': continue; case 'XML': $value = $property->getParts(); $fragment = new Xml\Element\XmlFragment($value[0]); $writer->write($fragment); break; default: $property->xmlSerialize($writer); break; } } if (!empty($group)) { $writer->endElement(); } } $writer->endElement(); }
/** * 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]]); } }