ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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 47 of file class.ilDOM2Util.php.

Referenced by ilPCParagraph\handleAjaxContent().

48  {
49  $newnode = $node->ownerDocument->createElement($name);
50 //echo htmlentities($node->ownerDocument->saveXML($node->ownerDocument->documentElement));
51 //echo "<br>".htmlentities($node->ownerDocument->saveXML($node)); exit;
52  $par = $node->parentNode;
53 //var_dump($node);
54 //var_dump($par);
55  if ($next_sib = $node->nextSibling)
56  {
57  $newnode = $par->insertBefore($newnode, $next_sib);
58  }
59  else
60  {
61  $newnode = $par->appendChild($newnode);
62  }
63 
64  $node = $par->removeChild($node);
65  $newnode->appendChild($node);
66 
67 // foreach ($node->childNodes as $child)
68 // {
69 // $child2 = $child->cloneNode(true);
70 // $newnode->appendChild($child2);
71 // }
72 
73  return $newnode;
74  }
+ 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.

Referenced by ilPCParagraph\handleAjaxContent().

21  {
22  $newnode = $node->ownerDocument->createElement($name);
23 
24  foreach ($node->childNodes as $child)
25  {
26  $child2 = $child->cloneNode(true);
27  $newnode->appendChild($child2);
28  }
29  if ($keep_attributes)
30  {
31  foreach ($node->attributes as $attrName => $attrNode)
32  {
33  $newnode->setAttribute($attrName, $attrNode);
34  }
35  }
36  $node->parentNode->replaceChild($newnode, $node);
37 
38  return $newnode;
39  }
+ 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 82 of file class.ilDOM2Util.php.

Referenced by ilPCParagraph\handleAjaxContent().

83  {
84  foreach ($node->childNodes as $child)
85  {
86  $child2 = $child->cloneNode(true);
87  $node->parentNode->insertBefore($child2, $node);
88  }
89  $node->parentNode->removeChild($node);
90  }
+ Here is the caller graph for this function:

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