/** * 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); } } } }
protected function copyNodes(DOMNode $dirty, DOMNode $clean) { foreach ($dirty->attributes as $name => $valueNode) { /* Copy over allowed attributes */ if (isset($this->allowed[$dirty->nodeName][$name])) { $attr = $clean->ownerDocument->createAttribute($name); $attr->value = $valueNode->value; $clean->appendChild($attr); } } foreach ($dirty->childNodes as $child) { /* Copy allowed elements */ if ($child->nodeType == XML_ELEMENT_NODE && isset($this->allowed[$child->nodeName])) { $node = $clean->ownerDocument->createElement($child->nodeName); $clean->appendChild($node); /* Examine children of this allowed element */ $this->copyNodes($child, $node); } else { if ($child->nodeType == XML_TEXT_NODE) { $text = $clean->ownerDocument->createTextNode($child->textContent); $clean->appendChild($text); } } } }
function createNode(DOMDocument $targetdoc, DOMNode $targetnode, DOMNode $entry, $with_content = true) { $a = $targetdoc->createElement('a'); $targetnode->appendChild($a); $a->setAttribute('href', $entry->getElementsByTagName('id')->item(0)->nodeValue); $a->appendChild($targetdoc->createElement('b', date('Y-m-d H:i:s', strtotime($entry->getElementsByTagName('updated')->item(0)->nodeValue)) . ': ')); $a->appendChild($targetdoc->createTextNode($entry->getElementsByTagName('title')->item(0)->nodeValue)); if ($with_content && ($contents = $entry->getElementsByTagName('content')) && $contents->length) { $div = $targetdoc->createElement('div'); $targetnode->appendChild($div); $div->appendChild($targetdoc->importNode($contents->item(0), true)); } }
/** * * @param DOMNode $dest_node * @param DOMNodeList $imported_nodes */ protected function append_nodes_to(DOMNode $dest_node, DOMNodeList $imported_nodes) { $dom = $this->dom; foreach ($imported_nodes as $node) { if ($node instanceof DOMAttr) { $dest_node->appendChild($dom->createTextNode($node->nodeValue . "\n")); } else { $dest_node->appendChild($dom->importNode($node, true)); $dest_node->appendChild($dom->createTextNode("\n")); // добавить WHITESPACE } } }
/** * Append to content nodes to the target nodes. * * @param array|\Traversable $contentNodes * @return array new nodes */ public function appendChildren($contentNodes) { $result = array(); if ($this->_node instanceof \DOMElement) { foreach ($contentNodes as $contentNode) { /** @var \DOMNode $contentNode */ if (Constraints::isNode($contentNode)) { $result[] = $this->_node->appendChild($contentNode->cloneNode(TRUE)); } } } return $result; }
public function appendToDom(\DOMNode $parent) { $node = $parent->appendChild(new \DOMElement('PaymentAccount')); $node->appendChild(new \DOMElement('PaymentAccountID', $this['PaymentAccountID'])); $node->appendChild(new \DOMElement('PaymentAccountType', $this['PaymentAccountType'])); $node->appendChild(new \DOMElement('PaymentAccountReferenceNumber', $this['PaymentAccountReferenceNumber'])); }
/** * Caste l'élement spécifié * * @param DOMNode $nodeParent DOMNode * @param String $value String * * @return void */ function castElement($nodeParent, $value) { $value = utf8_encode($value); $attribute = $this->createAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:type"); $attribute->nodeValue = $value; $nodeParent->appendChild($attribute); }
/** * @param \DOMNode $parent * @param SerializationContext $context * @return \DOMElement */ public function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_METADATA, 'md:NameIDFormat'); $parent->appendChild($result); $result->nodeValue = $this->value; return $result; }
function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { if ($ref === $this->_last_child) { $this->append_child($new_child, $update_node); return; } if (is_null($ref)) { $this->prepend_child($new_child, $update_node); return; } if ($ref->_parent !== $this) { throw new DOMPDF_Exception("Reference child is not a child of this node."); } // Update the node if ($update_node) { if ($ref->_next_sibling) { $next_node = $ref->_next_sibling->_node; $this->_node->insertBefore($new_child->_node, $next_node); } else { $new_child->_node = $this->_node->appendChild($new_child); } } // Remove the child from its parent if ($new_child->_parent) { $new_child->_parent->remove_child($new_child, false); } $new_child->_parent = $this; $new_child->_prev_sibling = $ref; $new_child->_next_sibling = $ref->_next_sibling; if ($ref->_next_sibling) { $ref->_next_sibling->_prev_sibling = $new_child; } $ref->_next_sibling = $new_child; }
/** * Builds and creates the Atom XML nodes required by this date * * The element node representing this date is created separately and * passed as the first parameter of this method. * * @param DOMNode $node the node representing this date. * * @return void */ protected function _buildNode(DOMNode $node) { $document = $node->ownerDocument; $date_string = $this->_date->format('c'); $text_node = $document->createTextNode($date_string); $node->appendChild($text_node); }
/** * Builds and creates the Atom XML nodes required by this content * * The element node representing this content is created separately and * passed as the first parameter of this method. * * The text content of this content is created as a CDATA section. * * @param DOMNode $node the node representing this content. Extra nodes * should be created and added to this node. * * @return void */ protected function _buildNode(DOMNode $node) { $document = $node->ownerDocument; $node->setAttributeNS(XML_Atom_Node::NS, 'type', $this->_type); $cdata_node = $document->createCDATASection($this->_text); $node->appendChild($cdata_node); }
/** * @param \DOMNode $node */ protected function postProcessXML($node) { // дата релиза if (!is_null($this->release)) { $release = date('d-m-Y', strtotime($this->release . ' 00:00:00')); $node->setAttribute('release', $release); $xDate = explode('-', $release); $fullDate = $xDate[0] . ' ' . \Difra\Locales::getInstance()->getXPath('portfolio/months/m_' . $xDate[1]) . ' ' . $xDate[2]; $node->setAttribute('fullDate', $fullDate); } // авторы if (!is_null($this->authors)) { $authorsArray = unserialize($this->authors); if (!empty($authorsArray)) { foreach ($authorsArray as $k => $data) { if (isset($data['role'])) { $roleNode = $node->appendChild($node->ownerDocument->createElement('role')); $roleNode->setAttribute('name', $data['role']); if (isset($data['contibutors']) && is_array($data['contibutors'])) { foreach ($data['contibutors'] as $cName) { $cNode = $roleNode->appendChild($node->ownerDocument->createElement('contibutor')); $cNode->setAttribute('name', $cName); } } } } } } }
public function appendToDom(\DOMNode $parent) { $node = $parent->appendChild(new \DOMElement('Application')); $node->appendChild(new \DOMElement('ApplicationID', $this['ApplicationID'])); $node->appendChild(new \DOMElement('ApplicationName', $this['ApplicationName'])); $node->appendChild(new \DOMElement('ApplicationVersion', $this['ApplicationVersion'])); }
public function appendToDom(\DOMNode $parent) { $node = $parent->appendChild(new \DOMElement('Card')); // Append parameters. $node->appendChild(new \DOMElement('CVV', $this['CVV'])); // Only one of the following field groups needs to be included; If more // than one is present, they will be given the following order of // precedence. To avoid unintended results only populate one field per // transaction. $cardData = ['MagneprintData' => false, 'EncryptedTrack2Data' => true, 'EncryptedTrack1Data' => true, 'EncryptedCardData' => true, 'Track2Data' => false, 'Track1Data' => false]; do { foreach ($cardData as $field => $isEncrypted) { if (!empty($this[$field])) { $node->appendChild(new \DOMElement($field, strtoupper($this[$field]))); if ($isEncrypted) { $node->appendChild(new \DOMElement('CardDataKeySerialNumber', strtoupper($this['CardDataKeySerialNumber']))); $node->appendChild(new \DOMElement('EncryptedFormat', $this['EncryptedFormat'])); } break 2; } } if (!empty($this['CardNumber'])) { $node->appendChild(new \DOMElement('CardNumber', $this['CardNumber'])); } if (!empty($this['ExpirationMonth']) && !empty($this['ExpirationYear'])) { $time = gmmktime(0, 0, 0, $this['ExpirationMonth'], 1, $this['ExpirationYear']); $node->appendChild(new \DOMElement('ExpirationMonth', gmdate('m', $time))); $node->appendChild(new \DOMElement('ExpirationYear', gmdate('y', $time))); } } while (false); }
/** * @param \DOMNode $node * @return \DOMNode|null */ public function appendChild(\DOMNode $node) { if ($node->ownerDocument === $this->ownerDocument) { return parent::appendChild($node); } return DOMStatic::appendTo($node, $this); }
/** * Возвращает список каналов по трекам в XML * @param array $tracks * @param \DOMNode $node * @return void */ public function getTracksChannelsXML($tracks, $node) { $db = \Difra\MySQL::getInstance(); $tracks = array_map('intval', $tracks); $channelsXML = $node->appendChild($node->ownerDocument->createElement('tracksInChannels')); $db->fetchXML($channelsXML, "SELECT `id`, `channel` FROM `radio_tracks` WHERE `id` IN (" . implode(', ', $tracks) . ")"); }
public function appendChild($element) { if ($element instanceof self) { $element = $element->getRawElement(); } $this->element->appendChild($element); }
/** * @param \DOMNode|\DOMElement $node * @param int $menuId */ private function getEditXML($node, $menuId) { $menu = \Difra\Plugins\CMS\Menu::get($menuId); $node->setAttribute('depth', $menu->getDepth()); $parentsNode = $node->appendChild($this->xml->createElement('parents')); \Difra\Plugins\CMS::getInstance()->getMenuItemsXML($parentsNode, $menu->getId()); }
function _toXML(DOMNode $node, $hl7_datatypes, $encoding) { $doc = $node->ownerDocument; $field = $this->getField(); $new_node = $doc->createElement($field->name); parent::_toXML($new_node, $hl7_datatypes, $encoding); $node->appendChild($new_node); }
/** * Map a set of node attributes to a node. * * @param DOMNode $node * @param array $attributes */ public function nodeAttributes(&$node, $attributes) { foreach ($attributes as $key => $value) { $attribute = $this->dom->createAttribute($key); $attribute->value = $value; $node->appendChild($attribute); } }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_METADATA, 'md:' . $this->getXmlNodeName()); $parent->appendChild($result); $result->setAttribute('Binding', $this->getBinding()); $result->setAttribute('Location', $this->getLocation()); return $result; }
/** * Serialize contentclass attribute * * @param eZContentClassAttribute $classAttribute * @param DOMNode $attributeNode * @param DOMNode $attributeParametersNode */ function serializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode) { $defaultZoneLayout = $classAttribute->attribute(self::DEFAULT_ZONE_LAYOUT_FIELD); $dom = $attributeParametersNode->ownerDocument; $defaultLayoutNode = $dom->createElement('default-layout'); $defaultLayoutNode->appendChild($dom->createTextNode($defaultZoneLayout)); $attributeParametersNode->appendChild($defaultLayoutNode); }
/** * Insert node as a first child or as the last child * (depending on position value) * * @param DOMNode $parent * @param DOMNode $node * @param bool $prepend */ public function insertNode(DOMNode $parent, DOMNode $node, $prepend = false) { if ($prepend === true) { $parent->insertBefore($node, $parent->firstChild); } else { $parent->appendChild($node); } }
public function appendToDom(\DOMNode $parent) { $node = $parent->appendChild(new \DOMElement('Credentials')); $node->appendChild(new \DOMElement('AccountID', $this['AccountID'])); $node->appendChild(new \DOMElement('AccountToken', $this['AccountToken'])); $node->appendChild(new \DOMElement('AcceptorID', $this['AcceptorID'])); $node->appendChild(new \DOMElement('NewAccountToken', $this['NewAccountToken'])); }
/** * vlozi predany LBCI do struktury jako posledniho potomka * @param LBoxConfigItem $child */ public function appendChild(LBoxConfigItem $child) { try { $this->node->appendChild($child->getNode()); } catch (Exception $e) { throw $e; } }
/** * @see parent::_toXML */ function _toXML(DOMNode $node, $hl7_datatypes, $encoding) { $doc = $node->ownerDocument; $new_node = $doc->createElement($this->name); foreach ($this->fields as $_field) { $_field->_toXML($new_node, $hl7_datatypes, $encoding); } $node->appendChild($new_node); }
protected function addChildren(\DOMNode $node, \DOMNode $elem) { foreach ($node->childNodes as $child) { if ($new_child = $this->convert($child)) { $elem->appendChild($new_child); } } return $elem; }
public function adopt($a_data) { /** * @var DOMDocumentFragment */ $frag = $this->m_node->ownerDocument->createDocumentFragment(); $frag->appendXML($a_data); $this->m_node->appendChild($frag); }
/** * * @param \DOMDocument $document * @param \DOMNode $node * @param string $tagname * @param string $tagcontent * @return \DOMElement */ protected function addTag(\DOMDocument $document, \DOMNode $node, $tagname, $tagcontent = null) { $tag = $document->createElement($tagname); if (trim($tagcontent) !== '') { $tag->appendChild($document->createTextNode($tagcontent)); } $node->appendChild($tag); return $tag; }
/** * Appends an XML representation of the field data onto the current node * @param DOMNode $field_node the node we are appending the representation onto */ protected function appendXMLRepresentation($field_node) { $doc = $field_node->ownerDocument; if (is_array($value = $this->getValue())) { foreach ($value as $v) { $field_node->appendChild($doc->createElement('value', $v)); } } }