ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
domxml-php4-php5.php
Go to the documentation of this file.
1<?php
37 // new
38 function domxml_new_doc($version)
39 {
40echo "-1";
41 return new php4DOMDocument('');
42 }
43
44 // same
46 {
47echo "-2";
48 return new php4DOMDocument($filename);
49 }
50
51 // different
52 function domxml_open_mem($str)
53 {
54echo "-3";
55 $dom=new php4DOMDocument('');
56 $dom->myDOMNode->loadXML($str);
57 return $dom;
58 }
59
60 // different -> adapted in ilias
61 function xpath_eval($xpath_context,$eval_str,$contextnode=null)
62 {
63echo "-4";
64 return $xpath_context->query($eval_str,$contextnode);
65 }
66
67 // same
68 function xpath_new_context($dom_document)
69 {
70echo "-5";
71 return new php4DOMXPath($dom_document);
72 }
73
74// same (nearly)
75class php4DOMAttr extends php4DOMNode
76{
77 function php4DOMAttr($aDOMAttr) {
78echo "-6";
79 $this->myDOMNode=$aDOMAttr;
80 }
81
82 function Name() {
83echo "-7";
84 return $this->myDOMNode->name;
85 }
86
87 function Specified() {
88echo "-8";
89 return $this->myDOMNode->specified;
90 }
91
92 function Value() {
93echo "-9";
94 return $this->myDOMNode->value;
95 }
96}
97
98// different
99class php4DOMDocument extends php4DOMNode
100{
101 // different
103 {
104echo "-A";
105 $this->myDOMNode=new DOMDocument();
106 if ($filename!='') $this->myDOMNode->load($filename);
107 }
108
109 // different (a little)
110 function create_attribute($name,$value)
111 {
112echo "-B";
113 $myAttr=$this->myDOMNode->createAttribute($name);
114 $myAttr->value=$value;
115 return new php4DOMAttr($myAttr,$this);
116 }
117
118 // different (little)
119 function create_cdata_section($content)
120 {
121echo "-C";
122 return new php4DOMNode($this->myDOMNode->createCDATASection($content),$this);
123 }
124
125 // different (little)
127 {
128echo "-D";
129 return new php4DOMNode($this->myDOMNode->createComment($data),$this);
130 }
131
132 // different (little)
133 function create_element($name)
134 {
135echo "-E";
136 return new php4DOMElement($this->myDOMNode->createElement($name),$this);
137 }
138
139 function create_text_node($content)
140 {
141echo "-F";
142 return new php4DOMNode($this->myDOMNode->createTextNode($content),$this);
143 }
144
146 {
147echo "-G";
148 return new php4DOMElement($this->myDOMNode->documentElement,$this);
149 }
150
151 function dump_file($filename,$compressionmode=false,$format=false)
152 {
153echo "-H";
154 return $this->myDOMNode->save($filename);
155 }
156
157 function dump_mem($format=false,$encoding=false)
158 {
159echo "-I";
160 return $this->myDOMNode->saveXML();
161 }
162
163 function get_element_by_id($id)
164 {
165echo "-J";
166 return new php4DOMElement($this->myDOMNode->getElementById($id),$this);
167 }
168
170 {
171echo "-K";
172 $myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
173 $nodeSet=array();
174 $i=0;
175 if (isset($myDOMNodeList))
176 while ($node=$myDOMNodeList->item($i))
177 {
178 $nodeSet[]=new php4DOMElement($node,$this);
179 $i++;
180 }
181 return $nodeSet;
182 }
183
184 function html_dump_mem()
185 {
186echo "-L";
187 return $this->myDOMNode->saveHTML();
188 }
189
190 function root()
191 {
192echo "-M";
193 return new php4DOMElement($this->myDOMNode->documentElement,$this);
194 }
195}
196
197class php4DOMElement extends php4DOMNode
198{
199 function get_attribute($name)
200 {
201echo "-N";
202 return $this->myDOMNode->getAttribute($name);
203 }
204
206 {
207echo "-O";
208 $myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
209 $nodeSet=array();
210 $i=0;
211 if (isset($myDOMNodeList))
212 while ($node=$myDOMNodeList->item($i))
213 {
214 $nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument);
215 $i++;
216 }
217 return $nodeSet;
218 }
219
220 function has_attribute($name)
221 {
222echo "-P";
223 return $this->myDOMNode->hasAttribute($name);
224 }
225
226 function remove_attribute($name)
227 {
228echo "-Q";
229 return $this->myDOMNode->removeAttribute($name);
230 }
231
232 function set_attribute($name,$value)
233 {
234echo "-R";
235 return $this->myDOMNode->setAttribute($name,$value);
236 }
237
238 function tagname()
239 {
240echo "-S";
241 return $this->myDOMNode->tagName;
242 }
243}
244
245class php4DOMNode
246{
247 var $myDOMNode;
249
250 function php4DOMNode($aDomNode,$aOwnerDocument)
251 {
252echo "-T";
253 $this->myDOMNode=$aDomNode;
254 $this->myOwnerDocument=$aOwnerDocument;
255 }
256
257 function __get($name)
258 {
259echo "-U";
260 if ($name=='type') return $this->myDOMNode->nodeType;
261 elseif ($name=='tagname') return $this->myDOMNode->tagName;
262 elseif ($name=='content') return $this->myDOMNode->textContent;
263 else
264 {
265 $myErrors=debug_backtrace();
266 trigger_error('Undefined property: '.get_class($this).'::$'.$name.' ['.$myErrors[0]['file'].':'.$myErrors[0]['line'].']',E_USER_NOTICE);
267 return false;
268 }
269 }
270
271 function append_child($newnode)
272 {
273echo "-V";
274 return new php4DOMElement($this->myDOMNode->appendChild($newnode->myDOMNode),$this->myOwnerDocument);
275 }
276
277 function append_sibling($newnode)
278 {
279echo "-W";
280 return new php4DOMElement($this->myDOMNode->parentNode->appendChild($newnode->myDOMNode),$this->myOwnerDocument);
281 }
282
283 function attributes()
284 {
285echo "-X";
286 $myDOMNodeList=$this->myDOMNode->attributes;
287 $nodeSet=array();
288 $i=0;
289 if (isset($myDOMNodeList))
290 while ($node=$myDOMNodeList->item($i))
291 {
292 $nodeSet[]=new php4DOMAttr($node,$this->myOwnerDocument);
293 $i++;
294 }
295 return $nodeSet;
296 }
297
298 function child_nodes()
299 {
300echo "-Y";
301 $myDOMNodeList=$this->myDOMNode->childNodes;
302 $nodeSet=array();
303 $i=0;
304 if (isset($myDOMNodeList))
305 while ($node=$myDOMNodeList->item($i))
306 {
307 $nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument);
308 $i++;
309 }
310 return $nodeSet;
311 }
312
313 function children() {
314echo "-Z";
315 return $this->child_nodes();
316 }
317
318 function clone_node($deep=false) {
319echo "-a";
320 return new php4DOMElement($this->myDOMNode->cloneNode($deep),$this->myOwnerDocument);
321 }
322
323 function first_child() {
324echo "-b";
325 return new php4DOMElement($this->myDOMNode->firstChild,$this->myOwnerDocument);
326 }
327 function get_content() {
328echo "-c";
329 return $this->myDOMNode->textContent;
330 }
331
332 function has_attributes() {
333echo "-d";
334 return $this->myDOMNode->hasAttributes();
335 }
337 {
338echo "-e";
339 return $this->myDOMNode->hasChildNodes();
340 }
341 function insert_before($newnode,$refnode)
342 {
343echo "-f";
344 return new php4DOMElement($this->myDOMNode->insertBefore($newnode->myDOMNode,$refnode->myDOMNode),$this->myOwnerDocument);
345 }
346
347 function is_blank_node()
348 {
349echo "-g";
350 $myDOMNodeList=$this->myDOMNode->childNodes;
351 $i=0;
352 if (isset($myDOMNodeList))
353 while ($node=$myDOMNodeList->item($i))
354 {
355 if (($node->nodeType==XML_ELEMENT_NODE)||
356 (($node->nodeType==XML_TEXT_NODE)&&!ereg('^([[:cntrl:]]|[[:space:]])*$',$node->nodeValue)))
357 return false;
358 $i++;
359 }
360 return true;
361 }
362
363 function last_child() {
364echo "-h";
365 return new php4DOMElement($this->myDOMNode->lastChild,$this->myOwnerDocument);
366 }
367
368 function new_child($name,$content)
369 {
370echo "-i";
371 $mySubNode=$this->myDOMNode->ownerDocument->createElement($name);
372 $mySubNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($content));
373 $this->myDOMNode->appendChild($mySubNode);
374 return new php4DOMElement($mySubNode,$this->myOwnerDocument);
375 }
376
377 function next_sibling() {
378echo "-j";
379 return new php4DOMElement($this->myDOMNode->nextSibling,$this->myOwnerDocument);
380 }
381
382 function node_name() {
383echo "-k";
384 return $this->myDOMNode->localName;
385 }
386
387 function node_type() {
388echo "-l";
389 return $this->myDOMNode->nodeType;
390 }
391
392 function node_value()
393 {
394echo "-m";
395 return $this->myDOMNode->nodeValue;
396 }
397
398 function owner_document()
399 {
400echo "-n";
402 }
403
404 function parent_node() {
405echo "-o";
406 return new php4DOMElement($this->myDOMNode->parentNode,$this->myOwnerDocument);
407 }
408
409 function prefix() {
410echo "-p";
411 return $this->myDOMNode->prefix;
412 }
413
414 function previous_sibling() {
415echo "-q";
416 return new php4DOMElement($this->myDOMNode->previousSibling,$this->myOwnerDocument);
417 }
418
419 function remove_child($oldchild)
420 {
421echo "-r";
422 return new php4DOMElement($this->myDOMNode->removeChild($oldchild->myDOMNode),$this->myOwnerDocument);
423 }
424
425 function replace_child($oldnode,$newnode) {
426echo "-s";
427 return new php4DOMElement($this->myDOMNode->replaceChild($oldnode->myDOMNode,$newnode->myDOMNode),$this->myOwnerDocument);
428 }
429
431 {
432echo "-t";
433 if (($this->myDOMNode->hasChildNodes())&&($this->myDOMNode->firstChild->nodeType==XML_TEXT_NODE))
434 $this->myDOMNode->removeChild($this->myDOMNode->firstChild);
435 return $this->myDOMNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($text));
436 }
437}
438
439class php4DOMNodelist
440{
441 var $myDOMNodelist;
442 var $nodeset;
443
444 function php4DOMNodelist($aDOMNodelist,$aOwnerDocument)
445 {
446echo "-u";
447 $this->myDOMNodelist=$aDOMNodelist;
448 $this->nodeset=array();
449 $i=0;
450 if (isset($this->myDOMNodelist))
451 while ($node=$this->myDOMNodelist->item($i))
452 {
453 $this->nodeset[]=new php4DOMElement($node,$aOwnerDocument);
454 $i++;
455 }
456 }
457}
458
459class php4DOMXPath
460{
461 var $myDOMXPath;
463 function php4DOMXPath($dom_document)
464 {
465echo "-v";
466 $this->myOwnerDocument=$dom_document;
467 $this->myDOMXPath=new DOMXPath($dom_document->myDOMNode);
468 }
469
470 function query($eval_str,$contextnode)
471 {
472echo "-w";
473 if (isset($contextnode)) return new php4DOMNodelist($this->myDOMXPath->query($eval_str,$contextnode->myDOMNode),$this->myOwnerDocument);
474 else return new php4DOMNodelist($this->myDOMXPath->query($eval_str),$this->myOwnerDocument);
475 }
476
477 function xpath_register_ns($prefix,$namespaceURI)
478 {
479echo "-x";
480 return $this->myDOMXPath->registerNamespace($prefix,$namespaceURI);
481 }
482}
483
484if (extension_loaded('xsl'))
485{//See also: http://alexandre.alapetite.net/doc-alex/xslt-php4-php5/
486
487 function domxml_xslt_stylesheet($xslstring)
488 {
489echo "-y";
490 return new php4DomXsltStylesheet(DOMDocument::loadXML($xslstring));
491 }
492
493 function domxml_xslt_stylesheet_doc($dom_document) {
494echo "-z";
495 return new php4DomXsltStylesheet($dom_document);
496 }
497
498 function domxml_xslt_stylesheet_file($xslfile) {
499echo "-Ä";
500 return new php4DomXsltStylesheet(DOMDocument::load($xslfile));
501 }
502
503 class php4DomXsltStylesheet
504 {
505 var $myxsltProcessor;
506 function php4DomXsltStylesheet($dom_document)
507 {
508echo "-Ö";
509 $this->myxsltProcessor=new xsltProcessor();
510 $this->myxsltProcessor->importStyleSheet($dom_document);
511 }
512
513 function process($dom_document,$xslt_parameters=array(),$param_is_xpath=false)
514 {
515echo "-Ü";
516 foreach ($xslt_parameters as $param=>$value)
517 $this->myxsltProcessor->setParameter('',$param,$value);
518 $myphp4DOMDocument=new php4DOMDocument();
519 $myphp4DOMDocument->myDOMNode=$this->myxsltProcessor->transformToDoc($dom_document->myDOMNode);
520 return $myphp4DOMDocument;
521 }
522
523 function result_dump_file($dom_document,$filename)
524 {
525echo "-ä";
526 $html=$dom_document->myDOMNode->saveHTML();
527 file_put_contents($filename,$html);
528 return $html;
529 }
530
531 function result_dump_mem($dom_document) {
532echo "-ö";
533 return $dom_document->myDOMNode->saveHTML();
534 }
535 }
536}
537
538?>
$filename
Definition: buildRTE.php:89
php4DOMAttr($aDOMAttr)
php4DOMDocument($filename='')
create_cdata_section($content)
get_elements_by_tagname($name)
dump_mem($format=false, $encoding=false)
create_text_node($content)
create_attribute($name, $value)
dump_file($filename, $compressionmode=false, $format=false)
get_elements_by_tagname($name)
set_attribute($name, $value)
php4DOMNode($aDomNode, $aOwnerDocument)
clone_node($deep=false)
remove_child($oldchild)
php4DOMNode($aDomNode)
new_child($name, $content)
replace_child($oldnode, $newnode)
insert_before($newnode, $refnode)
append_sibling($newnode)
append_child($newnode)
php4DOMNodelist($aDOMNodelist, $aOwnerDocument)
query($eval_str, $contextnode)
php4DOMXPath($dom_document)
xpath_register_ns($prefix, $namespaceURI)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
domxml_open_mem($str)
domxml_new_doc($version)
domxml_open_file($filename)
xpath_new_context($dom_document)
$html
Definition: example_001.php:87
$data
$text