protected function __collectGroup(DOMDocument $v9a09b4dfda82e3e665e31092d1c3ec8d, DOMNode $v1471e4e05a4db95d353cc867fe317314, DOMNode $vdb0f6f37ebeb6ea09489124345af2a45) { $v3d788fa62d7c185a1bee4c9147ee1091 = new DOMXPath($v9a09b4dfda82e3e665e31092d1c3ec8d); $vb8d7f0a7b1f89a0e2689069b9ead837d = $vdb0f6f37ebeb6ea09489124345af2a45->getElementsByTagName("Ид"); $v00655e48bd78b9fefe2ba39b753dd932 = $vdb0f6f37ebeb6ea09489124345af2a45->getElementsByTagName("Наименование"); $vb80bb7740288fda1f201890375a60c8f = $vb8d7f0a7b1f89a0e2689069b9ead837d->item(0)->nodeValue; $vb068931cc450442b63f5b3d276ea4297 = $v00655e48bd78b9fefe2ba39b753dd932->item(0)->nodeValue; $vc772070e479ef7642e1f6b1620b703ab = $v3d788fa62d7c185a1bee4c9147ee1091->evaluate(".//Группа[Ид='{$vb80bb7740288fda1f201890375a60c8f}']", $v1471e4e05a4db95d353cc867fe317314); if ($vc772070e479ef7642e1f6b1620b703ab instanceof DOMNodeList && $vc772070e479ef7642e1f6b1620b703ab->length) { return $vc772070e479ef7642e1f6b1620b703ab->item(0); } $v1722ade329f7d0765de2a5d5cf04b3e6 = $v9a09b4dfda82e3e665e31092d1c3ec8d->createElement('Группа'); $v1722ade329f7d0765de2a5d5cf04b3e6->appendChild($v9a09b4dfda82e3e665e31092d1c3ec8d->createElement('Ид', $vb80bb7740288fda1f201890375a60c8f)); $v1722ade329f7d0765de2a5d5cf04b3e6->appendChild($v9a09b4dfda82e3e665e31092d1c3ec8d->createElement('Наименование', $vb068931cc450442b63f5b3d276ea4297)); $vd0e45878043844ffc41aac437e86b602 = $vdb0f6f37ebeb6ea09489124345af2a45->parentNode ? $vdb0f6f37ebeb6ea09489124345af2a45->parentNode->parentNode : false; if ($vd0e45878043844ffc41aac437e86b602 && $vd0e45878043844ffc41aac437e86b602->nodeName == "Группа") { $v8040a7de679c140285d7b0ca689dadc5 = $this->__collectGroup($v9a09b4dfda82e3e665e31092d1c3ec8d, $v1471e4e05a4db95d353cc867fe317314, $vd0e45878043844ffc41aac437e86b602); $vecc14ae322be7f2622dee4a101209ee9 = $v8040a7de679c140285d7b0ca689dadc5->childNodes->item(2); if (!$vecc14ae322be7f2622dee4a101209ee9) { $vecc14ae322be7f2622dee4a101209ee9 = $v8040a7de679c140285d7b0ca689dadc5->appendChild($v9a09b4dfda82e3e665e31092d1c3ec8d->createElement("Группы")); } $vecc14ae322be7f2622dee4a101209ee9->appendChild($v1722ade329f7d0765de2a5d5cf04b3e6); } else { $v1471e4e05a4db95d353cc867fe317314->appendChild($v1722ade329f7d0765de2a5d5cf04b3e6); } return $v1722ade329f7d0765de2a5d5cf04b3e6; }
/** * Retorna a chave de 44 caracteres da nfe. * * @return string */ public function getChNFe() { if ($this->isError()) { return ''; } return $this->infProt->getElementsByTagName('chNFe')->item(0)->textContent; }
protected function loadFromXml(DOMNode $elem) { $attr = $elem->attributes->getNamedItem('type'); if ($attr != null) { $this->type = $attr->nodeValue; } else { $this->type = self::TYPE_PERSON; } $elems = $elem->getElementsByTagName('first_name'); if ($elems->length == 1) { $this->firstName = urldecode($elems->item(0)->nodeValue); } $elems = $elem->getElementsByTagName('last_name'); if ($elems->length == 1) { $this->lastName = urldecode($elems->item(0)->nodeValue); } $elems = $elem->getElementsByTagName('address'); if ($elems->length == 1) { $this->address = urldecode($elems->item(0)->nodeValue); } $elems = $elem->getElementsByTagName('email'); if ($elems->length == 1) { $this->email = urldecode($elems->item(0)->nodeValue); } $elems = $elem->getElementsByTagName('mobile_phone'); if ($elems->length == 1) { $this->mobilePhone = urldecode($elems->item(0)->nodeValue); } }
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 $xml * @return bool */ public function matchXmlStructure($xml) { $xml = XmlUtils::toXml($xml); $root = $xml->firstChild; $els = $this->xml->getElementsByTagName($root->nodeName); if (empty($els)) { throw new ElementNotFound($root->nodeName, 'Element'); } $matches = false; foreach ($els as $node) { $matches |= $this->matchForNode($root, $node); } return $matches; }
/** * Unserialize contentclass attribute * * @param eZContentClassAttribute $classAttribute * @param DOMNode $attributeNode * @param DOMNode $attributeParametersNode */ function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode) { $defaultZoneLayout = $attributeParametersNode->getElementsByTagName('default-layout')->item(0)->textContent; if ($defaultZoneLayout !== false) { $classAttribute->setAttribute(self::DEFAULT_ZONE_LAYOUT_FIELD, $defaultZoneLayout); } }
/** * Apply style information to object * If object has no style information yet, then create new style node * If object style information is similar to other object's style info, then apply the same style name * And if object old style information was not shared with other objects then delete old style info * Else leave old style info * Else just add new style description * * @param string $style_name * @param string $name * @param mixed $value * @param OpenDocument_StyledElement $object * @return string $style_name */ public function applyStyle($style_name, $name, $value, OpenDocument_StyledElement $object) { //check if other nodes have the same style name $nodes = $this->cursor->getElementsByTagName('*'); $count = 0; foreach ($nodes as $node) { if ($node->hasAttributeNS(self::NS_TEXT, 'style-name') && $node->getAttributeNS(self::NS_TEXT, 'style-name') == $style_name) { $count++; if ($count > 1) { break; } } } $generate = false; //get style node if ($count > 1) { $style = $this->getStyleNode($style_name)->cloneNode(true); $this->styles->appendChild($style); $generate = true; $style_name = uniqid('tmp'); //$object->generateStyleName(); $style->setAttributeNS(self::NS_STYLE, 'name', $style_name); } else { $style = $this->getStyleNode($style_name); } if (empty($style)) { if (empty($style_name)) { $generate = true; $style_name = uniqid('tmp'); } $style = $this->contentDOM->createElementNS(self::NS_STYLE, 'style'); $style->setAttributeNS(self::NS_STYLE, 'name', $style_name); $style->setAttributeNS(self::NS_STYLE, 'family', 'paragraph'); $style->setAttributeNS(self::NS_STYLE, 'parent-style-name', 'Standard'); $this->styles->appendChild($style); } $nodes = $style->getElementsByTagNameNS(self::NS_STYLE, 'text-properties'); if ($nodes->length) { $text_properties = $nodes->item(0); } else { $text_properties = $this->contentDOM->createElementNS(self::NS_STYLE, 'text-properties'); $style->appendChild($text_properties); } $text_properties->setAttribute($name, $value); //find alike style $nodes = $this->styles->getElementsByTagNameNS(self::NS_STYLE, 'style'); foreach ($nodes as $node) { if (!$style->isSameNode($node) && $this->compareChildNodes($style, $node)) { $style->parentNode->removeChild($style); return $node->getAttributeNS(self::NS_STYLE, 'name'); } } if ($generate) { $style_name = $object->generateStyleName(); $style->setAttributeNS(self::NS_STYLE, 'name', $style_name); } return $style->getAttributeNS(self::NS_STYLE, 'name'); }
/** * Returns the first $subnode occurence of a $node. * The subnode is identified by its name. * * @param DOMNode $node * @param string $subnode_name * @return DOMNode */ public static function getFirstElementByTagName($node, $subnode_name) { $nodes = $node->getElementsByTagName($subnode_name); if ($nodes->length > 0) { return $nodes->item(0); } else { return null; } }
/** * Return array of descendant DOMNode of $node with tagName equals to $name * * @param DOMNode $node to starts with * @param string $name of descendant * * @return array of descendant DOMNode with tagName equals to $name */ public static function getNodesName($node, $name) { if (strpos($name, ':') !== false) { list(, $localname) = explode(':', $name); $nodes = $node->getElementsByTagNameNS('*', $localname); } else { $nodes = $node->getElementsByTagName($name); } return self::filterNodeListByName($nodes, $name); }
/** * Get property from nide * * @param DOMNode $node Node * @param String $tagName tag name * @param Boolean $nullable property can be null * * @return String description * */ public static function getPropertyFromNode(\DOMNode $node, $tagName, $nullable = true) { $elements = $node->getElementsByTagName($tagName); if ($elements->length == 0) { if (!$nullable) { throw new MetadataException(sprintf('%s : hydratation error with "%s" node.', get_called_class(), $tagName)); } return null; } $value = $elements->item(0)->nodeValue; return $value == 'false' ? false : $value; }
/** * Create a MARC Data Field * * @param \DOMNode $objNode */ public function __construct(\DOMNode $objNode = null) { if ($objNode != null) { $this->tag = $objNode->getAttribute("tag"); $this->ind1 = $objNode->getAttribute("ind1"); $this->ind2 = $objNode->getAttribute("ind2"); foreach ($objNode->getElementsByTagName("subfield") as $objSubfield) { $objMarcSubField = new SubField($objSubfield); array_push($this->_subfields, $objMarcSubField); } } }
protected function loadFromXml(DOMNode $elem) { $attr = $elem->attributes->getNamedItem('currency'); if ($attr == null) { throw new Exception('Mobilpay_Payment_Invoice::loadFromXml failed; currency attribute missing', self::ERROR_LOAD_FROM_XML_CURRENCY_ATTR_MISSING); } $this->currency = $attr->nodeValue; $attr = $elem->attributes->getNamedItem('amount'); if ($attr != null) { $this->amount = $attr->nodeValue; } $attr = $elem->attributes->getNamedItem('installments'); if ($attr != null) { $this->installments = $attr->nodeValue; } $attr = $elem->attributes->getNamedItem('selected_installments'); if ($attr != null) { $this->selectedInstallments = $attr->nodeValue; } $elems = $elem->getElementsByTagName('details'); if ($elems->length == 1) { $this->details = urldecode($elems->item(0)->nodeValue); } $elems = $elem->getElementsByTagName('contact_info'); if ($elems->length == 1) { $addrElem = $elems->item(0); $elems = $addrElem->getElementsByTagName('billing'); if ($elems->length == 1) { $this->billingAddress = new Mobilpay_Payment_Address($elems->item(0)); } $elems = $addrElem->getElementsByTagName('shipping'); if ($elems->length == 1) { $this->shippingAddress = new Mobilpay_Payment_Address($elems->item(0)); } } }
/** * @param DOMElement|DOMNode $table * @param array $range * @return array */ protected function parseTable($table, $range = null) { $array = array(); foreach ($table->getElementsByTagName('tr') as $row => $tr) { if ($range) { foreach ($range as $i) { $array[$row][] = $tr->getElementsByTagName('td')->item($i)->textContent; } } else { foreach ($tr->getElementsByTagName('td') as $td) { $array[$row][] = $td->textContent; } } } return $array; }
public function configure($parent, $configContext, DOMNode $documentElement) { $this->setORBConfig($configContext); $section = $documentElement->getElementsByTagName("services")->item(0); // check required ! $this->m_configNode = $section; foreach ($section->childNodes as $element) { if (!$element instanceof DOMElement) { continue; } $nameElements = $element->getElementsByTagName("name"); $serviceName = trim($nameElements->item(0)->nodeValue); $idElements = $element->getElementsByTagName("serviceId"); $serviceId = trim($idElements->item(0)->nodeValue); ORBConfig::getInstance()->getServiceRegistry()->_addMapping($serviceName, $serviceId, array()); } }
function getItem(\DOMNode $itemDomNode) { $item = new \stdClass(); $item->title = $itemDomNode->getElementsByTagName('title')->item(0)->firstChild->data; $item->link = $itemDomNode->getElementsByTagName('link')->item(0)->firstChild->data; $item->description = $itemDomNode->getElementsByTagName('description')->item(0)->firstChild->data; $authorText = $itemDomNode->getElementsByTagName('author')->item(0)->firstChild->data; $arr = explode(' ', trim($authorText)); $item->authorEmail = trim($arr[0]); $item->guid = $itemDomNode->getElementsByTagName('guid')->item(0)->firstChild->data; $item->pubDate = $itemDomNode->getElementsByTagName('pubDate')->item(0)->firstChild->data; $item->viaUrl = $itemDomNode->getElementsByTagNameNS('http://www.editoreye.com/rss/via', 'link')->item(0)->getAttribute('url'); $item->via = $itemDomNode->getElementsByTagNameNS('http://www.editoreye.com/rss/via', 'link')->item(0)->getAttribute('name'); $item->authorName = $itemDomNode->getElementsByTagNameNS('http://purl.org/dc/elements/1.1/', 'creator')->item(0)->firstChild->data; $item->content = $itemDomNode->getElementsByTagName('content')->item(0)->firstChild->data; return $item; }
public function configure($parent, $configContext, DOMNode $documentElement) { $section = $documentElement->getElementsByTagName("logging")->item(0); $this->m_configNode = $section; $this->setORBConfig($configContext); $currentPolicyName = null; $categories = array(); foreach ($section->childNodes as $node) { if (!$node instanceof DOMElement) { continue; } switch ($node->nodeName) { case ORBConstants::CURRENT_POLICY: $currentPolicyName = $node->nodeValue; break; case ORBConstants::LOGGING_POLICY: $this->processPolicy($node); break; case ORBConstants::LOG: if ($node->getAttribute(ORBConstants::ENABLE) == ORBConstants::YES) { $categories[] = trim($node->nodeValue); } break; } } $this->currentPolicy = $this->loggingPolices[$currentPolicyName]; if ($this->currentPolicy != null) { if (LOGGING) { Log::log(LoggingConstants::DEBUG, "adding logger with current policy: " + $currentPolicyName); } Log::setLogger($this->currentPolicy->getLogger()); } else { if (LOGGING) { Log::log(LoggingConstants::ERROR, "the current policy value of " + $this->currentPolicy + " does not match any policyName elements"); } } foreach ($categories as $category) { Log::startLogging(LoggingConstants::getChannelByName($category)); } return $this; }
public function configure($parent, $configContext, DOMNode $documentElement) { $this->setORBConfig($configContext); $section = $documentElement->getElementsByTagName("classMappings")->item(0); // check required ! $this->m_configNode = $section; foreach ($section->childNodes as $element) { if (!$element instanceof DOMElement) { continue; } $elements = $element->getElementsByTagName("clientClass"); $clientClass = trim($elements->item(0)->nodeValue); $elements = $element->getElementsByTagName("serverClass"); $serverClass = trim($elements->item(0)->nodeValue); $type = TypeLoader::loadType($serverClass); if (LOGGING) { Log::log(LoggingConstants::DEBUG, $clientClass . " : " . $serverClass); } ORBConfig::getInstance()->getTypeMapper()->_addClientClassMapping($clientClass, $type); } }
/** * Returns the cell String value. * * @param \DOMNode $node * @return string The value associated with the cell */ protected function formatStringCellValue($node) { $pNodeValues = []; $pNodes = $node->getElementsByTagName(self::XML_NODE_P); foreach ($pNodes as $pNode) { $currentPValue = ''; foreach ($pNode->childNodes as $childNode) { if ($childNode instanceof \DOMText) { $currentPValue .= $childNode->nodeValue; } else { if ($childNode->nodeName === self::XML_NODE_S) { $spaceAttribute = $childNode->getAttribute(self::XML_ATTRIBUTE_C); $numSpaces = !empty($spaceAttribute) ? intval($spaceAttribute) : 1; $currentPValue .= str_repeat(' ', $numSpaces); } } } $pNodeValues[] = $currentPValue; } $escapedCellValue = implode("\n", $pNodeValues); $cellValue = $this->escaper->unescape($escapedCellValue); return $cellValue; }
protected function loadFromXml(DOMNode $elem) { $elems = $elem->getElementsByTagName('code'); if ($elems->length != 1) { throw new Exception('Mobilpay_Payment_Invoice_Item::loadFromXml failed! Invalid code element.', self::ERROR_LOAD_FROM_XML_CODE_ELEM_MISSING); } $this->code = urldecode($elems->item(0)->nodeValue); $elems = $elem->getElementsByTagName('name'); if ($elems->length != 1) { throw new Exception('Mobilpay_Payment_Invoice_Item::loadFromXml failed! Invalid name element.', self::ERROR_LOAD_FROM_XML_NAME_ELEM_MISSING); } $this->name = urldecode($elems->item(0)->nodeValue); $elems = $elem->getElementsByTagName('measurment'); if ($elems->length == 1) { $this->measurment = urldecode($elems->item(0)->nodeValue); } $elems = $elem->getElementsByTagName('quantity'); if ($elems->length != 1) { throw new Exception('Mobilpay_Payment_Invoice_Item::loadFromXml failed! Invalid quantity element.', self::ERROR_LOAD_FROM_XML_QUANTITY_ELEM_MISSING); } $this->quantity = doubleval(urldecode($elems->item(0)->nodeValue)); if ($this->quantity == 0) { throw new Exception('Mobilpay_Payment_Invoice_Item::loadFromXml failed! Invalid quantity value=' . $this->quantity, self::ERROR_LOAD_FROM_XML_QUANTITY_ELEM_EMPTY); } $elems = $elem->getElementsByTagName('price'); if ($elems->length != 1) { throw new Exception('Mobilpay_Payment_Invoice_Item::loadFromXml failed! Invalid price element.', self::ERROR_LOAD_FROM_XML_PRICE_ELEM_MISSING); } $this->price = doubleval(urldecode($elems->item(0)->nodeValue)); if ($this->price == 0) { throw new Exception('Mobilpay_Payment_Invoice_Item::loadFromXml failed! Invalid price value=' . $this->price, self::ERROR_LOAD_FROM_XML_PRICE_ELEM_EMPTY); } $elems = $elem->getElementsByTagName('vat'); if ($elems->length != 1) { throw new Exception('Mobilpay_Payment_Invoice_Item::loadFromXml failed! Invalid vat element.', self::ERROR_LOAD_FROM_XML_VAT_ELEM_MISSING); } $this->vat = doubleval(urldecode($elems->item(0)->nodeValue)); return $this; }
/** * Get Columns * * @return Array collection * */ protected function hydrateColumns(\DOMNode $node) { $columns = array(); $complexType = $node->getElementsByTagName('complexType'); foreach ($complexType as $elm) { if ($elm->getAttribute('name') === 'row') { $sequences = $elm->getElementsByTagName('sequence'); foreach ($sequences as $sequence) { foreach ($sequence->childNodes as $child) { if ($child->nodeType === XML_ELEMENT_NODE) { $columns[$child->getAttribute('name')] = $child->getAttribute('sql:field'); } } break; } break; } } return $columns; }
/** * Print a code comparison block found in a standard. * * @param DOMNode $node The DOMNode object for the code comparison block. * * @return void */ protected function printCodeComparisonBlock($node) { $codeBlocks = $node->getElementsByTagName('code'); $first = trim($codeBlocks->item(0)->nodeValue); $firstTitle = $codeBlocks->item(0)->getAttribute('title'); $firstTitleLines = array(); $tempTitle = ''; $words = explode(' ', $firstTitle); foreach ($words as $word) { if (strlen($tempTitle . $word) >= 45) { if (strlen($tempTitle . $word) === 45) { // Adding the extra space will push us to the edge // so we are done. $firstTitleLines[] = $tempTitle . $word; $tempTitle = ''; } else { if (strlen($tempTitle . $word) === 46) { // We are already at the edge, so we are done. $firstTitleLines[] = $tempTitle . $word; $tempTitle = ''; } else { $firstTitleLines[] = $tempTitle; $tempTitle = $word; } } } else { $tempTitle .= $word . ' '; } } //end foreach if ($tempTitle !== '') { $firstTitleLines[] = $tempTitle; } $first = str_replace('<em>', '', $first); $first = str_replace('</em>', '', $first); $firstLines = explode("\n", $first); $second = trim($codeBlocks->item(1)->nodeValue); $secondTitle = $codeBlocks->item(1)->getAttribute('title'); $secondTitleLines = array(); $tempTitle = ''; $words = explode(' ', $secondTitle); foreach ($words as $word) { if (strlen($tempTitle . $word) >= 45) { if (strlen($tempTitle . $word) === 45) { // Adding the extra space will push us to the edge // so we are done. $secondTitleLines[] = $tempTitle . $word; $tempTitle = ''; } else { if (strlen($tempTitle . $word) === 46) { // We are already at the edge, so we are done. $secondTitleLines[] = $tempTitle . $word; $tempTitle = ''; } else { $secondTitleLines[] = $tempTitle; $tempTitle = $word; } } } else { $tempTitle .= $word . ' '; } } //end foreach if ($tempTitle !== '') { $secondTitleLines[] = $tempTitle; } $second = str_replace('<em>', '', $second); $second = str_replace('</em>', '', $second); $secondLines = explode("\n", $second); $maxCodeLines = max(count($firstLines), count($secondLines)); $maxTitleLines = max(count($firstTitleLines), count($secondTitleLines)); echo str_repeat('-', 41); echo ' CODE COMPARISON '; echo str_repeat('-', 42) . PHP_EOL; for ($i = 0; $i < $maxTitleLines; $i++) { if (isset($firstTitleLines[$i]) === true) { $firstLineText = $firstTitleLines[$i]; } else { $firstLineText = ''; } if (isset($secondTitleLines[$i]) === true) { $secondLineText = $secondTitleLines[$i]; } else { $secondLineText = ''; } echo '| '; echo $firstLineText . str_repeat(' ', 46 - strlen($firstLineText)); echo ' | '; echo $secondLineText . str_repeat(' ', 47 - strlen($secondLineText)); echo ' |' . PHP_EOL; } //end for echo str_repeat('-', 100) . PHP_EOL; for ($i = 0; $i < $maxCodeLines; $i++) { if (isset($firstLines[$i]) === true) { $firstLineText = $firstLines[$i]; } else { $firstLineText = ''; } if (isset($secondLines[$i]) === true) { $secondLineText = $secondLines[$i]; } else { $secondLineText = ''; } echo '| '; echo $firstLineText . str_repeat(' ', 47 - strlen($firstLineText)); echo '| '; echo $secondLineText . str_repeat(' ', 48 - strlen($secondLineText)); echo '|' . PHP_EOL; } //end for echo str_repeat('-', 100) . PHP_EOL . PHP_EOL; }
/** * Make an absolute url from an element. * * @param string $base The base url * @param \DOMNode $elem Element on which we'll retrieve the attribute */ private function makeAbsolute($base, \DOMNode $elem) { $base = new \SimplePie_IRI($base); // remove '//' in URL path (used to prevent URLs from resolving properly) if (isset($base->ipath)) { $base->ipath = str_replace('//', '/', $base->ipath); } foreach (array('a' => 'href', 'img' => 'src', 'iframe' => 'src') as $tag => $attr) { $elems = $elem->getElementsByTagName($tag); for ($i = $elems->length - 1; $i >= 0; --$i) { $e = $elems->item($i); $this->makeAbsoluteAttr($base, $e, $attr); } if (strtolower($elem->nodeName) == $tag) { $this->makeAbsoluteAttr($base, $elem, $attr); } } }
protected function loadFromXml(DOMNode $elem) { $attr = $elem->attributes->getNamedItem('currency'); if ($attr == null) { throw new Exception('Mobilpay_Payment_Invoice::loadFromXml failed; currency attribute missing', self::ERROR_LOAD_FROM_XML_CURRENCY_ATTR_MISSING); } $this->currency = $attr->nodeValue; $attr = $elem->attributes->getNamedItem('amount'); if ($attr != null) { $this->amount = $attr->nodeValue; } $attr = $elem->attributes->getNamedItem('installments'); if ($attr != null) { $this->installments = $attr->nodeValue; } $attr = $elem->attributes->getNamedItem('selected_installments'); if ($attr != null) { $this->selectedInstallments = $attr->nodeValue; } $attr = $elem->attributes->getNamedItem('token_id'); if ($attr != null) { $this->tokenId = $attr->nodeValue; } $attr = $elem->attributes->getNamedItem('promotion_code'); if ($attr != null) { $this->promotionCode = $attr->nodeValue; } $elems = $elem->getElementsByTagName('details'); if ($elems->length == 1) { $this->details = urldecode($elems->item(0)->nodeValue); } $elems = $elem->getElementsByTagName('contact_info'); if ($elems->length == 1) { $addrElem = $elems->item(0); $elems = $addrElem->getElementsByTagName('billing'); if ($elems->length == 1) { $this->billingAddress = new Mobilpay_Payment_Address($elems->item(0)); } $elems = $addrElem->getElementsByTagName('shipping'); if ($elems->length == 1) { $this->shippingAddress = new Mobilpay_Payment_Address($elems->item(0)); } } $this->items = array(); $elems = $elem->getElementsByTagName('items'); if ($elems->length == 1) { $itemElems = $elems->item(0); $elems = $itemElems->getElementsByTagName('item'); if ($elems->length > 0) { $amount = 0; foreach ($elems as $itemElem) { try { $objItem = new Mobilpay_Payment_Invoice_Item($itemElem); $this->items[] = $objItem; $amount += $objItem->getTotalAmount(); } catch (Exception $e) { $e = $e; continue; } } $this->amount = $amount; } } $this->exchangeRates = array(); $elems = $elem->getElementsByTagName('exchange_rates'); if ($elems->length == 1) { $rateElems = $elems->item(0); $elems = $rateElems->getElementsByTagName('rate'); foreach ($elems as $rateElem) { try { $objRate = new Mobilpay_Payment_Exchange_Rate($rateElem); $this->exchangeRates[] = $objRate; } catch (Exception $e) { $e = $e; continue; } } } }
/** * Visit field list item * * @param DOMNode $root * @param ezcDocumentRstNode $node * @return void */ protected function visitFieldListItem(DOMNode $root, ezcDocumentRstNode $node) { // Get sectioninfo node, to add the stuff there. $secInfo = $root->getElementsByTagName('sectioninfo')->item(0); if ($secInfo === null) { // If not yet existant, create section info $secInfo = $root->ownerDocument->createElement('sectioninfo'); $root->insertBefore($secInfo, $root->firstChild); } $fieldListItemMapping = array('authors' => 'authors', 'description' => 'abstract', 'copyright' => 'copyright', 'version' => 'releaseinfo', 'date' => 'date', 'author' => 'author'); $fieldName = strtolower(trim($this->tokenListToString($node->name))); if (!isset($fieldListItemMapping[$fieldName])) { return $this->triggerError(E_NOTICE, "Unhandeled field list type '{$fieldName}'.", null, $node->token->line, $node->token->position); } $item = $this->document->createElement($fieldListItemMapping[$fieldName], htmlspecialchars($this->nodeToString($node))); $secInfo->appendChild($item); }
/** * VQModObject::_parseMods() * * @param DOMNode $node <modification> node to be parsed * @return null * @description Parses modifications in preparation for the applyMod method to work */ private function _parseMods(DOMNode $node) { $files = $node->getElementsByTagName('file'); $replaces = VQMod::$_replaces; foreach ($files as $file) { $path = $file->getAttribute('path') ? $file->getAttribute('path') : ''; $filesToMod = explode(',', $file->getAttribute('name')); foreach ($filesToMod as $filename) { $fileToMod = $path . $filename; if (!empty($replaces)) { foreach ($replaces as $r) { if (count($r) == 2) { $fileToMod = preg_replace($r[0], $r[1], $fileToMod); } } } $error = $file->hasAttribute('error') ? $file->getAttribute('error') : 'log'; $fullPath = VQMod::path($fileToMod); if (!$fullPath || !file_exists($fullPath)) { if (strpos($fileToMod, '*') !== false) { $fullPath = VQMod::getCwd() . $fileToMod; } else { if ($error == 'log' || $error == 'abort') { $skip = $error == 'log' ? ' (SKIPPED)' : ' (ABORTING MOD)'; VQMod::$log->write('VQModObject::parseMods - Could not resolve path for [' . $fileToMod . ']' . $skip, $this); } if ($error == 'log' || $error == 'skip') { continue; } elseif ($error == 'abort') { return false; } } } $operations = $file->getElementsByTagName('operation'); foreach ($operations as $opIndex => $operation) { $error = $operation->hasAttribute('error') ? $operation->getAttribute('error') : 'abort'; $ignoreif = $operation->getElementsByTagName('ignoreif')->item(0); if ($ignoreif) { $ignoreif = new VQSearchNode($ignoreif); } else { $ignoreif = false; } $this->mods[$fullPath][] = array('search' => new VQSearchNode($operation->getElementsByTagName('search')->item(0)), 'add' => new VQAddNode($operation->getElementsByTagName('add')->item(0)), 'ignoreif' => $ignoreif, 'error' => $error, 'fileToMod' => $fileToMod, 'opIndex' => $opIndex); } } } }
/** * pGeraInformacoesDasNotasReferenciadas * Devolve uma string contendo informação sobre as notas referenciadas. Suporta N notas, eletrônicas ou não * Exemplo: NFe Ref.: série: 01 número: 01 emit: 11.111.111/0001-01 * em 10/2010 [0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000] * * @return string Informacoes a serem adicionadas no rodapé sobre notas referenciadas. */ protected function pGeraInformacoesDasNotasReferenciadas() { $formaNfeRef = "\r\nNFe Ref.: série:%d número:%d emit:%s em %s [%s]"; $formaCTeRef = "\r\nCTe Ref.: série:%d número:%d emit:%s em %s [%s]"; $formaNfRef = "\r\nNF Ref.: série:%d numero:%d emit:%s em %s modelo: %d"; $formaECFRef = "\r\nECF Ref.: modelo: %s ECF:%d COO:%d"; $formaNfpRef = "\r\nNFP Ref.: série:%d número:%d emit:%s em %s modelo: %d IE:%s"; $saida = ''; $nfRefs = $this->ide->getElementsByTagName('NFref'); if (0 === $nfRefs->length) { return $saida; } foreach ($nfRefs as $nfRef) { if (empty($nfRef)) { continue; } $refNFe = $nfRef->getElementsByTagName('refNFe'); foreach ($refNFe as $chave_acessoRef) { $chave_acesso = $chave_acessoRef->nodeValue; $chave_acessoF = $this->pFormat($chave_acesso, $this->formatoChave); $data = substr($chave_acesso, 4, 2) . "/20" . substr($chave_acesso, 2, 2); $cnpj = $this->pFormat(substr($chave_acesso, 6, 14), "##.###.###/####-##"); $serie = substr($chave_acesso, 22, 3); $numero = substr($chave_acesso, 25, 9); $saida .= sprintf($formaNfeRef, $serie, $numero, $cnpj, $data, $chave_acessoF); } $refNF = $nfRef->getElementsByTagName('refNF'); foreach ($refNF as $umaRefNFe) { $data = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue; $cnpj = $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue; $mod = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue; $serie = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue; $numero = $umaRefNFe->getElementsByTagName('nNF')->item(0)->nodeValue; $data = substr($data, 2, 2) . "/20" . substr($data, 0, 2); $cnpj = $this->pFormat($cnpj, "##.###.###/####-##"); $saida .= sprintf($formaNfRef, $serie, $numero, $cnpj, $data, $mod); } $refCTe = $nfRef->getElementsByTagName('refCTe'); foreach ($refCTe as $chave_acessoRef) { $chave_acesso = $chave_acessoRef->nodeValue; $chave_acessoF = $this->pFormat($chave_acesso, $this->formatoChave); $data = substr($chave_acesso, 4, 2) . "/20" . substr($chave_acesso, 2, 2); $cnpj = $this->pFormat(substr($chave_acesso, 6, 14), "##.###.###/####-##"); $serie = substr($chave_acesso, 22, 3); $numero = substr($chave_acesso, 25, 9); $saida .= sprintf($formaCTeRef, $serie, $numero, $cnpj, $data, $chave_acessoF); } $refECF = $nfRef->getElementsByTagName('refECF'); foreach ($refECF as $umaRefNFe) { $mod = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue; $nECF = $umaRefNFe->getElementsByTagName('nECF')->item(0)->nodeValue; $nCOO = $umaRefNFe->getElementsByTagName('nCOO')->item(0)->nodeValue; $saida .= sprintf($formaECFRef, $mod, $nECF, $nCOO); } $refNFP = $nfRef->getElementsByTagName('refNFP'); foreach ($refNFP as $umaRefNFe) { $data = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue; $cnpj = !empty($umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue) ? $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue : ''; $cpf = !empty($umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue) ? $umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue : ''; $mod = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue; $serie = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue; $numero = $umaRefNFe->getElementsByTagName('nNF')->item(0)->nodeValue; $ie = $umaRefNFe->getElementsByTagName('IE')->item(0)->nodeValue; $data = substr($data, 2, 2) . "/20" . substr($data, 0, 2); if ($cnpj == '') { $cpf_cnpj = $this->pFormat($cpf, "###.###.###-##"); } else { $cpf_cnpj = $this->pFormat($cnpj, "##.###.###/####-##"); } $saida .= sprintf($formaNfpRef, $serie, $numero, $cpf_cnpj, $data, $mod, $ie); } } return $saida; }
/** * * @param DOMNode $element * @param type $json - a json that has an array of filters ('attribute' and 'value' keys) * @return array of DomNode - all elements of $element children (recursively) that pass the filter. */ private function findAllDOMElementsMathching(DOMNode $element, $json) { $result = array(); $allElements = $element->getElementsByTagName($json["type"]); foreach ($allElements as $nextElement) { if ($this->domElementPassesFilter($nextElement, $json["filters"])) { array_push($result, $nextElement); } } return $result; }
/** * Extract content appropriately from atom text constructs * * Because of different rules applied to the content element and other text * constructs, they are deployed as separate functions, but they share quite * a bit of processing. This method performs the core common process, which is * to apply the rules for different mime types in order to extract the content. * * @param DOMNode $content the text construct node to be parsed * @return String * @author James Stewart **/ protected function parseTextConstruct(DOMNode $content) { if ($content->hasAttribute('type')) { $type = $content->getAttribute('type'); } else { $type = 'text'; } if (strpos($type, 'text/') === 0) { $type = 'text'; } switch ($type) { case 'text': return $content->nodeValue; break; case 'html': return str_replace('<', '<', $content->nodeValue); break; case 'xhtml': $container = $content->getElementsByTagName('div'); if ($container->length == 0) { return false; } $contents = $container->item(0); if ($contents->hasChildNodes()) { /* Iterate through, applying xml:base and store the result */ $result = ''; foreach ($contents->childNodes as $node) { $result .= $this->traverseNode($node); } return utf8_decode($result); } break; case preg_match('@^[a-zA-Z]+/[a-zA-Z+]*xml@i', $type) > 0: return $content; break; case 'application/octet-stream': default: return base64_decode(trim($content->nodeValue)); break; } return false; }
/** * Returns the cell String value where string is inline. * * @param \DOMNode $node * @return string The value associated with the cell (null when the cell has an error) */ protected function formatInlineStringCellValue($node) { // inline strings are formatted this way: // <c r="A1" t="inlineStr"><is><t>[INLINE_STRING]</t></is></c> $tNode = $node->getElementsByTagName(self::XML_NODE_INLINE_STRING_VALUE)->item(0); $cellValue = $this->escaper->unescape($tNode->nodeValue); return $cellValue; }
protected static function hydrateDataSet(\DOMNode $node) { $result = array(); $cellData = $node->getElementsByTagName('Cell'); foreach ($cellData as $data) { $cellOrdinal = self::getAttribute($data, "CellOrdinal"); $cell = new CellData(); $cell->hydrate($data); $result[$cellOrdinal] = $cell; } return $result; }