ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilDOM2Util Class Reference

DOM 2 util. More...

+ Collaboration diagram for ilDOM2Util:

Static Public Member Functions

static changeName ($node, $name, $keep_attributes=true)
 Change name of a node. More...
 
static addParent ($node, $name)
 Add parent. More...
 
static replaceByChilds ($node)
 Replace a node by its child. More...
 

Detailed Description

DOM 2 util.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$ /

Definition at line 11 of file class.ilDOM2Util.php.

Member Function Documentation

◆ addParent()

static ilDOM2Util::addParent (   $node,
  $name 
)
static

Add parent.

Parameters
object$node
Returns

Definition at line 44 of file class.ilDOM2Util.php.

References $name.

Referenced by ilPCParagraph\handleAjaxContent().

45  {
46  $newnode = $node->ownerDocument->createElement($name);
47  //echo htmlentities($node->ownerDocument->saveXML($node->ownerDocument->documentElement));
48  //echo "<br>".htmlentities($node->ownerDocument->saveXML($node)); exit;
49  $par = $node->parentNode;
50  //var_dump($node);
51  //var_dump($par);
52  if ($next_sib = $node->nextSibling) {
53  $newnode = $par->insertBefore($newnode, $next_sib);
54  } else {
55  $newnode = $par->appendChild($newnode);
56  }
57 
58  $node = $par->removeChild($node);
59  $newnode->appendChild($node);
60 
61  // foreach ($node->childNodes as $child)
62  // {
63  // $child2 = $child->cloneNode(true);
64  // $newnode->appendChild($child2);
65  // }
66 
67  return $newnode;
68  }
+ Here is the caller graph for this function:

◆ changeName()

static ilDOM2Util::changeName (   $node,
  $name,
  $keep_attributes = true 
)
static

Change name of a node.

Parameters
object$node
stringnew name
Returns

Definition at line 20 of file class.ilDOM2Util.php.

References $name.

Referenced by ilPCParagraph\handleAjaxContent().

21  {
22  $newnode = $node->ownerDocument->createElement($name);
23 
24  foreach ($node->childNodes as $child) {
25  $child2 = $child->cloneNode(true);
26  $newnode->appendChild($child2);
27  }
28  if ($keep_attributes) {
29  foreach ($node->attributes as $attrName => $attrNode) {
30  $newnode->setAttribute($attrName, $attrNode);
31  }
32  }
33  $node->parentNode->replaceChild($newnode, $node);
34 
35  return $newnode;
36  }
+ Here is the caller graph for this function:

◆ replaceByChilds()

static ilDOM2Util::replaceByChilds (   $node)
static

Replace a node by its child.

Parameters
object$node
Returns

Definition at line 76 of file class.ilDOM2Util.php.

Referenced by ilPCParagraph\handleAjaxContent().

77  {
78  foreach ($node->childNodes as $child) {
79  $child2 = $child->cloneNode(true);
80  $node->parentNode->insertBefore($child2, $node);
81  }
82  $node->parentNode->removeChild($node);
83  }
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: