public function addGroup($title) { $element = $this->createElement('group'); $this->db->appendChild($element); $element->setTitle($title); return $element; }
function insert_node(DOMDocument &$doc, DOMElement &$field_elem, SimpleXMLElement $details_xml) { $travel_res_submitted_fields = dom_import_simplexml($details_xml->travel_res_submitted_fields[0]); //$travel_res_submitted_fields = $doc->createElement("travel_res_submitted_fields"); $dom_sxe = $doc->importNode($travel_res_submitted_fields, true); $field_elem->appendChild($dom_sxe); if ($details_xml->travel_product[0]) { $travel_res_product = dom_import_simplexml($details_xml->travel_product[0]); //$travel_res_submitted_fields = $doc->createElement("travel_res_submitted_fields"); $dom_sxe = $doc->importNode($travel_res_product, true); $field_elem->appendChild($dom_sxe); } if ($details_xml->travel_lookups[0]) { $travel_res_product_lookups = dom_import_simplexml($details_xml->travel_lookups[0]); //$travel_res_submitted_fields = $doc->createElement("travel_res_submitted_fields"); $dom_sxe_lkp = $doc->importNode($travel_res_product_lookups, true); $field_elem->appendChild($dom_sxe_lkp); } }
/** * Inserts <meta:creation-date /> and <dc:date/> tags. * * Note that OpenOffice.org 3.1.1 is not capable of parsing W3C compliant * dates with TZ offset correctly {@see * http://www.openoffice.org/issues/show_bug.cgi?id=107437}. We do not work * around this issue, since it's too minor. * * @param DOMElement $metaSection */ protected function insertDate(DOMElement $metaSection) { $date = new DateTime(); $dateString = $date->format(DateTime::W3C); $metaSection->appendChild($metaSection->ownerDocument->createElementNS(ezcDocumentOdt::NS_ODT_META, 'meta:creation-date', $dateString)); $metaSection->appendChild($metaSection->ownerDocument->createElementNS(ezcDocumentOdt::NS_DC, 'dc:date', $dateString)); }
/** * serialize * * @param DOMElement $prop * @return void */ public function serialize(Sabre_DAV_Server $server, DOMElement $prop) { $doc = $prop->ownerDocument; if (!$this->supportsLocks) { return null; } $lockEntry1 = $doc->createElementNS('DAV:', 'd:lockentry'); $lockEntry2 = $doc->createElementNS('DAV:', 'd:lockentry'); $prop->appendChild($lockEntry1); $prop->appendChild($lockEntry2); $lockScope1 = $doc->createElementNS('DAV:', 'd:lockscope'); $lockScope2 = $doc->createElementNS('DAV:', 'd:lockscope'); $lockType1 = $doc->createElementNS('DAV:', 'd:locktype'); $lockType2 = $doc->createElementNS('DAV:', 'd:locktype'); $lockEntry1->appendChild($lockScope1); $lockEntry1->appendChild($lockType1); $lockEntry2->appendChild($lockScope2); $lockEntry2->appendChild($lockType2); $lockScope1->appendChild($doc->createElementNS('DAV:', 'd:exclusive')); $lockScope2->appendChild($doc->createElementNS('DAV:', 'd:shared')); $lockType1->appendChild($doc->createElementNS('DAV:', 'd:write')); $lockType2->appendChild($doc->createElementNS('DAV:', 'd:write')); //$frag->appendXML('<d:lockentry><d:lockscope><d:exclusive /></d:lockscope><d:locktype><d:write /></d:locktype></d:lockentry>'); //$frag->appendXML('<d:lockentry><d:lockscope><d:shared /></d:lockscope><d:locktype><d:write /></d:locktype></d:lockentry>'); }
/** * Appends child node * * @param $tag * @return XmlBuilder */ public function __get($tag) { $node = $this->__dom__->createElement($tag); $this->__currentNode__->appendChild($node); $this->__currentNode__ = $node; return $this; }
/** * This function converts an associated array to an XML string. * * @access protected * @static * @param array $array the associated array to be converted * @param DOMElement $domElement the XML DOM element * @param DOMDocument $document the XML DOM document * @return string a string formatted with XML * * @see http://darklaunch.com/2009/05/23/php-xml-encode-using-domdocument-convert-array-to-xml-json-encode */ protected static function convert_to_xml($array, $domElement = NULL, $document = NULL) { if ($document === NULL) { $document = new DOMDocument(); $document->formatOutput = TRUE; static::convert_to_xml($array, $document, $document); return $document->asXML(); } else { if (is_array($array)) { foreach ($array as $node => $value) { $element = NULL; if (is_integer($node)) { $element = $domElement; } else { $element = $document->createElement($node); $domElement->appendChild($element); } static::convert_to_xml($value, $element, $document); } } else { if (is_string($array) and preg_match('/^<!CDATA\\[.*\\]\\]>$/', $array)) { $array = substr($array, 8, strlen($array) - 11); $element = $document->createCDATASection($array); $domElement->appendChild($element); } else { $element = $document->createTextNode($array); $domElement->appendChild($element); } } } }
/** * Build the document structures based on parameters and arguments. This method * is also called if you convert ths class instance to string */ public function createRequest() { if ($this->__documentReady === true) { return true; } foreach ($this->__argumentData as $aName => $aValue) { $argument = $this->createElement('argument'); $argument->setAttribute('name', $aName); $argument->appendChild($this->createCDATASection($aValue)); $this->__rootNode->appendChild($argument); } $resourceDescriptor = $this->createElement('resourceDescriptor'); foreach ($this->__resourceDescriptors as $rName => $rValue) { $resourceDescriptor->setAttribute($rName, $rValue); } $label = $this->createElement('label', $this->__label == null ? 'null' : $this->__label); $resourceDescriptor->appendChild($label); foreach ($this->__parameterData as $pName => $pValue) { $parameter = $this->createElement('parameter'); $parameter->setAttribute('name', $pName); $parameter->appendChild($this->createCDATASection($pValue)); $resourceDescriptor->appendChild($parameter); } $this->__rootNode->appendChild($resourceDescriptor); return $this->__documentReady = true; }
/** * Add dom attributes from array * @static * @param \DOMElement|\DOMNode $node * @param array $array * @param bool $verbal */ public static function array2domAttr(&$node, $array, $verbal = false) { if (is_array($array) and !empty($array)) { foreach ($array as $k => $v) { if (is_numeric($k) and !is_array($v) and !is_object($v) and ctype_alnum($v)) { $node->appendChild($node->ownerDocument->createElement(ctype_alpha($v[0]) ? $v : "_{$v}")); } elseif (is_array($v)) { if (is_numeric($k)) { $k = "_{$k}"; } $newNode = $node->appendChild($node->ownerDocument->createElement($k)); self::array2domAttr($newNode, $v, $verbal); } elseif (is_object($v)) { } else { if ($verbal) { if (is_null($v)) { $v = 'null'; } elseif ($v === false) { $v = 'false'; } elseif ($v === true) { $v = 'true'; } elseif ($v === 0) { $v = '0'; } } $node->setAttribute(ctype_alpha($k[0]) ? $k : "_{$k}", $v); } } } }
private function addElement(EntryModel $entry, $changeFrequency, $priority) { //Check if manually hidden if ($entry->SiteMapPluginHideFromSiteMap) { return; } //Check if entry has URL, some sections don't if (!$entry->getUrl()) { return; } $url = $this->dom->createElement('url'); $urlLoc = $this->dom->createElement('loc'); $urlLoc->nodeValue = $entry->getUrl(); $url->appendChild($urlLoc); $urlModified = $this->dom->createElement('lastmod'); $urlModified->nodeValue = $entry->postDate->w3c(); $url->appendChild($urlModified); $urlChangeFreq = $this->dom->createElement('changefreq'); $urlChangeFreq->nodeValue = $changeFrequency; $url->appendChild($urlChangeFreq); $urlPriority = $this->dom->createElement('priority'); $urlPriority->nodeValue = $priority; $url->appendChild($urlPriority); $this->urlset->appendChild($url); }
/** * Add new soap header. * * @param \DOMElement $node DOMElement to add * @param boolean $mustUnderstand SOAP header mustUnderstand attribute * @param string $actor SOAP actor/role * @param string $soapVersion SOAP version SOAP_1_1|SOAP_1_2 * * @return void */ public function addHeaderElement(\DOMElement $node, $mustUnderstand = null, $actor = null, $soapVersion = SOAP_1_1) { $root = $this->domDocument->documentElement; $namespace = $root->namespaceURI; $prefix = $root->prefix; if (null !== $mustUnderstand) { $node->appendChild(new \DOMAttr($prefix . ':mustUnderstand', (int) $mustUnderstand)); } if (null !== $actor) { $attributeName = $soapVersion == SOAP_1_1 ? 'actor' : 'role'; $node->appendChild(new \DOMAttr($prefix . ':' . $attributeName, $actor)); } $nodeListHeader = $root->getElementsByTagNameNS($namespace, 'Header'); // add header if not there if ($nodeListHeader->length == 0) { // new header element $header = $this->domDocument->createElementNS($namespace, $prefix . ':Header'); // try to add it before body $nodeListBody = $root->getElementsByTagNameNS($namespace, 'Body'); if ($nodeListBody->length == 0) { $root->appendChild($header); } else { $body = $nodeListBody->item(0); $header = $body->parentNode->insertBefore($header, $body); } $header->appendChild($node); } else { $nodeListHeader->item(0)->appendChild($node); } }
/** * Sets the message elements for this operation into the wsdl document * @param DOMElement $wsdl The parent domelement for the messages * @param DomDocument $dom The dom document to create the messages as children of */ public function setMessageElements(DOMElement $wsdl, DOMDocument $dom) { $input = $this->inputMessage->getMessageElement($dom); $output = $this->outputMessage->getMessageElement($dom); $wsdl->appendChild($input); $wsdl->appendChild($output); }
/** * Get the html node for this element * * @param \DOMElement $node * @param \AppShed\Remote\XML\DOMDocument $xml * @param \AppShed\Remote\HTML\Settings $settings */ protected function getHTMLNodeInner($node, $xml, $settings) { if (!empty($this->title)) { $node->appendChild($xml->createElement('div', ['class' => 'title', 'text' => $this->title])); } $node->appendChild($inner = $xml->createElement('div', 'textbox-container' . (empty($this->title) ? ' no-title' : ''))); $inner->appendChild($xml->createElement('span', ['class' => 'picked', 'data-value' => $this->value ? $this->type == static::TYPE_DATE ? $this->value->getTimestamp() : $this->value->format('H:i') : null, 'data-placeholder' => $this->placeHolder, 'data-variable' => $this->variableName, 'data-picker-type' => $this->type, 'data-save-value' => $this->save])); }
/** * @param Sitemap_URL $object */ public function add(Sitemap_URL $object) { $url = $object->create(); // Decorate the urlset $object->root($this->_root); // Append URL to root element $this->_root->appendChild($this->_xml->importNode($url, TRUE)); }
/** * Get the html node for this element * * @param \DOMElement $node * @param \AppShed\Remote\XML\DOMDocument $xml * @param \AppShed\Remote\HTML\Settings $settings */ protected function getHTMLNodeInner($node, $xml, $settings) { if ($this->image) { $node->appendChild($xml->createImgElement($this->image->getUrl(), 'icon', $this->image->getSize())); } $node->appendChild($xml->createElement('div', ['class' => 'text', 'text' => $this->title])); $this->applyLinkToNode($xml, $node, $settings); }
/** * Get the html node for this element * * @param \DOMElement $node * @param \AppShed\Remote\XML\DOMDocument $xml * @param \AppShed\Remote\HTML\Settings $settings */ protected function getHTMLNodeInner($node, $xml, $settings) { if (!empty($this->title)) { $node->appendChild($xml->createElement('div', ['class' => 'title', 'text' => $this->title])); } $node->appendChild($inner = $xml->createElement('div', 'textarea-container' . (empty($this->title) ? ' no-title' : ''))); $inner->appendChild($xml->createElement('textarea', ['class' => 'textarea', 'name' => $this->variableName, 'text' => $this->value, 'data-variable' => $this->variableName, 'data-save-value' => $this->save])); }
/** * Turns a passed Article class into the required markup for interacting * with Twinfield. * * This method doesn't return anything, instead just adds the Article to * this DOMDOcument instance for submission usage. * * @access public * @param \Pronamic\Twinfield\Article\Article $article * @return void | [Adds to this instance] */ public function addArticle(Article $article) { // Article->header elements and their methods $articleTags = array('office' => 'getOffice', 'code' => 'getCode', 'type' => 'getType', 'name' => 'getName', 'shortname' => 'getShortName', 'unitnamesingular' => 'getUnitNameSingular', 'unitnameplural' => 'getUnitNamePlural', 'vatcode' => 'getVatCode', 'allowchangevatcode' => 'getAllowChangeVatCode', 'allowdiscountorpremium' => 'getAllowDiscountorPremium', 'allowchangeunitsprice' => 'getAllowChangeUnitsPrice', 'allowdecimalquantity' => 'getAllowDecimalQuantity', 'performancetype' => 'getPerformanceType', 'percentage' => 'getPercentage'); // Make header element $headerElement = $this->createElement('header'); $this->articleElement->appendChild($headerElement); $status = $article->getStatus(); if (!empty($status)) { $headerElement->setAttribute('status', $status); } // Go through each Article element and use the assigned method foreach ($articleTags as $tag => $method) { // Make text node for method value $node = $this->createTextNode($article->{$method}()); // Make the actual element and assign the node $element = $this->createElement($tag); $element->appendChild($node); // Add the full element $headerElement->appendChild($element); } $lines = $article->getLines(); if (!empty($lines)) { // Element tags and their methods for lines $lineTags = ['unitspriceexcl' => 'getUnitsPriceExcl', 'unitspriceinc' => 'getUnitsPriceInc', 'units' => 'getUnits', 'name' => 'getName', 'shortname' => 'getShortName', 'subcode' => 'getSubCode', 'freetext1' => 'getFreeText1']; // Make addresses element $linesElement = $this->createElement('lines'); $this->articleElement->appendChild($linesElement); // Go through each line assigned to the article foreach ($lines as $line) { // Makes new articleLine element $lineElement = $this->createElement('line'); $linesElement->appendChild($lineElement); $status = $line->getStatus(); $id = $line->getID(); $inUse = $line->getInUse(); if (!empty($status)) { $lineElement->setAttribute('status', $status); } if (!empty($id)) { $lineElement->setAttribute('id', $id); } if (!empty($inUse)) { $lineElement->setAttribute('inuse', $inUse); } // Go through each line element and use the assigned method foreach ($lineTags as $tag => $method) { // Make the text node for the method value $node = $this->createTextNode($line->{$method}()); // Make the actual element and assign the text node $element = $this->createElement($tag); $element->appendChild($node); // Add the completed element $lineElement->appendChild($element); } } } }
/** * Creates a new <salesinvoice> element and assigns it to * this \DOMDocument and returns it. * * @access public * @return \DOMElement A <salesinvoice> DOMElement */ public function getNewInvoice() { // Make the new salesinvoice element $salesInvoiceElement = $this->createElement('salesinvoice'); // Add to the main salesinvoices element $this->salesInvoicesElement->appendChild($salesInvoiceElement); // Return the saleinvoice element return $salesInvoiceElement; }
public function getLineCoverage($line) { $coverage = $this->contextNode->getElementsByTagNameNS('http://schema.phpunit.de/coverage/1.0', 'coverage')->item(0); if (!$coverage) { $coverage = $this->contextNode->appendChild($this->dom->createElementNS('http://schema.phpunit.de/coverage/1.0', 'coverage')); } $lineNode = $coverage->appendChild($this->dom->createElementNS('http://schema.phpunit.de/coverage/1.0', 'line')); return new PHP_CodeCoverage_Report_XML_File_Coverage($lineNode, $line); }
/** * Appends the record to the XML response. * * Adds both the header and metadata elements as children of a record * element, which is appended to the document. * * @uses appendHeader * @uses appendMetadata */ public function appendRecord() { $record = $this->document->createElement('record'); $this->parentElement->appendChild($record); // Sets the parent of the next append functions $this->parentElement = $record; $this->appendHeader(); $this->appendMetadata(); }
public function execute(\DOMElement $apiDocument) { $errorText = "Unknown API action specified."; $errorNode = $this->document->createElement("error", $errorText); $apiDocument->appendChild($errorNode); $helpElement = $this->getHelpElement(); $apiDocument->appendChild($helpElement); return $apiDocument; }
/** * Возвращает XML со всеми комментариями по всем описанным в конфиге модулям * @param \DOMElement $node */ public function getAllCommentsXML($node) { $modules = \Difra\Config::getInstance()->get('comments'); if (empty($modules)) { $node->appendChild($node->ownerDocument->createElement('empty')); return; } $db = \Difra\MySQL::getInstance(); foreach ($modules['modules'] as $module) { $moduleXML = $node->appendChild($node->ownerDocument->createElement($module . '_comments')); $moduleXML->setAttribute('module', $module); // забираем комментарии по модулю $query = ''; switch ($module) { case 'albums': $query = "SELECT c.`id`, c.`text`, c.`reply_id`, DATE_FORMAT( c.`date`, '%T %d-%m-%Y' ) as `date`,\n\t\t\t\t\t\t\t\tuf.`value` AS `nickname`, bp.`link` AS `post_link`, bp.`name` AS `title`, g.`domain`,\n\t\t\t\t\t\t\t\tbp.`id` AS `post_id`\n\t\t\t\t\t\t\tFROM `albums_comments` c\n\t\t\t\t\t\t\tLEFT JOIN `users_fields` AS `uf` ON uf.`id`=c.`user` AND uf.`name`='nickname'\n\t\t\t\t\t\t\tLEFT JOIN `albums` AS `bp` ON bp.`id`=c.`parent_id`\n\t\t\t\t\t\t\tLEFT JOIN `groups` AS `g` ON g.`id`=bp.`group_id`\n\t\t\t\t\t\t\tORDER BY c.`date` DESC"; break; case 'blogs': $query = "SELECT c.`id`, c.`user`, c.`text`, c.`reply_id`, bp.`title`, b.`user` `post_owner`, b.`group`,\n\t\t\t\t\t\t\t\tg.`domain`, of.`value` AS `owner_nickname`, bp.`link` AS `post_link`, bp.`id` AS `post_id`,\n\t\t\t\t\t\t\t\tDATE_FORMAT( c.`date`, '%T %d-%m-%Y' ) as `date`, uf.`value` AS `nickname`\n\t\t\t\t\t\t\tFROM `blogs_comments` `c`\n\t\t\t\t\t\t\tLEFT JOIN `users_fields` AS `uf` ON uf.`id`=c.`user` AND uf.`name`='nickname'\n\t\t\t\t\t\t\tLEFT JOIN `blogs_posts` AS `bp` ON bp.`id`=c.`parent_id`\n\t\t\t\t\t\t\tLEFT JOIN `blogs` AS `b` ON b.`id`=bp.`blog`\n\t\t\t\t\t\t\tLEFT JOIN `groups` AS `g` ON g.`id`=b.`group`\n\t\t\t\t\t\t\tLEFT JOIN `users_fields` AS `of` ON of.`id`=b.`user` AND of.`name`='nickname'\n\t\t\t\t\t\t\tORDER BY c.`date` DESC"; break; case 'catalog': $query = "SELECT c.`id`, c.`text`, c.`reply_id`, DATE_FORMAT( c.`date`, '%T %d-%m-%Y' ) as `date`,\n\t\t\t\t\t\t\t\tuf.`value` AS `nickname`, bp.`name` AS `title`\n\t\t\t\t\t\t\tFROM `catalog_comments` c\n\t\t\t\t\t\t\tLEFT JOIN `users_fields` AS `uf` ON uf.`id`=c.`user` AND uf.`name`='nickname'\n\t\t\t\t\t\t\tLEFT JOIN `catalog_items` AS `bp` ON bp.`id`=c.`parent_id`\n\t\t\t\t\t\t\tORDER BY c.`date` DESC"; break; } $res = $db->fetch($query); foreach ($res as $data) { /** @var $itemNode \DOMElement */ $itemNode = $moduleXML->appendChild($node->ownerDocument->createElement('item')); $itemNode->setAttribute('id', $data['id']); $itemNode->setAttribute('nickname', $data['nickname']); $itemNode->setAttribute('date', $data['date']); $itemNode->setAttribute('text', $data['text']); $itemNode->setAttribute('reply_id', $data['reply_id']); $itemNode->setAttribute('title', $data['title']); $link = 'http://'; switch ($module) { case 'blogs': if ($data['domain'] != '') { // ссылка на блог группы $link .= $data['domain'] . '.' . \Difra\Site::getInstance()->getMainhost() . '/' . $data['post_id'] . '/' . rawurlencode($data['post_link']) . '/#comment' . $data['id']; } else { // ссылка на блог юзера $link .= \Difra\Site::getInstance()->getMainhost() . '/blogs/' . $data['owner_nickname'] . '/' . $data['post_id'] . '/' . rawurldecode($data['post_link']) . '/#comment' . $data['id']; } break; case 'albums': $link = 'http://' . $data['domain'] . '.' . \Difra\Site::getInstance()->getMainhost() . '/album/' . rawurldecode($data['post_link']) . '/#comment' . $data['id']; break; case 'catalog': $link = 'http://' . \Difra\Site::getInstance()->getMainhost() . '/c/'; break; } $itemNode->setAttribute('parentLink', $link); } } }
/** * Serializes the property in a DOM document * * @param Sabre_DAV_Server $server * @param DOMElement $node * @return void */ public function serialize(Sabre_DAV_Server $server, DOMElement $node) { $doc = $node->ownerDocument; $prefix = $node->lookupPrefix('urn:ietf:params:xml:ns:caldav'); if (!$prefix) { $prefix = 'cal'; } $node->appendChild($doc->createElement($prefix . ':supported-collation', 'i;ascii-casemap')); $node->appendChild($doc->createElement($prefix . ':supported-collation', 'i;octet')); }
public function addLanguage($language) { $this->checkForOptions(); if (!strlen($language)) { throw new eppException('No language specified for login attempt'); } if ($this->options) { $this->options->appendChild($this->createElement('lang', $language)); } }
/** * This method allows the exception to include additional information * into the WebDAV error response * * @param \Sabre\DAV\Server $server * @param \DOMElement $errorNode * @return void */ public function serialize(\Sabre\DAV\Server $server, \DOMElement $errorNode) { // set ownCloud namespace $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); // adding the retry node $error = $errorNode->ownerDocument->createElementNS('o:', 'o:retry', var_export($this->retry, true)); $errorNode->appendChild($error); // adding the message node $error = $errorNode->ownerDocument->createElementNS('o:', 'o:reason', $this->getMessage()); $errorNode->appendChild($error); }
public function buildXmlChildElementShema(\DOMDocument $xml, \DOMElement $sequence, HelperXmlSchemaBuilder $builder) { $when = $sequence->appendChild($xml->createElementNS(self::NS_XSD, 'element')); $when->setAttribute('ref', 'tns:when'); $when->setAttribute('minOccurs', '1'); $when->setAttribute('maxOccurs', 'unbounded'); $otherwise = $sequence->appendChild($xml->createElementNS(self::NS_XSD, 'element')); $otherwise->setAttribute('ref', 'tns:otherwise'); $otherwise->setAttribute('minOccurs', '0'); $otherwise->setAttribute('maxOccurs', '1'); }
public function build(DOMDocument $xml, DOMElement $rule) { $rule->appendChild($xml->createElement('rate', $this->rate)); if (isset($this->shipping_taxed)) { $rule->appendChild($xml->createElement('shipping_taxed', $this->shipping_taxed)); } $rule->appendChild($areas = $xml->createElement('tax-areas')); foreach ($this->areas as $area) { $area->build($xml, $areas); } }
/** * Serializes the property in a DOMDocument * * @param DAV\Server $server * @param \DOMElement $node * @return void */ public function serialize(DAV\Server $server, \DOMElement $node) { $doc = $node->ownerDocument; if ($this->canBeShared) { $xcomp = $doc->createElement('cs:can-be-shared'); $node->appendChild($xcomp); } if ($this->canBePublished) { $xcomp = $doc->createElement('cs:can-be-published'); $node->appendChild($xcomp); } }
/** * Get the html node for this element * * @param \DOMElement $node * @param \AppShed\Remote\XML\DOMDocument $xml * @param \AppShed\Remote\HTML\Settings $settings */ protected function getHTMLNodeInner($node, $xml, $settings) { $node->appendChild($inner = $xml->createElement('span', 'c-container' . (empty($this->title) ? ' no-title' : ''))); $params = ['type' => 'checkbox', 'name' => $this->variableName, 'data-variable' => $this->variableName, 'data-save-value' => $this->save, 'value' => $this->value]; if ($this->checked) { $params['checked'] = 'checked'; } $inner->appendChild($xml->createElement('input', $params)); if (!empty($this->title)) { $node->appendChild($xml->createElement('div', ['class' => 'title', 'text' => $this->title])); } }
private function xml2Array(array $array, DOMElement $root, DOMDocument $dom) { foreach ($array as $key => $value) { if (is_array($value)) { $sub = $dom->createElement($key); $this->xml2Array($value, $sub, $dom); $root->appendChild($sub); } else { $root->appendChild($dom->createElement($key, $value)); } } }
/** * Serializes the property in a DOMDocument * * @param DAV\Server $server * @param \DOMElement $node * @return void */ function serialize(DAV\Server $server, \DOMElement $node) { $doc = $node->ownerDocument; $prefix = isset($server->xmlNamespaces[Plugin::NS_CALDAV]) ? $server->xmlNamespaces[Plugin::NS_CALDAV] : 'cal'; $caldata = $doc->createElement($prefix . ':calendar-data'); $caldata->setAttribute('content-type', 'text/calendar'); $caldata->setAttribute('version', '2.0'); $node->appendChild($caldata); $caldata = $doc->createElement($prefix . ':calendar-data'); $caldata->setAttribute('content-type', 'application/calendar+json'); $node->appendChild($caldata); }