当前位置: 首页>>代码示例>>PHP>>正文


PHP DOMNode::getAttribute方法代码示例

本文整理汇总了PHP中DOMNode::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMNode::getAttribute方法的具体用法?PHP DOMNode::getAttribute怎么用?PHP DOMNode::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DOMNode的用法示例。


在下文中一共展示了DOMNode::getAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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));
 }
开发者ID:govtnz,项目名称:silverstripe-externallinks,代码行数:39,代码来源:CheckExternalLinksTask.php

示例2: 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;
 }
开发者ID:gobjila,项目名称:BackBee,代码行数:43,代码来源:LayoutRepository.php

示例3: parse

 public function parse(DOMNode $element)
 {
     if ($element->hasAttribute('name')) {
         $this->name = $element->getAttribute('name');
     }
     if ($element->hasAttribute('type')) {
         $this->type = $element->getAttribute('type');
     }
     for ($i = 0; $i < $element->childNodes->length; $i++) {
         $childElement = $element->childNodes->item($i);
         if ($childElement->parentNode !== $element) {
             continue;
         }
         if ($childElement instanceof DOMComment || $childElement instanceof DOMText) {
             continue;
         }
         switch ($childElement->nodeName) {
             case 'part':
                 $this->parts[] = new Ezer_XmlVariable($childElement);
                 break;
             default:
                 throw new Ezer_XmlPersistanceElementNotMappedException($childElement->nodeName);
         }
     }
 }
开发者ID:codegooglecom,项目名称:ezerphp,代码行数:25,代码来源:Ezer_XmlVariable.php

示例4: extractAndFormatNodeValue

 /**
  * Returns the (unescaped) correctly marshalled, cell value associated to the given XML node.
  *
  * @param \DOMNode $node
  * @return string|int|float|bool|\DateTime|null The value associated with the cell (null when the cell has an error)
  */
 public function extractAndFormatNodeValue($node)
 {
     // Default cell type is "n"
     $cellType = $node->getAttribute(self::XML_ATTRIBUTE_TYPE) ?: self::CELL_TYPE_NUMERIC;
     $cellStyleId = intval($node->getAttribute(self::XML_ATTRIBUTE_STYLE_ID));
     $vNodeValue = $this->getVNodeValue($node);
     if ($vNodeValue === '' && $cellType !== self::CELL_TYPE_INLINE_STRING) {
         return $vNodeValue;
     }
     switch ($cellType) {
         case self::CELL_TYPE_INLINE_STRING:
             return $this->formatInlineStringCellValue($node);
         case self::CELL_TYPE_SHARED_STRING:
             return $this->formatSharedStringCellValue($vNodeValue);
         case self::CELL_TYPE_STR:
             return $this->formatStrCellValue($vNodeValue);
         case self::CELL_TYPE_BOOLEAN:
             return $this->formatBooleanCellValue($vNodeValue);
         case self::CELL_TYPE_NUMERIC:
             return $this->formatNumericCellValue($vNodeValue, $cellStyleId);
         case self::CELL_TYPE_DATE:
             return $this->formatDateCellValue($vNodeValue);
         default:
             return null;
     }
 }
开发者ID:KiNgMaR,项目名称:spout,代码行数:32,代码来源:CellValueFormatter.php

示例5: process

function process(DOMNode $current_node)
{
    global $filter_args, $filter_tags, $filter_mandatory, $bbcode;
    if ($current_node instanceof DOMElement || $current_node instanceof DOMDocument) {
        // Recursion. I need iterator_to_array(), because it's likely
        // that node list will be modified.
        foreach (iterator_to_array($current_node->childNodes) as $node) {
            process($node);
        }
        // BBCode hack is NOT allowed to exist
        if ($current_node->tagName === 'bbcodehack') {
            $value = $current_node->hasAttribute('value') ? $current_node->getAttribute('value') : NULL;
            $nodes = $current_node->hasAttribute('pre') ? $current_node->getAttribute('pre') : $current_node->childNodes;
            $nodes = $bbcode[$current_node->getAttribute('name')]['callback']($current_node->ownerDocument, $nodes, $value, array('borked' => $current_node->hasAttribute('borked')));
            if (!is_array($nodes)) {
                $nodes = array($nodes);
            }
            foreach ($nodes as $node) {
                $current_node->parentNode->insertBefore($node, $current_node);
            }
            // Remove bbcodehack from DOM
            $current_node->parentNode->removeChild($current_node);
        } elseif ($current_node->tagName && !isset($filter_tags[$current_node->tagName])) {
            while ($current_node->hasChildNodes()) {
                $current_node->parentNode->insertBefore($current_node->childNodes->item(0), $current_node);
            }
            $current_node->parentNode->removeChild($current_node);
        } else {
            if ($current_node->hasAttributes()) {
                // I need iterator_to_array, as I modify attributes
                // list while iterating.
                foreach (iterator_to_array($current_node->attributes) as $attr) {
                    $attribute = isset($filter_tags[$current_node->tagName][$attr->name]) ? $filter_tags[$current_node->tagName][$attr->name] : (isset($filter_args[$attr->name]) ? $filter_args[$attr->name] : NULL);
                    if (!$attribute) {
                        $current_node->removeAttribute($attr->name);
                    } elseif (!is_bool($attribute)) {
                        $value = $attribute($attr->value, $current_node);
                        if ($value === NULL) {
                            $current_node->removeAttribute($attr->name);
                        } else {
                            $current_node->setAttribute($attr->name, $value);
                        }
                    }
                }
            }
            if (isset($filter_mandatory[$current_node->tagName])) {
                foreach ($filter_mandatory[$current_node->tagName] as $attr => $value) {
                    if (!$current_node->hasAttribute($attr)) {
                        $current_node->setAttribute($attr, $value);
                    }
                }
            }
        }
    } elseif ($current_node instanceof DOMComment) {
        // Unsafe because of conditional comments
        $current_node->parentNode->removeChild($current_node);
    }
}
开发者ID:knytrune,项目名称:ABXD,代码行数:58,代码来源:htmlfilter.php

示例6: attr

 public function attr($a_name, $a_value = null)
 {
     if (func_num_args() == 0) {
         return $this->m_node->getAttribute($a_name);
     }
     if (func_num_args() > 1) {
         $this->m_node->setAttribute($a_name, $a_value);
     }
     if (func_num_args() == 1) {
         $this->m_node->getAttribute($a_name);
     }
 }
开发者ID:BGCX261,项目名称:zoombi-svn-to-git,代码行数:12,代码来源:xmltag.php

示例7: __construct

 /**
  * 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);
         }
     }
 }
开发者ID:fresnostate-library,项目名称:xerxes,代码行数:17,代码来源:DataField.php

示例8: rtrim

 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);
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:7,代码来源:attribute_translator.cls.php

示例9: takeChildFromDOM

 /**
  * Creates individual Entry objects of the appropriate type and
  * stores them as members of this entry based upon DOM data.
  *
  * @param \DOMNode $child The \DOMNode to process
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function takeChildFromDOM($child)
 {
     $sc = $this->lookupNamespace('sc');
     $scp = $this->lookupNamespace('scp');
     $id = $child->namespaceURI . ':' . $child->localName;
     if ($child->localName == 'group') {
         $id .= ':' . $child->getAttribute('name');
     }
     switch ($id) {
         case "{$sc}:id":
         case "{$sc}:image_link":
         case "{$sc}:content_language":
         case "{$sc}:target_country":
         case "{$sc}:expiration_date":
         case "{$sc}:adult":
         case "{$sc}:attribute":
             $contentAttribute = new Attribute();
             $contentAttribute->transferFromDOM($child);
             $this->_contentAttributes[] = $contentAttribute;
             break;
         case "{$sc}:group:tax":
         case "{$scp}:tax":
             $tax = new \Magento\Framework\Gdata\Gshopping\Extension\Tax();
             $tax->transferFromDOM($child);
             $this->_tax[] = $tax;
             break;
         case $this->lookupNamespace('app') . ':' . 'control':
             $control = new \Magento\Framework\Gdata\Gshopping\Extension\Control();
             $control->transferFromDOM($child);
             $this->setControl($control);
             break;
         default:
             parent::takeChildFromDOM($child);
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:43,代码来源:Entry.php

示例10: 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;
			}
		}
	}
开发者ID:nathanfl,项目名称:medtele,代码行数:34,代码来源:Module.Class.php

示例11: attr

 public function attr($a_name, $a_value = null)
 {
     if (is_null($a_value)) {
         return $this->m_node->getAttribute($a_name);
     }
     $this->m_node->setAttribute($a_name, $a_value);
 }
开发者ID:BGCX261,项目名称:zoombi-svn-to-git,代码行数:7,代码来源:xmltag.php

示例12: __construct

 /**
  * Create a MARC Control Field
  * 
  * @param \DOMNode $objNode
  */
 public function __construct(\DOMNode $objNode = null)
 {
     if ($objNode != null) {
         $this->tag = $objNode->getAttribute("tag");
         $this->value = $objNode->nodeValue;
     }
 }
开发者ID:fresnostate-library,项目名称:xerxes,代码行数:12,代码来源:ControlField.php

示例13: __construct

 /**
  * Constructor.
  *
  * @param \DOMNode $node The node associated with this field
  */
 public function __construct(\DOMNode $node)
 {
     $this->node = $node;
     $this->name = $node->getAttribute('name');
     $this->xpath = new \DOMXPath($node->ownerDocument);
     $this->initialize();
 }
开发者ID:flelievre,项目名称:EasyVisit,代码行数:12,代码来源:FormField.php

示例14: _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;
             }
     }
 }
开发者ID:buga1234,项目名称:buga_segforours,代码行数:39,代码来源:Parser.php

示例15: __construct

 /**
  * Create a MARC Sub Field
  * 
  * @param \DOMNode $node
  */
 public function __construct(\DOMNode $node = null)
 {
     if ($node != null) {
         $this->code = $node->getAttribute("code");
         $this->value = $node->nodeValue;
     }
 }
开发者ID:navtis,项目名称:xerxes,代码行数:12,代码来源:SubField.php


注:本文中的DOMNode::getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。