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


PHP DOMElement类代码示例

本文整理汇总了PHP中DOMElement的典型用法代码示例。如果您正苦于以下问题:PHP DOMElement类的具体用法?PHP DOMElement怎么用?PHP DOMElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getEditXML

 /**
  * @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());
 }
开发者ID:difra-org,项目名称:difra,代码行数:11,代码来源:menu.php

示例2: handleImages

 /**
  *
  * @param DOMElement $dom
  * @return array
  */
 private function handleImages($dom, $url)
 {
     $images = array();
     $parts = parse_url($url);
     $savedImages = array();
     $imgElements = $dom->getElementsByTagName('img');
     foreach ($imgElements as $img) {
         $src = $img->getAttribute("src");
         $is_root = false;
         if (substr($src, 0, 1) == "/") {
             $is_root = true;
         }
         $parsed = parse_url($src);
         if (!isset($parsed["host"])) {
             if ($is_root) {
                 $src = http_build_url($url, $parsed, HTTP_URL_REPLACE);
             } else {
                 $src = http_build_url($url, $parsed, HTTP_URL_JOIN_PATH);
             }
         }
         $img->setAttribute("src", "");
         if (isset($savedImages[$src])) {
             $img->setAttribute("recindex", $savedImages[$src]);
         } else {
             $image = ImageHandler::DownloadImage($src);
             if ($image !== false) {
                 $images[$this->imgCounter] = new FileRecord(new Record($image));
                 $img->setAttribute("recindex", $this->imgCounter);
                 $savedImages[$src] = $this->imgCounter;
                 $this->imgCounter++;
             }
         }
     }
     return $images;
 }
开发者ID:master3395,项目名称:CBPPlatform,代码行数:40,代码来源:OnlineArticle.php

示例3: serialize

 /**
  * serialize
  *
  * @param Sabre_DAV_Server $server
  * @param DOMElement       $prop
  * @return void
  */
 public function serialize(Sabre_DAV_Server $server, DOMElement $prop)
 {
     $doc = $prop->ownerDocument;
     $prop->setAttribute('xmlns:b', 'urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/');
     $prop->setAttribute('b:dt', 'dateTime.rfc1123');
     $prop->nodeValue = Sabre_HTTP_Util::toHTTPDate($this->time);
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:14,代码来源:GetLastModified.php

示例4: appendToDOM

 /**
  * @see CultureFeed_Cdb_IElement::appendToDOM()
  */
 public function appendToDOM(DOMElement $element)
 {
     $dom = $element->ownerDocument;
     $virtualElement = $dom->createElement('virtual');
     $virtualElement->appendChild($dom->createElement('title', $this->title));
     $element->appendChild($virtualElement);
 }
开发者ID:cultuurnet,项目名称:cdb,代码行数:10,代码来源:VirtualAddress.php

示例5: serialize

 /**
  * serialize
  *
  * @param DAV\Server $server
  * @param \DOMElement $dom
  * @return void
  */
 public function serialize(DAV\Server $server, \DOMElement $dom)
 {
     $document = $dom->ownerDocument;
     $properties = $this->responseProperties;
     $xresponse = $document->createElement('d:response');
     $dom->appendChild($xresponse);
     $uri = DAV\URLUtil::encodePath($this->href);
     // Adding the baseurl to the beginning of the url
     $uri = $server->getBaseUri() . $uri;
     $xresponse->appendChild($document->createElement('d:href', $uri));
     // The properties variable is an array containing properties, grouped by
     // HTTP status
     foreach ($properties as $httpStatus => $propertyGroup) {
         // The 'href' is also in this array, and it's special cased.
         // We will ignore it
         if ($httpStatus == 'href') {
             continue;
         }
         // If there are no properties in this group, we can also just carry on
         if (!count($propertyGroup)) {
             continue;
         }
         $xpropstat = $document->createElement('d:propstat');
         $xresponse->appendChild($xpropstat);
         $xprop = $document->createElement('d:prop');
         $xpropstat->appendChild($xprop);
         $nsList = $server->xmlNamespaces;
         foreach ($propertyGroup as $propertyName => $propertyValue) {
             $propName = null;
             preg_match('/^{([^}]*)}(.*)$/', $propertyName, $propName);
             // special case for empty namespaces
             if ($propName[1] == '') {
                 $currentProperty = $document->createElement($propName[2]);
                 $xprop->appendChild($currentProperty);
                 $currentProperty->setAttribute('xmlns', '');
             } else {
                 if (!isset($nsList[$propName[1]])) {
                     $nsList[$propName[1]] = 'x' . count($nsList);
                 }
                 // If the namespace was defined in the top-level xml namespaces, it means
                 // there was already a namespace declaration, and we don't have to worry about it.
                 if (isset($server->xmlNamespaces[$propName[1]])) {
                     $currentProperty = $document->createElement($nsList[$propName[1]] . ':' . $propName[2]);
                 } else {
                     $currentProperty = $document->createElementNS($propName[1], $nsList[$propName[1]] . ':' . $propName[2]);
                 }
                 $xprop->appendChild($currentProperty);
             }
             if (is_scalar($propertyValue)) {
                 $text = $document->createTextNode($propertyValue);
                 $currentProperty->appendChild($text);
             } elseif ($propertyValue instanceof DAV\PropertyInterface) {
                 $propertyValue->serialize($server, $currentProperty);
             } elseif (!is_null($propertyValue)) {
                 throw new DAV\Exception('Unknown property value type: ' . gettype($propertyValue) . ' for property: ' . $propertyName);
             }
         }
         $xpropstat->appendChild($document->createElement('d:status', $server->httpResponse->getStatusMessage($httpStatus)));
     }
 }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:67,代码来源:Response.php

示例6: serialize

 /**
  * 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>');
 }
开发者ID:Sywooch,项目名称:forums,代码行数:31,代码来源:SupportedLock.php

示例7: serialize

 /**
  * serialize
  *
  * @param DAV\Server $server
  * @param \DOMElement $prop
  * @return void
  */
 public function serialize(DAV\Server $server, \DOMElement $prop)
 {
     $doc = $prop->ownerDocument;
     foreach ($this->locks as $lock) {
         $activeLock = $doc->createElementNS('DAV:', 'd:activelock');
         $prop->appendChild($activeLock);
         $lockScope = $doc->createElementNS('DAV:', 'd:lockscope');
         $activeLock->appendChild($lockScope);
         $lockScope->appendChild($doc->createElementNS('DAV:', 'd:' . ($lock->scope == DAV\Locks\LockInfo::EXCLUSIVE ? 'exclusive' : 'shared')));
         $lockType = $doc->createElementNS('DAV:', 'd:locktype');
         $activeLock->appendChild($lockType);
         $lockType->appendChild($doc->createElementNS('DAV:', 'd:write'));
         /* {DAV:}lockroot */
         if (!self::$hideLockRoot) {
             $lockRoot = $doc->createElementNS('DAV:', 'd:lockroot');
             $activeLock->appendChild($lockRoot);
             $href = $doc->createElementNS('DAV:', 'd:href');
             $href->appendChild($doc->createTextNode($server->getBaseUri() . $lock->uri));
             $lockRoot->appendChild($href);
         }
         $activeLock->appendChild($doc->createElementNS('DAV:', 'd:depth', $lock->depth == DAV\Server::DEPTH_INFINITY ? 'infinity' : $lock->depth));
         $activeLock->appendChild($doc->createElementNS('DAV:', 'd:timeout', 'Second-' . $lock->timeout));
         if ($this->revealLockToken) {
             $lockToken = $doc->createElementNS('DAV:', 'd:locktoken');
             $activeLock->appendChild($lockToken);
             $lockToken->appendChild($doc->createElementNS('DAV:', 'd:href', 'opaquelocktoken:' . $lock->token));
         }
         $activeLock->appendChild($doc->createElementNS('DAV:', 'd:owner', $lock->owner));
     }
 }
开发者ID:pkdevboxy,项目名称:webmail-lite,代码行数:37,代码来源:LockDiscovery.php

示例8: convert

 /**
  * Converts the 'font-size' CSS style.
  *
  * This method receives a $targetProperty DOMElement and converts the given 
  * style with $styleName and $styleValue to attributes on this 
  * $targetProperty.
  * 
  * @param DOMElement $targetProperty 
  * @param string $styleName 
  * @param ezcDocumentPcssStyleValue $styleValue 
  */
 public function convert(DOMElement $targetProperty, $styleName, ezcDocumentPcssStyleValue $styleValue)
 {
     $mmValue = sprintf('%smm', $styleValue->value);
     $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_FO, "fo:{$styleName}", $mmValue);
     $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, "style:{$styleName}-asian", $mmValue);
     $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, "style:{$styleName}-complex", $mmValue);
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:18,代码来源:font_size.php

示例9: addHTMLChildren

 /**
  *
  * @param \DOMElement $items
  * @param \AppShed\Remote\XML\DOMDocument $xml
  * @param \AppShed\Remote\HTML\Settings $settings
  * @param \AppShed\Remote\Style\CSSDocument $css
  * @param array $javascripts
  *
  * @return \AppShed\Remote\Element\Item\Item[] of header items
  */
 protected function addHTMLChildren($items, $xml, $settings, $css, &$javascripts)
 {
     $items->appendChild($itemsInner = $xml->createElement('div', 'items-inner'));
     $itemsInner->appendChild($table = $xml->createElement('table'));
     $table->appendChild($row = $xml->createElement('tr'));
     $settings->pushCurrentScreen($this->getId());
     $i = 0;
     $headButtons = [];
     foreach ($this->children as $child) {
         if ($child->getHeaderItem()) {
             $headButtons[] = $child;
         } else {
             $childNode = $child->getHTMLNode($xml, $settings);
             if ($childNode) {
                 if ($i == $this->columns) {
                     $table->appendChild($row = $xml->createElement('tr'));
                     $i = 0;
                 }
                 $i++;
                 $row->appendChild($childNode);
             }
             $child->getCSS($css, $settings);
             $child->getJavascript($javascripts, $settings);
         }
     }
     while ($i < $this->columns) {
         $row->appendChild($xml->createElement('td'));
         $i++;
     }
     $settings->popCurrentScreen();
     return $headButtons;
 }
开发者ID:appshed,项目名称:extension-api,代码行数:42,代码来源:Icon.php

示例10: unserializeContentClassAttribute

 /**
  * Unserialize contentclass attribute
  *
  * @param eZContentClassAttribute $classAttribute
  * @param DOMElement $attributeNode
  * @param DOMElement $attributeParametersNode
  */
 function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode)
 {
     $defaultZoneLayoutItem = $attributeParametersNode->getElementsByTagName('default-layout')->item(0);
     if ($defaultZoneLayoutItem !== null && $defaultZoneLayoutItem->textContent !== false) {
         $classAttribute->setAttribute(self::DEFAULT_ZONE_LAYOUT_FIELD, $defaultZoneLayoutItem->textContent);
     }
 }
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:14,代码来源:ezpagetype.php

示例11: export

 /**
  * Export this interface definition to the given parent DOMElement.
  *
  * @param \DOMElement        $parent    Element to augment.
  * @param InterfaceReflector $interface Element to log export.
  * @param \DOMElement        $child     if supplied this element will be
  *     augmented instead of freshly added.
  *
  * @return void
  */
 public function export(\DOMElement $parent, $interface, \DOMElement $child = null)
 {
     if ($child === null) {
         $child = new \DOMElement('interface');
         $parent->appendChild($child);
     }
     $child->setAttribute('namespace', $interface->getNamespace());
     $child->setAttribute('line', $interface->getLineNumber());
     $short_name = method_exists($interface, 'getShortName') ? $interface->getShortName() : $interface->getName();
     $child->appendChild(new \DOMElement('name', $short_name));
     $child->appendChild(new \DOMElement('full_name', $interface->getName()));
     foreach ($interface->getParentInterfaces() as $parent_interface) {
         $child->appendChild(new \DOMElement('extends', $parent_interface));
     }
     $object = new DocBlockExporter();
     $object->export($child, $interface);
     foreach ($interface->getConstants() as $constant) {
         $object = new ConstantExporter();
         $constant->setDefaultPackageName($interface->getDefaultPackageName());
         $object->export($child, $constant);
     }
     foreach ($interface->getProperties() as $property) {
         $object = new PropertyExporter();
         $property->setDefaultPackageName($interface->getDefaultPackageName());
         $object->export($child, $property);
     }
     foreach ($interface->getMethods() as $method) {
         $object = new MethodExporter();
         $method->setDefaultPackageName($interface->getDefaultPackageName());
         $object->export($child, $method);
     }
 }
开发者ID:rmoorman,项目名称:phpDocumentor2,代码行数:42,代码来源:InterfaceExporter.php

示例12: getImageParameters

 /**
  * Extract image parameters
  *
  * Extract the image parameters from a media object or inline media object
  * node in the Docbook document. Returns an array with named keys
  * containing the directive parameters.
  *
  * @param ezcDocumentElementVisitorConverter $converter
  * @param DOMElement $node
  * @return array
  */
 protected function getImageParameters(ezcDocumentElementVisitorConverter $converter, DOMElement $node)
 {
     $resource = $node->getElementsBytagName('imagedata')->item(0);
     $options = array('resource' => $resource->getAttribute('fileref'));
     // Get image resource
     // Transform attributes
     $attributes = array('width' => 'width', 'depth' => 'height');
     foreach ($attributes as $src => $dst) {
         if ($resource->hasAttribute($src)) {
             $options[$dst] = $resource->getAttribute($src);
         }
     }
     // Check if the image has a description
     if (($textobject = $node->getElementsBytagName('textobject')) && $textobject->length > 0) {
         $options['alt'] = trim($textobject->item(0)->textContent);
     }
     // Check if the image has additional description assigned. In such a
     // case we wrap the image and the text inside another block.
     if (($textobject = $node->getElementsBytagName('caption')) && $textobject->length > 0) {
         $textobject = $textobject->item(0);
         // Decorate the childs of the caption node recursively, as it might
         // contain additional markup.
         $options['text'] = preg_replace('(\\s+)', ' ', $converter->visitChildren($textobject, ''));
     }
     return $options;
 }
开发者ID:axelmdev,项目名称:ecommerce,代码行数:37,代码来源:mediaobject.php

示例13: parseParagraph

 function parseParagraph(DOMDocument $slide_xml, DOMElement $paragraph)
 {
     $runs = array();
     if ($paragraph->hasChildNodes()) {
         $paragraph_nodes = $paragraph->childNodes;
         //DOMNodeList
         $i = 0;
         // running through the runs here
         foreach ($paragraph_nodes as $paragraph_node) {
             if ($paragraph_node->nodeName == "a:fld") {
                 $runs[$i]['content'] = $this->parseNodeField($slide_xml, $paragraph_node);
             }
             if ($paragraph_node->nodeName == "a:pPr") {
                 $runs['properties'] = $this->parseNodeProperties($paragraph_node);
                 continue;
             }
             if ($paragraph_node->nodeName == 'a:r') {
                 list($string, $run_parameters) = $this->parseNodeRun($slide_xml, $paragraph_node);
                 $runs[$i]['content'] = $string;
                 foreach ($run_parameters as $parameter_name => $parameter_value) {
                     $runs[$i][$parameter_name] = $parameter_value;
                 }
             }
             // remove empty runs
             if (empty($runs[$i]['content'])) {
                 unset($runs[$i]);
             }
             if (empty($runs['properties']['bullet_type'])) {
                 unset($runs['properties']['bullet_type']);
             }
             $i++;
         }
     }
     return $runs;
 }
开发者ID:TBoonX,项目名称:SlideWiki,代码行数:35,代码来源:Paragraphs.php

示例14: parseNodes

 /**
  * Parse node values from xml nodes
  *
  * @param \DOMElement $childNode
  * @return array
  */
 protected function parseNodes($childNode)
 {
     $output = [];
     switch ($childNode->nodeName) {
         case 'vars':
             $moduleName = $childNode->getAttribute('module');
             $output[$childNode->tagName][$moduleName] = $this->parseVarElement($childNode);
             break;
         case 'exclude':
             /** @var $itemNode \DOMElement */
             foreach ($childNode->getElementsByTagName('item') as $itemNode) {
                 $itemType = $itemNode->getAttribute('type');
                 $output[$childNode->tagName][$itemType][] = $itemNode->nodeValue;
             }
             break;
         case 'media':
             foreach ($childNode->childNodes as $mediaNode) {
                 if ($mediaNode instanceof \DOMElement) {
                     $mediaNodesArray = $this->extractorPool->nodeProcessor($mediaNode->tagName)->process($mediaNode, $childNode->tagName);
                     $output = array_merge_recursive($output, $mediaNodesArray);
                 }
             }
             break;
     }
     return $output;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:32,代码来源:Converter.php

示例15: 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);
     }
 }
开发者ID:difra-org,项目名称:difra,代码行数:11,代码来源:Envi.php


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