本文整理汇总了PHP中DOMNode类的典型用法代码示例。如果您正苦于以下问题:PHP DOMNode类的具体用法?PHP DOMNode怎么用?PHP DOMNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DOMNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getXml
/**
* @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;
}
示例2: getStateXML
/**
* Get some configuration variables as XML node attributes
* @param \DOMElement|\DOMNode $node
*/
public static function getStateXML($node)
{
$config = self::getState();
foreach ($config as $k => $v) {
$node->setAttribute($k, $v);
}
}
示例3: append_style
static function append_style(DOMNode $node, $new_style)
{
$style = rtrim($node->getAttribute(self::$_style_attr), ";");
$style .= $new_style;
$style = ltrim($style, ";");
$node->setAttribute(self::$_style_attr, $style);
}
示例4: _buildNode
/**
* 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);
}
示例5: _nodeToValue
/**
* Converts a node to a PHP value
*
* @param DOMNode $node
* @return mixed
*/
private static function _nodeToValue($node)
{
$type = null;
if ($node instanceof DOMElement) {
$type = $node->getAttribute('type');
}
switch ($type) {
case 'datetime':
return self::_timestampToUTC((string) $node->nodeValue);
case 'date':
return new DateTime((string) $node->nodeValue);
case 'integer':
return (int) $node->nodeValue;
case 'boolean':
$value = (string) $node->nodeValue;
if (is_numeric($value)) {
return (bool) $value;
} else {
return $value !== "true" ? false : true;
}
case 'array':
case 'collection':
return self::_nodeToArray($node);
default:
if ($node->hasChildNodes()) {
return self::_nodeToArray($node);
} elseif (trim($node->nodeValue) === '') {
return null;
} else {
return $node->nodeValue;
}
}
}
示例6: processDataTag
private function processDataTag( DOMNode $node ) {
if( $node->hasAttribute( DATA_TYPE_ATTRIBUTE_NAME ) ) {
switch( $node->getAttribute( DEPENDENCY_TYPE_ATTRIBUTE_NAME ) ) {
case DATA_TYPE_STREAM_VALUE:
/******* nothing for now
$url = $this->buildURL( MODULE_STREAM_PATH . $node->nodeValue );
if( $this->url_exists( $url ) ) {
$this->xml->load( $url );
}
**********/
break;
case DATA_TYPE_PROCESSOR_VALUE:
break;
case DATA_TYPE_DYNAMICFILE_VALUE:
if ( file_exists( MODULE_FILE_PATH . $node->nodeValue ) ) {
ob_start();
$file = MODULE_FILE_PATH . $node->nodeValue;
include $file;
$this->dynamicFileOutput .= ob_get_contents();
ob_end_clean();
}
break;
case DATA_TYPE_STATICFILE_VALUE:
if ( file_exists( MODULE_FILE_PATH . $node->nodeValue ) ) {
$this->staticFileOutput .= file_get_contents( MODULE_FILE_PATH . $node->nodeValue );
} else {
//echo "loading: " . MODULE_FILE_PATH . $node->nodeValue;
}
break;
}
}
}
示例7: drawThumbnailZone
/**
* Draw a final layout zone on its thumbnail.
*
* @access private
*
* @param ressource $thumbnail The thumbnail ressource
* @param DOMNode $node The current node zone
* @param array $clip The clip rect to draw
* @param int $background The background color
* @param int $gridcolumn The number of columns in the grid
* @param boolean $lastChild True if the current node is the last child of its parent node
*
* @return int The new X axis position;
*/
private function drawThumbnailZone(&$thumbnail, $node, $clip, $background, $gridcolumn, $lastChild = false)
{
$x = $clip[0];
$y = $clip[1];
$width = $clip[2];
$height = $clip[3];
if (null !== ($spansize = preg_replace('/[^0-9]+/', '', $node->getAttribute('class')))) {
$width = floor($width * $spansize / $gridcolumn);
}
if (false !== strpos($node->getAttribute('class'), 'Child')) {
$height = floor($height / 2);
}
if (!$node->hasChildNodes()) {
$this->drawRect($thumbnail, array($x, $y, $width, $height), $background, $width == $clip[2] || strpos($node->getAttribute('class'), 'hChild'), $lastChild);
return $width + 2;
}
foreach ($node->childNodes as $child) {
if (is_a($child, 'DOMText')) {
continue;
}
if ('clear' == $child->getAttribute('class')) {
$x = $clip[0];
$y = $clip[1] + floor($height / 2) + 2;
continue;
}
$x += $this->drawThumbnailZone($thumbnail, $child, array($x, $y, $clip[2], $height), $background, $gridcolumn, $node->isSameNode($node->parentNode->lastChild));
}
return $x + $width - 2;
}
示例8: recursiveStripQuotes
function recursiveStripQuotes(DOMNode $node)
{
if (!$node->childNodes) {
return;
}
$purge = array();
foreach ($node->childNodes as $child) {
$class = null;
if ($child->attributes) {
$class = $child->attributes->getNamedItem('class');
}
if ($class && $class->value == 'quoteheader') {
$purge[] = $child;
} elseif ($class && $class->value == 'quotefooter') {
$purge[] = $child;
} elseif ($child->nodeName == 'blockquote') {
$purge[] = $child;
} else {
recursiveStripQuotes($child);
}
}
foreach ($purge as $child) {
$node->removeChild($child);
}
return $node;
}
示例9: getXml
/**
* @param \DOMNode $parent
* @param \AerialShip\LightSaml\Meta\SerializationContext $context
* @return \DOMNode
*/
function getXml(\DOMNode $parent, SerializationContext $context)
{
$objXMLSecDSig = new \XMLSecurityDSig();
$objXMLSecDSig->setCanonicalMethod($this->getCanonicalMethod());
$key = $this->getXmlSecurityKey();
switch ($key->type) {
case \XMLSecurityKey::RSA_SHA256:
$type = \XMLSecurityDSig::SHA256;
break;
case \XMLSecurityKey::RSA_SHA384:
$type = \XMLSecurityDSig::SHA384;
break;
case \XMLSecurityKey::RSA_SHA512:
$type = \XMLSecurityDSig::SHA512;
break;
default:
$type = \XMLSecurityDSig::SHA1;
}
$objXMLSecDSig->addReferenceList(array($parent), $type, array(Protocol::XMLSEC_TRANSFORM_ALGORITHM_ENVELOPED_SIGNATURE, \XMLSecurityDSig::EXC_C14N), array('id_name' => $this->getIDName(), 'overwrite' => FALSE));
$objXMLSecDSig->sign($key);
$objXMLSecDSig->add509Cert($this->getCertificate()->getData(), false, false);
$firstChild = $parent->hasChildNodes() ? $parent->firstChild : null;
if ($firstChild && $firstChild->localName == 'Issuer') {
// The signature node should come after the issuer node
$firstChild = $firstChild->nextSibling;
}
$objXMLSecDSig->insertSignature($parent, $firstChild);
}
示例10: checkPageLink
/**
* Check the status of a single link on a page
*
* @param BrokenExternalPageTrack $pageTrack
* @param DOMNode $link
*/
protected function checkPageLink(BrokenExternalPageTrack $pageTrack, DOMNode $link)
{
$class = $link->getAttribute('class');
$href = $link->getAttribute('href');
$markedBroken = preg_match('/\\b(ss-broken)\\b/', $class);
// Check link
$httpCode = $this->linkChecker->checkLink($href);
if ($httpCode === null) {
return;
}
// Null link means uncheckable, such as an internal link
// If this code is broken then mark as such
if ($foundBroken = $this->isCodeBroken($httpCode)) {
// Create broken record
$brokenLink = new BrokenExternalLink();
$brokenLink->Link = $href;
$brokenLink->HTTPCode = $httpCode;
$brokenLink->TrackID = $pageTrack->ID;
$brokenLink->StatusID = $pageTrack->StatusID;
// Slight denormalisation here for performance reasons
$brokenLink->write();
}
// Check if we need to update CSS class, otherwise return
if ($markedBroken == $foundBroken) {
return;
}
if ($foundBroken) {
$class .= ' ss-broken';
} else {
$class = preg_replace('/\\s*\\b(ss-broken)\\b\\s*/', ' ', $class);
}
$link->setAttribute('class', trim($class));
}
示例11: copyNodes
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);
}
}
}
}
示例12: appendToDom
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']));
}
示例13: castElement
/**
* 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);
}
示例14: array2domAttr
/**
* 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);
}
}
}
}
示例15: process
/**
* @param DOMNode $node
* @param ProxyObject $proxy
*/
private function process(DOMNode $node, ProxyObject $proxy)
{
$proxy->setName($node->nodeName);
if ($node->hasAttributes()) {
for ($i = 0; $i < $node->attributes->length; $i++) {
$attribute = $node->attributes->item($i);
$proxy->set($attribute->name, $attribute->value);
}
}
if ($node->hasChildNodes()) {
$nodeTypes = array();
foreach ($node->childNodes as $childNode) {
if ($childNode->nodeName === '#text') {
$proxy->setValue($childNode->nodeValue);
} else {
$childProxy = new ProxyObject();
$this->process($childNode, $childProxy);
$nodeTypes[$childProxy->getName()][] = $childProxy;
}
}
foreach ($nodeTypes as $tagName => $nodes) {
$proxy->set($tagName, $nodes);
}
}
}